Skip to content

Commit

Permalink
Support templated function argument type
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Nov 23, 2022
1 parent eec8087 commit cb8d2c4
Show file tree
Hide file tree
Showing 10 changed files with 3,218 additions and 10 deletions.
17 changes: 14 additions & 3 deletions catalog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ func TestCatalog(t *testing.T) {
langOpt := zetasql.NewLanguageOptions()
langOpt.SetNameResolutionMode(zetasql.NameResolutionDefault)
langOpt.SetProductMode(types.ProductExternal)
langOpt.SetEnabledLanguageFeatures([]zetasql.LanguageFeature{
zetasql.FeatureTemplateFunctions,
})
langOpt.SetSupportedStatementKinds([]resolved_ast.Kind{resolved_ast.QueryStmt})
opt := zetasql.NewAnalyzerOptions()
opt.SetAllowUndeclaredParameters(true)
Expand All @@ -176,14 +179,22 @@ func TestCatalog(t *testing.T) {
types.ScalarMode,
[]*types.FunctionSignature{
types.NewFunctionSignature(
types.NewFunctionArgumentType("", types.StringType()),
nil,
types.NewFunctionArgumentType(
types.StringType(),
types.NewFunctionArgumentTypeOptions(types.RequiredArgumentCardinality),
),
[]*types.FunctionArgumentType{
types.NewTemplatedFunctionArgumentType(
types.ArgTypeAny1,
types.NewFunctionArgumentTypeOptions(types.RequiredArgumentCardinality),
),
},
),
},
),
},
}
query := `SELECT * FROM sample_table WHERE MY_FUNC() = 'foo'`
query := `SELECT * FROM sample_table WHERE MY_FUNC(1.0) = 'foo'`
if _, err := zetasql.AnalyzeStatement(query, catalog, opt); err != nil {
t.Fatal(err)
}
Expand Down
Loading

0 comments on commit cb8d2c4

Please sign in to comment.