Skip to content

chore(optimizer)!: annotate snowflake ARRAY_COMPACT#6735

Merged
VaggelisD merged 1 commit intomainfrom
mlee/annotate-array_compact
Jan 14, 2026
Merged

chore(optimizer)!: annotate snowflake ARRAY_COMPACT#6735
VaggelisD merged 1 commit intomainfrom
mlee/annotate-array_compact

Conversation

@fivetran-MichaelLee
Copy link
Collaborator

This PR adds type annotation support for Snowflake's ARRAY_COMPACT function.

Changes

  • Added ArrayCompact expression class to expressions.py
  • Added type annotation for ARRAY_COMPACT in typing/snowflake.py
  • Added test cases in test_snowflake.py and annotate_functions.sql

ARRAY_COMPACT Support Across Dialects

Platform Supported Arguments Return Type
Snowflake Yes array: ARRAY (or VARIANT containing array) ARRAY (same type as input, with NULLs removed)
BigQuery No N/A N/A
Redshift No N/A N/A
PostgreSQL No N/A N/A
Databricks Yes array: ARRAY ARRAY (same type as input, with NULLs removed)
DuckDB No N/A N/A
TSQL No N/A N/A
Spark Yes array: ARRAY ARRAY (same type as input, with NULLs removed)

Note: ARRAY_COMPACT removes NULL values from an existing array. This is different from ARRAY_CONSTRUCT_COMPACT, which constructs a new array while omitting NULL values during construction.

@fivetran-MichaelLee fivetran-MichaelLee self-assigned this Jan 14, 2026
@github-actions
Copy link
Contributor

SQLGlot Integration Test Results

Comparing:

  • this branch (sqlglot:mlee/annotate-array_compact, sqlglot version: mlee/annotate-array_compact)
  • baseline (main, sqlglot version: 28.6.1.dev1)

⚠️ Limited to dialects: snowflake

By Dialect

dialect main sqlglot:mlee/annotate-array_compact difference links
snowflake -> duckdb 599/847 passed (70.7%) 599/847 passed (70.7%) No change full result / delta
snowflake -> snowflake 847/847 passed (100.0%) 847/847 passed (100.0%) No change full result / delta

Overall

main: 1694 total, 1446 passed (pass rate: 85.4%), sqlglot version: 28.6.1.dev1

sqlglot:mlee/annotate-array_compact: 1694 total, 1446 passed (pass rate: 85.4%), sqlglot version: mlee/annotate-array_compact

Difference: No change

Comment on lines +6074 to +6075
class ArrayCompact(Func):
pass
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also test the rest of the dialects and add additional tests.

For example this function exists in spark and databricks.

Copy link
Collaborator

@VaggelisD VaggelisD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, I'll go ahead and add the remaining tests thanks!

@VaggelisD VaggelisD merged commit c1fa7b5 into main Jan 14, 2026
9 checks passed
@VaggelisD VaggelisD deleted the mlee/annotate-array_compact branch January 14, 2026 10:01
dangotbanned added a commit to narwhals-dev/narwhals that referenced this pull request Feb 4, 2026
- Pin added #3432
- Original issue resolved eakmanrq/sqlframe#577
- Current pin blocking tobymao/sqlglot#6735
- Pin complained about #3445 (comment)
MarcoGorelli pushed a commit to narwhals-dev/narwhals that referenced this pull request Feb 4, 2026
- Pin added #3432
- Original issue resolved eakmanrq/sqlframe#577
- Current pin blocking tobymao/sqlglot#6735
- Pin complained about #3445 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants