Skip to content

CEIL and FLOOR do not support comma syntax #1376

@seve-martinez

Description

@seve-martinez

The current implementation only supports CEIL/FLOOR calls when including TO <DateTimeField>. However this syntax appears to be rare and so far I've only found it supported in Kinesis, which isn't supported by sqlparser at all.

The majority of dialects support a single expression, or an expression and a scale separated by a comma:

SELECT CEIL(321.56, 1)

-- prints 321.6

SELECT CEIL(321.56)
-- prints 322

Snowflake
BigQuery
Hive
ClickHouse
DuckDb
MsSql
MySql
Postgres
Redshift
SQLite

The existing impl:
https://github.com/sqlparser-rs/sqlparser-rs/blob/1e209d87415a5adfedccac8cee3e2860122e4acb/src/parser/mod.rs#L1694-L1716

Because the CEIL/FLOOR expressions expect a DateTimeField, I'm not sure it makes sense to just pass a numeric literal to this and force into a Custom(Ident) type.

Happy to open a PR for this, but wanted to understand the best way to handle field attribute here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions