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
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ def _construct_prompt(
else:
prompt.append(sge.Literal.string(elem))

return sge.Kwarg(this=param_name, expression=sge.Tuple(expressions=prompt))
# Need Struct rather than tuple syntax, as tuple syntax is ambiguous for single arg
return sge.Kwarg(this=param_name, expression=sge.Struct(expressions=prompt))


def _construct_named_args(op: ops.ScalarOp) -> list[sge.Kwarg]:
Expand Down
8 changes: 8 additions & 0 deletions packages/bigframes/tests/system/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,14 @@ def usa_names_grouped_table(
return session.bqclient.get_table(table_id)


@pytest.fixture(scope="session", autouse=True)
def use_sqlglot_compiler():
original_setting = bigframes.options.experiments.sql_compiler
bigframes.options.experiments.sql_compiler = "experimental"
yield
bigframes.options.experiments.sql_compiler = original_setting


@pytest.fixture()
def restore_sampling_settings():
enable_downsampling = bigframes.options.sampling.enable_downsampling
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
AI.CLASSIFY(input => (`string_col`), categories => ['greeting', 'rejection']) AS `result`
AI.CLASSIFY(input => STRUCT(`string_col`), categories => ['greeting', 'rejection']) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.CLASSIFY(
input => (`string_col`),
input => STRUCT(`string_col`),
categories => ['greeting', 'rejection'],
connection_id => 'bigframes-dev.us.bigframes-default-connection'
) AS `result`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.CLASSIFY(
input => (`string_col`),
input => STRUCT(`string_col`),
categories => ['greeting', 'rejection'],
examples => [('hi', ['greeting', 'positive']), ('bye', ['rejection', 'negative'])],
output_mode => 'multi'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.CLASSIFY(
input => (`string_col`),
input => STRUCT(`string_col`),
categories => ['greeting', 'rejection'],
output_mode => 'multi'
) AS `result`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.CLASSIFY(
input => (`string_col`),
input => STRUCT(`string_col`),
categories => ['greeting', 'rejection'],
examples => [('hi', 'greeting'), ('bye', 'rejection')],
endpoint => 'gemini-2.5-flash',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
endpoint => 'gemini-2.5-flash',
request_type => 'SHARED'
) AS `result`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE_BOOL(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
endpoint => 'gemini-2.5-flash'
) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE_BOOL(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
connection_id => 'bigframes-dev.us.bigframes-default-connection',
endpoint => 'gemini-2.5-flash'
) AS `result`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE_BOOL(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
model_params => JSON '{}'
) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE_DOUBLE(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
endpoint => 'gemini-2.5-flash'
) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE_DOUBLE(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
connection_id => 'bigframes-dev.us.bigframes-default-connection',
endpoint => 'gemini-2.5-flash'
) AS `result`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE_DOUBLE(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
model_params => JSON '{}'
) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE_INT(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
endpoint => 'gemini-2.5-flash'
) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE_INT(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
connection_id => 'bigframes-dev.us.bigframes-default-connection',
endpoint => 'gemini-2.5-flash'
) AS `result`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE_INT(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
model_params => JSON '{}'
) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
connection_id => 'bigframes-dev.us.bigframes-default-connection',
endpoint => 'gemini-2.5-flash'
) AS `result`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
model_params => JSON '{}'
) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.GENERATE(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
endpoint => 'gemini-2.5-flash',
output_schema => 'x INT64, y FLOAT64'
) AS `result`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.IF(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
optimization_mode => 'MINIMIZE_COST',
max_error_ratio => 0.5
) AS `result`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.IF(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
connection_id => 'bigframes-dev.us.bigframes-default-connection',
optimization_mode => 'MINIMIZE_COST',
max_error_ratio => 0.5
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.IF(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
endpoint => 'gemini-2.5-flash'
) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
SELECT
AI.SCORE(prompt => (`string_col`, ' is the same as ', `string_col`)) AS `result`
AI.SCORE(prompt => STRUCT(`string_col`, ' is the same as ', `string_col`)) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.SCORE(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
connection_id => 'bigframes-dev.us.bigframes-default-connection'
) AS `result`
FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` AS `bft_0`
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
AI.SCORE(
prompt => (`string_col`, ' is the same as ', `string_col`),
prompt => STRUCT(`string_col`, ' is the same as ', `string_col`),
endpoint => 'gemini-2.5-flash',
max_error_ratio => 0.5
) AS `result`
Expand Down
Loading