Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
dc56614
feat: support special characters in column names for filter parsing
GergesHany Oct 2, 2025
c369f5d
Merge branch 'staging' into fix/handle-special-characters-in-column-n…
vaibhav-datazip Oct 4, 2025
ce5816f
fix: update regex and add new test cases
GergesHany Oct 5, 2025
9185d89
fix: Update the regex to NOT accept trailing dots without decimal digits
GergesHany Oct 5, 2025
98f7d5d
refactor: remove backtick and <> operator support from filter parser
GergesHany Oct 7, 2025
83df23c
Remove unnecessary intermediate variables (operator[1,2], value[1,2])…
GergesHany Oct 7, 2025
8f2053d
Merge branch 'staging' into fix/handle-special-characters-in-column-n…
vaibhav-datazip Oct 12, 2025
ef7c64f
Merge branch 'staging' into fix/handle-special-characters-in-column-n…
vaibhav-datazip Oct 19, 2025
6739e9a
Merge branch 'staging' into fix/handle-special-characters-in-column-n…
vaibhav-datazip Oct 27, 2025
306da56
Merge branch 'staging' into fix/handle-special-characters-in-column-n…
vaibhav-datazip Oct 30, 2025
b689d4f
Refactor
GergesHany Nov 2, 2025
ef3ecdc
Merge branch 'staging' into fix/handle-special-characters-in-column-n…
vaibhav-datazip Nov 5, 2025
45d2561
removed the duplicate 'three conditions (not supported)' test case.
GergesHany Nov 5, 2025
eb5ca9a
refactor: migrate filter tests to testify and remove redundant test h…
GergesHany Nov 5, 2025
7c6146b
test: add test case for unquoted columns with underscores in filter
GergesHany Nov 5, 2025
04d6522
Updated the test case names to be more descriptive
GergesHany Nov 5, 2025
0788b54
Removed the duplicate 'double quotes mismatch' test case
GergesHany Nov 5, 2025
70e3f02
Cleaned up redundant test cases.
GergesHany Nov 5, 2025
e5ac061
Removed the duplicate 'empty value after operator' test case
GergesHany Nov 5, 2025
135081a
Removed the duplicate 'unquoted column with trailing space before op'
GergesHany Nov 5, 2025
a61b0fc
Merge branch 'staging' into fix/handle-special-characters-in-column-n…
shubham19may Nov 5, 2025
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
38 changes: 26 additions & 12 deletions types/stream_configured.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,35 +85,49 @@ func (s *ConfiguredStream) Cursor() (string, string) {
}

func (s *ConfiguredStream) GetFilter() (Filter, error) {
filter := s.StreamMetadata.Filter
filter := strings.TrimSpace(s.StreamMetadata.Filter)
if filter == "" {
return Filter{}, nil
}
// TODO: handle special characters in column name in filter
// example: a>b, a>=b, a<b, a<=b, a!=b, a=b, a="b", a=\"b\" and c>d, a="b" or c>d
var FilterRegex = regexp.MustCompile(`^(\w+)\s*(>=|<=|!=|>|<|=)\s*(\"[^\"]*\"|\d*\.?\d+|\w+)\s*(?:(and|or)\s*(\w+)\s*(>=|<=|!=|>|<|=)\s*(\"[^\"]*\"|\d*\.?\d+|\w+))?\s*$`)
var FilterRegex = regexp.MustCompile(`^(?:"([^"]*)"|(\w+))\s*(>=|<=|!=|>|<|=)\s*((?:"[^"]*"|-?\d+\.\d+|-?\d+|\.\d+|\w+))\s*(?:((?i:and|or))\s*(?:"([^"]*)"|(\w+))\s*(>=|<=|!=|>|<|=)\s*((?:"[^"]*"|-?\d+\.\d+|-?\d+|\.\d+|\w+)))?\s*$`)
matches := FilterRegex.FindStringSubmatch(filter)
if len(matches) == 0 {
return Filter{}, fmt.Errorf("invalid filter format: %s", filter)
}

// Helper function to extract value from multiple capture groups
extractValue := func(groups ...string) string {
for _, group := range groups {
if group != "" {
return group
}
}
return ""
}

var conditions []Condition

Column := extractValue(matches[1], matches[2])
conditions = append(conditions, Condition{
Column: matches[1],
Operator: matches[2],
Value: matches[3],
Column: Column,
Operator: matches[3],
Value: matches[4],
})

if matches[4] != "" {
// Check if there's a logical operator (and/or)
logicalOp := matches[5]
if logicalOp != "" {
Column := extractValue(matches[6], matches[7])
conditions = append(conditions, Condition{
Column: matches[5],
Operator: matches[6],
Value: matches[7],
Column: Column,
Operator: matches[8],
Value: matches[9],
})
}

return Filter{
Conditions: conditions,
LogicalOperator: matches[4],
LogicalOperator: logicalOp,
}, nil
}

Expand Down
Loading
Loading