Skip to content

[VL] Add ANSI mode support #10134

Description

@philo-he

Description

In this issue, we will list and track all tasks for ANSI mode support.

There are two Spark configurations directly related to ANSI usage.

  • spark.sql.ansi.enabled (default is true since Spark 4.0)
  • spark.sql.storeAssignmentPolicy (default is ANSI since Spark 3.0)

Please note this task list may not be complete; suggestions for additional tasks are welcome. Checked tasks have been claimed and may already have an associated PR or be finished. You are welcome to take on the unchecked tasks, but before doing so, please verify against the Velox codebase whether a relevant PR has already been created or merged.

Basic

1. Type Casting Functions (ANSI Strict)

cast several types to decimal
ANSI controls the overflow behavior in changePrecision
Cast.scala#L1103

2. Math Functions (ANSI Overflow Check)

3. Date/Time Functions (ANSI Validation)

4. Misc

5. Aggregation Functions (ANSI Overflow)

SUM, AVG, VAR_POP, VAR_SAMP, STDDEV_POP, STDDEV_SAMP

TRY_SUM (Spark 3.4+)

  • Returns NULL on overflow instead of error.

6. Window Functions (ANSI Overflow)

Same overflow checks apply in window operations:

  • SUM(...) OVER(...)
  • AVG(...) OVER(...)

7. ANSI SQL Compliant String Functions

SUBSTRING / SUBSTR

  • ANSI SQL standard argument order: SUBSTRING(str FROM start [FOR len])
  • Also supports classic form: SUBSTRING(str, start, len)

TRIM

  • ANSI syntax: TRIM(LEADING '0' FROM col) Also TRIM(BOTH ...), TRIM(TRAILING ...)

OVERLAY

  • ANSI SQL string replacement: OVERLAY(string PLACING replacement FROM start [FOR length])

See Spark ANSI compliance: https://github.com/apache/spark/blob/v4.0.0/docs/sql-ref-ansi-compliance.md
Related discussion: #4740.
facebookincubator/velox#3869

Metadata

Metadata

Labels

Type

No type

Projects

Status
Track

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions