这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func getPartitionsForArg(partitions []string, arg string) ([]string, error) {
return res, nil
}

func getPartitionMatchPatterns(partitions []string, arg string, parts []string) (string, string, error) { //nolint:staticcheck // TODO is tablePattern required as input?
func getPartitionMatchPatterns(partitions []string, arg string, parts []string) (string, string, error) {
var tablePattern, partitionPattern string
// '*' is not valid for a single part arg
if parts[0] == "*" {
Expand Down
21 changes: 13 additions & 8 deletions cmd/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/turbot/pipe-fittings/connection"
pconstants "github.com/turbot/pipe-fittings/constants"
"github.com/turbot/pipe-fittings/error_helpers"
"github.com/turbot/pipe-fittings/parse"
"github.com/turbot/tailpipe/internal/config"
"github.com/turbot/tailpipe/internal/constants"
"github.com/turbot/tailpipe/internal/database"
Expand Down Expand Up @@ -125,26 +126,30 @@ func getFilters() ([]string, error) {
var result []string
if viper.IsSet(pconstants.ArgFrom) {
from := viper.GetString(pconstants.ArgFrom)
// verify this is a valid date
t, err := time.Parse(time.RFC3339, from)
// parse the string as time.Time
// arg `from` accepts ISO 8601 date(2024-01-01), ISO 8601 datetime(2006-01-02T15:04:05), ISO 8601 datetime with ms(2006-01-02T15:04:05.000),
// RFC 3339 datetime with timezone(2006-01-02T15:04:05Z07:00) and relative time formats(T-2Y, T-10m, T-10W, T-180d, T-9H, T-10M)
t, err := parse.ParseTime(from, time.Now())
if err != nil {
return nil, fmt.Errorf("invalid date format for 'from': %s", from)
}
// format as SQL timestamp
fromDate := t.Format("2006-01-02")
fromTimestamp := t.Format("2006-01-02 15:04:05")
fromDate := t.Format(time.DateOnly)
fromTimestamp := t.Format(time.DateTime)
result = append(result, fmt.Sprintf("tp_date >= DATE '%s' AND tp_timestamp >= TIMESTAMP '%s'", fromDate, fromTimestamp))
}
if viper.IsSet(pconstants.ArgTo) {
to := viper.GetString(pconstants.ArgTo)
// verify this is a valid date
t, err := time.Parse(time.RFC3339, to)
// parse the string as time.Time
// arg `to` accepts ISO 8601 date(2024-01-01), ISO 8601 datetime(2006-01-02T15:04:05), ISO 8601 datetime with ms(2006-01-02T15:04:05.000),
// RFC 3339 datetime with timezone(2006-01-02T15:04:05Z07:00) and relative time formats(T-2Y, T-10m, T-10W, T-180d, T-9H, T-10M)
t, err := parse.ParseTime(to, time.Now())
if err != nil {
return nil, fmt.Errorf("invalid date format for 'to': %s", to)
}
// format as SQL timestamp
toDate := t.Format("2006-01-02")
toTimestamp := t.Format("2006-01-02 15:04:05")
toDate := t.Format(time.DateOnly)
toTimestamp := t.Format(time.DateTime)
result = append(result, fmt.Sprintf("tp_date <= DATE '%s' AND tp_timestamp <= TIMESTAMP '%s'", toDate, toTimestamp))
}
return result, nil
Expand Down
Loading