Skip to content

Small tasks on SQL compatibility #10540

@alexey-milovidov

Description

@alexey-milovidov
  • 1. Implement UNION DISTINCT. For implementation just add Distinct transform after union.
    Add syntax UNION without ALL or DISTINCT and setting union_default_mode (similar to join_default_strictness) with values: empty string, ALL, DISTINCT. When set to empty string, UNION without ALL or DISTINCT will throw an exception. When set to ALL or DISTINCT, the query will be rewritten in AST level.

  • 2. Implement NULL and NOT NULL modifiers after data type in table definition and in all places where data type can be parsed (e.g. CAST function/expression). If the type is not Nullable and if NULL is specified, it will be treated as Nullable; if NOT NULL is specified, it's noop. E.g. INT NULL is the same as Nullable(INT). If the type is Nullable and NULL or NOT NULL modifiers are specified, exception will be thrown. Add a setting data_type_default_nullable with values 0 and 1. If the value is 1, then data types without explicit modifier in table definition will be Nullable.

  • 3. Implement a setting rollup_use_null with values 0 and 1. When value is 1 and there is GROUP BY ... WITH ROLLUP or WITH CUBE, then RollupTransform and CubeTransform will treat GROUP BY keys as Nullable and emit Nullable columns. Add group_by_use_nulls setting #38642

  • 4. Implement positional specification for ORDER BY, GROUP BY and LIMIT BY. E.g. ORDER BY 1, 2. This does not correspond to SQL standard but improves compatibility with other DBMS. It should be controlled by setting enable_positional_arguments. Feature request: GROUP BY column number support #2592

  • 5. Implement a setting aggregate_functions_nullable_result. When this setting is enabled, aggregate functions will be rewritten with -OrNull modifier. Add setting aggregate_functions_null_for_empty #16123

  • 6. count and countDistinct (among with all uniq variants) from Nullable arguments should return non-Nullable result. For implementation, add a property to IAggregateFunction.

  • 7. Add support for multi-word expressions for data types, e.g. CHAR VARYING, DOUBLE PRECISION. Most of these complex expressions will simply map to existing data types.

  • 8. Support numeric parameters in VARCHAR, VARBINARY, INT... data types (e.g. VARCHAR(255)) and ignore them completely.

  • 9. CAST operator should accept not only exact data types but also data type modifiers Compatibility of CAST operator. #7119.

  • 10. Provide NUMERIC as a synonim to DECIMAL; provide many other similar symonims. Example: https://dev.mysql.com/doc/refman/8.0/en/other-vendor-data-types.html

Metadata

Metadata

Assignees

Labels

comp-sql-syntaxSQL/grammar parsing, AST nodes, syntax-level features.featuresql-compatibilitywarmup taskThe task for new ClickHouse team members. Low risk, moderate complexity, no urgency.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions