Skip to content

[GLUTEN-13457][FLINK][VL] Support NOT, IS FALSE, IS NOT TRUE to the velox flinksql functions - #13461

Open
sunshone wants to merge 2 commits into
apache:mainfrom
sunshone:flinksql-logical-expressions
Open

sunshone wants to merge 2 commits into
apache:mainfrom
sunshone:flinksql-logical-expressions

Conversation

@sunshone

@sunshone sunshone commented Oct 26, 2026 •

Copy link
Copy Markdown

What changes are proposed in this pull request?

Fixes #13457

Maps the Flink logical expressions to their velox flinksql implementations (companion velox PR bigo-sg/velox#90, velox4j ref bump bigo-sg/velox4j#71):

  • RexCallConverterFactory: NOT / IS FALSE / IS NOT TRUE / IS NOT FALSE entries — direct name mappings; these previously failed planning with "Function not supported".
  • IS TRUE → DefaultRexCallConverter("is_true"): Flink x IS TRUE returns FALSE for UNKNOWN and never NULL (ScalarOperatorGens.scala:771-777, NEVER_NULL); the previous equalto(x, true) mapping returns NULL for a NULL input. IsTrueRexCallConverter itself is pre-existing baseline code and is left untouched.
  • CI (.github/workflows/flink.yml): clone velox4j from the fork branch carrying the velox ref bump for this change (sunshone/velox4j flinksql-logical-expressions, pinned to the tip of that branch — the pin value lives in the workflow file and moves with the velox ref on each rebase), with a TODO recording the revert to bigo-sg/velox4j's gluten-20260829 branch (revert pin: see the TODO in flink.yml / Flink.md) once the velox-side flinksql functions land there; gluten-flink/docs/Flink.md build instructions updated accordingly.

The is_* names exist only in the velox flinksql namespace (companion PR), so landing order / version pairing matters; not reuses the single prestosql NOT implementation registered under the flinksql prefix, moving dialect ownership of the runtime path.

How was this patch tested?

  • New LogicalFunctionsTest in gluten-flink/ut (the ScalarFunctionsTest paradigm: bounded values table + runAndCheck changelog comparison) over a BOOLEAN column containing NULLs — 8/8 green: three-valued truth tables for all five operators (NOT preserves NULL; the IS_* predicates never return NULL), nested forms NOT(c1 IS FALSE) and (NOT(c1)) IS NOT TRUE (IS binds tighter than NOT in SQL), constant and constant-foldable operands including CAST(NULL AS BOOLEAN) IS TRUE asserting FALSE never NULL, and WHERE-clause filter cases. ScalarFunctionsTest regression 20/20.
  • End-to-end dual-run on Flink 1.19.2 (fixed filesystem inputs + print sink, changelog folded back to final result sets): 14 SQL cases, all FINISHED on both engines, 14/14 exact match — the five truth tables, nested / constant / filter cases, and regressions for already-mapped expressions (AND/OR three-valued logic, IS NULL / IS NOT NULL, regexp_extract / SUBSTRING / COALESCE, comparisons, IFNULL). GFV-side operator chains are Source -> gluten-calc -> Sink, confirming the expressions are offloaded to velox rather than falling back.

@github-actions github-actions Bot added the FLINK label Oct 26, 2026

@ggjh-159 ggjh-159 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

  1. This PR adds four mappings with no tests at all. Add SQL-level tests covering the three-valued truth tables of the four operators over a boolean column containing NULLs (NOT preserves NULL; the IS_* predicates never return NULL), nested forms such as NOT(c1 IS FALSE) and IS NOT TRUE(NOT c1), and constant / constant-foldable operands.

  2. .github/workflows/flink.yml:90 still clones velox4j at the gluten-20260829 branch, whose pinned velox does not contain the is_* functions these mappings resolve to, so the flink-test check cannot exercise them and would fail once tests are added. Point the clone at the velox4j branch carrying the velox ref bump for this change, and revert to gluten-20260829 once the velox-side functions land there.

@@ -111,6 +111,11 @@ public class RexCallConverterFactory {
Map.entry("count_char", Arrays.asList(() -> new DefaultRexCallConverter("count_char"))),
Map.entry("EXTRACT", Arrays.asList(() -> new DefaultRexCallConverter("extract"))),
Map.entry("IS TRUE", Arrays.asList(() -> new IsTrueRexCallConverter())),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The IS TRUE entry maps to equalto(x, true), which returns NULL for a NULL input, while Flink x IS TRUE returns FALSE and never NULL (ScalarOperatorGens.scala:771-777, NEVER_NULL). Switch this entry to the flinksql is_true function once it is available, and include IS TRUE in the SQL-level tests, asserting FALSE for NULL input.

@sunshone sunshone Oct 29, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Switched the IS TRUE entry to the flinksql is_true function (DefaultRexCallConverter), which returns FALSE and never NULL for a NULL input, and included IS TRUE in the SQL-level tests asserting FALSE for NULL — see the inline reply for details.

@github-actions github-actions Bot added the INFRA label Oct 29, 2026
@sunshone
sunshone force-pushed the flinksql-logical-expressions branch 5 times, most recently from af394da to d98b364 Compare October 29, 2026 09:42
@sunshone
sunshone force-pushed the flinksql-logical-expressions branch from ef74649 to d98b364 Compare October 29, 2026 11:33
@sunshone

sunshone commented Oct 29, 2026 •

Copy link
Copy Markdown
Author

@ggjh-159 Thanks for the thorough review!

  1. Added LogicalFunctionsTest in gluten-flink/ut (the SQL-level test module): 8 cases covering the truth tables over a boolean column with NULLs (NOT preserves NULL; the is_* predicates never return NULL), both nested forms (NOT(c IS FALSE) and IS NOT TRUE(NOT c) — note SQL precedence parses the latter as NOT(c IS NOT TRUE)), constant / constant-foldable operands including CAST(NULL AS BOOLEAN) IS TRUE, and the filter path.

  2. Pointed the workflow clone and the docs at the velox4j branch carrying the velox ref bump for this change, with a TODO to revert to the bigo-sg/velox4j gluten-20260829 branch once the velox-side flinksql logical functions land there. Also switched the IS TRUE mapping to the flinksql is_true function and added IS TRUE assertions to the tests — see the inline reply for details.

@sunshone
sunshone force-pushed the flinksql-logical-expressions branch 6 times, most recently from 6cb6b99 to df52202 Compare November 2, 2026 13:21
- RexCallConverterFactory: add converter entries for NOT, IS FALSE,
  IS NOT TRUE, IS NOT FALSE (default name mapping to the flinksql-
  registered functions; NOT overwrites the baseline via the same
  name in the vector function tier)

IS TRUE keeps the original IsTrueRexCallConverter.
@sunshone
sunshone force-pushed the flinksql-logical-expressions branch 5 times, most recently from 20cbd9c to 4e50a85 Compare November 3, 2026 03:58
@ggjh-159

ggjh-159 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@sunshone please update velox4j version and Flink.md

… velox4j pin

- Switch the IS TRUE entry in RexCallConverterFactory from
  IsTrueRexCallConverter (equalto(x, true), which returns NULL for a
  NULL input) to DefaultRexCallConverter("is_true"): Flink x IS TRUE
  returns FALSE for UNKNOWN and never NULL
  (ScalarOperatorGens.scala:771-777, NEVER_NULL). IsTrueRexCallConverter
  itself is baseline code and stays untouched.
- Add SQL-level tests (LogicalFunctionsTest, ScalarFunctionsTest
  paradigm) over a BOOLEAN column containing NULLs: three-valued truth
  tables for NOT/IS TRUE/IS FALSE/IS NOT TRUE/IS NOT FALSE (NOT
  preserves NULL, the IS_* predicates never return NULL), nested forms
  NOT(c1 IS FALSE) and (NOT(c1)) IS NOT TRUE (IS binds tighter than
  NOT, so the parenthesized form is the one that applies IS NOT TRUE to
  NOT c1), constant and constant-foldable operands including
  CAST(NULL AS BOOLEAN) IS TRUE, and a WHERE-clause filter case.
- Point the flink CI velox4j clone at the sunshone fork's
  flinksql-logical-expressions branch carrying the velox ref bump for
  this change (fix-velox4j.patch applies cleanly on the pinned head),
  reverting to bigo-sg gluten-20260829 once the velox-side functions
  land there.
@sunshone
sunshone force-pushed the flinksql-logical-expressions branch from 4e50a85 to 3717d81 Compare November 3, 2026 06:11

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FLINK][VL] Support the NOT, IS FALSE, IS NOT TRUE, logical expressions

3 participants