Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[String] Use direct string value from ZetaSQL #183

Merged
merged 1 commit into from
Mar 9, 2024
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
7 changes: 3 additions & 4 deletions internal/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ func ValueFromZetaSQLValue(v types.Value) (Value, error) {
return boolValueFromLiteral(v.SQLLiteral(0))
case types.FLOAT, types.DOUBLE:
return floatValueFromLiteral(v.SQLLiteral(0))
case types.STRING, types.ENUM:
case types.STRING:
return StringValue(v.StringValue()), nil
case types.ENUM:
return stringValueFromLiteral(v.SQLLiteral(0))
case types.BYTES:
return bytesValueFromLiteral(v.SQLLiteral(0))
Expand Down Expand Up @@ -206,9 +208,6 @@ func floatValueFromLiteral(lit string) (FloatValue, error) {
}

func stringValueFromLiteral(lit string) (StringValue, error) {
if strings.HasPrefix(lit, `'`) {
return StringValue(strings.Trim(lit, `'`)), nil
}
v, err := strconv.Unquote(lit)
if err != nil {
return "", fmt.Errorf("failed to unquote from string literal: %w", err)
Expand Down
9 changes: 9 additions & 0 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3364,6 +3364,15 @@ WITH markdown AS (
{"<h1>Another heading</h1>"},
},
},
// Regression tests for goccy/go-zetasqlite#178
{
name: "regexp_replace quoted",
query: `SELECT REGEXP_REPLACE('"quote123"', r'["\d]', '')`,
expectedRows: [][]interface{}{
{"quote"},
},
},

{
name: "regexp_substr",
query: `
Expand Down
Loading