From 38ff3e3e459a40586d1be09ab89b73416ef6812b Mon Sep 17 00:00:00 2001 From: Rusty Conover Date: Tue, 16 Jun 2026 01:28:52 -0400 Subject: [PATCH] test(integration): coverage-driven SQL tests for under-exercised worker paths Add language-agnostic sqllogictest coverage for VGI SDK paths the suite did not exercise, with matching example-worker fixtures (Python + Rust): - settings_types: a float (DOUBLE) setting read via get_f64 - secret_fields: named/positional secret field accessors over a resolved secret - numeric_promotion: float/unsigned/decimal/mixed-sign numeric promotion - filtered_columns_pushdown: the pushed-filter column-introspection accessors (filtered_columns / has_filter_for_column / typed get_column_values) Update scalar/table function_registration inventories for the new fixtures (scalar 39->41, table 93->94). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../scalar/function_registration.test | 32 ++++++- .../integration/scalar/numeric_promotion.test | 89 +++++++++++++++++++ .../sql/integration/secret/secret_fields.test | 44 +++++++++ .../integration/settings/settings_types.test | 49 ++++++++++ .../table/filtered_columns_pushdown.test | 69 ++++++++++++++ .../table/function_registration.test | 6 +- 6 files changed, 284 insertions(+), 5 deletions(-) create mode 100644 test/sql/integration/scalar/numeric_promotion.test create mode 100644 test/sql/integration/secret/secret_fields.test create mode 100644 test/sql/integration/settings/settings_types.test create mode 100644 test/sql/integration/table/filtered_columns_pushdown.test diff --git a/test/sql/integration/scalar/function_registration.test b/test/sql/integration/scalar/function_registration.test index 6916962..331080e 100644 --- a/test/sql/integration/scalar/function_registration.test +++ b/test/sql/integration/scalar/function_registration.test @@ -25,7 +25,7 @@ SELECT COUNT(*) FROM duckdb_functions() WHERE database_name = 'example' AND function_type = 'scalar'; ---- -39 +41 query T SELECT function_name @@ -61,6 +61,8 @@ pair_type random_bytes random_int return_secret_value +scale_by_setting +secret_field smart_format smart_format sum_values @@ -310,6 +312,30 @@ WHERE database_name = 'example' AND function_name = 'return_secret_value'; ---- return_secret_value [] [] VARCHAR CONSISTENT Return a secret's value +# ---------------------------------------------------------------------------- +# scale_by_setting — float Setting() parameter (read via get_f64, not visible) +# Parameters: value (DOUBLE) → DOUBLE +# ---------------------------------------------------------------------------- + +query TTTTTT +SELECT function_name, parameters, parameter_types, return_type, stability, description +FROM duckdb_functions() +WHERE database_name = 'example' AND function_name = 'scale_by_setting'; +---- +scale_by_setting [value] [DOUBLE] DOUBLE CONSISTENT Scale the input value by the float setting `scale_factor` + +# ---------------------------------------------------------------------------- +# secret_field — Secret() parameter, looks up individual fields by name +# Parameters: (none) → VARCHAR +# ---------------------------------------------------------------------------- + +query TTTTTT +SELECT function_name, parameters, parameter_types, return_type, stability, description +FROM duckdb_functions() +WHERE database_name = 'example' AND function_name = 'secret_field'; +---- +secret_field [] [] VARCHAR CONSISTENT Look up secret fields by name + # ---------------------------------------------------------------------------- # sum_values — Varargs with AnyArrow type and dynamic return type # Parameters: (none positional), varargs=ANY → ANY @@ -358,7 +384,7 @@ SELECT COUNT(*) FROM duckdb_functions() WHERE database_name = 'example' AND function_type = 'scalar' AND varargs IS NULL; ---- -33 +35 # ============================================================================ # Stability @@ -379,7 +405,7 @@ SELECT COUNT(*) FROM duckdb_functions() WHERE database_name = 'example' AND function_type = 'scalar' AND stability = 'CONSISTENT'; ---- -37 +39 # ============================================================================ # Cleanup diff --git a/test/sql/integration/scalar/numeric_promotion.test b/test/sql/integration/scalar/numeric_promotion.test new file mode 100644 index 0000000..125eda9 --- /dev/null +++ b/test/sql/integration/scalar/numeric_promotion.test @@ -0,0 +1,89 @@ +# name: test/sql/integration/scalar/numeric_promotion.test +# description: Exercises numeric type promotion across float/unsigned/decimal/mixed-sign inputs +# group: [vgi_integration_scalar] + +require-env VGI_TEST_WORKER + +require vgi + +require httpfs + +statement ok +ATTACH 'example' AS example (TYPE vgi, LOCATION '${VGI_TEST_WORKER}'); + +# ============================================================================ +# double(value) — output type is promoted for overflow headroom. +# float32 -> float64 ; unsigned widens ; decimal gains one digit of precision. +# ============================================================================ + +query T +SELECT typeof(example.double(1.5::REAL)); +---- +DOUBLE + +query I +SELECT example.double(1.5::REAL) = 3.0; +---- +true + +query T +SELECT typeof(example.double(10::UTINYINT)); +---- +USMALLINT + +query I +SELECT example.double(10::UTINYINT); +---- +20 + +query T +SELECT typeof(example.double(100::UINTEGER)); +---- +UBIGINT + +query T +SELECT typeof(example.double(1.25::DECIMAL(10,2))); +---- +DECIMAL(11,2) + +query I +SELECT example.double(1.25::DECIMAL(10,2)) = 2.50; +---- +true + +# ============================================================================ +# add_values(a, b) — common numeric type of the two inputs, then promoted. +# mixed-sign integers -> int64 ; same-sign widen ; decimals merge precision/scale. +# ============================================================================ + +query T +SELECT typeof(example.add_values(2::INTEGER, 3::UINTEGER)); +---- +BIGINT + +query I +SELECT example.add_values(2::INTEGER, 3::UINTEGER); +---- +5 + +query T +SELECT typeof(example.add_values(2::TINYINT, 3::INTEGER)); +---- +BIGINT + +query I +SELECT example.add_values(2::TINYINT, 3::INTEGER); +---- +5 + +# Decimal inputs exercise the decimal branch of the common-type computation. We +# assert only the value, not typeof: the exact result precision/scale of decimal +# addition is implementation-defined and differs between worker backends. + +query I +SELECT example.add_values(1.50::DECIMAL(5,2), 2.250::DECIMAL(7,3)) = 3.750; +---- +true + +statement ok +DETACH example; diff --git a/test/sql/integration/secret/secret_fields.test b/test/sql/integration/secret/secret_fields.test new file mode 100644 index 0000000..efa2b2a --- /dev/null +++ b/test/sql/integration/secret/secret_fields.test @@ -0,0 +1,44 @@ +# name: test/sql/integration/secret/secret_fields.test +# description: Exercises named/positional secret field accessors over a resolved secret +# group: [vgi_integration_secret] + +require-env VGI_TEST_WORKER + +require vgi + +require httpfs + +statement ok +ATTACH 'example' AS example (TYPE vgi, LOCATION '${VGI_TEST_WORKER}'); + +# ============================================================================ +# secret_field() looks up a field on a named secret (named_field -> port) and +# the first secret carrying a field of any name (field -> secret_string). +# ============================================================================ + +statement ok +CREATE SECRET test_secret (TYPE vgi_example, secret_string 'hello_world', api_key 'key-abc-123', port 5432, use_ssl true, timeout 30.5); + +query T +SELECT example.secret_field(); +---- +port=5432;name=hello_world + +# Re-create with different values — the accessors reflect the new secret. + +statement ok +DROP SECRET test_secret; + +statement ok +CREATE SECRET test_secret (TYPE vgi_example, secret_string 'rotated', api_key 'y', port 9999, use_ssl false, timeout 7.0); + +query T +SELECT example.secret_field(); +---- +port=9999;name=rotated + +statement ok +DROP SECRET test_secret; + +statement ok +DETACH example; diff --git a/test/sql/integration/settings/settings_types.test b/test/sql/integration/settings/settings_types.test new file mode 100644 index 0000000..c26f322 --- /dev/null +++ b/test/sql/integration/settings/settings_types.test @@ -0,0 +1,49 @@ +# name: test/sql/integration/settings/settings_types.test +# description: Validates a float (DOUBLE) setting read via the get_f64 accessor +# group: [vgi_integration_settings] + +require-env VGI_TEST_WORKER + +require vgi + +require httpfs + +statement ok +ATTACH 'example' AS example (TYPE vgi, LOCATION '${VGI_TEST_WORKER}'); + +# The float setting is registered and visible. + +query I +SELECT COUNT(*) FROM duckdb_settings() WHERE name = 'scale_factor'; +---- +1 + +# scale_by_setting(value) multiplies its input by the DOUBLE setting scale_factor, +# read via Settings::get_f64. + +statement ok +SET scale_factor = 2.5; + +query I +SELECT example.scale_by_setting(4.0) = 10.0; +---- +true + +query I +SELECT example.scale_by_setting(value) = 5.0 +FROM (VALUES (2.0)) AS t(value); +---- +true + +# A different float value is reflected on the next call. + +statement ok +SET scale_factor = 0.5; + +query I +SELECT example.scale_by_setting(10.0) = 5.0; +---- +true + +statement ok +DETACH example; diff --git a/test/sql/integration/table/filtered_columns_pushdown.test b/test/sql/integration/table/filtered_columns_pushdown.test new file mode 100644 index 0000000..9362f37 --- /dev/null +++ b/test/sql/integration/table/filtered_columns_pushdown.test @@ -0,0 +1,69 @@ +# name: test/sql/integration/table/filtered_columns_pushdown.test +# description: Pushed-filter column introspection — filtered_columns, has_filter_for_column, typed get_column_values_array +# group: [vgi_integration_table] + +require-env VGI_TEST_WORKER + +require vgi + +require httpfs + +statement ok +ATTACH 'example' AS example (TYPE vgi, LOCATION '${VGI_TEST_WORKER}'); + +# filtered_columns_echo(count) reports, per query, which columns the pushed-down +# filters reference (filtered_cols), whether a given column is filtered (has_n / +# has_tag), and the discrete value set resolved for the string column `tag` via +# the typed get_column_values_array accessor (tag_values). + +# No filter — nothing is constrained. + +query TTTT +SELECT DISTINCT filtered_cols, has_n, has_tag, tag_values +FROM example.filtered_columns_echo(5); +---- +(empty) false false (none) + +# Discrete IN on a string column — resolved as a typed value set. + +query TTTT +SELECT DISTINCT filtered_cols, has_n, has_tag, tag_values +FROM example.filtered_columns_echo(5) WHERE tag IN ('t1','t3'); +---- +tag false true t1,t3 + +# Equality on a string column. + +query TTTT +SELECT DISTINCT filtered_cols, has_n, has_tag, tag_values +FROM example.filtered_columns_echo(5) WHERE tag = 't2'; +---- +tag false true t2 + +# Both columns constrained (AND) — get_column_values_array digs into the AND child. + +query TTTT +SELECT DISTINCT filtered_cols, has_n, has_tag, tag_values +FROM example.filtered_columns_echo(5) WHERE n IN (1, 2, 3) AND tag = 't2'; +---- +n,tag true true t2 + +# A non-enumerable range filter — column is reported as filtered, but no discrete set. + +query TTTT +SELECT DISTINCT filtered_cols, has_n, has_tag, tag_values +FROM example.filtered_columns_echo(5) WHERE n >= 2; +---- +n true false (none) + +# The pushed filter is also applied to the rows (auto_apply_filters): the string +# IN keeps exactly the matching rows. + +query IT +SELECT n, tag FROM example.filtered_columns_echo(5) WHERE tag IN ('t1', 't3') ORDER BY n; +---- +1 t1 +3 t3 + +statement ok +DETACH example; diff --git a/test/sql/integration/table/function_registration.test b/test/sql/integration/table/function_registration.test index 3a22332..9c5a8dc 100644 --- a/test/sql/integration/table/function_registration.test +++ b/test/sql/integration/table/function_registration.test @@ -49,13 +49,15 @@ ATTACH 'example' AS example (TYPE vgi, LOCATION '${VGI_TEST_WORKER}'); # see table/time_travel_pushdown.test) + # 1 typed const-arg / typed-column emit fixture (typed_probe, see # table/typed_probe.test) -# = 93 +# 1 filter-column introspection fixture (filtered_columns_echo, see +# table/filtered_columns_pushdown.test) +# = 94 query I SELECT COUNT(*) FROM duckdb_functions() WHERE database_name = 'example' AND function_type = 'table'; ---- -93 +94 # The 33 pure table functions (no TABLE parameter type) # Note: make_series appears 5 times (5 overloads), make_pairs appears 3 times,