Skip to content

[VL] Add ANSI mode support #10134

@PHILO-HE

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)

Tasks

Basic

1. Type Casting Functions (ANSI Strict)

2. Arithmetic Functions (ANSI Overflow Check)

3. Date/Time Functions (ANSI Validation)

  • Datetime expressions: ToUnixTimestamp, UnixTimestamp, GetTimestamp, TryToTimestampExpressionBuilder, NextDay, DateAddInterval, ParseToDate, TryToDateExpressionBuilder, ParseToTimestamp, MakeDate, TryMakeTimestampLTZExpressionBuilder, MakeTimestamp

4. String to Numeric Conversion (ANSI Strict)

5. Aggregation Functions (ANSI Overflow)

SUM, AVG, VAR_POP, VAR_SAMP, STDDEV_POP, STDDEV_SAMP

  • In ANSI mode: overflow checks during accumulation.

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

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Track

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions