ZdravDim opened a new pull request, #60353: URL: https://github.com/apache/spark/pull/60353
### What changes were proposed in this pull request? This is the first PR for the `GAP FILL` relation operator ([SPARK-61276](https://issues.apache.org/jira/browse/SPARK-61276)). `GAP FILL` adds a row at each bin start of a regular time grid that has no input row, and can fill values in the added rows. This PR adds only the syntax. Every `GAP FILL` query is still rejected with `UNSUPPORTED_FEATURE.GAP_FILL`. Resolution and execution come in later PRs. ```sql SELECT * FROM relation GAP FILL ( [PARTITION BY col [, ...]] ORDER BY timeCol BIN WIDTH widthExpr [ALIGN TO originExpr] [FROM startExpr TO endExpr] [FILL (col method [, ...])] [MAX GAP maxGapExpr] [BIN_START [AS name]] [IS_GENERATED [AS name]] ) [AS alias] ``` The fill `method` is `LINEAR`, `FFILL` (or `FORWARD FILL`), `BFILL` (or `BACKWARD FILL`), `CONSTANT expr`, or `NULL`. The clause also works as a pipe operator: `|> GAP FILL (...)`. - Grammar: the `gapFillClause` rule and 9 new non-reserved keywords: `BACKWARD`, `BFILL`, `CONSTANT`, `FFILL`, `FILL`, `FORWARD`, `GAP`, `IS_GENERATED`, `LINEAR`. - Logical plan: `UnresolvedGapFill`, and `GapFillColumn` for each `FILL` entry. A repeated clause raises `DUPLICATE_CLAUSES`. - Conf `spark.sql.gapFillRelationOperator.enabled` (internal, default `false`). - Analyzer rule `ResolveGapFill`: rejects the node with `UNSUPPORTED_FEATURE.GAP_FILL`. With the conf on, it waits for the child to resolve, so an error such as a missing table is reported first. ### Why are the changes needed? Time series data often has missing time buckets. Filling them today takes a generated time grid, a join, and window functions. `GAP FILL` does it in one clause. Landing the syntax first keeps each PR small. ### Does this PR introduce _any_ user-facing change? Yes, small: - The 9 new keywords are non-reserved, so they still work as names. They are listed in `SQL_KEYWORDS()`, the docs keyword table, and the Thrift server and JDBC keyword lists. - A `GAP FILL` query now fails with `UNSUPPORTED_FEATURE.GAP_FILL` instead of a parse error. ### How was this patch tested? - `PlanParserSuite`: every clause and fill method, any clause order, the pipe form, aliases, repeated clauses, syntax errors, and the new keywords as names. - `ResolveGapFillSuite`: the rejection with the conf on and off. - Updated keyword goldens and the Thrift server and JDBC keyword tests. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Claude Opus 5.5) This pull request and its description were written by Isaac. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
