diff --git a/AST.md b/AST.md new file mode 100644 index 000000000000..7134816ac189 --- /dev/null +++ b/AST.md @@ -0,0 +1,761 @@ +# `EXPLAIN AST json = 1` — JSON dump of the parsed AST + +`EXPLAIN AST json = 1 ` serializes the parsed (not analyzed) AST of +a query to JSON. It is implemented by `formatASTAsJSON` in +`src/Parsers/DumpASTNode.cpp`; `InterpreterExplainQuery` calls +`formatASTAsJSONDocument`, which wraps the result in the versioned document. + +This document is the contributor reference: how to run it, the output +contract, the per-class schema, and how to extend it to new AST nodes. It +consolidates the earlier design notes (formerly `AST2.md` / `AST3.md`). + +## Running it + +```bash +clickhouse local --format TSVRaw -q "EXPLAIN AST json = 1 SELECT * FROM foo WHERE x = 1" +clickhouse client --format TSVRaw -q "EXPLAIN AST json = 1 SELECT * FROM foo WHERE x = 1" +``` + +`--format TSVRaw` matters: the explain result is a single string cell, and +the default TSV format escapes the embedded newlines as `\n`. `TSVRaw` +prints them literally so you get readable multi-line JSON. Pipe into `jq` +for querying: + +```bash +clickhouse local --format TSVRaw -q "EXPLAIN AST json = 1 SELECT * FROM foo WHERE x = 1" \ + | jq '.ast.selects[0].where' +``` + +The query only has to **parse** — referenced tables and columns need not +exist. `json` is mutually exclusive with the `graph` option of +`EXPLAIN AST`. + +## Document wrapper and version + +The top-level value is a versioned document, not the root node directly: + +```json +{ "version": 2, "ast": { "type": "SelectWithUnionQuery", ... } } +``` + +`version` (`AST_JSON_FORMAT_VERSION` in `DumpASTNode.h`) is bumped on any +backwards-incompatible change to the JSON shape, so external consumers that +pin reference fixtures can detect breaks. The AST itself is under `ast`. + +## Downstream consumer — clickhouse-js-parser + +This format is consumed by the TypeScript parser at +, which pins the +fixtures in `tests/ast_json_fixtures` as a reference suite (vendored +alongside its existing `clickhouse-reference-{ast,format,explain,round-trip}` +suites). Several format decisions exist specifically to line up with it, and +should not be "simplified" away without coordinating there: + +- **Versioned document.** The js parser pins fixtures, so any break must be + detectable — hence `{ version, ast }` and the `AST_JSON_FORMAT_VERSION` + bump-on-break rule above. +- **64-bit integers as strings.** Its AST stores `Literal.value` as `string` + because JS `JSON.parse` corrupts integers above 2^53; see the contract + below. +- **Named slots mirror its AST types.** The slot names and shapes track the + node types in the parser's `src/ast.ts` — e.g. `QueryParameter` nodes + (including in identifier/table position, `Identifier = string | QueryParam`), + `LimitByClause { count, by, offset }` ↔ our `limit_by { length, offset?, + by }`, the `WindowFrameBound` discriminated union ↔ our `frame_begin` / + `frame_end` `{ type, offset?, preceding? }`, and the except/replace/apply + `ColumnTransformer` types ↔ our inlined `transformers` array. +- **Operator-name normalization** matches its text-explain serializer's + operator map (`src/explain.ts`); see "Known divergences" below. + +When changing the format: bump `AST_JSON_FORMAT_VERSION`, update the `039*` +stateless tests and regenerate `tests/ast_json_fixtures`, and flag the change +so the js parser can re-vendor and pin the new version. + +## Output contract + +Every node is a JSON object with: + +- `type` — the short class id (e.g. `"Function"`, `"Identifier"`, + `"Literal"`), computed by `astTypeName`: `IAST::getID(' ')` trimmed at the + first space (getID packs auxiliary data after a space delimiter). A few + classes return a descriptive getID that *itself* contains a space + (`"Dictionary lifetime"`); trimming those would collapse the five + `Dictionary*` classes onto one `"Dictionary"`, so the sub-elements are + spelled out explicitly in `astTypeName`. +- `alias` — only when the node has an alias. + +`type` tells you the shape. Beyond that, a node exposes its sub-nodes in +one of two ways: + +1. **Named slots** — most classes expose each meaningful sub-node under a + named key (`arguments`, `where`, `table_expression`, ...). When a class + does this it does **not** also emit `children`. +2. **`children` array** — kept only for genuinely *homogeneous lists*, + where positionality carries no hidden meaning: + - `ExpressionList` + - `TablesInSelectQuery` (one element per JOIN) + +So: if `type` is `"Function"` you read `arguments` / `parameters`; if it is +`"ExpressionList"` you read `children`. + +Absent optional slots are omitted entirely (no `null`s). List-shaped +clauses **inline** their inner `ExpressionList` wrapper rather than emit it, +because the wrapper is a parser-internal detail. + +64-bit integer literal values (`UInt64` / `Int64`) — and settings values in +the `Settings` node's `changes` map — are emitted as JSON **strings**, not +numbers: values above 2^53 would lose precision when a JavaScript consumer +runs them through `JSON.parse`. `value_type` still says how to interpret the +string. + +## Implementation + +`formatASTAsJSON(const IAST &)` builds the tree recursively. For each node +it writes `type` and `alias`, then calls: + +```cpp +bool enrichNode(JSONBuilder::JSONMap & node, const IAST & ast); +``` + +`enrichNode` adds the per-class fields and returns `handled_children`. When +it returns `true`, `formatASTAsJSON` skips the generic `children` walk for +that node (everything interesting is already under a named slot). The +default is `return false`, so any class not special-cased keeps its +positional `children` array. + +Two helpers (anonymous namespace): + +- `inlineExpressionList(list)` — emit an `ASTExpressionList`'s children as a + JSON array, dropping the wrapper. A null list yields `[]`. +- `addNodeSlot(node, key, child)` — emit a single sub-node under `key`, only + when present. + +`formatASTAsJSONDocument` wraps the result of `formatASTAsJSON` in the +`{ version, ast }` document; it is the entry point used by the interpreter. + +### Dispatch ordering caveat + +`enrichNode` is an `if / else if` chain of `dynamic_cast`s. Derived classes +must be matched **before** their base. In particular +`ASTSelectIntersectExceptQuery` derives from `ASTSelectQuery` but keeps its +operand selects in `children` (not in the `Expression` slots), so it is +matched first; it re-exposes those operands under `selects` and returns +`true`. Adding a new subclass of an already-handled class without ordering +it first will silently route it through the base branch. + +## Schema by node class + +Scalar flags below are emitted only when set/non-default unless noted. + +### Expressions + +- **Function** (`arguments` always present, even if empty): + `name`, `is_operator`, `is_window_function`, `is_lambda_function`, + `kind`, `nulls_action`, `arguments` (inlined), `parameters` (inlined, + parametric aggregates), `window_definition` *or* `window_name`. + Operators and lambdas are ordinary functions: `a + b` → `name: "plus"`; + a lambda's parameter-tuple and body come through `arguments`. +- **Identifier**: `name`, `name_parts` (when compound). +- **TableIdentifier**: `name` (short), `database` (when qualified). +- **QueryParameter**: `name`, `param_type` (the `{name:type}` substitution; + appears in value position and in identifier/table position). Note these + survive into the AST only inside a parameterized view — otherwise the + parameter is substituted (or errors) before `EXPLAIN` runs. +- **Literal**: `value_type` (the `Field` type), `value`. `Null` → JSON null, + `Bool` → JSON bool, `Float64` → JSON number, `String` → JSON string; + `UInt64` / `Int64` → JSON **string** (see contract); `Array` / `Tuple` → + JSON array of typed `{value_type, value}` elements, `Map` / `Object` → JSON + object of typed values; everything else → string via `FieldVisitorToString` + (see "Container and fallback value serialization"). +- **Asterisk**: `expression`, `transformers` (an array; plain `*` is bare). +- **QualifiedAsterisk**: `qualifier`, `transformers` (array). +- **ColumnsRegexpMatcher**: `pattern`, `expression`, `transformers` (array). +- **ColumnsListMatcher**: `expression`, `columns` (inlined), `transformers` + (array). +- **ColumnsApplyTransformer**: `func_name`, `parameters`, `lambda`, + `lambda_arg`, `column_name_prefix`. +- **ColumnsExceptTransformer**: `is_strict`, `columns` (inlined) for the + explicit column-list form, or `pattern` for the regexp form + (`EXCEPT 'a.*'`). +- **ColumnsReplaceTransformer**: `is_strict`, `replacements` (inlined). +- **ColumnsReplaceTransformer::Replacement**: `name`, `expression`. + +`transformers` is a JSON array of the transformer nodes (the +`ASTColumnsTransformerList` wrapper is inlined, like every other list slot). + +### Clauses and queries + +- **SelectQuery**: scalar flags `distinct`, `group_by_all`, + `group_by_with_totals` / `_rollup` / `_cube` / `_grouping_sets`, + `order_by_all`, `recursive_with`, `limit_with_ties` (`LIMIT ... WITH TIES`); + then one slot per clause — + `with`, `select`, `from`, `prewhere`, `where`, `group_by`, `having`, + `window`, `qualify`, `order_by`, `offset`, `limit`, `settings`, + `interpolate`, and `limit_by`. List-shaped clauses are inlined; the rest + are nodes. `LIMIT ... BY ...` is grouped into one object slot + `limit_by: { length, offset?, by }` (`by` inlined). `ALIASES` / + `CTE_ALIASES` are analyzer state and never present on parsed ASTs, so + they are omitted. +- **SelectWithUnionQuery**: `union_mode` (non-default only), `selects` + (inlines `list_of_selects`), plus the shared output clause (see below). +- **SelectIntersectExceptQuery**: `operator`, `selects` (the operand selects, + mirroring `SelectWithUnionQuery`). +- **Subquery**: `cte_name`, `query` (its single child). +- **WithElement**: `name`, `subquery`, `aliases`. +- **Output clause** (shared by all `ASTQueryWithOutput` subclasses — e.g. + `SelectWithUnionQuery` and the table-scoped DDL/DML): the trailing + `[INTO OUTFILE [APPEND | TRUNCATE] [AND STDOUT] + [COMPRESSION [LEVEL ]]] [FORMAT ] [SETTINGS ...]` suffix. + Serialized as `out_file` (the filename literal node; present only for + `INTO OUTFILE`), the `outfile_append` / `outfile_truncate` / + `outfile_with_stdout` boolean flags (each only when set), `compression` and + `compression_level` (literal nodes), `format` (a plain string, mirroring the + InsertQuery `format` field), and `settings` (the output-level `SETTINGS` + placed *after* `FORMAT`, e.g. `SELECT ... FORMAT TSV SETTINGS max_threads = + 1`). All slots are omitted when absent. Note the position of `SETTINGS` + matters: a `SETTINGS` placed *before* `FORMAT` (`SELECT 1 SETTINGS x = 1 + FORMAT TSV`) is consumed into the operand `SelectQuery`'s own `settings` + slot instead of the wrapper's output-clause `settings`. + +### FROM / JOIN + +- **TablesInSelectQueryElement**: `table_join`, `table_expression`, + `array_join`. +- **TableExpression**: `database_and_table_name` / `table_function` / + `subquery` (one of), `final`, `sample_size`, `sample_offset`, + `column_aliases`. +- **TableJoin**: `kind` (always), `strictness`, `locality`, `using` + (inlined), `on`. +- **ArrayJoin**: `kind` (`INNER` / `LEFT`), `expressions` (inlined). + +### ORDER BY / WINDOW / misc + +- **OrderByElement**: `expression`, `direction`, `nulls_first`, `with_fill`, + `collation`, `fill_from`, `fill_to`, `fill_step`, `fill_staleness`. +- **WindowListElement**: `name`, `definition`. +- **WindowDefinition**: `parent_window_name`, `partition_by` (inlined), + `order_by` (inlined), and — when the frame is non-default — `frame_type` + plus `frame_begin` / `frame_end`, each a `{ type, offset?, preceding? }` + object (`type` is the boundary type; `preceding` emitted only when true). +- **InterpolateElement**: `column`, `expr`. +- **Settings** (the `SETTINGS` clause / `ASTSetQuery`; `type` is `"Settings"`, + not `"Set"` — see note below): `changes` (name → value object, values + stringified like literals), `default_settings`. +- **SampleRatio**: `numerator`, `denominator` (exact rationals, stringified + since they may exceed `UInt64`). + +### DDL / DML + +- **CreateQuery** (also `AttachQuery` by `type` when `attach`): the `attach` / + `temporary` / `if_not_exists` / `is_*_view` / `is_dictionary` / `replace_*` / + `create_or_replace` flags (when set), `attach_from_path` and + `attach_as_replicated` (the `ATTACH TABLE t FROM '/path'` source and the + `ATTACH TABLE t AS [NOT] REPLICATED` conversion marker), `uuid`, `cluster` + (`ON CLUSTER`), `database`, `table`, `columns_list`, `aliases`, `storage`, + `as_table_function`, `as_database` / `as_table`, `select`, `targets`, + `comment`, `dictionary_attributes`, `dictionary`, `refresh` (the refreshable + materialized-view `REFRESH ...` strategy). +- **RefreshStrategy** (`ASTRefreshStrategy`; the MV `REFRESH` clause, also the + target of `ALTER ... MODIFY REFRESH`): `schedule_kind` (`AFTER` / `EVERY` / + `UNKNOWN`), `append`, `period`, `offset`, `spread` (each a `TimeInterval`), + `dependencies` (inlined), `settings`. `schedule_kind` / `append` are scalar + members, not `children`. +- **TimeInterval** (`ASTTimeInterval`, e.g. `1 YEAR 3 DAY`): `interval`, an + array of `{kind, value}` units (`kind` from `IntervalKind::toString()`). The + whole value is held in a member with no AST children. +- **Columns** (`ASTColumns`): `columns`, `indices`, `constraints`, + `projections` (inlined), `primary_key`, `primary_key_from_columns`. +- **ColumnDeclaration**: `name`, `data_type`, `default_specifier`, + `default_expression`, `null_modifier`, `ephemeral_default`, + `primary_key_specifier`, `comment`, `codec`, `statistics`, `ttl`, + `collation`, `settings`. +- **DataType**: `name`, `arguments` (inlined, e.g. `Decimal(10, 2)`). +- **EnumDataType** (`Enum` / `Enum8` / `Enum16` with fully explicit values): + `name`, `values` (array of `{ name, value }`; `value` is a JSON number — enum + values fit in `Int16`). Auto-assigned enums (`Enum8('a', 'b')`) instead parse + to a generic `DataType` carrying the elements in `arguments`. +- **TupleDataType** (`Tuple`): `name`, `arguments` (the element types, inlined), + and `element_names` (array of strings) for a *named* tuple. Unnamed tuples omit + `element_names`. +- **ObjectTypeArgument** (`ASTObjectTypeArgument`; its `type` is overridden + from the raw `"ASTObjectTypeArgument"` getID): one argument of a JSON/Object + type — exactly one of `path_with_type` (an `ObjectTypedPath`), `skip_path` + (`SKIP x`), `skip_path_regexp` (`SKIP REGEXP '...'`), or `parameter` + (a `setting = N` pair) is present. +- **ObjectTypedPath** (`ASTObjectTypedPathArgument`, a JSON/Object typed path + `a.b.c Type`): `name` (the path) and `data_type` (not `type`, which is + reserved for the node-class discriminator). The path is otherwise only + echoed into `getID`, which `astTypeName` trims away. +- **Storage**: `engine`, `partition_by`, `primary_key`, `order_by`, + `sample_by`, `ttl_table`, `settings`. +- **InsertQuery**: `database`, `table`, `table_function`, `columns`, + `format`, `partition_by`, `settings`, `select`, `infile`, `compression`. +- **Index**: `name`, `expression`, `index_type`, `granularity`. +- **Constraint**: `name`, `constraint_type` (`CHECK` / `ASSUME`), + `expression`. +- **Projection**: `name`, `query`, `index`, `index_type` (the `INDEX expr TYPE + name` projection index type, an `ASTFunction`), `settings` (projection-level + `SETTINGS`). `index_type` and `settings` live in dedicated members, not + `children`. +- **ProjectionSelectQuery**: `with`, `select`, `group_by`, `order_by` (all + inlined). Unlike a normal SELECT, a projection stores its `ORDER BY` as a + *single* node — multiple keys packed into a `tuple(...)` and a lone key kept + bare — so `order_by` is reconstructed as a flat list of keys (the tuple's + arguments, or the single key), matching the SQL formatter. A projection's + `GROUP BY` is a plain expression list (no GROUPING SETS / ROLLUP / CUBE in the + projection grammar). +- **TTLElement**: `mode` (`DELETE` / `MOVE` / `GROUP_BY` / `RECOMPRESS`), + `ttl`, and for `MOVE` the `destination_type` / `destination_name` / + `if_exists`; for `GROUP_BY` the `group_by_key` and `group_by_assignments` + (both arrays of nodes, kept in dedicated members the native AST otherwise + drops); `where`, `recompression_codec`. +- **Collation** (`ASTCollation`, the `COLLATE` clause of a column or ORDER BY + element): `name` (the collation identifier; falls back to the parsed node + when it is not a plain identifier). The name lives in the `collation` member, + not `children`. +- **Partition**: `all`, `value`, `id`. +- **DeleteQuery**: `database`, `table`, `cluster`, `partition`, `predicate`. +- **UpdateQuery**: `database`, `table`, `cluster`, `assignments`, + `predicate`, `partition`. +- **DropQuery** (also `DetachQuery` / `TruncateQuery` by `type`): `kind`, + `database`, `table`, `cluster`, `if_exists` / `if_empty` / `is_dictionary` + / `is_view` / `sync` / `permanently`, `database_and_tables`. For + `TRUNCATE ALL TABLES FROM db`: `has_all` / `has_tables`, plus the optional + table-name pattern `like` with `not_like` / `case_insensitive_like` flags. +- **OptimizeQuery**: `database`, `table`, `cluster`, `partition`, `final`, + `deduplicate`, `deduplicate_by_columns`, `cleanup`. +- **Assignment**: `column`, `expression`. +- **AlterQuery**: `alter_object` (`TABLE` / `DATABASE`), `database`, `table`, + `cluster`, `commands` (inlined). +- **AlterCommand**: `command_type` (the full `ALTER` verb, e.g. `ADD_COLUMN`, + `MOVE_PARTITION`, `MODIFY_TTL`), the relevant flags, and whichever sub-node + slots apply — `column_declaration`, `column`, `order_by`, `index_declaration`, + `partition`, `predicate`, `assignments`, `comment`, `ttl`, `settings_changes`, + `select`, `rename_to`, `snapshot_desc`, ... plus the `from*` / `to*` / + `move_destination_name` / `with_name` / `snapshot_name` strings, + `move_destination_type` (`DISK` / `VOLUME` / `TABLE` / `SHARD`, on + `MOVE_PARTITION`), and `replace` (on `REPLACE_PARTITION`, distinguishing + `REPLACE` from `ATTACH ... FROM`). +- **CreateFunctionQuery**: `or_replace`, `if_not_exists`, `cluster`, + `function_name`, `function_core`. +- **DropFunctionQuery**: `function_name`, `if_exists`, `cluster`. +- **CreateNamedCollectionQuery**: `collection_name`, `if_not_exists`, + `cluster`, `changes` (the `key = value` body as a name -> value object), and + `overridability` (a name -> bool object, present only for keys carrying an + explicit `OVERRIDABLE` / `NOT OVERRIDABLE` flag). The node has no `children`. + Unlike the `Settings` node's `changes` (untyped strings), each value here is a + typed `{value_type, value}` pair, exactly like a `Literal`. A named collection + carries no schema, so the tag is required to keep the value forms from + colliding: `b = 5` (`UInt64`) vs `b = '5'` (`String`) both stringify to `"5"`; + likewise `a = -5` (`Int64`) vs `'-5'`, `a = disk(...)` (a function, stored as a + `CustomType`) vs the same text as a `String`, and `a = 1.0` (`Float64`, value + `1`) vs the integer `1`. +- **CreateWorkloadQuery**: `or_replace`, `if_not_exists`, `cluster`, + `workload_name`, `workload_parent` (the `IN parent` clause), and `changes` + (array of `{name, value, resource?}` — each SETTINGS entry with its optional + `FOR resource`). `value` is a typed `{value_type, value}` pair, as for a named + collection above (same collision reasoning). +- **CreateResourceQuery**: `or_replace`, `if_not_exists`, `cluster`, + `resource_name`, `unit` (`IOByte` / `CPUNanosecond` / `QuerySlot`), and + `operations` (array of `{mode, disk?}`; `mode` is `READ` / `WRITE` / + `MASTER_THREAD` / `WORKER_THREAD` / `QUERY`, and an absent `disk` means ANY + DISK). +- **DropNamedCollectionQuery** / **DropWorkloadQuery** / + **DropResourceQuery**: `collection_name` / `workload_name` / `resource_name` + respectively, plus `if_exists` and `cluster`. All are plain string members + (no `children`), so without the explicit branches these nodes would expose + nothing but their `type`. +- **BackupQuery** (also `RestoreQuery` by `type`): `kind`, `cluster`, + `elements`, `backup_name` (the `TO` / `FROM` destination), `base_backup_name` + (incremental base), `settings`, `cluster_host_ids` (internal, normally + absent). Each `elements` entry has `element_type`, `database` / `table`, + `new_database` / `new_table` (only when an `AS` clause renamed the object), + `partitions`, `except_tables` (array of `{database, table}`), + `except_databases`. Note the parser folds the `DICTIONARY` / `VIEW` keywords + into `element_type` `TABLE`. +- **Dictionary** (`ASTDictionary`): `primary_key` (inlined), `source`, + `lifetime`, `layout`, `range`, `settings`. +- **DictionaryAttributeDeclaration**: `name`, `data_type`, `default_value`, + `expression`, `hierarchical`, `bidirectional`, `injective`, `is_object_id`. +- **FunctionWithKeyValueArguments**: `name`, `elements` (inlined `pair`s). +- **pair** (`ASTPair`): `key`, `value`. +- the dictionary sub-elements — layout (`layout_type`, `parameters`), + lifetime (`min_sec`, `max_sec`), range (`min_attr_name`, `max_attr_name`), + settings (`changes`). +- **ViewTargets**: `targets` (array of `{kind, database, table, inner_engine, + table_ast}`). + +The dictionary sub-elements get explicit `type` ids — `DictionaryLayout`, +`DictionaryLifetime`, `DictionaryRange`, `DictionarySettings` — set in +`astTypeName`. Their `getID`s (`"Dictionary lifetime"`, ...) would otherwise +all trim at the first space to the same `"Dictionary"` as the container. +`ASTSetQuery` is likewise overridden to `"Settings"` (its `getID` is `"Set"`, +confusable with `SET` statements and the `Set` data structure). + +### Other statements and elements + +- **Explain**: `kind`, `query`, `settings`, `table_function`, `table_override`, + `output_settings`. `settings` is the EXPLAIN-level settings clause + (`EXPLAIN SETTINGS = ...`, `ASTExplainQuery::ast_settings`), while + `output_settings` is the trailing output-clause settings + (`EXPLAIN ... FORMAT SETTINGS =`, the `ASTQueryWithOutput` base + `settings_ast`). Both may be present at once and are kept on separate keys. +- **DescribeQuery**: `table_expression`. +- **ShowTables**: covers SHOW TABLES / DATABASES / CLUSTERS / CLUSTER / + DICTIONARIES / SETTINGS / MERGES / FILESYSTEM CACHES on one class. The + variant-selector flags `databases`, `clusters`, `cluster` (singular, SHOW + CLUSTER ``), `dictionaries`, `show_settings` (the internal + `m_settings` member — renamed so the `m_` prefix does not leak and it does + not collide with the `settings` slot), `changed` (SHOW CHANGED SETTINGS), + `merges`, `caches`, `temporary`, `full`; `cluster_name` (the SHOW CLUSTER + operand, the internal `cluster_str` member — `cluster` elsewhere is the ON + CLUSTER string, so that key is not reused); `from`, `like`, `not_like`, + `case_insensitive_like` (LIKE vs ILIKE), `where`, `limit`. +- **ShowColumns**: `extended` / `full` flags, `table` (always present — the + grammar requires `FROM `), `database`, `like` / `not_like` / + `case_insensitive_like`, `where`, `limit`. The native AST keeps all of these + in plain members (its `children` is empty), so they are surfaced explicitly + here; otherwise `SHOW COLUMNS`, `SHOW FIELDS`, `SHOW EXTENDED FULL COLUMNS`, + ... would collapse to a bare `{"type": "ShowColumns"}` and lose the table. +- **ShowSetting**: `setting_name` (the sole operand; lives in a private member, + so without this it would collapse to a bare `{"type": "ShowSetting"}`). +- **ShowFunctions**: `like` / `case_insensitive_like` (the sole operand; a plain + member, so otherwise `SHOW FUNCTIONS LIKE '...'` loses its filter). +- **ShowIndexes** (`ASTShowIndexesQuery`, `SHOW INDEX/INDEXES/INDICES/KEYS`): + `extended`, `table` (mandatory), `database`, `where`. Its `getID` is a mis-set + `"ShowColumns"` (shared verbatim with `ASTShowColumnsQuery`), so `astTypeName` + overrides the `type` to `"ShowIndexes"` to keep the two distinct statements + distinguishable. +- **CreateIndexQuery** / **DropIndexQuery**: table target, `if_not_exists` / + `unique` / `if_exists`, `index_name`, `index_declaration`. +- **CheckQuery**: table target, `partition`, `part_name`. +- **UseQuery**: `database`. +- **KillQueryQuery**: `kill_type`, `sync`, `test`, `cluster`, `where`. The + `SYNC` / `ASYNC` / `TEST` mode is the `sync` and `test` bool pair — `ASYNC` is + neither set. +- **TransactionControl** (`ASTTransactionControl`; `type` is overridden from the + raw `"ASTTransactionControl"` getID): `action` (`BEGIN` / `COMMIT` / + `ROLLBACK` / `SET_SNAPSHOT`) and, for `SET_SNAPSHOT`, `snapshot` (stringified + `UInt64`). Both collapse onto one class otherwise. +- **Rename**: `exchange` / `database` / `dictionary` flags, `cluster`, + `elements` (array of `{from_database, from_table, to_database, to_table, + if_exists}`). +- **SYSTEM** (`ASTSystemQuery`): `system_type`, then the operand fields — + each only meaningful for a subset of the ~130 sub-commands, surfaced + whenever populated: `database`, `table`, `if_exists`, `cluster`, `replica`, + `shard`, `replica_zk_path` and `is_drop_whole_replica` (DROP REPLICA), + `with_tables`, `target_model`, `target_function`, `storage_policy` / + `volume` / `disk` (STOP MOVES / MERGES scopes and cache drops), `seconds` + (SUSPEND FOR; stringified `UInt64`), `sync_replica_mode` (`STRICT` / + `LIGHTWEIGHT` / `PULL`; `DEFAULT` omitted) with `src_replicas` + (LIGHTWEIGHT FROM list), `tables` (FLUSH LOGS / FLUSH ASYNC INSERT QUEUE + targets, an array of `{database?, table}`), `settings`, + `schema_cache_storage` / `schema_cache_format` (DROP SCHEMA CACHE), + `filesystem_cache_name` / `key_to_drop` / `offset_to_drop` (stringified; + filesystem-cache drops), `distributed_cache_drop_connections` / + `distributed_cache_server_id`, `query_result_cache_tag`, `backup_name` / + `backup_source` (UNFREEZE / RESTORE-related), `fail_point_name` / + `fail_point_action` (`PAUSE` / `RESUME`), `fake_time_for_view` + (TEST VIEW SET FAKE TIME; stringified — absent means UNSET), and for + START/STOP LISTEN the `server_type` object `{type, custom_name?, + exclude_types?, exclude_custom_names?}` (values from + `ServerType::serverTypeToString`). The `SYSTEM INSTRUMENT` operands are + compiled only under `USE_XRAY` and are not serialized. +- **Stat** (`ASTStatisticsDeclaration`): `columns`, `types`. +- **StorageOrderByElement**: `expression`, `direction`. +- **NameTypePair**: `name`, `data_type`. +- **QualifiedColumnsRegexpMatcher** / **QualifiedColumnsListMatcher**: + `pattern` / `columns`, `qualifier`, `transformers`. + +A generic fallback over `ASTQueryWithTableAndOutput` gives `database` / +`table` / `temporary` / `uuid` (when set, e.g. `UNDROP TABLE t UUID '...'`) to +every other simple table-scoped statement that carries only a target — +`EXISTS *`, `SHOW CREATE *`, etc. `UndropQuery` additionally exposes `cluster` +(`ON CLUSTER`). + +### Access management + +The access-control statements store their content in typed member fields and +plain value objects rather than the positional `children` list (`GrantQuery` +has no children at all; `CreateUserQuery` keeps only `AuthenticationData` +markers), so each is enriched with named slots. Scalar flags are emitted only +when set. + +- **GrantQuery** / **RevokeQuery** (one class `ASTGrantQuery`, split by + `is_revoke`): `attach_mode`, `admin_option`, `current_grants`, + `replace_access`, `replace_granted_roles`, `cluster`; then either + `access_rights` (privilege grant) **or** `roles` (role grant, a + `RolesOrUsersSet`), and `grantees` (`RolesOrUsersSet`). `access_rights` is an + array of privilege elements — `{access_types, database?, default_database?, + table?, columns?, parameter?, wildcard?, grant_option?, is_partial_revoke?}`; + `access_types` is the decoded keyword list (`["SELECT", "UPDATE"]`). +- **CheckGrantQuery**: `access_rights` (same element shape). +- **CreateUserQuery** (also ALTER USER via `alter`): `alter`, `attach`, + `if_exists`, `if_not_exists`, `or_replace`, `cluster`, `names` + (`UserNamesWithHost`), `new_name`, `storage_name`, `authentication_methods` + (array of `AuthenticationData`), `reset_authentication_methods_to_new`, + `add_identified_with`, `replace_authentication_methods`, `hosts` / `add_hosts` + / `remove_hosts` (the HOST clause, see below), `default_roles` + (`RolesOrUsersSet`), `default_database` (`DatabaseOrNone`), `settings` / + `alter_settings`, `grantees` (`RolesOrUsersSet`), `global_valid_until`. +- **CreateRoleQuery** (also ALTER ROLE): `alter`, `attach`, the `if_*` flags, + `cluster`, `names` (string array), `new_name`, `storage_name`, `settings` / + `alter_settings`. +- **CreateQuotaQuery** (also ALTER QUOTA): `alter`, `attach`, the `if_*` flags, + `cluster`, `names`, `new_name`, `key_type`, `storage_name`, `limits`, `roles` + (`RolesOrUsersSet`). Each `limits` entry is `{duration_sec, + randomize_interval?, drop?, max?}` where `max` maps quota-type name → + stringified value (e.g. `{ "QUERIES": "100", "RESULT_ROWS": "1000" }`; the + keys are the uppercase `toString(QuotaType)` set below). +- **SetRoleQuery** (`SET ROLE` / `SET DEFAULT ROLE`): `kind`, `roles` + (`RolesOrUsersSet`), `to_users` (`RolesOrUsersSet`, for `SET DEFAULT ROLE`). +- **CreateRowPolicyQuery** (also ALTER ROW POLICY): `alter`, `attach`, the + `if_*` flags, `cluster`, `storage_name`, `names` (`RowPolicyNames`), + `new_short_name`, `is_restrictive` (bool), `filters`, `roles`. Each `filters` + entry is `{filter_type, condition?}` — `condition` is omitted when the filter + was set to `NONE`. +- **CreateSettingsProfileQuery** (also ALTER SETTINGS PROFILE): like + CreateRole, plus `to_roles` (`RolesOrUsersSet`). +- **CreateMaskingPolicyQuery** (also ALTER MASKING POLICY): the create/alter + flags, `cluster`, `storage_name`, `name`, `database`, `table`, `new_name`, + `update_assignments` (inlined `Assignment` list), `where_condition`, `roles`, + `priority` (stringified, only when non-zero). +- **DropAccessEntityQuery**: `entity_type`, `if_exists`, `cluster`, + `storage_name`, `names`, `row_policy_names` (`RowPolicyNames`, for policies). +- **MoveAccessEntityQuery**: `entity_type`, `cluster`, `storage_name`, `names`, + `row_policy_names`. +- **ExecuteAsQuery**: `target_user` (`UserNameWithHost`), `subquery`. +- **ShowGrantsQuery**: `for_roles` (`RolesOrUsersSet`), `with_implicit`, + `final`. +- **ShowCreateAccessEntityQuery**: `entity_type`, `names`, `row_policy_names`, + `current_quota`, `current_user`, `all`, `short_name`, `database`, `table`. +- **ShowAccessEntitiesQuery**: `entity_type`, `all`, `current_quota`, + `current_roles`, `enabled_roles`, `short_name`, `database`, `table`. + +Shared helper nodes: + +- **RolesOrUsersSet**: `all`, `use_keyword_any`, `names`, `current_user`, + `except_names`, `except_current_user`, `id_mode` (when true the `names` hold + UUIDs rather than names). +- **UserNamesWithHost**: `users` (array of `UserNameWithHost`). +- **UserNameWithHost**: `name`, `host_pattern` (only when present). +- **AuthenticationData**: `auth_type`, `contains_password`, `contains_hash`, + `ssl_cert_subject_type`, `valid_until`, and `arguments` — the password / hash + / salt / server / realm literal nodes, emitted verbatim (the JSON reflects + the parsed literals regardless of secret-masking display settings). +- **SettingsProfileElements**: `elements` (array of `SettingsProfileElement`). +- **SettingsProfileElement**: `parent_profile`, `setting_name`, `value`, + `min_value`, `max_value`, `disallowed_values`, `writability`, `id_mode`. + Values are stringified like literals. +- **AlterSettingsProfileElements**: `add_settings`, `modify_settings`, + `drop_settings` (each a `SettingsProfileElements`), `drop_all_settings`, + `drop_all_profiles`. +- **RowPolicyNames**: `policies` (array of `{short_name, database?, table?}`). +- **RowPolicyName**: `short_name`, `database`, `table`. +- **DatabaseOrNone**: `none: true` **or** `database`. +- **PublicSSHKey**: `key_type`, `key_base64`. + +The privilege list (`access_rights`) and the HOST clause (`hosts` / +`add_hosts` / `remove_hosts`) are plain value objects, not AST nodes, so they +are serialized inline. The HOST object is `{any_host?, local_host?, names?, +name_regexps?, like_patterns?, addresses?, subnets?}` (addresses and subnets in +canonical text form). + +### Not yet enriched + +`ParallelWithQuery` keeps `children` deliberately — it is a homogeneous list +of parallel sub-queries. Any class not special-cased in `enrichNode` likewise +falls back to the positional `children` array. The JSON stays valid; only +those subtrees are positional. + +## Container and fallback value serialization + +`Literal.value` is native JSON for the scalar `Field` types (with the 64-bit +integer caveat). The container `Field` types recurse, preserving each +element's own type: + +- **Array** / **Tuple**: a JSON array of typed elements, each a + `{ "value_type": , "value": }` pair mirroring how an + `ASTLiteral` node is serialized — so `[1, 2]` becomes + `[{"value_type": "UInt64", "value": "1"}, {"value_type": "UInt64", + "value": "2"}]`. +- **Map** / **Object**: a JSON object keyed by the (stringified) key with + typed values, e.g. `{"tbl": {"value_type": "String", "value": "x = 1"}}`. + JSON keys are always strings; a non-`String` map key falls back to its + `FieldVisitorToString` form (an integer key becomes its digits). A `Map` + whose elements are not two-element (key, value) tuples — not expected for a + real `Map` field — falls back to the generic array-of-typed-elements form. + +Every remaining `value_type` is stringified by `FieldVisitorToString` +(`src/Common/FieldVisitorToString.cpp`, the authority for the exact syntax). +Consumers re-parsing those strings should pin against that. The shape: + +- **String** (and `String`-typed scalars): the content is delivered + already-unescaped in the JSON string. +- **Decimal32/64/128/256**: the decimal text, e.g. `Decimal(10, 2)` casts + serialize the type as a plain string. +- **UUID / IPv4 / IPv6**: their canonical text form, e.g. + `00000000-0000-0000-0000-000000000000`. +- **Int128 / UInt128 / Int256 / UInt256**: decimal digits as a string. +- **Bool** is native JSON (`true` / `false`); `Null` is JSON `null`. + +Note integer literals too large for `UInt256` are parsed as `Float64` and +emitted as JSON numbers (so they can lose precision — that is a property of +the parser, not the serializer). + +## Enum value sets + +These slots carry a fixed set of strings from internal `toString` helpers. +Pinned here so upstream renames are reviewable. Values omitted when the +node's default applies are marked *(default, omitted)*. + +- **Function.kind**: `WINDOW_FUNCTION`, `LAMBDA_FUNCTION`, `TABLE_ENGINE`, + `DATABASE_ENGINE`, `BACKUP_NAME`, `CODEC`, `STATISTICS` + (`ORDINARY_FUNCTION` *(default, omitted)*). +- **Function.nulls_action**: `RESPECT NULLS`, `IGNORE NULLS` + (`EMPTY` *(default, omitted)*). +- **TableJoin.kind**: `INNER`, `LEFT`, `RIGHT`, `FULL`, `CROSS`, `COMMA`, + `PASTE`. +- **TableJoin.strictness**: `RIGHT_ANY`, `ANY`, `ALL`, `ASOF`, `SEMI`, + `ANTI` (`UNSPECIFIED` *(default, omitted)*). +- **TableJoin.locality**: `LOCAL`, `GLOBAL` (`UNSPECIFIED` *(default, + omitted)*). +- **ArrayJoin.kind**: `INNER`, `LEFT`. +- **SelectWithUnionQuery.union_mode** (only when non-default): `UNION_ALL`, + `UNION_DISTINCT`, `EXCEPT_ALL`, `EXCEPT_DISTINCT`, `INTERSECT_ALL`, + `INTERSECT_DISTINCT` (the `*_DEFAULT` variants are not emitted). +- **SelectIntersectExceptQuery.operator**: `INTERSECT ALL`, + `INTERSECT DISTINCT`, `EXCEPT ALL`, `EXCEPT DISTINCT`. +- **OrderByElement.direction** / **StorageOrderByElement.direction**: `ASC`, + `DESC`. +- **ColumnDeclaration.default_specifier**: `DEFAULT`, `MATERIALIZED`, + `ALIAS`, `EPHEMERAL`, `AUTO_INCREMENT` (Empty *(default, omitted)*). + `null_modifier` is a JSON bool, not a string. +- **WindowDefinition.frame_type**: `ROWS`, `GROUPS`, `RANGE`. +- **frame_begin.type / frame_end.type**: `Unbounded`, `Current`, `Offset`. +- **Constraint.constraint_type**: `CHECK`, `ASSUME`. +- **DropQuery.kind**: `DROP`, `DETACH`, `TRUNCATE` (also reflected in the + node's `type`: `DropQuery` / `DetachQuery` / `TruncateQuery`). +- **BackupQuery.kind**: `BACKUP`, `RESTORE` (also reflected in the node's + `type`: `BackupQuery` / `RestoreQuery`). +- **BackupQuery.elements[].element_type**: `TABLE`, `TEMPORARY_TABLE`, + `DATABASE`, `ALL`. +- **KillQueryQuery.kill_type**: `QUERY`, `MUTATION`, `PART_MOVE_TO_SHARD`, + `TRANSACTION`. +- **TTLElement.mode**: `DELETE`, `MOVE`, `GROUP_BY`, `RECOMPRESS`. +- **TTLElement.destination_type** (with `MOVE`): `DISK`, `VOLUME`, `TABLE`, + `DELETE`, `SHARD`. +- **AlterQuery.alter_object**: `TABLE`, `DATABASE` (`UNKNOWN` *(default, + omitted)*). +- **AlterCommand.command_type**: `ADD_COLUMN`, `DROP_COLUMN`, + `MODIFY_COLUMN`, `COMMENT_COLUMN`, `RENAME_COLUMN`, `MATERIALIZE_COLUMN`, + `MODIFY_ORDER_BY`, `MODIFY_SAMPLE_BY`, `MODIFY_TTL`, `REWRITE_PARTS`, + `MATERIALIZE_TTL`, `MODIFY_SETTING`, `RESET_SETTING`, `MODIFY_QUERY`, + `MODIFY_REFRESH`, `REMOVE_TTL`, `REMOVE_SAMPLE_BY`, `ADD_INDEX`, + `DROP_INDEX`, `MATERIALIZE_INDEX`, `ADD_CONSTRAINT`, `DROP_CONSTRAINT`, + `ADD_PROJECTION`, `DROP_PROJECTION`, `MATERIALIZE_PROJECTION`, + `ADD_STATISTICS`, `DROP_STATISTICS`, `MODIFY_STATISTICS`, + `MATERIALIZE_STATISTICS`, `DROP_PARTITION`, `DROP_DETACHED_PARTITION`, + `FORGET_PARTITION`, `ATTACH_PARTITION`, `MOVE_PARTITION`, + `REPLACE_PARTITION`, `FETCH_PARTITION`, `FREEZE_PARTITION`, `FREEZE_ALL`, + `UNFREEZE_PARTITION`, `UNFREEZE_ALL`, `DELETE`, `UPDATE`, + `APPLY_DELETED_MASK`, `APPLY_PATCHES`, `NO_TYPE`, `MODIFY_DATABASE_SETTING`, + `MODIFY_DATABASE_COMMENT`, `MODIFY_COMMENT`, `MODIFY_SQL_SECURITY`, + `UNLOCK_SNAPSHOT`. +- **TransactionControl.action**: `BEGIN`, `COMMIT`, `ROLLBACK`, `SET_SNAPSHOT`. +- **RefreshStrategy.schedule_kind**: `AFTER`, `EVERY`, `UNKNOWN`. +- **SetRoleQuery.kind**: `SET_ROLE`, `SET_ROLE_DEFAULT`, `SET_DEFAULT_ROLE`. +- **CreateQuotaQuery.key_type** (`toString(QuotaKeyType)`): `NONE`, + `USER_NAME`, `IP_ADDRESS`, `FORWARDED_IP_ADDRESS`, `CLIENT_KEY`, + `CLIENT_KEY_OR_USER_NAME`, `CLIENT_KEY_OR_IP_ADDRESS`. +- **CreateQuotaQuery.limits[].max** keys (`toString(QuotaType)`): `QUERIES`, + `QUERY_SELECTS`, `QUERY_INSERTS`, `ERRORS`, `RESULT_ROWS`, `RESULT_BYTES`, + `READ_ROWS`, `READ_BYTES`, `EXECUTION_TIME`, `WRITTEN_BYTES`, + `FAILED_SEQUENTIAL_AUTHENTICATIONS`. +- **CreateRowPolicyQuery.filters[].filter_type** + (`toString(RowPolicyFilterType)`): `SELECT_FILTER`. +- **SettingsProfileElement.writability**: `WRITABLE`, `CONST`, + `CHANGEABLE_IN_READONLY`. +- **AuthenticationData.auth_type** (`toString(AuthenticationType)`, the SQL + keyword): `NO_PASSWORD`, `PLAINTEXT_PASSWORD`, `SHA256_PASSWORD`, + `DOUBLE_SHA1_PASSWORD`, `LDAP`, `KERBEROS`, `SSL_CERTIFICATE`, + `BCRYPT_PASSWORD`, `SSH_KEY`, `HTTP`, `JWT`, `SCRAM_SHA256_PASSWORD`, + `NO_AUTHENTICATION`. +- **entity_type** on the Drop/Move/ShowCreate/Show access statements + (`toString(AccessEntityType)`, uppercased with spaces): `USER`, `ROLE`, + `SETTINGS PROFILE`, `ROW POLICY`, `QUOTA`, `MASKING POLICY`. + +`Explain.kind` (`ASTExplainQuery::toString`) and `SYSTEM.system_type` +(`ASTSystemQuery::typeToString`) draw from large sets — see those helpers. +The `03930_explain_ast_json_type_ids` test snapshots the complete set of +node `type` ids so a new descriptive `getID` cannot silently collide. + +## Known divergences for source-fidelity consumers + +The JSON reflects the parsed `IAST`, not the source text. Consumers needing +source fidelity should know (no code change planned): + +- **Operator spelling is normalized**: `!=` and `<>` both become + `notEquals`, `||` → `concat`, `a BETWEEN x AND y` → `and(greaterOrEquals, + lessOrEquals)`, etc. The text-explain serializer's operator map is the + inverse. +- **No comments, source locations, or parenthesization** are preserved by + the parser, so they are absent from the JSON. +- **Empty vs absent `ExpressionList`** is indistinguishable after inlining — + an empty inlined list and a missing clause both read as "no/empty array". +- **`LIMIT n, m` comma syntax is normalized** into separate `offset` / + `limit` slots (there is no record that the comma form was used). +- **`INTERPOLATE` is attached at `SelectQuery` level** (the `interpolate` + slot), not to the last `WITH FILL` `ORDER BY` element. + +## Adding a new node class + +1. In `enrichNode`, add an `else if (const auto * x = dynamic_cast(&ast))` + branch (before its base class if it derives from a handled one). +2. Emit scalars with `node.add`, list slots with `inlineExpressionList`, + single sub-nodes with `addNodeSlot` / `formatASTAsJSON`. +3. `return true` to suppress `children` — unless the node legitimately + carries a homogeneous list you want to keep there, in which case emit + only the scalars and fall through to `return false`. +4. Add the `#include` for the node header. +5. Extend the doc list in `DumpASTNode.h` and add a case to the relevant + test below. + +This is a deliberate schema break versus the original opaque `children` +dump; acceptable because `EXPLAIN AST json = 1` is new and undocumented. +Inlining `ExpressionList` wrappers loses the (query-unobservable) +distinction between an empty list and an absent clause. + +## Tests + +`tests/queries/0_stateless/`: + +- `03917_explain_ast_json_function` — Function slots. +- `03918_explain_ast_json_order_by` — OrderByElement slots. +- `03919_explain_ast_json_select_query` — SelectQuery clauses. +- `03920_explain_ast_json_expressions` — literals, lambda, operators, CAST, + NULLS action, compound identifiers. +- `03921_explain_ast_json_union` — UNION modes, INTERSECT / EXCEPT. +- `03922_explain_ast_json_showcase` — one maximal query dumped in full (no + node filtering); doubles as a readable example of the format. +- `03923_explain_ast_json_wrappers` — joins, array join, table expressions, + subquery collapse, window frames, interpolate. +- `03924_explain_ast_json_leaf_state` — SETTINGS, SAMPLE, asterisks and + COLUMNS matchers / transformers. +- `03925_explain_ast_json_ddl` — CREATE TABLE family + INSERT. +- `03926_explain_ast_json_ddl_elements` — index/constraint/projection/TTL/ + partition and DELETE/UPDATE/DROP/OPTIMIZE. +- `03927_explain_ast_json_alter_dict` — ALTER family and dictionaries. +- `03928_explain_ast_json_misc_queries` — EXPLAIN/DESCRIBE/SHOW/KILL/RENAME/ + SYSTEM and the table-target fallback. +- `03929_explain_ast_json_query_parameters` — the `{ version, ast }` wrapper + and query parameters (via a parameterized view). +- `03930_explain_ast_json_type_ids` — snapshot of every emitted node `type` + id (collision guard). +- `03931_explain_ast_json_datatype_elements` — the data-type element slots: + `EnumDataType.values`, `TupleDataType.element_names` (named / unnamed / + mixed), the `Nested` `NameTypePair` elements, the auto-enum fallback, and the + `Dynamic(max_types = N)` argument. + +The tests pipe through `jq` (`--format TSVRaw`) to keep references readable +and focused. diff --git a/datatype-parser/.gitignore b/datatype-parser/.gitignore new file mode 100644 index 000000000000..567609b1234a --- /dev/null +++ b/datatype-parser/.gitignore @@ -0,0 +1 @@ +build/ diff --git a/datatype-parser/CMakeLists.txt b/datatype-parser/CMakeLists.txt new file mode 100644 index 000000000000..5ff06511c952 --- /dev/null +++ b/datatype-parser/CMakeLists.txt @@ -0,0 +1,27 @@ +cmake_minimum_required(VERSION 3.16) +project(chdt_datatype_parser CXX) + +# A self-contained library: no dependency on the ClickHouse source tree. +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +add_compile_options(-Wall -Wextra) + +add_library(chdt_datatype_parser + src/lexer.cpp + src/parser.cpp + src/json.cpp +) +target_include_directories(chdt_datatype_parser PUBLIC include) + +# CLI: read a data-type string, print its JSON AST. Exit non-zero on error. +add_executable(chdt-parse tool/main.cpp) +target_link_libraries(chdt-parse PRIVATE chdt_datatype_parser) + +enable_testing() +add_subdirectory(test) diff --git a/datatype-parser/README.md b/datatype-parser/README.md new file mode 100644 index 000000000000..9e480404e420 --- /dev/null +++ b/datatype-parser/README.md @@ -0,0 +1,107 @@ +# chdt — standalone ClickHouse data-type parser + +A small, self-contained C++ library that parses a ClickHouse **data-type +string** (the kind sent in the types row of `RowBinaryWithNamesAndTypes`, e.g. +`Array(Nullable(UInt64))`, `Tuple(a UInt8, b String)`, `Enum8('a' = 1)`, +`Decimal(10, 2)`) into a JSON AST. + +It is extracted from the server's `ParserDataType` +(`src/Parsers/ParserDataType.cpp`) but has **no dependency on the ClickHouse +source tree** — only the C++20 standard library. The JSON it emits mirrors the +data-type subtree of the frozen `EXPLAIN AST json = 1` document (format +**version 2**; see `AST.md` in the ClickHouse repo), so its output is a drop-in +match for what the server produces. + +## Why this exists + +The server's type parser is entangled with the lexer, the expression parsers, +and the `IAST` / `Field` machinery. Vendoring all of that verbatim would pull +in ~9–10k lines (`Field`, `ReadHelpers`, `Exception`, the formatting/hashing +layer). Instead, this reimplements just the type grammar on a minimal AST: + +- a purpose-built tokenizer (`src/lexer.*`) covering the slice of SQL that type + strings use, in place of the full `Lexer` and its `UTF8Helpers` / + `find_symbols` dependencies; +- a faithful port of `ParserDataType::parseImpl` (`src/parser.cpp`) — same + control flow: identifier + SQL-standard multi-word aliases, the Enum and + Tuple special cases, then the generic parametric-argument loop; +- plain structs for the AST (`include/chdt/ast.h`) instead of `IAST` + `Field`. + +## Building + +```bash +cmake -S . -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build +``` + +This produces `libchdt_datatype_parser.a` and the `chdt-parse` CLI. + +## Usage + +Library: + +```cpp +#include "chdt/parser.h" + +chdt::ParseResult r = chdt::parseDataType("Tuple(a UInt8, b String)"); +if (r.ok()) + std::string json = chdt::toJSON(*r.ast); +else + /* r.error->message, r.error->position */; +``` + +CLI: + +```bash +./build/chdt-parse "Array(Nullable(UInt64))" +echo "Enum8('a' = 1, 'b' = 2)" | ./build/chdt-parse +``` + +## Output shape + +Node types and slots match the server (format v2): + +| `type` | slots | +|------------------|----------------------------------------------------------| +| `DataType` | `name`, `arguments?` (present iff the type had `(...)`) | +| `EnumDataType` | `name`, `values` (array of `{ name, value }`) | +| `TupleDataType` | `name`, `arguments?`, `element_names?` (named tuples) | +| `NameTypePair` | `name`, `data_type` (a `Nested(...)` element) | +| `Literal` | `value_type`, `value` (64-bit ints as JSON strings) | +| `Function` | `name`, `is_operator?`, `arguments` (e.g. `max_types=5`) | +| `Identifier` | `name`, `name_parts?` | + +`EnumDataType.values` and `TupleDataType.element_names` are carried here exactly +as the server emits them since format v2. + +## Coverage + +Supported: scalars, parametric types with literal args (`Decimal`, +`FixedString`, `DateTime64`, …), nested type args (`Array`, `Map`, `Nullable`, +`LowCardinality`, `Variant`, …), enums (explicit → `EnumDataType`; +auto-assigned → generic `DataType`), named/unnamed/mixed tuples, `Nested`, +`Dynamic(max_types = N)`, the legacy `Object('json')`, and the SQL-standard +multi-word aliases (`DOUBLE PRECISION`, `CHAR VARYING`, `INT SIGNED`, …). + +**Deliberately not supported yet** (the parser returns a clear error): + +- `AggregateFunction` / `SimpleAggregateFunction` — needs the function-expression + parser the server reaches for here. +- the new `JSON(...)` object-argument syntax (`JSON(a.b UInt32, SKIP x)`). Bare + `JSON` and legacy `Object('json')` parse fine. + +## Tests + +`ctest` runs two suites against the parser: + +- **oracle** (`test/oracle_compare.py`) — for each type in `test/cases.txt`, + compares the parser's JSON against the `data_type` subtree the real server + emits for `CREATE TABLE t (c ) ENGINE = Null`. Needs a `clickhouse` + binary (default: `../build/programs/clickhouse`; override with + `-DCLICKHOUSE_BINARY=...`). +- **unsupported** (`test/check_unsupported.py`) — asserts the deferred types in + `test/cases_unsupported.txt` are rejected. + +```bash +ctest --test-dir build --output-on-failure +``` diff --git a/datatype-parser/include/chdt/ast.h b/datatype-parser/include/chdt/ast.h new file mode 100644 index 000000000000..948a1eccb71d --- /dev/null +++ b/datatype-parser/include/chdt/ast.h @@ -0,0 +1,87 @@ +#pragma once + +/// Minimal, self-contained AST for ClickHouse data-type strings. +/// +/// The node shapes mirror the frozen `EXPLAIN AST json = 1` document +/// (format version 2; see ClickHouse `AST.md`) so that JSON produced here is +/// a drop-in match for the data-type subtree the server emits — and a +/// superset of it: `EnumDataType.values` and `TupleDataType.element_names` +/// are carried here as they are in the server (since v2). +/// +/// This header has no dependency on the ClickHouse source tree. + +#include +#include +#include +#include + +namespace chdt +{ + +enum class NodeKind +{ + DataType, /// generic type: name + optional argument list + EnumDataType, /// Enum / Enum8 / Enum16 with fully explicit values + TupleDataType, /// Tuple, with optional element names + NameTypePair, /// `name Type` element of a Nested(...) + Literal, /// numeric / string argument (e.g. Decimal(10, 2)) + Function, /// operator/function argument (e.g. `max_types = 5`) + Identifier, /// bare identifier argument +}; + +struct Node; +using NodePtr = std::shared_ptr; + +struct EnumValue +{ + std::string name; + int64_t value = 0; +}; + +/// One node type for the whole tree. Only the fields relevant to `kind` are +/// populated; serialization emits exactly the slots the server would. +struct Node +{ + explicit Node(NodeKind kind_) : kind(kind_) {} + + NodeKind kind; + + /// DataType / EnumDataType / TupleDataType / Function / Identifier / NameTypePair + std::string name; + + /// DataType / TupleDataType / Function argument list (children inlined in JSON). + std::vector arguments; + /// DataType only: whether the type carried a parenthesised argument list at + /// all. `UInt8` omits the `arguments` slot; `Array(...)` emits it (possibly + /// empty). Tuple/Function always emit their list. + bool has_argument_list = false; + + /// EnumDataType: explicit `'name' = value` pairs. + std::vector values; + + /// TupleDataType: element names. Empty => unnamed tuple (slot omitted). + std::vector element_names; + + /// NameTypePair: the element's type. + NodePtr data_type; + + /// Literal: `value_type` is the Field type id ("UInt64", "Int64", + /// "Float64", "String"); `value` is the textual value. + std::string value_type; + std::string value; + + /// Function: set for operators such as `equals`. + bool is_operator = false; + + /// Identifier: populated when the identifier is compound (a.b). + std::vector name_parts; + + static NodePtr make(NodeKind kind_) { return std::make_shared(kind_); } +}; + +/// Serialize a node tree to JSON, matching the server's `formatASTAsJSON` +/// shape for data types. `indent` < 0 produces compact output; >= 0 produces +/// pretty output with that many spaces per level. +std::string toJSON(const Node & node, int indent = 2); + +} diff --git a/datatype-parser/include/chdt/parser.h b/datatype-parser/include/chdt/parser.h new file mode 100644 index 000000000000..489a8c3698bd --- /dev/null +++ b/datatype-parser/include/chdt/parser.h @@ -0,0 +1,44 @@ +#pragma once + +/// Public entry point: parse a ClickHouse data-type string into the AST in +/// `ast.h`. Self-contained — no dependency on the ClickHouse source tree. +/// +/// Coverage mirrors the server's `ParserDataType` (`src/Parsers/ParserDataType.cpp`) +/// with two deliberate omissions, deferred for now: +/// * AggregateFunction / SimpleAggregateFunction — would pull in the full +/// function-expression parser; a clear error is returned instead. +/// * the new JSON/Object path-typed arguments (`JSON(a.b UInt32, SKIP x)`). +/// The bare `JSON` type and legacy `Object('json')` parse fine; the +/// object-argument syntax returns an error. +/// Everything else — nested types, parametric types, enums (explicit and +/// auto-assigned), named/unnamed tuples, Nested, Dynamic(max_types=N), and the +/// SQL-standard multi-word aliases — is supported. + +#include +#include + +#include "chdt/ast.h" + +namespace chdt + +{ + +struct ParseError +{ + std::string message; /// human-readable description + size_t position = 0; /// byte offset into the input where parsing stuck +}; + +struct ParseResult +{ + NodePtr ast; /// non-null on success + std::optional error; /// set on failure + + bool ok() const { return ast != nullptr; } +}; + +/// Parse the whole string as a single data type. Trailing tokens after a +/// complete type are an error (the entire input must be one type). +ParseResult parseDataType(const std::string & input); + +} diff --git a/datatype-parser/src/json.cpp b/datatype-parser/src/json.cpp new file mode 100644 index 000000000000..40bf14c6c630 --- /dev/null +++ b/datatype-parser/src/json.cpp @@ -0,0 +1,243 @@ +#include "chdt/ast.h" + +#include + +namespace chdt +{ + +namespace +{ + +void escapeTo(std::string & out, const std::string & s) +{ + out.push_back('"'); + for (unsigned char c : s) + { + switch (c) + { + case '"': out += "\\\""; break; + case '\\': out += "\\\\"; break; + case '\b': out += "\\b"; break; + case '\f': out += "\\f"; break; + case '\n': out += "\\n"; break; + case '\r': out += "\\r"; break; + case '\t': out += "\\t"; break; + default: + if (c < 0x20) + { + char buf[8]; + std::snprintf(buf, sizeof(buf), "\\u%04x", c); + out += buf; + } + else + out.push_back(static_cast(c)); + } + } + out.push_back('"'); +} + +struct Writer +{ + std::string out; + int indent; /// spaces per level, or < 0 for compact + + void newlineIndent(int depth) + { + if (indent < 0) + return; + out.push_back('\n'); + out.append(static_cast(indent) * depth, ' '); + } + + void colon() { out += (indent < 0) ? ":" : ": "; } +}; + +/// Object emission is inline (each node writes its own members in order). +void writeNode(Writer & w, const Node & node, int depth); + +/// Emit `"key": ` prefix; returns whether a leading comma is needed next. +void writeKey(Writer & w, const char * key, bool & first, int depth) +{ + if (!first) + w.out.push_back(','); + first = false; + w.newlineIndent(depth + 1); + escapeTo(w.out, key); + w.colon(); +} + +void writeArray(Writer & w, const std::vector & items, int depth) +{ + if (items.empty()) + { + w.out += "[]"; + return; + } + w.out.push_back('['); + bool first = true; + for (const auto & item : items) + { + if (!first) + w.out.push_back(','); + first = false; + w.newlineIndent(depth + 1); + writeNode(w, *item, depth + 1); + } + w.newlineIndent(depth); + w.out.push_back(']'); +} + +void writeStringArray(Writer & w, const std::vector & items, int depth) +{ + if (items.empty()) + { + w.out += "[]"; + return; + } + w.out.push_back('['); + bool first = true; + for (const auto & item : items) + { + if (!first) + w.out.push_back(','); + first = false; + w.newlineIndent(depth + 1); + escapeTo(w.out, item); + } + w.newlineIndent(depth); + w.out.push_back(']'); +} + +void writeLiteralValue(Writer & w, const Node & node) +{ + /// 64-bit integers are emitted as JSON strings (the server's contract: + /// values above 2^53 lose precision under JS `JSON.parse`). Float64 is a + /// JSON number; String is a JSON string. + if (node.value_type == "Float64") + w.out += node.value; /// already a valid JSON number + else if (node.value_type == "String") + escapeTo(w.out, node.value); + else /// UInt64 / Int64 / fallback + escapeTo(w.out, node.value); +} + +void writeNode(Writer & w, const Node & node, int depth) +{ + w.out.push_back('{'); + bool first = true; + + auto key = [&](const char * k) { writeKey(w, k, first, depth); }; + + switch (node.kind) + { + case NodeKind::DataType: + key("type"); escapeTo(w.out, "DataType"); + key("name"); escapeTo(w.out, node.name); + if (node.has_argument_list) + { + key("arguments"); + writeArray(w, node.arguments, depth + 1); + } + break; + + case NodeKind::EnumDataType: + { + key("type"); escapeTo(w.out, "EnumDataType"); + key("name"); escapeTo(w.out, node.name); + key("values"); + if (node.values.empty()) + w.out += "[]"; + else + { + w.out.push_back('['); + bool vfirst = true; + for (const auto & v : node.values) + { + if (!vfirst) + w.out.push_back(','); + vfirst = false; + w.newlineIndent(depth + 2); + w.out.push_back('{'); + bool mfirst = true; + writeKey(w, "name", mfirst, depth + 2); + escapeTo(w.out, v.name); + writeKey(w, "value", mfirst, depth + 2); + w.out += std::to_string(v.value); + w.newlineIndent(depth + 2); + w.out.push_back('}'); + } + w.newlineIndent(depth + 1); + w.out.push_back(']'); + } + break; + } + + case NodeKind::TupleDataType: + key("type"); escapeTo(w.out, "TupleDataType"); + key("name"); escapeTo(w.out, node.name); + if (node.has_argument_list) + { + key("arguments"); + writeArray(w, node.arguments, depth + 1); + } + if (!node.element_names.empty()) + { + key("element_names"); + writeStringArray(w, node.element_names, depth + 1); + } + break; + + case NodeKind::NameTypePair: + key("type"); escapeTo(w.out, "NameTypePair"); + key("name"); escapeTo(w.out, node.name); + if (node.data_type) + { + key("data_type"); + writeNode(w, *node.data_type, depth + 1); + } + break; + + case NodeKind::Literal: + key("type"); escapeTo(w.out, "Literal"); + key("value_type"); escapeTo(w.out, node.value_type); + key("value"); writeLiteralValue(w, node); + break; + + case NodeKind::Function: + key("type"); escapeTo(w.out, "Function"); + key("name"); escapeTo(w.out, node.name); + if (node.is_operator) + { + key("is_operator"); + w.out += "true"; + } + key("arguments"); + writeArray(w, node.arguments, depth + 1); + break; + + case NodeKind::Identifier: + key("type"); escapeTo(w.out, "Identifier"); + key("name"); escapeTo(w.out, node.name); + if (!node.name_parts.empty()) + { + key("name_parts"); + writeStringArray(w, node.name_parts, depth + 1); + } + break; + } + + w.newlineIndent(depth); + w.out.push_back('}'); +} + +} /// namespace + +std::string toJSON(const Node & node, int indent) +{ + Writer w; + w.indent = indent; + writeNode(w, node, 0); + return w.out; +} + +} diff --git a/datatype-parser/src/lexer.cpp b/datatype-parser/src/lexer.cpp new file mode 100644 index 000000000000..256abebbd78a --- /dev/null +++ b/datatype-parser/src/lexer.cpp @@ -0,0 +1,200 @@ +#include "lexer.h" + +namespace chdt +{ + +namespace +{ + +bool isSpace(char c) +{ + return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f' || c == '\v'; +} + +bool isDigit(char c) +{ + return c >= '0' && c <= '9'; +} + +bool isWordFirst(char c) +{ + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_' || c == '$'; +} + +bool isWordChar(char c) +{ + return isWordFirst(c) || isDigit(c); +} + +/// Decode the body of a quoted token (string literal or quoted identifier). +/// `quote` is the surrounding quote character. Handles C-style backslash +/// escapes and the SQL doubled-quote escape (e.g. '' inside '...'). Mirrors +/// the relevant behaviour of `tryReadQuotedStringWithSQLStyle`. +bool decodeQuoted(const std::string & in, size_t & pos, char quote, std::string & out, std::string & error) +{ + /// pos points at the opening quote. + ++pos; + while (pos < in.size()) + { + char c = in[pos]; + if (c == quote) + { + /// Doubled quote -> literal quote. + if (pos + 1 < in.size() && in[pos + 1] == quote) + { + out.push_back(quote); + pos += 2; + continue; + } + ++pos; /// consume the closing quote + return true; + } + if (c == '\\') + { + if (pos + 1 >= in.size()) + { + error = "unterminated escape in quoted literal"; + return false; + } + char e = in[pos + 1]; + switch (e) + { + case 'b': out.push_back('\b'); break; + case 'f': out.push_back('\f'); break; + case 'n': out.push_back('\n'); break; + case 'r': out.push_back('\r'); break; + case 't': out.push_back('\t'); break; + case '0': out.push_back('\0'); break; + case 'a': out.push_back('\a'); break; + case 'v': out.push_back('\v'); break; + /// \\, \', \", \`, and any other char: keep the literal char. + default: out.push_back(e); break; + } + pos += 2; + continue; + } + out.push_back(c); + ++pos; + } + error = "unterminated quoted literal"; + return false; +} + +} /// namespace + +std::vector tokenize(const std::string & input) +{ + std::vector tokens; + size_t pos = 0; + const size_t n = input.size(); + + auto fail = [&](size_t at, const std::string & msg) + { + tokens.push_back(Token{TokenType::Error, msg, false, at}); + }; + + while (pos < n) + { + char c = input[pos]; + + if (isSpace(c)) + { + ++pos; + continue; + } + + const size_t start = pos; + + switch (c) + { + case '(': tokens.push_back({TokenType::OpeningParen, "(", false, start}); ++pos; continue; + case ')': tokens.push_back({TokenType::ClosingParen, ")", false, start}); ++pos; continue; + case ',': tokens.push_back({TokenType::Comma, ",", false, start}); ++pos; continue; + case '=': tokens.push_back({TokenType::Equals, "=", false, start}); ++pos; continue; + case '-': tokens.push_back({TokenType::Minus, "-", false, start}); ++pos; continue; + default: break; + } + + /// A dot may start a fractional number (.5) or be a standalone separator. + if (c == '.' && !(pos + 1 < n && isDigit(input[pos + 1]))) + { + tokens.push_back({TokenType::Dot, ".", false, start}); + ++pos; + continue; + } + + /// Quoted identifiers. + if (c == '`' || c == '"') + { + std::string decoded; + std::string error; + if (!decodeQuoted(input, pos, c, decoded, error)) + { + fail(start, error); + break; + } + tokens.push_back({TokenType::QuotedIdent, decoded, false, start}); + continue; + } + + /// String literal. + if (c == '\'') + { + std::string decoded; + std::string error; + if (!decodeQuoted(input, pos, c, decoded, error)) + { + fail(start, error); + break; + } + tokens.push_back({TokenType::String, decoded, false, start}); + continue; + } + + /// Number. + if (isDigit(c) || c == '.') + { + bool is_float = false; + /// integer part + while (pos < n && isDigit(input[pos])) + ++pos; + /// fraction + if (pos < n && input[pos] == '.') + { + is_float = true; + ++pos; + while (pos < n && isDigit(input[pos])) + ++pos; + } + /// exponent + if (pos < n && (input[pos] == 'e' || input[pos] == 'E')) + { + is_float = true; + ++pos; + if (pos < n && (input[pos] == '+' || input[pos] == '-')) + ++pos; + while (pos < n && isDigit(input[pos])) + ++pos; + } + tokens.push_back({TokenType::Number, input.substr(start, pos - start), is_float, start}); + continue; + } + + /// Bare word / identifier / keyword. + if (isWordFirst(c)) + { + while (pos < n && isWordChar(input[pos])) + ++pos; + tokens.push_back({TokenType::Word, input.substr(start, pos - start), false, start}); + continue; + } + + fail(start, std::string("unexpected character '") + c + "'"); + break; + } + + tokens.push_back({TokenType::End, "", false, pos}); + return tokens; +} + +} diff --git a/datatype-parser/src/lexer.h b/datatype-parser/src/lexer.h new file mode 100644 index 000000000000..9edf36bb21d9 --- /dev/null +++ b/datatype-parser/src/lexer.h @@ -0,0 +1,50 @@ +#pragma once + +/// A small purpose-built tokenizer for ClickHouse data-type strings. +/// +/// Type strings use a tiny slice of the SQL grammar — identifiers (bare, +/// backtick- or double-quoted), single-quoted string literals, numbers, and a +/// handful of punctuation tokens. Rather than vendor the full ClickHouse +/// `Lexer` (and its `UTF8Helpers` / `find_symbols` dependencies), this covers +/// exactly that slice, keeping the library free of any ClickHouse headers. + +#include +#include +#include + +namespace chdt +{ + +enum class TokenType +{ + End, /// end of input + Word, /// bare identifier / keyword, e.g. UInt8, Array, SIGNED + QuotedIdent, /// `backtick` or "double"-quoted identifier (decoded) + Number, /// numeric literal (raw text, no sign) + String, /// single-quoted string literal (decoded) + OpeningParen, /// ( + ClosingParen, /// ) + Comma, /// , + Equals, /// = + Minus, /// - + Dot, /// . + Error, /// malformed token; `text` holds the message +}; + +struct Token +{ + TokenType type = TokenType::End; + /// Word/Number: raw source text. QuotedIdent/String: decoded content. + /// Error: the error message. + std::string text; + /// Number only: true when the literal has a fractional part or exponent. + bool is_float = false; + /// Byte offset of the token start in the input (for diagnostics). + size_t begin = 0; +}; + +/// Tokenize the whole input. The returned vector always ends with an `End` +/// token. A malformed token yields a single trailing `Error` token. +std::vector tokenize(const std::string & input); + +} diff --git a/datatype-parser/src/parser.cpp b/datatype-parser/src/parser.cpp new file mode 100644 index 000000000000..fffb56a29303 --- /dev/null +++ b/datatype-parser/src/parser.cpp @@ -0,0 +1,530 @@ +#include "chdt/parser.h" + +#include "lexer.h" + +#include +#include +#include +#include + +/// A faithful port of ClickHouse's `ParserDataType::parseImpl` +/// (src/Parsers/ParserDataType.cpp) onto the self-contained AST in `ast.h`. +/// The control flow deliberately tracks the original: identifier + SQL-standard +/// multi-word aliases, the Enum and Tuple special cases, then the generic +/// parametric-argument loop. AggregateFunction/SimpleAggregateFunction and the +/// JSON object-argument syntax are reported as unsupported (see parser.h). + +namespace chdt +{ + +namespace +{ + +std::string toUpper(const std::string & s) +{ + std::string r = s; + for (char & c : r) + if (c >= 'a' && c <= 'z') + c = static_cast(c - 'a' + 'A'); + return r; +} + +std::string toLower(const std::string & s) +{ + std::string r = s; + for (char & c : r) + if (c >= 'A' && c <= 'Z') + c = static_cast(c - 'A' + 'a'); + return r; +} + +bool isWordCharOrDollar(char c) +{ + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_' || c == '$'; +} + +bool isEnumTypeUpper(const std::string & u) +{ + return u == "ENUM" || u == "ENUM8" || u == "ENUM16"; +} + +class Parser +{ +public: + explicit Parser(std::vector tokens_) : tokens(std::move(tokens_)) {} + + ParseResult run() + { + /// A lexing error surfaces as a trailing Error token. + for (const auto & tok : tokens) + if (tok.type == TokenType::Error) + return fail(tok.begin, tok.text); + + NodePtr node = parseType(); + if (!node) + { + if (hard_error) + return ParseResult{nullptr, hard_error}; + return fail(cur().begin, "expected a data type"); + } + + if (cur().type != TokenType::End) + return fail(cur().begin, "unexpected trailing input after the data type"); + + return ParseResult{node, std::nullopt}; + } + +private: + std::vector tokens; + size_t pos = 0; + std::optional hard_error; + + const Token & cur() const { return tokens[pos]; } + TokenType type() const { return tokens[pos].type; } + void advance() + { + if (tokens[pos].type != TokenType::End) + ++pos; + } + + static ParseResult fail(size_t at, const std::string & msg) { return ParseResult{nullptr, ParseError{msg, at}}; } + + void setHardError(size_t at, const std::string & msg) + { + if (!hard_error) + hard_error = ParseError{msg, at}; + } + + bool isIdentifier() const { return type() == TokenType::Word || type() == TokenType::QuotedIdent; } + + /// Consume `count` consecutive Word tokens iff they match `words` + /// (case-insensitive). Returns the original-cased joined match or "". + bool matchWords(std::initializer_list words) + { + size_t p = pos; + for (const char * w : words) + { + if (tokens[p].type != TokenType::Word || toUpper(tokens[p].text) != toUpper(std::string(w))) + return false; + ++p; + } + pos = p; + return true; + } + + /// Read a single identifier (bare or quoted) into `name`. + bool parseIdentifier(std::string & name) + { + if (!isIdentifier()) + return false; + name = cur().text; + advance(); + return true; + } + + NodePtr parseType() + { + std::string type_name; + if (!parseIdentifier(type_name)) + return nullptr; + + /// Reject quoted garbage that cannot be a type name (e.g. `x.y`, `Null`). + if (!std::all_of(type_name.begin(), type_name.end(), [](char c) { return isWordCharOrDollar(c); })) + return nullptr; + + const std::string type_name_upper = toUpper(type_name); + + /// Keywords that the column-declaration parser claims before the type. + if (type_name_upper == "NOT" || type_name_upper == "NULL" || type_name_upper == "DEFAULT" + || type_name_upper == "MATERIALIZED" || type_name_upper == "EPHEMERAL" || type_name_upper == "ALIAS" + || type_name_upper == "AUTO" || type_name_upper == "PRIMARY" || type_name_upper == "COMMENT" + || type_name_upper == "CODEC") + return nullptr; + + /// SQL-standard multi-word type names. + std::string suffix = parseTypeNameSuffix(type_name_upper); + if (!suffix.empty()) + type_name = type_name_upper + " " + suffix; + + skipTrailingComma(); + + /// Enum special case -> EnumDataType with explicit values. + if (isEnumTypeUpper(type_name_upper) && type() == TokenType::OpeningParen) + { + size_t saved = pos; + advance(); + std::vector values; + if (parseEnumValues(values) && type() == TokenType::ClosingParen) + { + advance(); + auto node = Node::make(NodeKind::EnumDataType); + node->name = type_name; + node->values = std::move(values); + return node; + } + pos = saved; + } + + /// Tuple special case -> TupleDataType with optional element names. + if (type_name == "Tuple" && type() == TokenType::OpeningParen) + { + if (NodePtr tuple = parseTuple(type_name)) + return tuple; + /// else: fall through to the generic path + } + + auto node = Node::make(NodeKind::DataType); + node->name = type_name; + + if (type() != TokenType::OpeningParen) + return node; + advance(); + + if (!parseArgumentList(type_name, node->arguments)) + return nullptr; + + if (type() != TokenType::ClosingParen) + return nullptr; + advance(); + + node->has_argument_list = true; + return node; + } + + /// Returns the suffix to append for SQL-standard multi-word names, or "". + std::string parseTypeNameSuffix(const std::string & u) + { + if (u == "NATIONAL") + { + if (matchWords({"CHARACTER", "LARGE", "OBJECT"})) return "CHARACTER LARGE OBJECT"; + if (matchWords({"CHARACTER", "VARYING"})) return "CHARACTER VARYING"; + if (matchWords({"CHAR", "VARYING"})) return "CHAR VARYING"; + if (matchWords({"CHARACTER"})) return "CHARACTER"; + if (matchWords({"CHAR"})) return "CHAR"; + } + else if (u == "BINARY" || u == "CHARACTER" || u == "CHAR" || u == "NCHAR") + { + if (matchWords({"LARGE", "OBJECT"})) return "LARGE OBJECT"; + if (matchWords({"VARYING"})) return "VARYING"; + } + else if (u == "DOUBLE") + { + if (matchWords({"PRECISION"})) return "PRECISION"; + } + else if (u.find("INT") != std::string::npos) + { + /// MySQL-compatible SIGNED / UNSIGNED, optionally after `(width)`. + if (matchWords({"SIGNED"})) return "SIGNED"; + if (matchWords({"UNSIGNED"})) return "UNSIGNED"; + if (type() == TokenType::OpeningParen) + { + size_t saved = pos; + advance(); + if (type() == TokenType::Number) + advance(); + if (type() == TokenType::ClosingParen) + { + advance(); + if (matchWords({"SIGNED"})) return "SIGNED"; + if (matchWords({"UNSIGNED"})) return "UNSIGNED"; + } + else + { + /// not the width form; leave the paren for generic args + pos = saved; + } + } + } + return ""; + } + + /// Skip a trailing comma right before a closing paren: `Tuple(Int, String,)`. + void skipTrailingComma() + { + if (type() == TokenType::Comma && tokens[pos + 1].type == TokenType::ClosingParen) + advance(); + } + + /// Explicit-only enum body: 'name' = value, ... . Returns false (caller + /// restores) for auto-assigned or otherwise non-trivial enums. + bool parseEnumValues(std::vector & values) + { + bool first = true; + while (true) + { + if (!first) + { + if (type() != TokenType::Comma) + break; + advance(); + } + first = false; + + if (type() != TokenType::String) + return false; + std::string name = cur().text; + advance(); + + if (type() != TokenType::Equals) + return false; + advance(); + + bool negative = false; + if (type() == TokenType::Minus) + { + negative = true; + advance(); + } + + if (type() != TokenType::Number || cur().is_float) + return false; + int64_t v = std::strtoll(cur().text.c_str(), nullptr, 10); + advance(); + + values.push_back(EnumValue{name, negative ? -v : v}); + } + return !values.empty(); + } + + /// Parse a Tuple body into element types + names. Returns null (with the + /// position restored) if it cannot, so the caller can try the generic path. + NodePtr parseTuple(const std::string & type_name) + { + size_t saved = pos; + advance(); /// consume '(' + + auto node = Node::make(NodeKind::TupleDataType); + node->name = type_name; + + std::vector names; + bool has_named = false; + bool first = true; + + while (true) + { + if (!first) + { + if (type() == TokenType::Comma) + advance(); + else + break; + } + first = false; + + size_t element_pos = pos; + std::string ident; + /// Try: identifier Type (named element) + if (parseIdentifier(ident)) + { + if (NodePtr t = parseType()) + { + names.push_back(ident); + node->arguments.push_back(t); + has_named = true; + continue; + } + } + /// Else: just Type (unnamed element) + pos = element_pos; + if (NodePtr t = parseType()) + { + names.emplace_back(""); + node->arguments.push_back(t); + } + else + { + break; + } + } + + if (type() == TokenType::ClosingParen && !node->arguments.empty()) + { + advance(); + node->has_argument_list = true; + if (has_named) + node->element_names = std::move(names); + return node; + } + + pos = saved; + return nullptr; + } + + /// The generic comma-separated argument list inside `Type(...)`. + bool parseArgumentList(const std::string & type_name, std::vector & out) + { + const std::string lower = toLower(type_name); + + if (type_name == "AggregateFunction" || type_name == "SimpleAggregateFunction") + { + setHardError(cur().begin, type_name + " is not supported by this parser yet"); + return false; + } + if (lower == "json") + { + setHardError(cur().begin, "JSON typed/object arguments are not supported by this parser yet"); + return false; + } + + size_t arg_num = 0; + while (true) + { + if (arg_num > 0) + { + if (type() == TokenType::Comma) + advance(); + else + break; + } + + NodePtr arg; + if (type_name == "Dynamic") + arg = parseEqualsArgument(); + else if (type_name == "Nested") + arg = parseNameTypePair(); + else if (type_name == "Tuple") + arg = parseNameTypePairOrType(); + else + arg = parseGenericArgument(); + + if (!arg) + break; + + out.push_back(arg); + ++arg_num; + } + return true; + } + + /// `identifier = number` -> Function equals(Identifier, Literal). + NodePtr parseEqualsArgument() + { + std::string ident; + if (!parseIdentifier(ident)) + return nullptr; + if (type() != TokenType::Equals) + return nullptr; + advance(); + NodePtr number = parseNumberLiteral(); + if (!number) + return nullptr; + + auto id = Node::make(NodeKind::Identifier); + id->name = ident; + auto fn = Node::make(NodeKind::Function); + fn->name = "equals"; + fn->is_operator = true; + fn->arguments = {id, number}; + return fn; + } + + /// `name Type` -> NameTypePair (Nested elements). + NodePtr parseNameTypePair() + { + std::string name; + if (!parseIdentifier(name)) + return nullptr; + NodePtr t = parseType(); + if (!t) + return nullptr; + auto node = Node::make(NodeKind::NameTypePair); + node->name = name; + node->data_type = t; + return node; + } + + NodePtr parseNameTypePairOrType() + { + size_t saved = pos; + if (NodePtr pair = parseNameTypePair()) + return pair; + pos = saved; + return parseType(); + } + + /// Generic argument: a scalar literal (optionally `lit = lit`), or a type. + NodePtr parseGenericArgument() + { + if (NodePtr lit = parseScalarLiteral()) + { + if (type() == TokenType::Equals) + { + advance(); + NodePtr rhs = parseScalarLiteral(); + if (!rhs) + return nullptr; + auto fn = Node::make(NodeKind::Function); + fn->name = "equals"; + fn->is_operator = true; + fn->arguments = {lit, rhs}; + return fn; + } + return lit; + } + return parseType(); + } + + NodePtr parseNumberLiteral() + { + bool negative = false; + if (type() == TokenType::Minus) + { + negative = true; + advance(); + } + if (type() != TokenType::Number) + return nullptr; + + /// The lexer only skips over a number without checking correctness (the + /// server's `Lexer` does the same: "not to parse a number or check + /// correctness, but only to skip it"). The server then rejects a + /// malformed literal when it converts the token text into a `Field`; we + /// have no such stage, so we validate here by parsing the lexeme in + /// full. Without this, a bare exponent like `1e` would be emitted + /// verbatim into a `Float64` literal's JSON `value`, yielding invalid + /// JSON (`"value":1e`). Fail loudly instead. + const std::string & text = cur().text; + char * end_ptr = nullptr; + if (cur().is_float) + std::strtod(text.c_str(), &end_ptr); + else + std::strtoull(text.c_str(), &end_ptr, 10); + if (end_ptr != text.c_str() + text.size()) + { + setHardError(cur().begin, "malformed numeric literal: '" + text + "'"); + return nullptr; + } + + auto node = Node::make(NodeKind::Literal); + node->value_type = cur().is_float ? "Float64" : (negative ? "Int64" : "UInt64"); + node->value = (negative ? "-" : "") + text; + advance(); + return node; + } + + /// A scalar literal: number (optionally signed) or string. + NodePtr parseScalarLiteral() + { + if (type() == TokenType::Number || type() == TokenType::Minus) + return parseNumberLiteral(); + if (type() == TokenType::String) + { + auto node = Node::make(NodeKind::Literal); + node->value_type = "String"; + node->value = cur().text; + advance(); + return node; + } + return nullptr; + } +}; + +} /// namespace + +ParseResult parseDataType(const std::string & input) +{ + Parser parser(tokenize(input)); + return parser.run(); +} + +} diff --git a/datatype-parser/test/CMakeLists.txt b/datatype-parser/test/CMakeLists.txt new file mode 100644 index 000000000000..6c99f8bdc308 --- /dev/null +++ b/datatype-parser/test/CMakeLists.txt @@ -0,0 +1,24 @@ +# The oracle test needs a ClickHouse binary to produce expected output. +# Override with -DCLICKHOUSE_BINARY=/path/to/clickhouse at configure time. +set(CLICKHOUSE_BINARY "${CMAKE_SOURCE_DIR}/../build/programs/clickhouse" + CACHE FILEPATH "Path to the clickhouse binary used as the oracle") + +find_package(Python3 COMPONENTS Interpreter) + +if(Python3_Interpreter_FOUND) + add_test( + NAME oracle + COMMAND ${Python3_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/oracle_compare.py + --clickhouse ${CLICKHOUSE_BINARY} + --tool $ + --cases ${CMAKE_CURRENT_SOURCE_DIR}/cases.txt + ) + add_test( + NAME unsupported + COMMAND ${Python3_EXECUTABLE} + ${CMAKE_CURRENT_SOURCE_DIR}/check_unsupported.py + --tool $ + --cases ${CMAKE_CURRENT_SOURCE_DIR}/cases_unsupported.txt + ) +endif() diff --git a/datatype-parser/test/cases.txt b/datatype-parser/test/cases.txt new file mode 100644 index 000000000000..37844c31f4fc --- /dev/null +++ b/datatype-parser/test/cases.txt @@ -0,0 +1,72 @@ +# Supported data types, one per line. Each is compared against the +# data_type subtree the ClickHouse server emits for +# EXPLAIN AST json = 1 CREATE TABLE t (c ) ENGINE = Null +# Blank lines and #-comments are ignored. + +# scalars +UInt8 +Int64 +Float64 +String +Date +DateTime +UUID +Bool +IPv4 +IPv6 + +# parametric with literal args +FixedString(16) +Decimal(10, 2) +Decimal(38, 10) +Decimal32(4) +DateTime64(3) +DateTime64(3, 'UTC') +DateTime('UTC') + +# nested type args +Nullable(UInt64) +Array(String) +Array(Array(Int32)) +Array(Nullable(UInt64)) +Map(String, UInt64) +Map(String, Array(UInt8)) +LowCardinality(String) +LowCardinality(Nullable(String)) +Array(Tuple(Float64, Float64)) + +# tuples +Tuple(UInt8, String) +Tuple(a UInt8, b String) +Tuple(a UInt8, String) +Tuple(Decimal(10, 2), Nullable(String)) + +# enums (explicit -> EnumDataType; auto-assigned -> generic DataType) +Enum8('a' = 1, 'b' = 2) +Enum16('x' = -1, 'y' = 100) +Enum('a' = 1, 'b' = 2) +Enum8('a', 'b') + +# nested table type +Nested(a UInt8, b String) +Nested(a Array(UInt8), b Tuple(x UInt8, y String)) + +# SQL-standard multi-word aliases +DOUBLE PRECISION +CHAR VARYING +INT SIGNED +INT UNSIGNED + +# legacy object + dynamic +Object('json') +Dynamic +Dynamic(max_types = 5) + +# misc families harvested from the fixture corpus +Variant(UInt8, String) +varchar +varchar(255) +BFloat16 +Time +int +Int diff --git a/datatype-parser/test/cases_unsupported.txt b/datatype-parser/test/cases_unsupported.txt new file mode 100644 index 000000000000..49d01330c3d3 --- /dev/null +++ b/datatype-parser/test/cases_unsupported.txt @@ -0,0 +1,13 @@ +# Types that the parser deliberately rejects (see parser.h). Each must make +# chdt-parse exit non-zero. Blank lines and #-comments are ignored. +AggregateFunction(sum, UInt64) +AggregateFunction(1, quantiles(0.5), Float64) +SimpleAggregateFunction(sum, UInt64) +JSON(max_dynamic_paths = 16) +JSON(a.b UInt32, SKIP x) +# Malformed numeric literals: the lexer skips over them without checking +# correctness, so they must be rejected when the lexeme is parsed into a value +# (see parseNumberLiteral). A bare exponent has no digits. +Decimal(1e, 2) +DateTime64(1e+) +Enum8('a' = 1e) diff --git a/datatype-parser/test/check_unsupported.py b/datatype-parser/test/check_unsupported.py new file mode 100644 index 000000000000..062952fac34f --- /dev/null +++ b/datatype-parser/test/check_unsupported.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python3 +"""Assert that chdt-parse rejects the deliberately-unsupported types.""" + +import argparse +import subprocess +import sys + + +def read_cases(path): + cases = [] + with open(path) as f: + for line in f: + line = line.strip() + if line and not line.startswith("#"): + cases.append(line) + return cases + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--tool", required=True) + ap.add_argument("--cases", required=True) + args = ap.parse_args() + + cases = read_cases(args.cases) + failures = 0 + for type_str in cases: + out = subprocess.run([args.tool, type_str], capture_output=True, text=True) + if out.returncode != 0: + print(f" ok rejected: {type_str}") + else: + failures += 1 + print(f"FAIL unexpectedly accepted: {type_str}") + + print(f"\n{len(cases) - failures}/{len(cases)} correctly rejected") + return 1 if failures else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/datatype-parser/test/oracle_compare.py b/datatype-parser/test/oracle_compare.py new file mode 100644 index 000000000000..8a26ae35ba3c --- /dev/null +++ b/datatype-parser/test/oracle_compare.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python3 +"""Compare the standalone parser's JSON AST against the ClickHouse server. + +For each data type in the cases file, the expected output is the `data_type` +subtree the server produces for + + EXPLAIN AST json = 1 CREATE TABLE t (c ) ENGINE = Null + +(version 2 of the format). The actual output is `chdt-parse `. The two +JSON trees are compared structurally (key order ignored). +""" + +import argparse +import json +import subprocess +import sys + + +def canon(value): + """Recursively sort dict keys so comparison ignores key order.""" + if isinstance(value, dict): + return {k: canon(value[k]) for k in sorted(value)} + if isinstance(value, list): + return [canon(v) for v in value] + return value + + +def find_column_data_type(node, column): + """Depth-first search for the ColumnDeclaration named `column`.""" + if isinstance(node, dict): + if node.get("type") == "ColumnDeclaration" and node.get("name") == column: + return node.get("data_type") + for v in node.values(): + found = find_column_data_type(v, column) + if found is not None: + return found + elif isinstance(node, list): + for v in node: + found = find_column_data_type(v, column) + if found is not None: + return found + return None + + +def server_data_type(clickhouse, type_str): + sql = f"EXPLAIN AST json = 1 CREATE TABLE t (c {type_str}) ENGINE = Null" + out = subprocess.run( + [clickhouse, "local", "--format", "TSVRaw", "-q", sql], + capture_output=True, text=True, + ) + if out.returncode != 0: + raise RuntimeError(f"server failed: {out.stderr.strip()}") + doc = json.loads(out.stdout) + if doc.get("version") != 2: + raise RuntimeError(f"unexpected format version {doc.get('version')}") + dt = find_column_data_type(doc["ast"], "c") + if dt is None: + raise RuntimeError("could not locate column data_type in server AST") + return dt + + +def tool_data_type(tool, type_str): + out = subprocess.run([tool, type_str], capture_output=True, text=True) + if out.returncode != 0: + raise RuntimeError(f"chdt-parse failed: {out.stderr.strip()}") + return json.loads(out.stdout) + + +def read_cases(path): + cases = [] + with open(path) as f: + for line in f: + line = line.strip() + if line and not line.startswith("#"): + cases.append(line) + return cases + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--clickhouse", required=True) + ap.add_argument("--tool", required=True) + ap.add_argument("--cases", required=True) + args = ap.parse_args() + + cases = read_cases(args.cases) + failures = 0 + for type_str in cases: + try: + expected = canon(server_data_type(args.clickhouse, type_str)) + actual = canon(tool_data_type(args.tool, type_str)) + except Exception as exc: # noqa: BLE001 + print(f"ERROR {type_str!r}: {exc}") + failures += 1 + continue + + if expected == actual: + print(f" ok {type_str}") + else: + failures += 1 + print(f"FAIL {type_str}") + print(" expected:", json.dumps(expected)) + print(" actual: ", json.dumps(actual)) + + print(f"\n{len(cases) - failures}/{len(cases)} passed") + return 1 if failures else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/datatype-parser/tool/main.cpp b/datatype-parser/tool/main.cpp new file mode 100644 index 000000000000..83ab686ea843 --- /dev/null +++ b/datatype-parser/tool/main.cpp @@ -0,0 +1,46 @@ +#include "chdt/parser.h" + +#include +#include +#include + +/// chdt-parse: read a ClickHouse data-type string and print its JSON AST. +/// +/// chdt-parse "Array(Nullable(UInt64))" # type from arguments +/// echo "Tuple(a UInt8, b String)" | chdt-parse # type from stdin +/// +/// Prints the JSON AST and exits 0 on success. On a parse error, prints +/// "error: (at byte N)" to stderr and exits 1. +int main(int argc, char ** argv) +{ + std::string input; + if (argc > 1) + { + for (int i = 1; i < argc; ++i) + { + if (i > 1) + input += ' '; + input += argv[i]; + } + } + else + { + std::ostringstream ss; + ss << std::cin.rdbuf(); + input = ss.str(); + } + + /// Trim trailing newline/whitespace from stdin. + while (!input.empty() && (input.back() == '\n' || input.back() == '\r' || input.back() == ' ' || input.back() == '\t')) + input.pop_back(); + + chdt::ParseResult result = chdt::parseDataType(input); + if (!result.ok()) + { + std::cerr << "error: " << result.error->message << " (at byte " << result.error->position << ")\n"; + return 1; + } + + std::cout << chdt::toJSON(*result.ast) << "\n"; + return 0; +} diff --git a/src/Interpreters/InterpreterExplainQuery.cpp b/src/Interpreters/InterpreterExplainQuery.cpp index f18bc6708eda..f109a4f5ee31 100644 --- a/src/Interpreters/InterpreterExplainQuery.cpp +++ b/src/Interpreters/InterpreterExplainQuery.cpp @@ -204,6 +204,7 @@ namespace struct QueryASTSettings { bool graph = false; + bool json = false; bool optimize = false; constexpr static char name[] = "AST"; @@ -211,6 +212,7 @@ struct QueryASTSettings std::unordered_map> boolean_settings = { {"graph", graph}, + {"json", json}, {"optimize", optimize} }; @@ -508,7 +510,24 @@ QueryPipeline InterpreterExplainQuery::executeImpl() ExplainAnalyzedSyntaxVisitor(data).visit(query); } - if (settings.graph) + if (settings.graph && settings.json) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Options 'graph' and 'json' are mutually exclusive in EXPLAIN AST"); + + if (settings.json) + { + auto ast_json = formatASTAsJSONDocument(*ast.getExplainedQuery()); + + auto json_io_settings = getFormatSettings(query_context); + json_io_settings.json.quote_64bit_integers = false; + + JSONBuilder::FormatSettings json_format_settings{.settings = json_io_settings}; + JSONBuilder::FormatContext format_context{.out = buf}; + + ast_json->format(json_format_settings, format_context); + + single_line = true; + } + else if (settings.graph) dumpASTInDotFormat(*ast.getExplainedQuery(), buf); else dumpAST(*ast.getExplainedQuery(), buf); diff --git a/src/Interpreters/executeQuery.cpp b/src/Interpreters/executeQuery.cpp index 558e627a5b3a..c8c983312e4e 100644 --- a/src/Interpreters/executeQuery.cpp +++ b/src/Interpreters/executeQuery.cpp @@ -1310,8 +1310,11 @@ static BlockIO executeQueryImpl( } else if (const auto * explain_query = out_ast->as()) { - if (!explain_query->children.empty()) - if (const auto * create_of_explain_query = explain_query->children[0]->as()) + /// Use the explained query directly: when EXPLAIN settings are + /// present (e.g. `EXPLAIN AST json = 1 ...`) children[0] is the + /// settings node, not the explained query. + if (const auto & explained_query = explain_query->getExplainedQuery()) + if (const auto * create_of_explain_query = explained_query->as()) is_create_parameterized_view = create_of_explain_query->isParameterizedView(); } } diff --git a/src/Parsers/ASTColumnsTransformers.h b/src/Parsers/ASTColumnsTransformers.h index a736cb49313f..1b628f9f520f 100644 --- a/src/Parsers/ASTColumnsTransformers.h +++ b/src/Parsers/ASTColumnsTransformers.h @@ -78,6 +78,7 @@ class ASTColumnsExceptTransformer : public IASTColumnsTransformer } void transform(ASTs & nodes) const override; void setPattern(String pattern_); + const std::optional & getPattern() const { return pattern; } std::shared_ptr getMatcher() const; void appendColumnName(WriteBuffer & ostr) const override; void updateTreeHashImpl(SipHash & hash_state, bool ignore_aliases) const override; diff --git a/src/Parsers/DumpASTNode.cpp b/src/Parsers/DumpASTNode.cpp new file mode 100644 index 000000000000..52d80dd1fa18 --- /dev/null +++ b/src/Parsers/DumpASTNode.cpp @@ -0,0 +1,3046 @@ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + + +namespace DB +{ + +namespace +{ + +const char * functionKindToString(ASTFunction::Kind kind) +{ + switch (kind) + { + case ASTFunction::Kind::ORDINARY_FUNCTION: return "ORDINARY_FUNCTION"; + case ASTFunction::Kind::WINDOW_FUNCTION: return "WINDOW_FUNCTION"; + case ASTFunction::Kind::LAMBDA_FUNCTION: return "LAMBDA_FUNCTION"; + case ASTFunction::Kind::TABLE_ENGINE: return "TABLE_ENGINE"; + case ASTFunction::Kind::DATABASE_ENGINE: return "DATABASE_ENGINE"; + case ASTFunction::Kind::BACKUP_NAME: return "BACKUP_NAME"; + case ASTFunction::Kind::CODEC: return "CODEC"; + case ASTFunction::Kind::STATISTICS: return "STATISTICS"; + } + return ""; +} + +const char * nullsActionToString(NullsAction action) +{ + switch (action) + { + case NullsAction::EMPTY: return "EMPTY"; + case NullsAction::RESPECT_NULLS: return "RESPECT NULLS"; + case NullsAction::IGNORE_NULLS: return "IGNORE NULLS"; + } + return ""; +} + +const char * windowFrameTypeToString(WindowFrame::FrameType type) +{ + switch (type) + { + case WindowFrame::FrameType::ROWS: return "ROWS"; + case WindowFrame::FrameType::GROUPS: return "GROUPS"; + case WindowFrame::FrameType::RANGE: return "RANGE"; + } + return ""; +} + +const char * windowBoundaryTypeToString(WindowFrame::BoundaryType type) +{ + switch (type) + { + case WindowFrame::BoundaryType::Unbounded: return "Unbounded"; + case WindowFrame::BoundaryType::Current: return "Current"; + case WindowFrame::BoundaryType::Offset: return "Offset"; + } + return ""; +} + +const char * ttlModeToString(TTLMode mode) +{ + switch (mode) + { + case TTLMode::DELETE: return "DELETE"; + case TTLMode::MOVE: return "MOVE"; + case TTLMode::GROUP_BY: return "GROUP_BY"; + case TTLMode::RECOMPRESS: return "RECOMPRESS"; + } + return ""; +} + +const char * dataDestinationTypeToString(DataDestinationType type) +{ + switch (type) + { + case DataDestinationType::DISK: return "DISK"; + case DataDestinationType::VOLUME: return "VOLUME"; + case DataDestinationType::TABLE: return "TABLE"; + case DataDestinationType::DELETE: return "DELETE"; + case DataDestinationType::SHARD: return "SHARD"; + } + return ""; +} + +const char * constraintTypeToString(ASTConstraintDeclaration::Type type) +{ + switch (type) + { + case ASTConstraintDeclaration::Type::CHECK: return "CHECK"; + case ASTConstraintDeclaration::Type::ASSUME: return "ASSUME"; + } + return ""; +} + +const char * alterObjectTypeToString(ASTAlterQuery::AlterObjectType type) +{ + switch (type) + { + case ASTAlterQuery::AlterObjectType::TABLE: return "TABLE"; + case ASTAlterQuery::AlterObjectType::DATABASE: return "DATABASE"; + case ASTAlterQuery::AlterObjectType::UNKNOWN: return "UNKNOWN"; + } + return ""; +} + +const char * alterCommandTypeToString(ASTAlterCommand::Type type) +{ + switch (type) + { + case ASTAlterCommand::ADD_COLUMN: return "ADD_COLUMN"; + case ASTAlterCommand::DROP_COLUMN: return "DROP_COLUMN"; + case ASTAlterCommand::MODIFY_COLUMN: return "MODIFY_COLUMN"; + case ASTAlterCommand::COMMENT_COLUMN: return "COMMENT_COLUMN"; + case ASTAlterCommand::RENAME_COLUMN: return "RENAME_COLUMN"; + case ASTAlterCommand::MATERIALIZE_COLUMN: return "MATERIALIZE_COLUMN"; + case ASTAlterCommand::MODIFY_ORDER_BY: return "MODIFY_ORDER_BY"; + case ASTAlterCommand::MODIFY_SAMPLE_BY: return "MODIFY_SAMPLE_BY"; + case ASTAlterCommand::MODIFY_TTL: return "MODIFY_TTL"; + case ASTAlterCommand::REWRITE_PARTS: return "REWRITE_PARTS"; + case ASTAlterCommand::MATERIALIZE_TTL: return "MATERIALIZE_TTL"; + case ASTAlterCommand::MODIFY_SETTING: return "MODIFY_SETTING"; + case ASTAlterCommand::RESET_SETTING: return "RESET_SETTING"; + case ASTAlterCommand::MODIFY_QUERY: return "MODIFY_QUERY"; + case ASTAlterCommand::MODIFY_REFRESH: return "MODIFY_REFRESH"; + case ASTAlterCommand::REMOVE_TTL: return "REMOVE_TTL"; + case ASTAlterCommand::REMOVE_SAMPLE_BY: return "REMOVE_SAMPLE_BY"; + case ASTAlterCommand::ADD_INDEX: return "ADD_INDEX"; + case ASTAlterCommand::DROP_INDEX: return "DROP_INDEX"; + case ASTAlterCommand::MATERIALIZE_INDEX: return "MATERIALIZE_INDEX"; + case ASTAlterCommand::ADD_CONSTRAINT: return "ADD_CONSTRAINT"; + case ASTAlterCommand::DROP_CONSTRAINT: return "DROP_CONSTRAINT"; + case ASTAlterCommand::ADD_PROJECTION: return "ADD_PROJECTION"; + case ASTAlterCommand::DROP_PROJECTION: return "DROP_PROJECTION"; + case ASTAlterCommand::MATERIALIZE_PROJECTION: return "MATERIALIZE_PROJECTION"; + case ASTAlterCommand::ADD_STATISTICS: return "ADD_STATISTICS"; + case ASTAlterCommand::DROP_STATISTICS: return "DROP_STATISTICS"; + case ASTAlterCommand::MODIFY_STATISTICS: return "MODIFY_STATISTICS"; + case ASTAlterCommand::MATERIALIZE_STATISTICS: return "MATERIALIZE_STATISTICS"; + case ASTAlterCommand::DROP_PARTITION: return "DROP_PARTITION"; + case ASTAlterCommand::DROP_DETACHED_PARTITION: return "DROP_DETACHED_PARTITION"; + case ASTAlterCommand::FORGET_PARTITION: return "FORGET_PARTITION"; + case ASTAlterCommand::ATTACH_PARTITION: return "ATTACH_PARTITION"; + case ASTAlterCommand::MOVE_PARTITION: return "MOVE_PARTITION"; + case ASTAlterCommand::REPLACE_PARTITION: return "REPLACE_PARTITION"; + case ASTAlterCommand::FETCH_PARTITION: return "FETCH_PARTITION"; + case ASTAlterCommand::FREEZE_PARTITION: return "FREEZE_PARTITION"; + case ASTAlterCommand::FREEZE_ALL: return "FREEZE_ALL"; + case ASTAlterCommand::UNFREEZE_PARTITION: return "UNFREEZE_PARTITION"; + case ASTAlterCommand::UNFREEZE_ALL: return "UNFREEZE_ALL"; + case ASTAlterCommand::DELETE: return "DELETE"; + case ASTAlterCommand::UPDATE: return "UPDATE"; + case ASTAlterCommand::APPLY_DELETED_MASK: return "APPLY_DELETED_MASK"; + case ASTAlterCommand::APPLY_PATCHES: return "APPLY_PATCHES"; + case ASTAlterCommand::NO_TYPE: return "NO_TYPE"; + case ASTAlterCommand::MODIFY_DATABASE_SETTING: return "MODIFY_DATABASE_SETTING"; + case ASTAlterCommand::MODIFY_DATABASE_COMMENT: return "MODIFY_DATABASE_COMMENT"; + case ASTAlterCommand::MODIFY_COMMENT: return "MODIFY_COMMENT"; + case ASTAlterCommand::MODIFY_SQL_SECURITY: return "MODIFY_SQL_SECURITY"; + case ASTAlterCommand::UNLOCK_SNAPSHOT: return "UNLOCK_SNAPSHOT"; + } + return ""; +} + +const char * killTypeToString(ASTKillQueryQuery::Type type) +{ + switch (type) + { + case ASTKillQueryQuery::Type::Query: return "QUERY"; + case ASTKillQueryQuery::Type::Mutation: return "MUTATION"; + case ASTKillQueryQuery::Type::PartMoveToShard: return "PART_MOVE_TO_SHARD"; + case ASTKillQueryQuery::Type::Transaction: return "TRANSACTION"; + } + return ""; +} + +const char * dropKindToString(ASTDropQuery::Kind kind) +{ + switch (kind) + { + case ASTDropQuery::Kind::Drop: return "DROP"; + case ASTDropQuery::Kind::Detach: return "DETACH"; + case ASTDropQuery::Kind::Truncate: return "TRUNCATE"; + } + return ""; +} + +const char * syncReplicaModeToString(SyncReplicaMode mode) +{ + switch (mode) + { + case SyncReplicaMode::DEFAULT: return "DEFAULT"; + case SyncReplicaMode::STRICT: return "STRICT"; + case SyncReplicaMode::LIGHTWEIGHT: return "LIGHTWEIGHT"; + case SyncReplicaMode::PULL: return "PULL"; + } + return ""; +} + +const char * failPointActionToString(ASTSystemQuery::FailPointAction action) +{ + switch (action) + { + case ASTSystemQuery::FailPointAction::UNSPECIFIED: return "UNSPECIFIED"; + case ASTSystemQuery::FailPointAction::PAUSE: return "PAUSE"; + case ASTSystemQuery::FailPointAction::RESUME: return "RESUME"; + } + return ""; +} + +const char * backupKindToString(ASTBackupQuery::Kind kind) +{ + switch (kind) + { + case ASTBackupQuery::Kind::BACKUP: return "BACKUP"; + case ASTBackupQuery::Kind::RESTORE: return "RESTORE"; + } + return ""; +} + +const char * backupElementTypeToString(ASTBackupQuery::ElementType type) +{ + switch (type) + { + case ASTBackupQuery::ElementType::TABLE: return "TABLE"; + case ASTBackupQuery::ElementType::TEMPORARY_TABLE: return "TEMPORARY_TABLE"; + case ASTBackupQuery::ElementType::DATABASE: return "DATABASE"; + case ASTBackupQuery::ElementType::ALL: return "ALL"; + } + return ""; +} + +const char * resourceAccessModeToString(ResourceAccessMode mode) +{ + switch (mode) + { + case ResourceAccessMode::DiskRead: return "READ"; + case ResourceAccessMode::DiskWrite: return "WRITE"; + case ResourceAccessMode::MasterThread: return "MASTER_THREAD"; + case ResourceAccessMode::WorkerThread: return "WORKER_THREAD"; + case ResourceAccessMode::Query: return "QUERY"; + } + return ""; +} + +const char * settingWritabilityToString(SettingConstraintWritability writability) +{ + switch (writability) + { + case SettingConstraintWritability::WRITABLE: return "WRITABLE"; + case SettingConstraintWritability::CONST: return "CONST"; + case SettingConstraintWritability::CHANGEABLE_IN_READONLY: return "CHANGEABLE_IN_READONLY"; + case SettingConstraintWritability::MAX: return ""; + } + return ""; +} + +const char * setRoleKindToString(ASTSetRoleQuery::Kind kind) +{ + switch (kind) + { + case ASTSetRoleQuery::Kind::SET_ROLE: return "SET_ROLE"; + case ASTSetRoleQuery::Kind::SET_ROLE_DEFAULT: return "SET_ROLE_DEFAULT"; + case ASTSetRoleQuery::Kind::SET_DEFAULT_ROLE: return "SET_DEFAULT_ROLE"; + } + return ""; +} + +const char * transactionActionToString(ASTTransactionControl::QueryType action) +{ + switch (action) + { + case ASTTransactionControl::BEGIN: return "BEGIN"; + case ASTTransactionControl::COMMIT: return "COMMIT"; + case ASTTransactionControl::ROLLBACK: return "ROLLBACK"; + case ASTTransactionControl::SET_SNAPSHOT: return "SET_SNAPSHOT"; + } + return ""; +} + +const char * refreshScheduleKindToString(RefreshScheduleKind kind) +{ + switch (kind) + { + case RefreshScheduleKind::UNKNOWN: return "UNKNOWN"; + case RefreshScheduleKind::AFTER: return "AFTER"; + case RefreshScheduleKind::EVERY: return "EVERY"; + } + return ""; +} + +const char * fieldTypeName(Field::Types::Which which) +{ + switch (which) + { + case Field::Types::Null: return "Null"; + case Field::Types::UInt64: return "UInt64"; + case Field::Types::Int64: return "Int64"; + case Field::Types::Float64: return "Float64"; + case Field::Types::UInt128: return "UInt128"; + case Field::Types::Int128: return "Int128"; + case Field::Types::UInt256: return "UInt256"; + case Field::Types::Int256: return "Int256"; + case Field::Types::String: return "String"; + case Field::Types::Array: return "Array"; + case Field::Types::Tuple: return "Tuple"; + case Field::Types::Map: return "Map"; + case Field::Types::Object: return "Object"; + case Field::Types::Bool: return "Bool"; + case Field::Types::UUID: return "UUID"; + case Field::Types::IPv4: return "IPv4"; + case Field::Types::IPv6: return "IPv6"; + case Field::Types::Decimal32: return "Decimal32"; + case Field::Types::Decimal64: return "Decimal64"; + case Field::Types::Decimal128: return "Decimal128"; + case Field::Types::Decimal256: return "Decimal256"; + case Field::Types::AggregateFunctionState: return "AggregateFunctionState"; + case Field::Types::CustomType: return "CustomType"; + } + return ""; +} + +JSONBuilder::ItemPtr fieldToJSON(const Field & value); + +/// Wrap a Field as a typed JSON object: { "value_type": , "value": }. +/// This mirrors how an `ASTLiteral` node is serialized, so that the element types +/// of nested containers (e.g. the `UInt64` elements of an `Array`) are preserved +/// rather than being flattened into an untyped string. +JSONBuilder::ItemPtr fieldToTypedJSON(const Field & value) +{ + auto map = std::make_unique(); + map->add("value_type", String(fieldTypeName(value.getType()))); + map->add("value", fieldToJSON(value)); + return map; +} + +/// Emit the elements of an Array/Tuple/Map (all backed by a FieldVector) as a JSON +/// array of typed values, preserving each element's individual type. +JSONBuilder::ItemPtr fieldVectorToJSON(const FieldVector & elements) +{ + auto array = std::make_unique(); + for (const auto & element : elements) + array->add(fieldToTypedJSON(element)); + return array; +} + +/// Stringify a Map key for use as a JSON object key (JSON keys are always +/// strings). String keys are emitted verbatim; other scalar keys fall back to +/// their FieldVisitorToString form (e.g. an integer key becomes its digits). +String fieldMapKeyToString(const Field & key) +{ + if (key.getType() == Field::Types::String) + return key.safeGet(); + return applyVisitor(FieldVisitorToString(), key); +} + +/// A Map field is physically a vector of two-element (key, value) Tuples. +/// Emit it as a JSON object keyed by the (stringified) map key with typed +/// values, mirroring the `{k: v}` SETTINGS map syntax. If any element is not a +/// two-element tuple (not expected for a real Map field), fall back to the +/// generic array-of-tuples form so no information is lost. +JSONBuilder::ItemPtr fieldMapToJSON(const Map & map) +{ + for (const auto & element : map) + { + if (element.getType() != Field::Types::Tuple || element.safeGet().size() != 2) + return fieldVectorToJSON(map); + } + + auto object = std::make_unique(); + for (const auto & element : map) + { + const Tuple & kv = element.safeGet(); + object->add(fieldMapKeyToString(kv[0]), fieldToTypedJSON(kv[1])); + } + return object; +} + +/// Map a Field to a JSONBuilder value. +/// Common scalar Field types are emitted as native JSON values. Array / Tuple +/// recurse to a JSON array of typed `{ "value_type", "value" }` elements; Map / +/// Object become a JSON object keyed by the (stringified) key with typed values. +/// Remaining exotic types fall back to a string produced by `FieldVisitorToString`. +JSONBuilder::ItemPtr fieldToJSON(const Field & value) +{ + switch (value.getType()) + { + case Field::Types::Null: + return std::make_unique(); + case Field::Types::Bool: + /// Bool is stored as UInt64 under the hood. + return std::make_unique(value.safeGet() != 0); + case Field::Types::UInt64: + /// Emitted as a string: values above 2^53 lose precision when a + /// JavaScript consumer runs them through JSON.parse (IEEE-754). + return std::make_unique(std::to_string(value.safeGet())); + case Field::Types::Int64: + return std::make_unique(std::to_string(value.safeGet())); + case Field::Types::Float64: + return std::make_unique>(value.safeGet()); + case Field::Types::String: + return std::make_unique(value.safeGet()); + case Field::Types::Array: + return fieldVectorToJSON(value.safeGet()); + case Field::Types::Tuple: + return fieldVectorToJSON(value.safeGet()); + case Field::Types::Map: + return fieldMapToJSON(value.safeGet()); + case Field::Types::Object: + { + /// Object is keyed by String, so emit a JSON object of typed values. + auto map = std::make_unique(); + for (const auto & [key, element] : value.safeGet()) + map->add(key, fieldToTypedJSON(element)); + return map; + } + default: + return std::make_unique(applyVisitor(FieldVisitorToString(), value)); + } +} + +/// Emit the children of an `ASTExpressionList` as a JSON array, inlining the +/// wrapper node itself. The wrapper is a parser-internal detail, so consumers +/// see the clause's elements directly. A null `list` yields an empty array. +JSONBuilder::ItemPtr inlineExpressionList(const ASTPtr & list) +{ + auto array = std::make_unique(); + if (list) + for (const auto & child : list->children) + array->add(formatASTAsJSON(*child)); + return array; +} + +/// Emit a single sub-node under `key`, but only when it is present. +void addNodeSlot(JSONBuilder::JSONMap & node, const char * key, const ASTPtr & child) +{ + if (child) + node.add(key, formatASTAsJSON(*child)); +} + +/// Overloads for the raw `IAST *` / `ASTExpressionList *` members that DDL +/// nodes hold (alongside `children`) instead of `ASTPtr`s. +void addNodeSlot(JSONBuilder::JSONMap & node, const char * key, const IAST * child) +{ + if (child) + node.add(key, formatASTAsJSON(*child)); +} + +JSONBuilder::ItemPtr inlineExpressionList(const IAST * list) +{ + auto array = std::make_unique(); + if (list) + for (const auto & child : list->children) + array->add(formatASTAsJSON(*child)); + return array; +} + +/// Emit a plain `ASTs` vector (not wrapped in an `ASTExpressionList`) as a JSON +/// array. Used by nodes that keep loose node lists in dedicated members, e.g. +/// `ASTTTLElement::group_by_key`. +JSONBuilder::ItemPtr inlineASTs(const ASTs & list) +{ + auto array = std::make_unique(); + for (const auto & child : list) + if (child) + array->add(formatASTAsJSON(*child)); + return array; +} + +/// The `INTO OUTFILE` / `FORMAT` part of the trailing output clause held in +/// the ASTQueryWithOutput base: +/// `[INTO OUTFILE [APPEND | TRUNCATE] [AND STDOUT] [COMPRESSION +/// [LEVEL ]]] [FORMAT ]`. All members are null-safe (each slot is +/// only emitted when present). The `format` name is emitted as a plain string +/// to match the `format` field used for INSERT; `out_file`, `compression` and +/// `compression_level` are literal nodes serialized recursively, and the +/// APPEND / TRUNCATE / AND STDOUT modifiers are exposed as boolean flags. +/// +/// The trailing `SETTINGS` slot is *not* handled here: it is added by each +/// caller under `"settings"`, because the settings member differs per node +/// type (`settings_ast` for most, but `ASTExplainQuery` keeps a separate +/// EXPLAIN-level settings on that key). Callers that expose the base +/// `settings_ast` do `addNodeSlot(node, "settings", query.settings_ast)`. +void addOutfileAndFormat(JSONBuilder::JSONMap & node, const ASTQueryWithOutput & query) +{ + if (query.out_file) + { + node.add("out_file", formatASTAsJSON(*query.out_file)); + if (query.isOutfileAppend()) + node.add("outfile_append", true); + if (query.isOutfileTruncate()) + node.add("outfile_truncate", true); + if (query.isIntoOutfileWithStdout()) + node.add("outfile_with_stdout", true); + addNodeSlot(node, "compression", query.compression); + addNodeSlot(node, "compression_level", query.compression_level); + } + + String format_name; + if (tryGetIdentifierNameInto(query.format_ast, format_name)) + node.add("format", format_name); +} + +/// Common `database` / `table` / `temporary` slots shared by the table-scoped +/// DDL/DML statements (DROP, OPTIMIZE, DELETE, UPDATE, ...). +void addTableTarget(JSONBuilder::JSONMap & node, const ASTQueryWithTableAndOutput & query) +{ + if (query.isTemporary()) + node.add("temporary", true); + addNodeSlot(node, "database", query.database); + addNodeSlot(node, "table", query.table); + if (query.uuid != UUIDHelpers::Nil) + node.add("uuid", toString(query.uuid)); + /// Trailing output options held in the ASTQueryWithOutput base. + addNodeSlot(node, "settings", query.settings_ast); + addOutfileAndFormat(node, query); +} + +/// Serialize the privilege list of a GRANT / REVOKE / CHECK GRANT statement. +/// Each AccessRightsElement is one "... ON ..." line; the AccessFlags bitmask +/// is decoded to its keyword list (SELECT, UPDATE(col), ...) via toKeywords(). +/// These live in a plain value vector, not in the AST `children`. +JSONBuilder::ItemPtr serializeAccessElements(const AccessRightsElements & elements) +{ + auto array = std::make_unique(); + for (const auto & element : elements) + { + auto item = std::make_unique(); + + auto access_types = std::make_unique(); + for (const auto & keyword : element.access_flags.toKeywords()) + access_types->add(String(keyword)); + item->add("access_types", std::move(access_types)); + + if (!element.database.empty()) + item->add("database", element.database); + if (element.default_database) + item->add("default_database", true); + if (!element.table.empty()) + item->add("table", element.table); + if (!element.columns.empty()) + { + auto columns = std::make_unique(); + for (const auto & column : element.columns) + columns->add(column); + item->add("columns", std::move(columns)); + } + if (!element.parameter.empty()) + item->add("parameter", element.parameter); + if (element.wildcard) + item->add("wildcard", true); + if (element.grant_option) + item->add("grant_option", true); + if (element.is_partial_revoke) + item->add("is_partial_revoke", true); + + array->add(std::move(item)); + } + return array; +} + +/// Serialize an AllowedClientHosts value object (the HOST clause of CREATE USER). +/// Like AccessRightsElements it is a plain value member, not an AST node. +JSONBuilder::ItemPtr serializeAllowedHosts(const AllowedClientHosts & hosts) +{ + auto map = std::make_unique(); + if (hosts.containsAnyHost()) + map->add("any_host", true); + if (hosts.containsLocalHost()) + map->add("local_host", true); + + auto add_strings = [&](const char * key, const Strings & values) + { + if (values.empty()) + return; + auto array = std::make_unique(); + for (const auto & value : values) + array->add(value); + map->add(key, std::move(array)); + }; + + add_strings("names", hosts.getNames()); + add_strings("name_regexps", hosts.getNameRegexps()); + add_strings("like_patterns", hosts.getLikePatterns()); + + if (!hosts.getAddresses().empty()) + { + auto array = std::make_unique(); + for (const auto & address : hosts.getAddresses()) + array->add(address.toString()); + map->add("addresses", std::move(array)); + } + if (!hosts.getSubnets().empty()) + { + auto array = std::make_unique(); + for (const auto & subnet : hosts.getSubnets()) + array->add(subnet.toString()); + map->add("subnets", std::move(array)); + } + return map; +} + +/// Emit a plain list of strings under `key` (only when non-empty). +void addStringList(JSONBuilder::JSONMap & node, const char * key, const Strings & values) +{ + if (values.empty()) + return; + auto array = std::make_unique(); + for (const auto & value : values) + array->add(value); + node.add(key, std::move(array)); +} + +/// Add per-class structured fields to `node`. Returns `true` when the class +/// exposes all of its sub-nodes through named slots and the generic +/// positional `children` array must therefore be suppressed. +bool enrichNode(JSONBuilder::JSONMap & node, const IAST & ast) +{ + if (const auto * function = dynamic_cast(&ast)) + { + node.add("name", function->name); + + if (function->isOperator()) + node.add("is_operator", true); + if (function->isWindowFunction()) + node.add("is_window_function", true); + if (function->isLambdaFunction()) + node.add("is_lambda_function", true); + + if (function->getKind() != ASTFunction::Kind::ORDINARY_FUNCTION) + node.add("kind", String(functionKindToString(function->getKind()))); + + if (function->getNullsAction() != NullsAction::EMPTY) + node.add("nulls_action", String(nullsActionToString(function->getNullsAction()))); + + /// `arguments` is always present (possibly empty), so consumers never + /// have to branch on its presence. + node.add("arguments", inlineExpressionList(function->arguments)); + + /// `parameters` only exists for parametric aggregates, e.g. quantile(0.9)(x). + if (function->parameters) + node.add("parameters", inlineExpressionList(function->parameters)); + + /// Exactly one of `window_definition` / `window_name` is present for + /// window functions; both absent otherwise. `window_definition` is not + /// an `ASTExpressionList`, so it is emitted as a node. + if (function->window_definition) + node.add("window_definition", formatASTAsJSON(*function->window_definition)); + if (!function->window_name.empty()) + node.add("window_name", function->window_name); + + return true; + } + else if (const auto * table_identifier = dynamic_cast(&ast)) + { + node.add("name", table_identifier->shortName()); + + const auto database = table_identifier->getDatabaseName(); + if (!database.empty()) + node.add("database", database); + } + else if (const auto * identifier = dynamic_cast(&ast)) + { + node.add("name", identifier->name()); + + if (identifier->compound()) + { + auto parts = std::make_unique(); + for (const auto & part : identifier->name_parts) + parts->add(part); + node.add("name_parts", std::move(parts)); + } + } + else if (const auto * query_parameter = dynamic_cast(&ast)) + { + /// `{name:type}` — appears in value position and in identifier/table + /// position. The substitution type is exposed as `param_type`. + node.add("name", query_parameter->name); + node.add("param_type", query_parameter->type); + + return true; + } + else if (const auto * literal = dynamic_cast(&ast)) + { + node.add("value_type", String(fieldTypeName(literal->value.getType()))); + node.add("value", fieldToJSON(literal->value)); + } + else if (const auto * order_by = dynamic_cast(&ast)) + { + /// The sort expression is the mandatory first child; collation and the + /// WITH FILL bounds are optional named slots. + if (!order_by->children.empty()) + node.add("expression", formatASTAsJSON(*order_by->children.front())); + + node.add("direction", String(order_by->direction >= 0 ? "ASC" : "DESC")); + if (order_by->nulls_direction_was_explicitly_specified) + node.add("nulls_first", order_by->nulls_direction != order_by->direction); + + addNodeSlot(node, "collation", order_by->getCollation()); + + if (order_by->with_fill) + node.add("with_fill", true); + addNodeSlot(node, "fill_from", order_by->getFillFrom()); + addNodeSlot(node, "fill_to", order_by->getFillTo()); + addNodeSlot(node, "fill_step", order_by->getFillStep()); + addNodeSlot(node, "fill_staleness", order_by->getFillStaleness()); + + return true; + } + else if (const auto * intersect_except = dynamic_cast(&ast)) + { + /// Derives from ASTSelectQuery but keeps its operand selects in the + /// positional `children` array rather than the `Expression` slots, so + /// it must be matched *before* ASTSelectQuery. We expose those operands + /// under `selects` (mirroring ASTSelectWithUnionQuery) and suppress + /// `children`. + if (intersect_except->final_operator != ASTSelectIntersectExceptQuery::Operator::UNKNOWN) + node.add("operator", String(ASTSelectIntersectExceptQuery::fromOperator(intersect_except->final_operator))); + node.add("selects", inlineExpressionList(intersect_except)); + + return true; + } + else if (const auto * select = dynamic_cast(&ast)) + { + if (select->distinct) + node.add("distinct", true); + if (select->group_by_all) + node.add("group_by_all", true); + if (select->group_by_with_totals) + node.add("group_by_with_totals", true); + if (select->group_by_with_rollup) + node.add("group_by_with_rollup", true); + if (select->group_by_with_cube) + node.add("group_by_with_cube", true); + if (select->group_by_with_grouping_sets) + node.add("group_by_with_grouping_sets", true); + if (select->order_by_all) + node.add("order_by_all", true); + if (select->recursive_with) + node.add("recursive_with", true); + if (select->limit_with_ties) + node.add("limit_with_ties", true); + + /// Expose each clause through a named slot, in declaration order. + /// List-shaped clauses inline their `ASTExpressionList` wrapper; the + /// rest are emitted as single nodes. `ALIASES` / `CTE_ALIASES` are + /// analyzer state and never appear on parsed-but-not-analyzed ASTs, so + /// they are intentionally omitted. + using Expression = ASTSelectQuery::Expression; + struct Slot + { + Expression expr; + const char * key; + bool is_list; + }; + static constexpr Slot slots[] = { + {Expression::WITH, "with", true}, + {Expression::SELECT, "select", true}, + {Expression::TABLES, "from", false}, + {Expression::PREWHERE, "prewhere", false}, + {Expression::WHERE, "where", false}, + {Expression::GROUP_BY, "group_by", true}, + {Expression::HAVING, "having", false}, + {Expression::WINDOW, "window", true}, + {Expression::QUALIFY, "qualify", false}, + {Expression::ORDER_BY, "order_by", true}, + {Expression::LIMIT_OFFSET, "offset", false}, + {Expression::LIMIT_LENGTH, "limit", false}, + {Expression::SETTINGS, "settings", false}, + {Expression::INTERPOLATE, "interpolate", true}, + }; + + for (const auto & slot : slots) + { + auto expr = select->getExpression(slot.expr); + if (!expr) + continue; + if (slot.is_list) + node.add(slot.key, inlineExpressionList(expr)); + else + node.add(slot.key, formatASTAsJSON(*expr)); + } + + /// LIMIT ... BY ... is grouped into one object: {length, offset?, by}. + if (auto by = select->getExpression(Expression::LIMIT_BY)) + { + auto limit_by = std::make_unique(); + if (auto length = select->getExpression(Expression::LIMIT_BY_LENGTH)) + limit_by->add("length", formatASTAsJSON(*length)); + if (auto offset = select->getExpression(Expression::LIMIT_BY_OFFSET)) + limit_by->add("offset", formatASTAsJSON(*offset)); + limit_by->add("by", inlineExpressionList(by)); + node.add("limit_by", std::move(limit_by)); + } + + return true; + } + else if (const auto * select_union = dynamic_cast(&ast)) + { + if (select_union->hasNonDefaultUnionMode()) + node.add("union_mode", String(toString(select_union->union_mode))); + + /// Inline the `list_of_selects` wrapper so the operand selects appear + /// directly under `selects`. + node.add("selects", inlineExpressionList(select_union->list_of_selects)); + /// The trailing output clause (`INTO OUTFILE` / `FORMAT` / output-level + /// `SETTINGS`, incl. on UNION / INTERSECT / EXCEPT) lives on this + /// wrapper, not on the operand selects. The `SETTINGS` here is the one + /// placed *after* `FORMAT` (`SELECT ... FORMAT x SETTINGS y`); a + /// `SETTINGS` before `FORMAT` is consumed into the operand select's + /// own `settings` slot instead. + addNodeSlot(node, "settings", select_union->settings_ast); + addOutfileAndFormat(node, *select_union); + + return true; + } + else if (const auto * subquery = dynamic_cast(&ast)) + { + if (!subquery->cte_name.empty()) + node.add("cte_name", subquery->cte_name); + + /// A subquery wraps exactly one query node. + if (!subquery->children.empty()) + node.add("query", formatASTAsJSON(*subquery->children.front())); + + return true; + } + else if (const auto * with_element = dynamic_cast(&ast)) + { + node.add("name", with_element->name); + addNodeSlot(node, "subquery", with_element->subquery); + addNodeSlot(node, "aliases", with_element->aliases); + + return true; + } + else if (const auto * table_element = dynamic_cast(&ast)) + { + addNodeSlot(node, "table_join", table_element->table_join); + addNodeSlot(node, "table_expression", table_element->table_expression); + addNodeSlot(node, "array_join", table_element->array_join); + + return true; + } + else if (const auto * table_expression = dynamic_cast(&ast)) + { + /// Exactly one of these three identifies the table. + addNodeSlot(node, "database_and_table_name", table_expression->database_and_table_name); + addNodeSlot(node, "table_function", table_expression->table_function); + addNodeSlot(node, "subquery", table_expression->subquery); + + if (table_expression->final) + node.add("final", true); + addNodeSlot(node, "sample_size", table_expression->sample_size); + addNodeSlot(node, "sample_offset", table_expression->sample_offset); + addNodeSlot(node, "column_aliases", table_expression->column_aliases); + + return true; + } + else if (const auto * table_join = dynamic_cast(&ast)) + { + node.add("kind", String(toString(table_join->kind))); + if (table_join->strictness != JoinStrictness::Unspecified) + node.add("strictness", String(toString(table_join->strictness))); + if (table_join->locality != JoinLocality::Unspecified) + node.add("locality", String(toString(table_join->locality))); + + if (table_join->using_expression_list) + node.add("using", inlineExpressionList(table_join->using_expression_list)); + addNodeSlot(node, "on", table_join->on_expression); + + return true; + } + else if (const auto * array_join = dynamic_cast(&ast)) + { + node.add("kind", String(array_join->kind == ASTArrayJoin::Kind::Left ? "LEFT" : "INNER")); + if (array_join->expression_list) + node.add("expressions", inlineExpressionList(array_join->expression_list)); + + return true; + } + else if (const auto * window_list_element = dynamic_cast(&ast)) + { + node.add("name", window_list_element->name); + addNodeSlot(node, "definition", window_list_element->definition); + + return true; + } + else if (const auto * window_definition = dynamic_cast(&ast)) + { + if (!window_definition->parent_window_name.empty()) + node.add("parent_window_name", window_definition->parent_window_name); + + if (window_definition->partition_by) + node.add("partition_by", inlineExpressionList(window_definition->partition_by)); + if (window_definition->order_by) + node.add("order_by", inlineExpressionList(window_definition->order_by)); + + /// The frame is only meaningful when it differs from the implicit + /// default. Each boundary is one object: {type, offset?, preceding?}, + /// `preceding` emitted only when true (per the flags-when-set contract). + if (!window_definition->frame_is_default) + { + node.add("frame_type", String(windowFrameTypeToString(window_definition->frame_type))); + + auto begin = std::make_unique(); + begin->add("type", String(windowBoundaryTypeToString(window_definition->frame_begin_type))); + addNodeSlot(*begin, "offset", window_definition->frame_begin_offset); + if (window_definition->frame_begin_preceding) + begin->add("preceding", true); + node.add("frame_begin", std::move(begin)); + + auto end = std::make_unique(); + end->add("type", String(windowBoundaryTypeToString(window_definition->frame_end_type))); + addNodeSlot(*end, "offset", window_definition->frame_end_offset); + if (window_definition->frame_end_preceding) + end->add("preceding", true); + node.add("frame_end", std::move(end)); + } + + return true; + } + else if (const auto * interpolate = dynamic_cast(&ast)) + { + node.add("column", interpolate->column); + addNodeSlot(node, "expr", interpolate->expr); + + return true; + } + else if (const auto * set_query = dynamic_cast(&ast)) + { + /// The SETTINGS clause: expose the changes as a name -> value object. + if (!set_query->changes.empty()) + { + auto changes = std::make_unique(); + for (const auto & change : set_query->changes) + changes->add(change.name, fieldToJSON(change.value)); + node.add("changes", std::move(changes)); + } + + if (!set_query->default_settings.empty()) + { + auto defaults = std::make_unique(); + for (const auto & name : set_query->default_settings) + defaults->add(name); + node.add("default_settings", std::move(defaults)); + } + + return true; + } + else if (const auto * sample_ratio = dynamic_cast(&ast)) + { + /// Kept as an exact rational; the components can exceed UInt64, so they + /// are emitted as strings. + node.add("numerator", String(ASTSampleRatio::toString(sample_ratio->ratio.numerator))); + node.add("denominator", String(ASTSampleRatio::toString(sample_ratio->ratio.denominator))); + + return true; + } + else if (const auto * asterisk = dynamic_cast(&ast)) + { + addNodeSlot(node, "expression", asterisk->expression); + if (asterisk->transformers) + node.add("transformers", inlineExpressionList(asterisk->transformers)); + + return true; + } + else if (const auto * qualified_asterisk = dynamic_cast(&ast)) + { + addNodeSlot(node, "qualifier", qualified_asterisk->qualifier); + if (qualified_asterisk->transformers) + node.add("transformers", inlineExpressionList(qualified_asterisk->transformers)); + + return true; + } + else if (const auto * regexp_matcher = dynamic_cast(&ast)) + { + node.add("pattern", regexp_matcher->getPattern()); + addNodeSlot(node, "expression", regexp_matcher->expression); + if (regexp_matcher->transformers) + node.add("transformers", inlineExpressionList(regexp_matcher->transformers)); + + return true; + } + else if (const auto * list_matcher = dynamic_cast(&ast)) + { + addNodeSlot(node, "expression", list_matcher->expression); + if (list_matcher->column_list) + node.add("columns", inlineExpressionList(list_matcher->column_list)); + if (list_matcher->transformers) + node.add("transformers", inlineExpressionList(list_matcher->transformers)); + + return true; + } + else if (const auto * apply = dynamic_cast(&ast)) + { + if (!apply->func_name.empty()) + node.add("func_name", apply->func_name); + addNodeSlot(node, "parameters", apply->parameters); + addNodeSlot(node, "lambda", apply->lambda); + if (!apply->lambda_arg.empty()) + node.add("lambda_arg", apply->lambda_arg); + if (!apply->column_name_prefix.empty()) + node.add("column_name_prefix", apply->column_name_prefix); + + return true; + } + else if (const auto * except = dynamic_cast(&ast)) + { + if (except->is_strict) + node.add("is_strict", true); + if (!except->children.empty()) + node.add("columns", inlineExpressionList(&ast)); + if (const auto & pattern = except->getPattern()) + node.add("pattern", *pattern); + + return true; + } + else if (const auto * replace = dynamic_cast(&ast)) + { + if (replace->is_strict) + node.add("is_strict", true); + if (!replace->children.empty()) + node.add("replacements", inlineExpressionList(&ast)); + + return true; + } + else if (const auto * replacement = dynamic_cast(&ast)) + { + node.add("name", replacement->name); + if (!replacement->children.empty()) + node.add("expression", formatASTAsJSON(*replacement->children.front())); + + return true; + } + else if (const auto * enum_type = dynamic_cast(&ast)) + { + /// Must precede the ASTDataType branch: ASTEnumDataType derives from it, + /// but its values live in a dedicated vector rather than in `getArguments`. + node.add("name", enum_type->name); + + auto values = std::make_unique(); + for (const auto & [enum_name, enum_value] : enum_type->values) + { + auto value_node = std::make_unique(); + value_node->add("name", enum_name); + value_node->add("value", enum_value); + values->add(std::move(value_node)); + } + node.add("values", std::move(values)); + + return true; + } + else if (const auto * tuple_type = dynamic_cast(&ast)) + { + /// Must precede the ASTDataType branch (derived class). The element types + /// are in `getArguments`; the names of a named tuple are stored separately + /// in `element_names` (empty for an unnamed tuple). + node.add("name", tuple_type->name); + if (auto arguments = tuple_type->getArguments()) + node.add("arguments", inlineExpressionList(arguments)); + + if (!tuple_type->element_names.empty()) + { + auto names = std::make_unique(); + for (const auto & elem_name : tuple_type->element_names) + names->add(elem_name); + node.add("element_names", std::move(names)); + } + + return true; + } + else if (const auto * data_type = dynamic_cast(&ast)) + { + node.add("name", data_type->name); + if (auto arguments = data_type->getArguments()) + node.add("arguments", inlineExpressionList(arguments)); + + return true; + } + else if (const auto * create = dynamic_cast(&ast)) + { + if (create->attach) + node.add("attach", true); + if (create->isTemporary()) + node.add("temporary", true); + if (create->if_not_exists) + node.add("if_not_exists", true); + if (create->is_ordinary_view) + node.add("is_ordinary_view", true); + if (create->is_materialized_view) + node.add("is_materialized_view", true); + if (create->is_window_view) + node.add("is_window_view", true); + if (create->is_dictionary) + node.add("is_dictionary", true); + if (create->is_populate) + node.add("is_populate", true); + if (create->is_create_empty) + node.add("is_create_empty", true); + if (create->is_clone_as) + node.add("is_clone_as", true); + if (create->replace_view) + node.add("replace_view", true); + if (create->replace_table) + node.add("replace_table", true); + if (create->create_or_replace) + node.add("create_or_replace", true); + if (create->has_attach_from_path) + node.add("attach_from_path", create->attach_from_path); + if (create->attach_as_replicated.has_value()) + node.add("attach_as_replicated", *create->attach_as_replicated); + if (create->uuid != UUIDHelpers::Nil) + node.add("uuid", toString(create->uuid)); + if (!create->cluster.empty()) + node.add("cluster", create->cluster); + + addNodeSlot(node, "database", create->database); + addNodeSlot(node, "table", create->table); + + addNodeSlot(node, "columns_list", create->columns_list); + if (create->aliases_list) + node.add("aliases", inlineExpressionList(create->aliases_list)); + addNodeSlot(node, "storage", create->storage); + addNodeSlot(node, "as_table_function", create->as_table_function); + if (!create->as_database.empty()) + node.add("as_database", create->as_database); + if (!create->as_table.empty()) + node.add("as_table", create->as_table); + addNodeSlot(node, "select", create->select); + addNodeSlot(node, "targets", create->targets); + addNodeSlot(node, "comment", create->comment); + if (create->dictionary_attributes_list) + node.add("dictionary_attributes", inlineExpressionList(create->dictionary_attributes_list)); + addNodeSlot(node, "dictionary", create->dictionary); + addNodeSlot(node, "refresh", create->refresh_strategy); + addNodeSlot(node, "settings", create->settings_ast); + addOutfileAndFormat(node, *create); + + return true; + } + else if (const auto * columns = dynamic_cast(&ast)) + { + if (columns->columns) + node.add("columns", inlineExpressionList(columns->columns)); + if (columns->indices) + node.add("indices", inlineExpressionList(columns->indices)); + if (columns->constraints) + node.add("constraints", inlineExpressionList(columns->constraints)); + if (columns->projections) + node.add("projections", inlineExpressionList(columns->projections)); + addNodeSlot(node, "primary_key", columns->primary_key); + addNodeSlot(node, "primary_key_from_columns", columns->primary_key_from_columns); + + return true; + } + else if (const auto * column = dynamic_cast(&ast)) + { + node.add("name", column->name); + addNodeSlot(node, "data_type", column->getType()); + + if (column->default_specifier != ColumnDefaultSpecifier::Empty) + node.add("default_specifier", String(toString(column->default_specifier))); + addNodeSlot(node, "default_expression", column->getDefaultExpression()); + + if (column->null_modifier.has_value()) + node.add("null_modifier", *column->null_modifier); + if (column->ephemeral_default) + node.add("ephemeral_default", true); + if (column->primary_key_specifier) + node.add("primary_key_specifier", true); + + addNodeSlot(node, "comment", column->getComment()); + addNodeSlot(node, "codec", column->getCodec()); + addNodeSlot(node, "statistics", column->getStatisticsDesc()); + addNodeSlot(node, "ttl", column->getTTL()); + addNodeSlot(node, "collation", column->getCollation()); + addNodeSlot(node, "settings", column->getSettings()); + + return true; + } + else if (const auto * storage = dynamic_cast(&ast)) + { + addNodeSlot(node, "engine", storage->engine); + addNodeSlot(node, "partition_by", storage->partition_by); + addNodeSlot(node, "primary_key", storage->primary_key); + addNodeSlot(node, "order_by", storage->order_by); + addNodeSlot(node, "sample_by", storage->sample_by); + addNodeSlot(node, "ttl_table", storage->ttl_table); + addNodeSlot(node, "settings", storage->settings); + + return true; + } + else if (const auto * insert = dynamic_cast(&ast)) + { + addNodeSlot(node, "database", insert->database); + addNodeSlot(node, "table", insert->table); + addNodeSlot(node, "table_function", insert->table_function); + if (insert->columns) + node.add("columns", inlineExpressionList(insert->columns)); + if (!insert->format.empty()) + node.add("format", insert->format); + addNodeSlot(node, "partition_by", insert->partition_by); + addNodeSlot(node, "settings", insert->settings_ast); + addNodeSlot(node, "select", insert->select); + addNodeSlot(node, "infile", insert->infile); + addNodeSlot(node, "compression", insert->compression); + + return true; + } + else if (const auto * index = dynamic_cast(&ast)) + { + node.add("name", index->name); + addNodeSlot(node, "expression", index->getExpression()); + addNodeSlot(node, "index_type", index->getType().get()); + node.add("granularity", index->granularity); + + return true; + } + else if (const auto * constraint = dynamic_cast(&ast)) + { + node.add("name", constraint->name); + node.add("constraint_type", String(constraintTypeToString(constraint->type))); + addNodeSlot(node, "expression", constraint->expr); + + return true; + } + else if (const auto * projection = dynamic_cast(&ast)) + { + node.add("name", projection->name); + addNodeSlot(node, "query", projection->query); + addNodeSlot(node, "index", projection->index); + /// The indexed-projection TYPE (PROJECTION p INDEX expr TYPE name) and the + /// projection-level SETTINGS live in dedicated members, not in `children`. + addNodeSlot(node, "index_type", static_cast(projection->type)); + addNodeSlot(node, "settings", static_cast(projection->with_settings)); + + return true; + } + else if (const auto * projection_select = dynamic_cast(&ast)) + { + if (auto with_list = projection_select->with()) + node.add("with", inlineExpressionList(with_list)); + if (auto select_list = projection_select->select()) + node.add("select", inlineExpressionList(select_list)); + if (auto group_by_list = projection_select->groupBy()) + node.add("group_by", inlineExpressionList(group_by_list)); + /// Unlike a normal SELECT (whose ORDER BY is an ExpressionList of + /// OrderByElement), a projection stores ORDER BY as a *single* node: + /// multiple keys are packed into a `tuple(...)` function and a lone key + /// is kept bare (see ParserProjectionSelectQuery / formatImpl). Inlining + /// its `children` directly drops a single key (a bare identifier has no + /// children), and for the other cases leaks the argument-list wrapper — + /// losing the function name of a `f(x)` key entirely. Mirror the + /// formatter instead and expose the keys as a flat `order_by` list. + if (auto projection_order_by = projection_select->orderBy()) + { + if (const auto * tuple_key = projection_order_by->as(); tuple_key && tuple_key->name == "tuple" && tuple_key->arguments) + node.add("order_by", inlineExpressionList(tuple_key->arguments)); + else + node.add("order_by", inlineASTs(ASTs{projection_order_by})); + } + + return true; + } + else if (const auto * ttl = dynamic_cast(&ast)) + { + node.add("mode", String(ttlModeToString(ttl->mode))); + addNodeSlot(node, "ttl", ttl->ttl()); + + if (ttl->mode == TTLMode::MOVE) + { + node.add("destination_type", String(dataDestinationTypeToString(ttl->destination_type))); + if (!ttl->destination_name.empty()) + node.add("destination_name", ttl->destination_name); + if (ttl->if_exists) + node.add("if_exists", true); + } + /// GROUP BY ... SET ... keeps its keys and assignments in dedicated + /// members; the native AST otherwise retains only `mode: GROUP_BY`. + if (ttl->mode == TTLMode::GROUP_BY) + { + if (!ttl->group_by_key.empty()) + node.add("group_by_key", inlineASTs(ttl->group_by_key)); + if (!ttl->group_by_assignments.empty()) + node.add("group_by_assignments", inlineASTs(ttl->group_by_assignments)); + } + addNodeSlot(node, "where", ttl->where()); + addNodeSlot(node, "recompression_codec", ttl->recompression_codec); + + return true; + } + else if (const auto * partition = dynamic_cast(&ast)) + { + if (partition->all) + node.add("all", true); + addNodeSlot(node, "value", partition->value); + addNodeSlot(node, "id", partition->id); + + return true; + } + else if (const auto * collation = dynamic_cast(&ast)) + { + /// The collation name (COLLATE 'en_US') lives in the `collation` member, + /// not in `children`, so without this branch the node would expose only + /// its `type`. Applies to both column and ORDER BY collations. + if (collation->collation) + { + if (auto name = tryGetIdentifierName(collation->collation)) + node.add("name", *name); + else + node.add("name", formatASTAsJSON(*collation->collation)); + } + + return true; + } + else if (const auto * typed_path = dynamic_cast(&ast)) + { + /// JSON/Object typed path (a.b.c Type): the path name is kept in the + /// `path` member (only echoed into getID, which astTypeName trims off). + /// The slot for the type is `data_type` (not `type`, which is reserved + /// for the node-class discriminator). + node.add("name", typed_path->path); + addNodeSlot(node, "data_type", typed_path->type); + + return true; + } + else if (const auto * object_arg = dynamic_cast(&ast)) + { + /// An argument of a JSON/Object type: exactly one of a typed path, a + /// skipped path, a skipped-path regexp, or a `setting = N` parameter. + addNodeSlot(node, "path_with_type", object_arg->path_with_type); + addNodeSlot(node, "skip_path", object_arg->skip_path); + addNodeSlot(node, "skip_path_regexp", object_arg->skip_path_regexp); + addNodeSlot(node, "parameter", object_arg->parameter); + + return true; + } + else if (const auto * tcl = dynamic_cast(&ast)) + { + /// Transaction statements collapse to one node type; the action and the + /// snapshot value are otherwise lost. + node.add("action", String(transactionActionToString(tcl->action))); + if (tcl->action == ASTTransactionControl::SET_SNAPSHOT) + node.add("snapshot", std::to_string(tcl->snapshot)); + + return true; + } + else if (const auto * refresh = dynamic_cast(&ast)) + { + /// REFRESH ... strategy of a refreshable materialized view. The schedule + /// kind and the APPEND flag are scalar members, not children. + node.add("schedule_kind", String(refreshScheduleKindToString(refresh->schedule_kind))); + if (refresh->append) + node.add("append", true); + addNodeSlot(node, "period", static_cast(refresh->period)); + addNodeSlot(node, "offset", static_cast(refresh->offset)); + addNodeSlot(node, "spread", static_cast(refresh->spread)); + addNodeSlot(node, "dependencies", static_cast(refresh->dependencies)); + addNodeSlot(node, "settings", static_cast(refresh->settings)); + + return true; + } + else if (const auto * interval = dynamic_cast(&ast)) + { + /// Compound time interval (1 YEAR 3 DAY 15 MINUTE). The whole value is + /// held in the `interval` member with no AST children. + auto units = std::make_unique(); + for (auto [kind, value] : interval->interval.toIntervals()) + { + auto entry = std::make_unique(); + entry->add("kind", String(kind.toString())); + entry->add("value", std::to_string(value)); + units->add(std::move(entry)); + } + node.add("interval", std::move(units)); + + return true; + } + else if (const auto * assignment = dynamic_cast(&ast)) + { + node.add("column", assignment->column_name); + addNodeSlot(node, "expression", assignment->expression()); + + return true; + } + else if (const auto * del = dynamic_cast(&ast)) + { + addTableTarget(node, *del); + if (!del->cluster.empty()) + node.add("cluster", del->cluster); + addNodeSlot(node, "partition", del->partition); + addNodeSlot(node, "predicate", del->predicate); + + return true; + } + else if (const auto * update = dynamic_cast(&ast)) + { + addTableTarget(node, *update); + if (!update->cluster.empty()) + node.add("cluster", update->cluster); + if (update->assignments) + node.add("assignments", inlineExpressionList(update->assignments)); + addNodeSlot(node, "predicate", update->predicate); + addNodeSlot(node, "partition", update->partition); + + return true; + } + else if (const auto * drop = dynamic_cast(&ast)) + { + node.add("kind", String(dropKindToString(drop->kind))); + addTableTarget(node, *drop); + if (!drop->cluster.empty()) + node.add("cluster", drop->cluster); + if (drop->if_exists) + node.add("if_exists", true); + if (drop->if_empty) + node.add("if_empty", true); + if (drop->is_dictionary) + node.add("is_dictionary", true); + if (drop->is_view) + node.add("is_view", true); + if (drop->sync) + node.add("sync", true); + if (drop->permanently) + node.add("permanently", true); + if (drop->has_all) + node.add("has_all", true); + if (drop->has_tables) + node.add("has_tables", true); + if (!drop->like.empty()) + { + node.add("like", drop->like); + if (drop->not_like) + node.add("not_like", true); + if (drop->case_insensitive_like) + node.add("case_insensitive_like", true); + } + addNodeSlot(node, "database_and_tables", drop->database_and_tables); + + return true; + } + else if (const auto * optimize = dynamic_cast(&ast)) + { + addTableTarget(node, *optimize); + if (!optimize->cluster.empty()) + node.add("cluster", optimize->cluster); + addNodeSlot(node, "partition", optimize->partition); + if (optimize->final) + node.add("final", true); + if (optimize->deduplicate) + node.add("deduplicate", true); + addNodeSlot(node, "deduplicate_by_columns", optimize->deduplicate_by_columns); + if (optimize->cleanup) + node.add("cleanup", true); + + return true; + } + else if (const auto * alter = dynamic_cast(&ast)) + { + if (alter->alter_object != ASTAlterQuery::AlterObjectType::UNKNOWN) + node.add("alter_object", String(alterObjectTypeToString(alter->alter_object))); + addTableTarget(node, *alter); + if (!alter->cluster.empty()) + node.add("cluster", alter->cluster); + if (alter->command_list) + node.add("commands", inlineExpressionList(alter->command_list)); + + return true; + } + else if (const auto * command = dynamic_cast(&ast)) + { + node.add("command_type", String(alterCommandTypeToString(command->type))); + + if (command->detach) + node.add("detach", true); + if (command->part) + node.add("part", true); + if (command->clear_column) + node.add("clear_column", true); + if (command->clear_index) + node.add("clear_index", true); + if (command->clear_statistics) + node.add("clear_statistics", true); + if (command->clear_projection) + node.add("clear_projection", true); + if (command->if_not_exists) + node.add("if_not_exists", true); + if (command->if_exists) + node.add("if_exists", true); + if (command->first) + node.add("first", true); + + addNodeSlot(node, "column_declaration", command->col_decl); + addNodeSlot(node, "column", command->column); + addNodeSlot(node, "order_by", command->order_by); + addNodeSlot(node, "sample_by", command->sample_by); + addNodeSlot(node, "index_declaration", command->index_decl); + addNodeSlot(node, "index", command->index); + addNodeSlot(node, "constraint_declaration", command->constraint_decl); + addNodeSlot(node, "constraint", command->constraint); + addNodeSlot(node, "projection_declaration", command->projection_decl); + addNodeSlot(node, "projection", command->projection); + addNodeSlot(node, "statistics_declaration", command->statistics_decl); + addNodeSlot(node, "partition", command->partition); + addNodeSlot(node, "predicate", command->predicate); + if (command->update_assignments) + node.add("assignments", inlineExpressionList(command->update_assignments)); + addNodeSlot(node, "comment", command->comment); + addNodeSlot(node, "ttl", command->ttl); + addNodeSlot(node, "settings_changes", command->settings_changes); + addNodeSlot(node, "settings_resets", command->settings_resets); + addNodeSlot(node, "select", command->select); + addNodeSlot(node, "sql_security", command->sql_security); + addNodeSlot(node, "rename_to", command->rename_to); + addNodeSlot(node, "refresh", command->refresh); + + /// move_destination_type is only initialized for MOVE PARTITION/PART. + if (command->type == ASTAlterCommand::MOVE_PARTITION) + node.add("move_destination_type", String(dataDestinationTypeToString(command->move_destination_type))); + if (!command->move_destination_name.empty()) + node.add("move_destination_name", command->move_destination_name); + if (!command->from.empty()) + node.add("from", command->from); + if (!command->with_name.empty()) + node.add("with_name", command->with_name); + /// Distinguishes REPLACE PARTITION ... FROM (true) from ATTACH PARTITION ... FROM (false). + if (command->type == ASTAlterCommand::REPLACE_PARTITION) + node.add("replace", command->replace); + if (!command->from_database.empty()) + node.add("from_database", command->from_database); + if (!command->from_table.empty()) + node.add("from_table", command->from_table); + if (!command->to_database.empty()) + node.add("to_database", command->to_database); + if (!command->to_table.empty()) + node.add("to_table", command->to_table); + /// snapshot_name / snapshot_desc are only initialized for UNLOCK SNAPSHOT. + if (command->type == ASTAlterCommand::UNLOCK_SNAPSHOT) + { + if (!command->snapshot_name.empty()) + node.add("snapshot_name", command->snapshot_name); + addNodeSlot(node, "snapshot_desc", command->snapshot_desc); + } + if (!command->remove_property.empty()) + node.add("remove_property", command->remove_property); + + return true; + } + else if (const auto * create_function = dynamic_cast(&ast)) + { + if (create_function->or_replace) + node.add("or_replace", true); + if (create_function->if_not_exists) + node.add("if_not_exists", true); + if (!create_function->cluster.empty()) + node.add("cluster", create_function->cluster); + addNodeSlot(node, "function_name", create_function->function_name); + addNodeSlot(node, "function_core", create_function->function_core); + + return true; + } + else if (const auto * drop_function = dynamic_cast(&ast)) + { + /// `function_name` / `cluster` are plain strings here (not child nodes), + /// so without this branch the node would expose nothing but its `type`. + node.add("function_name", drop_function->function_name); + if (drop_function->if_exists) + node.add("if_exists", true); + if (!drop_function->cluster.empty()) + node.add("cluster", drop_function->cluster); + + return true; + } + else if (const auto * create_named_collection = dynamic_cast(&ast)) + { + /// CREATE NAMED COLLECTION. Everything lives in plain members (the node + /// has no `children`), so without this branch the JSON would expose + /// only its `type`. + node.add("collection_name", create_named_collection->collection_name); + if (create_named_collection->if_not_exists) + node.add("if_not_exists", true); + if (!create_named_collection->cluster.empty()) + node.add("cluster", create_named_collection->cluster); + + /// The `key = value` body as a name -> value object. Unlike the + /// `Settings` node (whose values are untyped strings), named-collection + /// values are emitted as typed `{ "value_type", "value" }` pairs, just + /// like an `ASTLiteral`. Per-key OVERRIDABLE / NOT OVERRIDABLE flags, when + /// present, are surfaced separately under `overridability`. + if (!create_named_collection->changes.empty()) + { + auto changes = std::make_unique(); + for (const auto & change : create_named_collection->changes) + changes->add(change.name, fieldToTypedJSON(change.value)); + node.add("changes", std::move(changes)); + } + if (!create_named_collection->overridability.empty()) + { + auto overridability = std::make_unique(); + for (const auto & [key, value] : create_named_collection->overridability) + overridability->add(key, value); + node.add("overridability", std::move(overridability)); + } + + return true; + } + else if (const auto * create_workload = dynamic_cast(&ast)) + { + /// CREATE WORKLOAD. The name / parent identifiers live in `children`, + /// but the SETTINGS changes (each with an optional `FOR resource`) are + /// kept in a plain member, so handle the whole node explicitly. + if (create_workload->or_replace) + node.add("or_replace", true); + if (create_workload->if_not_exists) + node.add("if_not_exists", true); + if (!create_workload->cluster.empty()) + node.add("cluster", create_workload->cluster); + addNodeSlot(node, "workload_name", create_workload->workload_name); + addNodeSlot(node, "workload_parent", create_workload->workload_parent); + + if (!create_workload->changes.empty()) + { + auto changes = std::make_unique(); + for (const auto & change : create_workload->changes) + { + auto item = std::make_unique(); + item->add("name", change.name); + item->add("value", fieldToTypedJSON(change.value)); + if (!change.resource.empty()) + item->add("resource", change.resource); + changes->add(std::move(item)); + } + node.add("changes", std::move(changes)); + } + + return true; + } + else if (const auto * create_resource = dynamic_cast(&ast)) + { + /// CREATE RESOURCE. The name identifier is in `children`, but the + /// operation list and cost unit are plain members. + if (create_resource->or_replace) + node.add("or_replace", true); + if (create_resource->if_not_exists) + node.add("if_not_exists", true); + if (!create_resource->cluster.empty()) + node.add("cluster", create_resource->cluster); + addNodeSlot(node, "resource_name", create_resource->resource_name); + node.add("unit", String(costUnitToString(create_resource->unit))); + + auto operations = std::make_unique(); + for (const auto & operation : create_resource->operations) + { + auto item = std::make_unique(); + item->add("mode", String(resourceAccessModeToString(operation.mode))); + /// Absent `disk` means the operation applies to ALL disks. + if (operation.disk) + item->add("disk", *operation.disk); + operations->add(std::move(item)); + } + node.add("operations", std::move(operations)); + + return true; + } + else if (const auto * drop_named_collection = dynamic_cast(&ast)) + { + /// DROP NAMED COLLECTION. `collection_name` / `cluster` are plain + /// strings (not child nodes), so without this branch the node would + /// expose nothing but its `type`. + node.add("collection_name", drop_named_collection->collection_name); + if (drop_named_collection->if_exists) + node.add("if_exists", true); + if (!drop_named_collection->cluster.empty()) + node.add("cluster", drop_named_collection->cluster); + + return true; + } + else if (const auto * drop_workload = dynamic_cast(&ast)) + { + /// DROP WORKLOAD. `workload_name` / `cluster` are plain strings (not + /// child nodes), so without this branch the node would expose nothing + /// but its `type`. + node.add("workload_name", drop_workload->workload_name); + if (drop_workload->if_exists) + node.add("if_exists", true); + if (!drop_workload->cluster.empty()) + node.add("cluster", drop_workload->cluster); + + return true; + } + else if (const auto * drop_resource = dynamic_cast(&ast)) + { + /// DROP RESOURCE. `resource_name` / `cluster` are plain strings (not + /// child nodes), so without this branch the node would expose nothing + /// but its `type`. + node.add("resource_name", drop_resource->resource_name); + if (drop_resource->if_exists) + node.add("if_exists", true); + if (!drop_resource->cluster.empty()) + node.add("cluster", drop_resource->cluster); + + return true; + } + else if (const auto * backup = dynamic_cast(&ast)) + { + /// BACKUP / RESTORE. The subject of the operation lives in `elements` + /// (plain structs, not child nodes), so without this branch the JSON + /// would expose only the destination function from `children`. + node.add("kind", String(backupKindToString(backup->kind))); + if (!backup->cluster.empty()) + node.add("cluster", backup->cluster); + + auto elements = std::make_unique(); + for (const auto & element : backup->elements) + { + auto entry = std::make_unique(); + entry->add("element_type", String(backupElementTypeToString(element.type))); + + if (!element.database_name.empty()) + entry->add("database", element.database_name); + if (!element.table_name.empty()) + entry->add("table", element.table_name); + + /// `new_*` mirror the original names unless an `AS` clause renamed + /// the object; only surface them when they actually differ. + if (element.new_database_name != element.database_name) + entry->add("new_database", element.new_database_name); + if (element.new_table_name != element.table_name) + entry->add("new_table", element.new_table_name); + + if (element.partitions) + { + auto partitions = std::make_unique(); + for (const auto & partition_ast : *element.partitions) + partitions->add(formatASTAsJSON(*partition_ast)); + entry->add("partitions", std::move(partitions)); + } + + if (!element.except_tables.empty()) + { + auto except_tables = std::make_unique(); + for (const auto & [db, tbl] : element.except_tables) + { + auto except_table = std::make_unique(); + if (!db.empty()) + except_table->add("database", db); + except_table->add("table", tbl); + except_tables->add(std::move(except_table)); + } + entry->add("except_tables", std::move(except_tables)); + } + + if (!element.except_databases.empty()) + { + auto except_databases = std::make_unique(); + for (const auto & db : element.except_databases) + except_databases->add(db); + entry->add("except_databases", std::move(except_databases)); + } + + elements->add(std::move(entry)); + } + node.add("elements", std::move(elements)); + + /// `TO` / `FROM` destination, the optional incremental base, and the + /// SETTINGS clause. `cluster_host_ids` is internal (populated only when + /// rewriting an ON CLUSTER query), so it is normally absent. + addNodeSlot(node, "backup_name", backup->backup_name); + addNodeSlot(node, "base_backup_name", backup->base_backup_name); + addNodeSlot(node, "settings", backup->settings); + addNodeSlot(node, "cluster_host_ids", backup->cluster_host_ids); + /// BACKUP/RESTORE derives from ASTQueryWithOutput, so it can carry a + /// trailing FORMAT / INTO OUTFILE clause. (The SYNC/ASYNC wait mode is + /// not a dedicated field — it is carried as the `async` setting inside + /// the `settings` object above.) + addOutfileAndFormat(node, *backup); + + return true; + } + else if (const auto * dictionary = dynamic_cast(&ast)) + { + if (dictionary->primary_key) + node.add("primary_key", inlineExpressionList(dictionary->primary_key)); + addNodeSlot(node, "source", dictionary->source); + addNodeSlot(node, "lifetime", dictionary->lifetime); + addNodeSlot(node, "layout", dictionary->layout); + addNodeSlot(node, "range", dictionary->range); + addNodeSlot(node, "settings", dictionary->dict_settings); + + return true; + } + else if (const auto * dict_layout = dynamic_cast(&ast)) + { + node.add("layout_type", dict_layout->layout_type); + if (dict_layout->parameters) + node.add("parameters", inlineExpressionList(dict_layout->parameters)); + + return true; + } + else if (const auto * dict_lifetime = dynamic_cast(&ast)) + { + node.add("min_sec", dict_lifetime->min_sec); + node.add("max_sec", dict_lifetime->max_sec); + + return true; + } + else if (const auto * dict_range = dynamic_cast(&ast)) + { + node.add("min_attr_name", dict_range->min_attr_name); + node.add("max_attr_name", dict_range->max_attr_name); + + return true; + } + else if (const auto * dict_settings = dynamic_cast(&ast)) + { + if (!dict_settings->changes.empty()) + { + auto changes = std::make_unique(); + for (const auto & change : dict_settings->changes) + changes->add(change.name, fieldToJSON(change.value)); + node.add("changes", std::move(changes)); + } + + return true; + } + else if (const auto * dict_attr = dynamic_cast(&ast)) + { + node.add("name", dict_attr->name); + addNodeSlot(node, "data_type", dict_attr->type); + addNodeSlot(node, "default_value", dict_attr->default_value); + addNodeSlot(node, "expression", dict_attr->expression); + if (dict_attr->hierarchical) + node.add("hierarchical", true); + if (dict_attr->bidirectional) + node.add("bidirectional", true); + if (dict_attr->injective) + node.add("injective", true); + if (dict_attr->is_object_id) + node.add("is_object_id", true); + + return true; + } + else if (const auto * kv = dynamic_cast(&ast)) + { + node.add("name", kv->name); + if (kv->elements) + node.add("elements", inlineExpressionList(kv->elements)); + + return true; + } + else if (const auto * pair = dynamic_cast(&ast)) + { + node.add("key", pair->first); + addNodeSlot(node, "value", pair->second); + + return true; + } + else if (const auto * view_targets = dynamic_cast(&ast)) + { + auto targets = std::make_unique(); + for (const auto & target : view_targets->targets) + { + auto entry = std::make_unique(); + entry->add("kind", String(toString(target.kind))); + if (!target.table_id.database_name.empty()) + entry->add("database", target.table_id.database_name); + if (!target.table_id.table_name.empty()) + entry->add("table", target.table_id.table_name); + addNodeSlot(*entry, "inner_engine", target.inner_engine); + addNodeSlot(*entry, "table_ast", target.table_ast); + targets->add(std::move(entry)); + } + node.add("targets", std::move(targets)); + + return true; + } + else if (const auto * explain = dynamic_cast(&ast)) + { + node.add("kind", ASTExplainQuery::toString(explain->getKind())); + addNodeSlot(node, "query", explain->getExplainedQuery()); + /// EXPLAIN-level settings: `EXPLAIN SETTINGS = ...` (ASTExplainQuery::ast_settings). + addNodeSlot(node, "settings", explain->getSettings()); + addNodeSlot(node, "table_function", explain->getTableFunction()); + addNodeSlot(node, "table_override", explain->getTableOverride()); + addOutfileAndFormat(node, *explain); + /// Trailing output-clause settings: `EXPLAIN ... FORMAT SETTINGS =` + /// (the ASTQueryWithOutput base `settings_ast`). This is distinct from the + /// EXPLAIN-level `settings` above, so it needs its own key. Every other + /// ASTQueryWithOutput node maps `settings_ast` onto "settings", but Explain + /// already uses that key for its EXPLAIN-level settings. + addNodeSlot(node, "output_settings", explain->settings_ast); + + return true; + } + else if (const auto * describe = dynamic_cast(&ast)) + { + addNodeSlot(node, "table_expression", describe->table_expression); + addNodeSlot(node, "settings", describe->settings_ast); + addOutfileAndFormat(node, *describe); + + return true; + } + else if (const auto * show_tables = dynamic_cast(&ast)) + { + /// SHOW TABLES / DATABASES / CLUSTERS / CLUSTER / DICTIONARIES / + /// SETTINGS / MERGES / FILESYSTEM CACHES all collapse onto this one + /// class; the flags below select which variant and carry its modifiers. + if (show_tables->databases) + node.add("databases", true); + if (show_tables->clusters) + node.add("clusters", true); + /// `cluster` (singular) is SHOW CLUSTER ; the name lives in the + /// plain `cluster_str` member, not in `children`. It is emitted as + /// `cluster_name` — `cluster` on other nodes is the ON CLUSTER string, + /// so reusing that key for the internal-style `_str` name would be + /// confusing. + if (show_tables->cluster) + node.add("cluster", true); + if (!show_tables->cluster_str.empty()) + node.add("cluster_name", show_tables->cluster_str); + if (show_tables->dictionaries) + node.add("dictionaries", true); + /// The `m_settings` member (SHOW SETTINGS); emitted as `show_settings` + /// so the internal `m_` prefix does not leak into the public format + /// (a bare `settings` would collide with the settings slot). + if (show_tables->m_settings) + node.add("show_settings", true); + if (show_tables->changed) + node.add("changed", true); + if (show_tables->merges) + node.add("merges", true); + if (show_tables->caches) + node.add("caches", true); + if (show_tables->temporary) + node.add("temporary", true); + if (show_tables->full) + node.add("full", true); + addNodeSlot(node, "from", show_tables->from); + if (!show_tables->like.empty()) + node.add("like", show_tables->like); + if (show_tables->not_like) + node.add("not_like", true); + /// LIKE vs ILIKE. + if (show_tables->case_insensitive_like) + node.add("case_insensitive_like", true); + /// The WHERE filter and LIMIT (both plain child ASTs) are only used by + /// the SHOW TABLES / DICTIONARIES variant, but surface them whenever set. + addNodeSlot(node, "where", show_tables->where_expression); + addNodeSlot(node, "limit", show_tables->limit_length); + addNodeSlot(node, "settings", show_tables->settings_ast); + addOutfileAndFormat(node, *show_tables); + + return true; + } + else if (const auto * show_columns = dynamic_cast(&ast)) + { + /// SHOW [EXTENDED] [FULL] COLUMNS/FIELDS FROM
[FROM ] + /// [(NOT) (I)LIKE | WHERE ] [LIMIT ]. ClickHouse's + /// native AST keeps every operand in plain members (the `children` + /// array is empty), so without this branch the JSON would collapse to + /// bare {"type":"ShowColumns"} and the table, filters and modifiers + /// would all be lost. + if (show_columns->extended) + node.add("extended", true); + if (show_columns->full) + node.add("full", true); + /// `table` is mandatory (the parser requires `FROM
`); `database` + /// is only present when the query named one (via `db.table` or a second + /// `FROM `). + node.add("table", show_columns->table); + if (!show_columns->database.empty()) + node.add("database", show_columns->database); + if (!show_columns->like.empty()) + { + node.add("like", show_columns->like); + if (show_columns->not_like) + node.add("not_like", true); + /// LIKE vs ILIKE. + if (show_columns->case_insensitive_like) + node.add("case_insensitive_like", true); + } + /// WHERE and LIKE are mutually exclusive in the grammar, but both are + /// plain child ASTs; surface each whenever set. + addNodeSlot(node, "where", show_columns->where_expression); + addNodeSlot(node, "limit", show_columns->limit_length); + addNodeSlot(node, "settings", show_columns->settings_ast); + addOutfileAndFormat(node, *show_columns); + + return true; + } + else if (const auto * show_setting = dynamic_cast(&ast)) + { + /// SHOW SETTING . The setting name is the sole operand and lives + /// in a private member, so without this branch the JSON would collapse + /// to bare {"type":"ShowSetting"} and the name would be lost. + node.add("setting_name", show_setting->getSettingName()); + addNodeSlot(node, "settings", show_setting->settings_ast); + addOutfileAndFormat(node, *show_setting); + + return true; + } + else if (const auto * show_functions = dynamic_cast(&ast)) + { + /// SHOW FUNCTIONS [(I)LIKE ]. The pattern is the only operand + /// and lives in a plain member (empty `children`), so without this + /// branch the JSON would collapse to bare {"type":"ShowFunctions"} and + /// the LIKE / ILIKE filter would be lost. + if (!show_functions->like.empty()) + { + node.add("like", show_functions->like); + /// LIKE vs ILIKE. + if (show_functions->case_insensitive_like) + node.add("case_insensitive_like", true); + } + addNodeSlot(node, "settings", show_functions->settings_ast); + addOutfileAndFormat(node, *show_functions); + + return true; + } + else if (const auto * show_indexes = dynamic_cast(&ast)) + { + /// SHOW [EXTENDED] INDEX/INDEXES/INDICES/KEYS FROM
[FROM ] + /// [WHERE ]. A distinct class from ASTShowColumnsQuery that keeps + /// every operand in plain members (empty `children`), so without this + /// branch the JSON would collapse to bare {"type":"ShowIndexes"} and + /// the table, database and WHERE filter would be lost. (Its `type` is + /// disambiguated from ShowColumns in astTypeName — see below.) + if (show_indexes->extended) + node.add("extended", true); + /// `table` is mandatory (the parser requires `FROM
`); `database` + /// is only present when named (via `db.table` or a second `FROM `). + node.add("table", show_indexes->table); + if (!show_indexes->database.empty()) + node.add("database", show_indexes->database); + addNodeSlot(node, "where", show_indexes->where_expression); + addNodeSlot(node, "settings", show_indexes->settings_ast); + addOutfileAndFormat(node, *show_indexes); + + return true; + } + else if (const auto * create_index = dynamic_cast(&ast)) + { + addTableTarget(node, *create_index); + if (!create_index->cluster.empty()) + node.add("cluster", create_index->cluster); + if (create_index->if_not_exists) + node.add("if_not_exists", true); + if (create_index->unique) + node.add("unique", true); + addNodeSlot(node, "index_name", create_index->index_name); + addNodeSlot(node, "index_declaration", create_index->index_decl); + + return true; + } + else if (const auto * drop_index = dynamic_cast(&ast)) + { + addTableTarget(node, *drop_index); + if (!drop_index->cluster.empty()) + node.add("cluster", drop_index->cluster); + if (drop_index->if_exists) + node.add("if_exists", true); + addNodeSlot(node, "index_name", drop_index->index_name); + + return true; + } + else if (const auto * check = dynamic_cast(&ast)) + { + addTableTarget(node, *check); + addNodeSlot(node, "partition", check->partition); + if (!check->part_name.empty()) + node.add("part_name", check->part_name); + + return true; + } + else if (const auto * use = dynamic_cast(&ast)) + { + addNodeSlot(node, "database", use->database); + + return true; + } + else if (const auto * kill = dynamic_cast(&ast)) + { + node.add("kill_type", String(killTypeToString(kill->type))); + if (kill->sync) + node.add("sync", true); + if (kill->test) + node.add("test", true); + if (!kill->cluster.empty()) + node.add("cluster", kill->cluster); + addNodeSlot(node, "where", kill->where_expression); + addNodeSlot(node, "settings", kill->settings_ast); + addOutfileAndFormat(node, *kill); + + return true; + } + else if (const auto * rename = dynamic_cast(&ast)) + { + if (rename->exchange) + node.add("exchange", true); + if (rename->database) + node.add("database", true); + if (rename->dictionary) + node.add("dictionary", true); + if (!rename->cluster.empty()) + node.add("cluster", rename->cluster); + + auto elements = std::make_unique(); + for (const auto & element : rename->getElements()) + { + auto entry = std::make_unique(); + if (!element.from.getDatabase().empty()) + entry->add("from_database", element.from.getDatabase()); + if (!element.from.getTable().empty()) + entry->add("from_table", element.from.getTable()); + if (!element.to.getDatabase().empty()) + entry->add("to_database", element.to.getDatabase()); + if (!element.to.getTable().empty()) + entry->add("to_table", element.to.getTable()); + if (element.if_exists) + entry->add("if_exists", true); + elements->add(std::move(entry)); + } + node.add("elements", std::move(elements)); + addNodeSlot(node, "settings", rename->settings_ast); + + return true; + } + else if (const auto * system = dynamic_cast(&ast)) + { + /// SYSTEM covers ~130 sub-commands; the operand fields below are each + /// only meaningful for a subset, but they default to empty/zero and are + /// surfaced whenever populated so every variant round-trips. + node.add("system_type", String(ASTSystemQuery::typeToString(system->type))); + addNodeSlot(node, "database", system->database); + addNodeSlot(node, "table", system->table); + if (system->if_exists) + node.add("if_exists", true); + if (!system->cluster.empty()) + node.add("cluster", system->cluster); + if (!system->replica.empty()) + node.add("replica", system->replica); + if (!system->shard.empty()) + node.add("shard", system->shard); + if (!system->replica_zk_path.empty()) + node.add("replica_zk_path", system->replica_zk_path); + if (system->is_drop_whole_replica) + node.add("is_drop_whole_replica", true); + if (system->with_tables) + node.add("with_tables", true); + if (!system->target_model.empty()) + node.add("target_model", system->target_model); + if (!system->target_function.empty()) + node.add("target_function", system->target_function); + if (!system->storage_policy.empty()) + node.add("storage_policy", system->storage_policy); + if (!system->volume.empty()) + node.add("volume", system->volume); + if (!system->disk.empty()) + node.add("disk", system->disk); + /// Stringified like the other 64-bit scalars (precision-safe for JS consumers). + if (system->seconds) + node.add("seconds", std::to_string(system->seconds)); + /// SYNC REPLICA ... {STRICT|LIGHTWEIGHT|PULL} plus the optional + /// LIGHTWEIGHT FROM source list. + if (system->sync_replica_mode != SyncReplicaMode::DEFAULT) + node.add("sync_replica_mode", String(syncReplicaModeToString(system->sync_replica_mode))); + addStringList(node, "src_replicas", system->src_replicas); + /// FLUSH LOGS / FLUSH ASYNC INSERT QUEUE target list (`db.table` pairs). + if (!system->tables.empty()) + { + auto tables = std::make_unique(); + for (const auto & [db, tbl] : system->tables) + { + auto item = std::make_unique(); + if (!db.empty()) + item->add("database", db); + item->add("table", tbl); + tables->add(std::move(item)); + } + node.add("tables", std::move(tables)); + } + addNodeSlot(node, "settings", system->query_settings); + if (!system->schema_cache_storage.empty()) + node.add("schema_cache_storage", system->schema_cache_storage); + if (!system->schema_cache_format.empty()) + node.add("schema_cache_format", system->schema_cache_format); + if (!system->filesystem_cache_name.empty()) + node.add("filesystem_cache_name", system->filesystem_cache_name); + if (!system->key_to_drop.empty()) + node.add("key_to_drop", system->key_to_drop); + if (system->offset_to_drop.has_value()) + node.add("offset_to_drop", std::to_string(*system->offset_to_drop)); + if (system->distributed_cache_drop_connections) + node.add("distributed_cache_drop_connections", true); + if (!system->distributed_cache_server_id.empty()) + node.add("distributed_cache_server_id", system->distributed_cache_server_id); + if (system->query_result_cache_tag.has_value()) + node.add("query_result_cache_tag", *system->query_result_cache_tag); + if (!system->backup_name.empty()) + node.add("backup_name", system->backup_name); + addNodeSlot(node, "backup_source", system->backup_source); + if (!system->fail_point_name.empty()) + node.add("fail_point_name", system->fail_point_name); + if (system->fail_point_action != ASTSystemQuery::FailPointAction::UNSPECIFIED) + node.add("fail_point_action", String(failPointActionToString(system->fail_point_action))); + /// SYSTEM TEST VIEW ... SET/UNSET FAKE TIME: absent value means UNSET. + if (system->fake_time_for_view.has_value()) + node.add("fake_time_for_view", std::to_string(*system->fake_time_for_view)); + /// START/STOP LISTEN [EXCEPT ...]. `server_type.type` is + /// only initialised for these two commands, so guard the access. + if (system->type == ASTSystemQuery::Type::START_LISTEN + || system->type == ASTSystemQuery::Type::STOP_LISTEN) + { + auto server_type = std::make_unique(); + server_type->add("type", String(ServerType::serverTypeToString(system->server_type.type))); + if (!system->server_type.custom_name.empty()) + server_type->add("custom_name", system->server_type.custom_name); + if (!system->server_type.exclude_types.empty()) + { + auto exclude_types = std::make_unique(); + for (auto excluded : system->server_type.exclude_types) + exclude_types->add(String(ServerType::serverTypeToString(excluded))); + server_type->add("exclude_types", std::move(exclude_types)); + } + if (!system->server_type.exclude_custom_names.empty()) + { + auto exclude_custom_names = std::make_unique(); + for (const auto & excluded : system->server_type.exclude_custom_names) + exclude_custom_names->add(excluded); + server_type->add("exclude_custom_names", std::move(exclude_custom_names)); + } + node.add("server_type", std::move(server_type)); + } + + /// NOTE: the SYSTEM INSTRUMENT ADD/REMOVE operands are compiled only + /// under USE_XRAY and are intentionally not serialized here. + + return true; + } + else if (const auto * statistics = dynamic_cast(&ast)) + { + addNodeSlot(node, "columns", statistics->columns); + addNodeSlot(node, "types", statistics->types); + + return true; + } + else if (const auto * storage_order_by = dynamic_cast(&ast)) + { + if (!storage_order_by->children.empty()) + node.add("expression", formatASTAsJSON(*storage_order_by->children.front())); + node.add("direction", String(storage_order_by->direction >= 0 ? "ASC" : "DESC")); + + return true; + } + else if (const auto * name_type = dynamic_cast(&ast)) + { + node.add("name", name_type->name); + addNodeSlot(node, "data_type", name_type->type); + + return true; + } + else if (const auto * q_regexp = dynamic_cast(&ast)) + { + node.add("pattern", q_regexp->getPattern()); + addNodeSlot(node, "qualifier", q_regexp->qualifier); + addNodeSlot(node, "transformers", q_regexp->transformers); + + return true; + } + else if (const auto * q_list = dynamic_cast(&ast)) + { + addNodeSlot(node, "qualifier", q_list->qualifier); + if (q_list->column_list) + node.add("columns", inlineExpressionList(q_list->column_list)); + addNodeSlot(node, "transformers", q_list->transformers); + + return true; + } + else if (const auto * undrop = dynamic_cast(&ast)) + { + addTableTarget(node, *undrop); + if (!undrop->cluster.empty()) + node.add("cluster", undrop->cluster); + + return true; + } + else if (const auto * grant = dynamic_cast(&ast)) + { + if (grant->attach_mode) + node.add("attach_mode", true); + if (grant->admin_option) + node.add("admin_option", true); + if (grant->current_grants) + node.add("current_grants", true); + if (grant->replace_access) + node.add("replace_access", true); + if (grant->replace_granted_roles) + node.add("replace_granted_roles", true); + if (!grant->cluster.empty()) + node.add("cluster", grant->cluster); + + /// Role-grant (GRANT role TO ...) uses `roles`; privilege-grant uses the + /// AccessRightsElements value vector. They are mutually exclusive. + if (grant->roles) + addNodeSlot(node, "roles", grant->roles.get()); + else + node.add("access_rights", serializeAccessElements(grant->access_rights_elements)); + + addNodeSlot(node, "grantees", grant->grantees.get()); + + return true; + } + else if (const auto * check_grant = dynamic_cast(&ast)) + { + node.add("access_rights", serializeAccessElements(check_grant->access_rights_elements)); + + return true; + } + else if (const auto * create_user = dynamic_cast(&ast)) + { + if (create_user->alter) + node.add("alter", true); + if (create_user->attach) + node.add("attach", true); + if (create_user->if_exists) + node.add("if_exists", true); + if (create_user->if_not_exists) + node.add("if_not_exists", true); + if (create_user->or_replace) + node.add("or_replace", true); + if (!create_user->cluster.empty()) + node.add("cluster", create_user->cluster); + + addNodeSlot(node, "names", create_user->names.get()); + if (create_user->new_name) + node.add("new_name", *create_user->new_name); + if (!create_user->storage_name.empty()) + node.add("storage_name", create_user->storage_name); + + if (!create_user->authentication_methods.empty()) + { + auto methods = std::make_unique(); + for (const auto & method : create_user->authentication_methods) + methods->add(formatASTAsJSON(*method)); + node.add("authentication_methods", std::move(methods)); + } + if (create_user->reset_authentication_methods_to_new) + node.add("reset_authentication_methods_to_new", true); + if (create_user->add_identified_with) + node.add("add_identified_with", true); + if (create_user->replace_authentication_methods) + node.add("replace_authentication_methods", true); + + if (create_user->hosts) + node.add("hosts", serializeAllowedHosts(*create_user->hosts)); + if (create_user->add_hosts) + node.add("add_hosts", serializeAllowedHosts(*create_user->add_hosts)); + if (create_user->remove_hosts) + node.add("remove_hosts", serializeAllowedHosts(*create_user->remove_hosts)); + + addNodeSlot(node, "default_roles", create_user->default_roles.get()); + addNodeSlot(node, "default_database", create_user->default_database.get()); + addNodeSlot(node, "settings", create_user->settings.get()); + addNodeSlot(node, "alter_settings", create_user->alter_settings.get()); + addNodeSlot(node, "grantees", create_user->grantees.get()); + addNodeSlot(node, "global_valid_until", create_user->global_valid_until); + + return true; + } + else if (const auto * create_role = dynamic_cast(&ast)) + { + if (create_role->alter) + node.add("alter", true); + if (create_role->attach) + node.add("attach", true); + if (create_role->if_exists) + node.add("if_exists", true); + if (create_role->if_not_exists) + node.add("if_not_exists", true); + if (create_role->or_replace) + node.add("or_replace", true); + if (!create_role->cluster.empty()) + node.add("cluster", create_role->cluster); + + addStringList(node, "names", create_role->names); + if (!create_role->new_name.empty()) + node.add("new_name", create_role->new_name); + if (!create_role->storage_name.empty()) + node.add("storage_name", create_role->storage_name); + + addNodeSlot(node, "settings", create_role->settings.get()); + addNodeSlot(node, "alter_settings", create_role->alter_settings.get()); + + return true; + } + else if (const auto * create_quota = dynamic_cast(&ast)) + { + if (create_quota->alter) + node.add("alter", true); + if (create_quota->attach) + node.add("attach", true); + if (create_quota->if_exists) + node.add("if_exists", true); + if (create_quota->if_not_exists) + node.add("if_not_exists", true); + if (create_quota->or_replace) + node.add("or_replace", true); + if (!create_quota->cluster.empty()) + node.add("cluster", create_quota->cluster); + + addStringList(node, "names", create_quota->names); + if (!create_quota->new_name.empty()) + node.add("new_name", create_quota->new_name); + if (create_quota->key_type) + node.add("key_type", toString(*create_quota->key_type)); + if (!create_quota->storage_name.empty()) + node.add("storage_name", create_quota->storage_name); + + if (!create_quota->all_limits.empty()) + { + auto limits_array = std::make_unique(); + for (const auto & limits : create_quota->all_limits) + { + auto limits_item = std::make_unique(); + limits_item->add("duration_sec", std::to_string(limits.duration.count())); + if (limits.randomize_interval) + limits_item->add("randomize_interval", true); + if (limits.drop) + limits_item->add("drop", true); + + auto max_map = std::make_unique(); + bool has_max = false; + for (size_t i = 0; i < static_cast(QuotaType::MAX); ++i) + { + if (limits.max[i]) + { + max_map->add(toString(static_cast(i)), std::to_string(*limits.max[i])); + has_max = true; + } + } + if (has_max) + limits_item->add("max", std::move(max_map)); + + limits_array->add(std::move(limits_item)); + } + node.add("limits", std::move(limits_array)); + } + + addNodeSlot(node, "roles", create_quota->roles.get()); + + return true; + } + else if (const auto * set_role = dynamic_cast(&ast)) + { + node.add("kind", String(setRoleKindToString(set_role->kind))); + addNodeSlot(node, "roles", set_role->roles.get()); + addNodeSlot(node, "to_users", set_role->to_users.get()); + + return true; + } + else if (const auto * row_policy = dynamic_cast(&ast)) + { + if (row_policy->alter) + node.add("alter", true); + if (row_policy->attach) + node.add("attach", true); + if (row_policy->if_exists) + node.add("if_exists", true); + if (row_policy->if_not_exists) + node.add("if_not_exists", true); + if (row_policy->or_replace) + node.add("or_replace", true); + if (!row_policy->cluster.empty()) + node.add("cluster", row_policy->cluster); + if (!row_policy->storage_name.empty()) + node.add("storage_name", row_policy->storage_name); + + addNodeSlot(node, "names", row_policy->names.get()); + if (!row_policy->new_short_name.empty()) + node.add("new_short_name", row_policy->new_short_name); + if (row_policy->is_restrictive) + node.add("is_restrictive", *row_policy->is_restrictive); + + if (!row_policy->filters.empty()) + { + auto filters = std::make_unique(); + for (const auto & [filter_type, condition] : row_policy->filters) + { + auto filter_item = std::make_unique(); + filter_item->add("filter_type", toString(filter_type)); + /// `nullptr` condition means the filter was set to NONE. + if (condition) + filter_item->add("condition", formatASTAsJSON(*condition)); + filters->add(std::move(filter_item)); + } + node.add("filters", std::move(filters)); + } + + addNodeSlot(node, "roles", row_policy->roles.get()); + + return true; + } + else if (const auto * profile = dynamic_cast(&ast)) + { + if (profile->alter) + node.add("alter", true); + if (profile->attach) + node.add("attach", true); + if (profile->if_exists) + node.add("if_exists", true); + if (profile->if_not_exists) + node.add("if_not_exists", true); + if (profile->or_replace) + node.add("or_replace", true); + if (!profile->cluster.empty()) + node.add("cluster", profile->cluster); + if (!profile->storage_name.empty()) + node.add("storage_name", profile->storage_name); + + addStringList(node, "names", profile->names); + if (!profile->new_name.empty()) + node.add("new_name", profile->new_name); + + addNodeSlot(node, "settings", profile->settings.get()); + addNodeSlot(node, "alter_settings", profile->alter_settings.get()); + addNodeSlot(node, "to_roles", profile->to_roles.get()); + + return true; + } + else if (const auto * masking = dynamic_cast(&ast)) + { + if (masking->alter) + node.add("alter", true); + if (masking->attach) + node.add("attach", true); + if (masking->if_exists) + node.add("if_exists", true); + if (masking->if_not_exists) + node.add("if_not_exists", true); + if (masking->or_replace) + node.add("or_replace", true); + if (!masking->cluster.empty()) + node.add("cluster", masking->cluster); + if (!masking->storage_name.empty()) + node.add("storage_name", masking->storage_name); + + if (!masking->name.empty()) + node.add("name", masking->name); + if (!masking->database.empty()) + node.add("database", masking->database); + if (!masking->table_name.empty()) + node.add("table", masking->table_name); + if (!masking->new_name.empty()) + node.add("new_name", masking->new_name); + + if (masking->update_assignments) + node.add("update_assignments", inlineExpressionList(masking->update_assignments)); + addNodeSlot(node, "where_condition", masking->where_condition); + addNodeSlot(node, "roles", masking->roles.get()); + if (masking->priority != 0) + node.add("priority", std::to_string(masking->priority)); + + return true; + } + else if (const auto * drop_access = dynamic_cast(&ast)) + { + node.add("entity_type", toString(drop_access->type)); + if (drop_access->if_exists) + node.add("if_exists", true); + if (!drop_access->cluster.empty()) + node.add("cluster", drop_access->cluster); + if (!drop_access->storage_name.empty()) + node.add("storage_name", drop_access->storage_name); + addStringList(node, "names", drop_access->names); + addNodeSlot(node, "row_policy_names", drop_access->row_policy_names.get()); + /// DROP MASKING POLICY carries its target in a dedicated struct (the + /// `short_name ON db.table` triple), not in `names`. + if (drop_access->masking_policy_name) + { + auto masking_name = std::make_unique(); + masking_name->add("short_name", drop_access->masking_policy_name->short_name); + if (!drop_access->masking_policy_name->database.empty()) + masking_name->add("database", drop_access->masking_policy_name->database); + masking_name->add("table", drop_access->masking_policy_name->table_name); + node.add("masking_policy_name", std::move(masking_name)); + } + + return true; + } + else if (const auto * move_access = dynamic_cast(&ast)) + { + node.add("entity_type", toString(move_access->type)); + if (!move_access->cluster.empty()) + node.add("cluster", move_access->cluster); + if (!move_access->storage_name.empty()) + node.add("storage_name", move_access->storage_name); + addStringList(node, "names", move_access->names); + addNodeSlot(node, "row_policy_names", move_access->row_policy_names.get()); + + return true; + } + else if (const auto * execute_as = dynamic_cast(&ast)) + { + addNodeSlot(node, "target_user", execute_as->target_user); + addNodeSlot(node, "subquery", execute_as->subquery); + + return true; + } + else if (const auto * show_grants = dynamic_cast(&ast)) + { + addNodeSlot(node, "for_roles", show_grants->for_roles.get()); + if (show_grants->with_implicit) + node.add("with_implicit", true); + if (show_grants->final) + node.add("final", true); + addNodeSlot(node, "settings", show_grants->settings_ast); + addOutfileAndFormat(node, *show_grants); + + return true; + } + else if (const auto * show_create_access = dynamic_cast(&ast)) + { + node.add("entity_type", toString(show_create_access->type)); + addStringList(node, "names", show_create_access->names); + addNodeSlot(node, "row_policy_names", show_create_access->row_policy_names.get()); + if (show_create_access->current_quota) + node.add("current_quota", true); + if (show_create_access->current_user) + node.add("current_user", true); + if (show_create_access->all) + node.add("all", true); + if (!show_create_access->short_name.empty()) + node.add("short_name", show_create_access->short_name); + if (show_create_access->database_and_table_name) + { + node.add("database", show_create_access->database_and_table_name->first); + node.add("table", show_create_access->database_and_table_name->second); + } + addNodeSlot(node, "settings", show_create_access->settings_ast); + addOutfileAndFormat(node, *show_create_access); + + return true; + } + else if (const auto * show_access = dynamic_cast(&ast)) + { + node.add("entity_type", toString(show_access->type)); + if (show_access->all) + node.add("all", true); + if (show_access->current_quota) + node.add("current_quota", true); + if (show_access->current_roles) + node.add("current_roles", true); + if (show_access->enabled_roles) + node.add("enabled_roles", true); + if (!show_access->short_name.empty()) + node.add("short_name", show_access->short_name); + if (show_access->database_and_table_name) + { + node.add("database", show_access->database_and_table_name->first); + node.add("table", show_access->database_and_table_name->second); + } + + return true; + } + else if (const auto * roles_set = dynamic_cast(&ast)) + { + if (roles_set->all) + node.add("all", true); + if (roles_set->use_keyword_any) + node.add("use_keyword_any", true); + addStringList(node, "names", roles_set->names); + if (roles_set->current_user) + node.add("current_user", true); + addStringList(node, "except_names", roles_set->except_names); + if (roles_set->except_current_user) + node.add("except_current_user", true); + if (roles_set->id_mode) + node.add("id_mode", true); + + return true; + } + else if (const auto * user_names = dynamic_cast(&ast)) + { + auto users = std::make_unique(); + for (const auto & child : user_names->children) + users->add(formatASTAsJSON(*child)); + node.add("users", std::move(users)); + + return true; + } + else if (const auto * user_name = dynamic_cast(&ast)) + { + /// toString() is "name" or "name@host"; split off the host so each part + /// is exposed separately (host_pattern is "" / unset for the common case). + String full = user_name->toString(); + String host_pattern = user_name->getHostPattern(); + if (!host_pattern.empty() && full.size() > host_pattern.size() + 1) + node.add("name", full.substr(0, full.size() - host_pattern.size() - 1)); + else + node.add("name", full); + if (!host_pattern.empty()) + node.add("host_pattern", host_pattern); + + return true; + } + else if (const auto * auth = dynamic_cast(&ast)) + { + if (auth->type) + node.add("auth_type", toString(*auth->type)); + if (auth->contains_password) + node.add("contains_password", true); + if (auth->contains_hash) + node.add("contains_hash", true); + if (auth->ssl_cert_subject_type) + node.add("ssl_cert_subject_type", *auth->ssl_cert_subject_type); + /// valid_until is a separate member, not part of `children`. + addNodeSlot(node, "valid_until", auth->valid_until); + + /// Password / hash / salt / server / realm literals (verbatim). + auto args = std::make_unique(); + for (const auto & child : auth->children) + args->add(formatASTAsJSON(*child)); + node.add("arguments", std::move(args)); + + return true; + } + else if (const auto * profile_elements = dynamic_cast(&ast)) + { + auto elements = std::make_unique(); + for (const auto & element : profile_elements->elements) + elements->add(formatASTAsJSON(*element)); + node.add("elements", std::move(elements)); + + return true; + } + else if (const auto * profile_element = dynamic_cast(&ast)) + { + if (!profile_element->parent_profile.empty()) + node.add("parent_profile", profile_element->parent_profile); + if (!profile_element->setting_name.empty()) + node.add("setting_name", profile_element->setting_name); + if (profile_element->value) + node.add("value", fieldToJSON(*profile_element->value)); + if (profile_element->min_value) + node.add("min_value", fieldToJSON(*profile_element->min_value)); + if (profile_element->max_value) + node.add("max_value", fieldToJSON(*profile_element->max_value)); + if (!profile_element->disallowed_values.empty()) + { + auto disallowed = std::make_unique(); + for (const auto & value : profile_element->disallowed_values) + disallowed->add(fieldToJSON(value)); + node.add("disallowed_values", std::move(disallowed)); + } + if (profile_element->writability) + node.add("writability", String(settingWritabilityToString(*profile_element->writability))); + if (profile_element->id_mode) + node.add("id_mode", true); + + return true; + } + else if (const auto * alter_profile = dynamic_cast(&ast)) + { + addNodeSlot(node, "add_settings", alter_profile->add_settings.get()); + addNodeSlot(node, "modify_settings", alter_profile->modify_settings.get()); + addNodeSlot(node, "drop_settings", alter_profile->drop_settings.get()); + if (alter_profile->drop_all_settings) + node.add("drop_all_settings", true); + if (alter_profile->drop_all_profiles) + node.add("drop_all_profiles", true); + + return true; + } + else if (const auto * policy_names = dynamic_cast(&ast)) + { + auto policies = std::make_unique(); + for (const auto & full_name : policy_names->full_names) + { + auto item = std::make_unique(); + item->add("short_name", full_name.short_name); + if (!full_name.database.empty()) + item->add("database", full_name.database); + if (!full_name.table_name.empty()) + item->add("table", full_name.table_name); + policies->add(std::move(item)); + } + node.add("policies", std::move(policies)); + + return true; + } + else if (const auto * policy_name = dynamic_cast(&ast)) + { + node.add("short_name", policy_name->full_name.short_name); + if (!policy_name->full_name.database.empty()) + node.add("database", policy_name->full_name.database); + if (!policy_name->full_name.table_name.empty()) + node.add("table", policy_name->full_name.table_name); + + return true; + } + else if (const auto * database_or_none = dynamic_cast(&ast)) + { + if (database_or_none->none) + node.add("none", true); + else + node.add("database", database_or_none->database_name); + + return true; + } + else if (const auto * ssh_key = dynamic_cast(&ast)) + { + node.add("key_type", ssh_key->type); + node.add("key_base64", ssh_key->key_base64); + + return true; + } + else if (const auto * table_query = dynamic_cast(&ast)) + { + /// Generic fallback for the simple table-scoped statements that carry + /// nothing but a target (EXISTS, SHOW CREATE, ...). Must stay after + /// every richer ASTQueryWithTableAndOutput subclass above. + addTableTarget(node, *table_query); + + return true; + } + + return false; +} + +/// The node's "type" id. +/// +/// By default it is `IAST::getID(' ')` trimmed at the first space — getID packs +/// auxiliary data after a space delimiter (e.g. "Function quantile"), and the +/// structured info is re-exposed via enrichNode. A few classes, however, return +/// a purely descriptive getID that itself contains a space ("Dictionary +/// lifetime", ...). Trimming those collapses the five Dictionary* classes onto +/// the same "Dictionary" — so they are spelled out explicitly here. +String astTypeName(const IAST & ast) +{ + if (dynamic_cast(&ast)) + return "DictionaryLifetime"; + if (dynamic_cast(&ast)) + return "DictionaryLayout"; + if (dynamic_cast(&ast)) + return "DictionaryRange"; + if (dynamic_cast(&ast)) + return "DictionarySettings"; + + /// getID is "Set"; rename to avoid confusion with SET statements / the Set + /// data structure — this is the SETTINGS clause. + if (dynamic_cast(&ast)) + return "Settings"; + + /// ASTShowIndexesQuery::getID is a mis-set "ShowColumns" (shared verbatim + /// with ASTShowColumnsQuery), which would make the two distinct statements + /// SHOW COLUMNS and SHOW INDEXES indistinguishable. Spell it out so the + /// type alone identifies the statement. + if (dynamic_cast(&ast)) + return "ShowIndexes"; + + /// GRANT and REVOKE share one class (ASTGrantQuery); split by is_revoke so + /// the type alone identifies the statement. + if (const auto * grant = dynamic_cast(&ast)) + return grant->is_revoke ? "RevokeQuery" : "GrantQuery"; + + /// These access statements have descriptive getID()s that contain spaces + /// (e.g. "CREATE ROW POLICY or ALTER ROW POLICY query", "DROP USER query"), + /// which would otherwise trim to "CREATE" / "DROP" / "SHOW" / "MOVE". + if (dynamic_cast(&ast)) + return "CreateRowPolicyQuery"; + if (dynamic_cast(&ast)) + return "CreateMaskingPolicyQuery"; + if (dynamic_cast(&ast)) + return "DropAccessEntityQuery"; + if (dynamic_cast(&ast)) + return "MoveAccessEntityQuery"; + if (dynamic_cast(&ast)) + return "ShowCreateAccessEntityQuery"; + if (dynamic_cast(&ast)) + return "ShowAccessEntitiesQuery"; + + /// getID is the raw class name "ASTTransactionControl"; drop the AST prefix + /// so it matches the rest of the type ids (BEGIN/COMMIT/ROLLBACK/SET SNAPSHOT + /// are split out into the `action` field). + if (dynamic_cast(&ast)) + return "TransactionControl"; + + /// getID is the descriptive "Refresh strategy definition", which would + /// otherwise trim to "Refresh". + if (dynamic_cast(&ast)) + return "RefreshStrategy"; + + /// getID is the raw class name "ASTObjectTypeArgument"; drop the AST prefix. + if (dynamic_cast(&ast)) + return "ObjectTypeArgument"; + + String id = ast.getID(' '); + auto space_pos = id.find(' '); + if (space_pos != String::npos) + id.resize(space_pos); + return id; +} + +} + +JSONBuilder::ItemPtr formatASTAsJSON(const IAST & ast) +{ + auto node = std::make_unique(); + + node->add("type", astTypeName(ast)); + + String alias = ast.tryGetAlias(); + if (!alias.empty()) + node->add("alias", alias); + + bool handled_children = enrichNode(*node, ast); + + if (!handled_children && !ast.children.empty()) + { + auto children = std::make_unique(); + for (const auto & child : ast.children) + children->add(formatASTAsJSON(*child)); + node->add("children", std::move(children)); + } + + return node; +} + +JSONBuilder::ItemPtr formatASTAsJSONDocument(const IAST & ast) +{ + auto document = std::make_unique(); + document->add("version", AST_JSON_FORMAT_VERSION); + document->add("ast", formatASTAsJSON(ast)); + return document; +} + +} diff --git a/src/Parsers/DumpASTNode.h b/src/Parsers/DumpASTNode.h index 5efc0e018f47..7080b1cf0015 100644 --- a/src/Parsers/DumpASTNode.h +++ b/src/Parsers/DumpASTNode.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include @@ -156,6 +157,77 @@ inline void dumpASTInDotFormat(const IAST & ast, WriteBuffer & ostr, bool root = } +/// Build a JSONBuilder representation of the AST. +/// Every node carries: +/// - "type": short class name (e.g. "Function", "Identifier", "Literal") +/// - "alias": only present when the node has an alias +/// - "children": only present when the node has child nodes +/// Selected node classes contribute extra structured fields such as `name`, +/// `value`, `value_type`, `direction`, etc. — see implementation. +/// +/// Some classes expose their sub-nodes through named slots instead of the +/// positional `children` array, which is then omitted for those nodes: +/// - ASTFunction: `arguments` (always present), `parameters`, +/// `window_definition` — the inner `ExpressionList` wrappers are inlined. +/// - ASTOrderByElement: `expression`, `collation`, `fill_from`, `fill_to`, +/// `fill_step`, `fill_staleness`. +/// - ASTSelectQuery: one named slot per clause (`with`, `select`, `from`, +/// `where`, `group_by`, `order_by`, `limit`, `offset`, `limit_by`, ...); +/// list-shaped clauses inline their `ExpressionList` wrapper. +/// - The structural wrappers — ASTSelectWithUnionQuery, ASTSubquery, +/// ASTWithElement, ASTTablesInSelectQueryElement, ASTTableExpression, +/// ASTTableJoin, ASTArrayJoin, ASTWindowListElement, ASTWindowDefinition, +/// ASTInterpolateElement — likewise expose named slots. +/// - Leaf-ish nodes that used to hide state: ASTSetQuery (`changes`), +/// ASTSampleRatio (`numerator` / `denominator`), ASTAsterisk / +/// ASTQualifiedAsterisk and the COLUMNS matchers / transformers. +/// - DDL/DML: ASTCreateQuery, ASTColumns, ASTColumnDeclaration, ASTDataType, +/// ASTEnumDataType (`values`), ASTTupleDataType (`element_names`), +/// ASTStorage, ASTInsertQuery, ASTIndexDeclaration, ASTConstraintDeclaration, +/// ASTProjectionDeclaration (incl. `index_type` / `settings`), +/// ASTProjectionSelectQuery, ASTTTLElement (incl. GROUP BY +/// `group_by_key` / `group_by_assignments`), ASTCollation, +/// ASTObjectTypedPathArgument, ASTPartition, ASTAssignment, ASTDeleteQuery, +/// ASTUpdateQuery, ASTDropQuery, ASTOptimizeQuery, ASTAlterQuery, +/// ASTAlterCommand, ASTCreateFunctionQuery, ASTDropFunctionQuery, +/// ASTCreateNamedCollectionQuery, ASTDropNamedCollectionQuery, +/// ASTCreateWorkloadQuery, ASTDropWorkloadQuery, ASTCreateResourceQuery, +/// ASTDropResourceQuery, ASTRefreshStrategy, +/// ASTTimeInterval, ASTDictionary (and its sub-elements), +/// ASTDictionaryAttributeDeclaration, ASTFunctionWithKeyValueArguments, +/// ASTPair, ASTViewTargets, ASTExplainQuery, ASTDescribeQuery, +/// ASTShowTablesQuery, ASTCreateIndexQuery, ASTDropIndexQuery, +/// ASTCheckTableQuery, ASTUseQuery, ASTKillQueryQuery, ASTRenameQuery, +/// ASTTransactionControl, ASTSystemQuery, ASTStatisticsDeclaration, +/// ASTNameTypePair, the qualified COLUMNS matchers, and a generic +/// ASTQueryWithTableAndOutput fallback (EXISTS / SHOW CREATE / ...). +/// - Access management: ASTGrantQuery (GrantQuery / RevokeQuery), +/// ASTCheckGrantQuery, ASTCreateUserQuery, ASTCreateRoleQuery, +/// ASTCreateQuotaQuery, ASTSetRoleQuery, ASTCreateRowPolicyQuery, +/// ASTCreateSettingsProfileQuery, ASTCreateMaskingPolicyQuery, +/// ASTDropAccessEntityQuery, ASTMoveAccessEntityQuery, ASTExecuteAsQuery, +/// ASTShowGrantsQuery, ASTShowCreateAccessEntityQuery, +/// ASTShowAccessEntitiesQuery, and the shared helpers ASTRolesOrUsersSet, +/// ASTUserNamesWithHost / ASTUserNameWithHost, ASTAuthenticationData, +/// ASTSettingsProfileElements / ASTSettingsProfileElement / +/// ASTAlterSettingsProfileElements, ASTRowPolicyNames / ASTRowPolicyName, +/// ASTDatabaseOrNone, ASTPublicSSHKey. The privilege lists +/// (AccessRightsElements) and HOST clause (AllowedClientHosts) are plain +/// value objects serialized inline. +/// `children` survives only on homogeneous lists (ExpressionList, +/// TablesInSelectQuery). +JSONBuilder::ItemPtr formatASTAsJSON(const IAST & ast); + + +/// Bump on any backwards-incompatible change to the JSON shape. External +/// consumers (e.g. clickhouse-js-parser) pin reference fixtures on it. +constexpr int AST_JSON_FORMAT_VERSION = 2; + +/// `formatASTAsJSON` wrapped in a versioned document: `{ "version": N, "ast": {...} }`. +/// This is what `EXPLAIN AST json = 1` emits at top level. +JSONBuilder::ItemPtr formatASTAsJSONDocument(const IAST & ast); + + /// String stream dumped in dtor template class DebugASTLog diff --git a/tests/ast_json_fixtures/.gitignore b/tests/ast_json_fixtures/.gitignore new file mode 100644 index 000000000000..9e43ed0409fe --- /dev/null +++ b/tests/ast_json_fixtures/.gitignore @@ -0,0 +1,2 @@ +# Locally generated bulk corpus from harvest_stateless.py +harvested/ diff --git a/tests/ast_json_fixtures/README.md b/tests/ast_json_fixtures/README.md new file mode 100644 index 000000000000..a98bd71bd09d --- /dev/null +++ b/tests/ast_json_fixtures/README.md @@ -0,0 +1,134 @@ +# SQL → JSON-AST fixtures + +A static, vendorable corpus mapping SQL queries to their parsed AST as +produced by `EXPLAIN AST json = 1` (see `../../AST.md`). Intended as golden +files for verifying an alternative parser / AST serializer against the +reference ClickHouse implementation. + +The `.json` files are the full document, `{ "version": N, "ast": {...} }`; +pin against `version` so a schema break is detectable. 64-bit integer +literal values are JSON strings (see `../../AST.md`). + +## Layout + +``` +cases/ + 01_literals.sql 01_literals.json + 02_identifiers.sql 02_identifiers.json + ... + 41_showcase.sql 41_showcase.json +generate.sh +``` + +Each case is a pair sharing a basename: + +- `.sql` — one input statement (the source of truth). +- `.json` — the expected AST: the exact, pretty-printed output of + `EXPLAIN AST json = 1 `. + +The corpus is deliberately broad: literals and operators, functions / +lambdas / parametric aggregates, window functions (named and inline), +every SELECT clause, joins (ON / USING / GLOBAL ANY / CROSS / COMMA), +ARRAY JOIN, table functions and subqueries, SAMPLE / FINAL, CTEs and set +operations, asterisk transformers and `COLUMNS(...)`, and one maximal +`41_showcase` query that exercises most node types at once. + +## Output conventions + +The JSON shape is documented in `../../AST.md`. In short: each node has a +`type`; sub-nodes appear under named slots; `children` survives only on +homogeneous lists (`ExpressionList`, `TablesInSelectQuery`). Absent optional +fields are omitted (no `null`s). The queries only need to parse — referenced +tables / columns do not have to exist. + +## Verifying your parser + +For each `.sql`, run your parser, serialize to the same JSON shape, and +compare against the matching `.json`. Compare structurally (parse both +sides and diff the trees) rather than byte-for-byte, so key order and +whitespace don't cause spurious failures: + +```bash +for sql in cases/*.sql; do + name=$(basename "$sql" .sql) + mine=$(my-parser --json "$sql") + if ! diff <(jq -S . <<<"$mine") <(jq -S . "cases/$name.json") >/dev/null; then + echo "MISMATCH: $name" + fi +done +``` + +(`jq -S` sorts object keys for order-insensitive comparison.) + +## Regenerating + +The `.json` files are generated; regenerate them when the serializer +changes: + +```bash +CLICKHOUSE_BINARY=/path/to/clickhouse ./generate.sh +``` + +Add a new case by adding one `emit ""` line to `generate.sh` +and rerunning. These fixtures are a standalone corpus and are not wired +into ClickHouse CI. + +## Bulk corpus from the stateless tests + +The curated cases above are hand-picked for readability. For a much +larger, real-world corpus you can reuse the existing stateless test suite: +`tests/queries/0_stateless/*.sql` holds ~124k statements. `harvest_stateless.py` +extracts them, runs each through `EXPLAIN AST json = 1`, and writes the +SQL → JSON pairs that parse: + +```bash +CLICKHOUSE_BINARY=/path/to/clickhouse ./harvest_stateless.py --write --out harvested +``` + +- ~94k statements remain after dropping query-parameter placeholders + (`{x:UInt8}`, which the reference parser cannot substitute without values) + and de-duplicating. Essentially all of them parse — observed yield ~100%. +- It batches statements through one `clickhouse local` process per batch + (`--batch`, default 500) with `--multiquery --ignore-error`; since + `EXPLAIN AST` only parses and never executes, this is side-effect-free and + resynchronises past any reject. A full harvest takes well under a minute. +- Output filenames are content hashes; pass `--limit N` for a quick sample + and `--batch 1` to fall back to one process per statement. + +The full harvested corpus is **not committed** (tens of thousands of files); +generate it locally when you need it. Note that non-SELECT statements +(DDL/DML such as `InsertQuery`, `CreateQuery`) appear too — their nodes are +not specially enriched yet, so they fall back to the positional `children` +array, but the JSON is still valid and reflects the reference parser. + +### Shape dedup — `shapes/` + +Text de-dup still leaves ~86k statements (`SELECT a` and `SELECT b` are +distinct). `--dedupe shape` instead keeps one representative per distinct +*AST shape*: a structural signature of node types, slot keys, enum/flag +scalars and literal `value_type`, dropping leaf values (names, literals, +aliases, settings contents). The representative kept is the shortest +statement for that shape, so the selection is deterministic. + +`--shape-depth D` caps the signature depth for coarser dedup. Observed +counts over the stateless corpus: + +| depth | distinct shapes | +|------:|----------------:| +| 2 | 155 | +| 3 | 1,440 | +| 4 | 5,141 | +| 5 | 9,797 | +| ∞ (0) | 16,733 | + +The committed `shapes/` directory is the **depth-3** set — 1,440 +structurally-distinct, shortest-representative pairs (~12 MB), a compact +high-coverage corpus for parser conformance. Regenerate with: + +```bash +CLICKHOUSE_BINARY=/path/to/clickhouse \ + ./harvest_stateless.py --dedupe shape --shape-depth 3 --out shapes --write +``` + +Use a larger `--shape-depth` (or `0`) for finer coverage, smaller for a +quick smoke set. diff --git a/tests/ast_json_fixtures/cases/01_literals.json b/tests/ast_json_fixtures/cases/01_literals.json new file mode 100644 index 000000000000..6ba5ed6ae9f3 --- /dev/null +++ b/tests/ast_json_fixtures/cases/01_literals.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-2" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 3.5 + }, + { + "type": "Literal", + "value_type": "String", + "value": "str" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Bool", + "value": true + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "String", + "value": "a" + } + ] + }, + { + "type": "Function", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "k" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/01_literals.sql b/tests/ast_json_fixtures/cases/01_literals.sql new file mode 100644 index 000000000000..c31e30d3ea04 --- /dev/null +++ b/tests/ast_json_fixtures/cases/01_literals.sql @@ -0,0 +1 @@ +SELECT 1, -2, 3.5, 'str', NULL, true, [1, 2], (1, 'a'), map('k', 1) diff --git a/tests/ast_json_fixtures/cases/02_identifiers.json b/tests/ast_json_fixtures/cases/02_identifiers.json new file mode 100644 index 000000000000..6ca5b9a67223 --- /dev/null +++ b/tests/ast_json_fixtures/cases/02_identifiers.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "t.b", + "name_parts": ["t", "b"] + }, + { + "type": "Identifier", + "name": "db.tbl.c", + "name_parts": ["db", "tbl", "c"] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/02_identifiers.sql b/tests/ast_json_fixtures/cases/02_identifiers.sql new file mode 100644 index 000000000000..88fc5bda5e5c --- /dev/null +++ b/tests/ast_json_fixtures/cases/02_identifiers.sql @@ -0,0 +1 @@ +SELECT a, t.b, db.tbl.c diff --git a/tests/ast_json_fixtures/cases/03_function_call.json b/tests/ast_json_fixtures/cases/03_function_call.json new file mode 100644 index 000000000000..a3ed55c409a3 --- /dev/null +++ b/tests/ast_json_fixtures/cases/03_function_call.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "f", + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/03_function_call.sql b/tests/ast_json_fixtures/cases/03_function_call.sql new file mode 100644 index 000000000000..1ea9f8240164 --- /dev/null +++ b/tests/ast_json_fixtures/cases/03_function_call.sql @@ -0,0 +1 @@ +SELECT f(x, y) diff --git a/tests/ast_json_fixtures/cases/04_no_args.json b/tests/ast_json_fixtures/cases/04_no_args.json new file mode 100644 index 000000000000..82b064569fd6 --- /dev/null +++ b/tests/ast_json_fixtures/cases/04_no_args.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "now", + "arguments": [] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/04_no_args.sql b/tests/ast_json_fixtures/cases/04_no_args.sql new file mode 100644 index 000000000000..31700225c6cd --- /dev/null +++ b/tests/ast_json_fixtures/cases/04_no_args.sql @@ -0,0 +1 @@ +SELECT now() diff --git a/tests/ast_json_fixtures/cases/05_operators.json b/tests/ast_json_fixtures/cases/05_operators.json new file mode 100644 index 000000000000..750bba231645 --- /dev/null +++ b/tests/ast_json_fixtures/cases/05_operators.json @@ -0,0 +1,129 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "z" + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "p" + }, + { + "type": "Identifier", + "name": "q" + } + ] + }, + { + "type": "Identifier", + "name": "r" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/05_operators.sql b/tests/ast_json_fixtures/cases/05_operators.sql new file mode 100644 index 000000000000..3d608adf299a --- /dev/null +++ b/tests/ast_json_fixtures/cases/05_operators.sql @@ -0,0 +1 @@ +SELECT a + b, x IN (1, 2), y BETWEEN 1 AND 2, NOT z, p AND q OR r diff --git a/tests/ast_json_fixtures/cases/06_subscript.json b/tests/ast_json_fixtures/cases/06_subscript.json new file mode 100644 index 000000000000..3f6b06b7adb1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/06_subscript.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "arr" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tup" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/06_subscript.sql b/tests/ast_json_fixtures/cases/06_subscript.sql new file mode 100644 index 000000000000..2f077808f402 --- /dev/null +++ b/tests/ast_json_fixtures/cases/06_subscript.sql @@ -0,0 +1 @@ +SELECT arr[1], tup.2 diff --git a/tests/ast_json_fixtures/cases/07_cast.json b/tests/ast_json_fixtures/cases/07_cast.json new file mode 100644 index 000000000000..adde1053e77b --- /dev/null +++ b/tests/ast_json_fixtures/cases/07_cast.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Int64" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/07_cast.sql b/tests/ast_json_fixtures/cases/07_cast.sql new file mode 100644 index 000000000000..c198db97c489 --- /dev/null +++ b/tests/ast_json_fixtures/cases/07_cast.sql @@ -0,0 +1 @@ +SELECT CAST(x AS Int64), y::String diff --git a/tests/ast_json_fixtures/cases/08_lambda.json b/tests/ast_json_fixtures/cases/08_lambda.json new file mode 100644 index 000000000000..26d310f9a2bf --- /dev/null +++ b/tests/ast_json_fixtures/cases/08_lambda.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/08_lambda.sql b/tests/ast_json_fixtures/cases/08_lambda.sql new file mode 100644 index 000000000000..ee6c53eae9fc --- /dev/null +++ b/tests/ast_json_fixtures/cases/08_lambda.sql @@ -0,0 +1 @@ +SELECT arrayMap(e -> e * 2, arr) diff --git a/tests/ast_json_fixtures/cases/09_parametric_agg.json b/tests/ast_json_fixtures/cases/09_parametric_agg.json new file mode 100644 index 000000000000..a4ba68d2c08c --- /dev/null +++ b/tests/ast_json_fixtures/cases/09_parametric_agg.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "quantile", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.9 + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/09_parametric_agg.sql b/tests/ast_json_fixtures/cases/09_parametric_agg.sql new file mode 100644 index 000000000000..74641f47b95e --- /dev/null +++ b/tests/ast_json_fixtures/cases/09_parametric_agg.sql @@ -0,0 +1 @@ +SELECT quantile(0.9)(x) diff --git a/tests/ast_json_fixtures/cases/100_outfile_format_settings.json b/tests/ast_json_fixtures/cases/100_outfile_format_settings.json new file mode 100644 index 000000000000..ad9255edbb0a --- /dev/null +++ b/tests/ast_json_fixtures/cases/100_outfile_format_settings.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + }, + "out_file": { + "type": "Literal", + "value_type": "String", + "value": "\/tmp\/f.tsv" + }, + "outfile_truncate": true, + "outfile_with_stdout": true, + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/cases/100_outfile_format_settings.sql b/tests/ast_json_fixtures/cases/100_outfile_format_settings.sql new file mode 100644 index 000000000000..7f30c8e72f60 --- /dev/null +++ b/tests/ast_json_fixtures/cases/100_outfile_format_settings.sql @@ -0,0 +1 @@ +SELECT 1 INTO OUTFILE '/tmp/f.tsv' TRUNCATE AND STDOUT FORMAT TSV SETTINGS max_threads = 1 diff --git a/tests/ast_json_fixtures/cases/101_outfile_compression.json b/tests/ast_json_fixtures/cases/101_outfile_compression.json new file mode 100644 index 000000000000..af82c12a3e79 --- /dev/null +++ b/tests/ast_json_fixtures/cases/101_outfile_compression.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "out_file": { + "type": "Literal", + "value_type": "String", + "value": "\/tmp\/f.csv.gz" + }, + "outfile_append": true, + "compression": { + "type": "Literal", + "value_type": "String", + "value": "gzip" + }, + "compression_level": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/cases/101_outfile_compression.sql b/tests/ast_json_fixtures/cases/101_outfile_compression.sql new file mode 100644 index 000000000000..50d002c43dd7 --- /dev/null +++ b/tests/ast_json_fixtures/cases/101_outfile_compression.sql @@ -0,0 +1 @@ +SELECT 1 INTO OUTFILE '/tmp/f.csv.gz' APPEND COMPRESSION 'gzip' LEVEL 3 FORMAT CSV diff --git a/tests/ast_json_fixtures/cases/102_map_setting.json b/tests/ast_json_fixtures/cases/102_map_setting.json new file mode 100644 index 000000000000..779cbe9f1f73 --- /dev/null +++ b/tests/ast_json_fixtures/cases/102_map_setting.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "additional_table_filters": { + "tbl": { + "value_type": "String", + "value": "x = 1" + } + } + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/102_map_setting.sql b/tests/ast_json_fixtures/cases/102_map_setting.sql new file mode 100644 index 000000000000..c00e06c3d817 --- /dev/null +++ b/tests/ast_json_fixtures/cases/102_map_setting.sql @@ -0,0 +1 @@ +SELECT 1 SETTINGS additional_table_filters = {'tbl': 'x = 1'} diff --git a/tests/ast_json_fixtures/cases/103_truncate_all_tables.json b/tests/ast_json_fixtures/cases/103_truncate_all_tables.json new file mode 100644 index 000000000000..27d0869f3bfc --- /dev/null +++ b/tests/ast_json_fixtures/cases/103_truncate_all_tables.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "TruncateQuery", + "kind": "TRUNCATE", + "database": { + "type": "Identifier", + "name": "db" + }, + "has_all": true, + "has_tables": true, + "like": "%tmp%" + } +} diff --git a/tests/ast_json_fixtures/cases/103_truncate_all_tables.sql b/tests/ast_json_fixtures/cases/103_truncate_all_tables.sql new file mode 100644 index 000000000000..ac241be72e89 --- /dev/null +++ b/tests/ast_json_fixtures/cases/103_truncate_all_tables.sql @@ -0,0 +1 @@ +TRUNCATE ALL TABLES FROM db LIKE '%tmp%' diff --git a/tests/ast_json_fixtures/cases/104_create_function_cluster.json b/tests/ast_json_fixtures/cases/104_create_function_cluster.json new file mode 100644 index 000000000000..53fb675a43f1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/104_create_function_cluster.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "cluster": "c", + "function_name": { + "type": "Identifier", + "name": "f" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/cases/104_create_function_cluster.sql b/tests/ast_json_fixtures/cases/104_create_function_cluster.sql new file mode 100644 index 000000000000..c934223ed7c6 --- /dev/null +++ b/tests/ast_json_fixtures/cases/104_create_function_cluster.sql @@ -0,0 +1 @@ +CREATE FUNCTION f ON CLUSTER c AS x -> x + 1 diff --git a/tests/ast_json_fixtures/cases/105_drop_function.json b/tests/ast_json_fixtures/cases/105_drop_function.json new file mode 100644 index 000000000000..33d597d4fd3e --- /dev/null +++ b/tests/ast_json_fixtures/cases/105_drop_function.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "f", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/cases/105_drop_function.sql b/tests/ast_json_fixtures/cases/105_drop_function.sql new file mode 100644 index 000000000000..38dd8cf2c793 --- /dev/null +++ b/tests/ast_json_fixtures/cases/105_drop_function.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS f diff --git a/tests/ast_json_fixtures/cases/106_attach_from_path.json b/tests/ast_json_fixtures/cases/106_attach_from_path.json new file mode 100644 index 000000000000..97b4d6122648 --- /dev/null +++ b/tests/ast_json_fixtures/cases/106_attach_from_path.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "attach_from_path": "\/data\/t", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "File", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "TSV" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/106_attach_from_path.sql b/tests/ast_json_fixtures/cases/106_attach_from_path.sql new file mode 100644 index 000000000000..6defef5474c1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/106_attach_from_path.sql @@ -0,0 +1 @@ +ATTACH TABLE t FROM '/data/t' (x UInt8) ENGINE = File(TSV) diff --git a/tests/ast_json_fixtures/cases/107_attach_uuid.json b/tests/ast_json_fixtures/cases/107_attach_uuid.json new file mode 100644 index 000000000000..7479841b4786 --- /dev/null +++ b/tests/ast_json_fixtures/cases/107_attach_uuid.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "uuid": "123e4567-e89b-12d3-a456-426614174000", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/107_attach_uuid.sql b/tests/ast_json_fixtures/cases/107_attach_uuid.sql new file mode 100644 index 000000000000..1692e49f9613 --- /dev/null +++ b/tests/ast_json_fixtures/cases/107_attach_uuid.sql @@ -0,0 +1 @@ +ATTACH TABLE t UUID '123e4567-e89b-12d3-a456-426614174000' (x UInt8) ENGINE = Memory diff --git a/tests/ast_json_fixtures/cases/108_attach_as_replicated.json b/tests/ast_json_fixtures/cases/108_attach_as_replicated.json new file mode 100644 index 000000000000..f598e48ca3f7 --- /dev/null +++ b/tests/ast_json_fixtures/cases/108_attach_as_replicated.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "attach_as_replicated": true, + "table": { + "type": "Identifier", + "name": "t" + } + } +} diff --git a/tests/ast_json_fixtures/cases/108_attach_as_replicated.sql b/tests/ast_json_fixtures/cases/108_attach_as_replicated.sql new file mode 100644 index 000000000000..70cadb039b01 --- /dev/null +++ b/tests/ast_json_fixtures/cases/108_attach_as_replicated.sql @@ -0,0 +1 @@ +ATTACH TABLE t AS REPLICATED diff --git a/tests/ast_json_fixtures/cases/109_undrop.json b/tests/ast_json_fixtures/cases/109_undrop.json new file mode 100644 index 000000000000..b6f0cc22dc34 --- /dev/null +++ b/tests/ast_json_fixtures/cases/109_undrop.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "UndropQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "uuid": "123e4567-e89b-12d3-a456-426614174000" + } +} diff --git a/tests/ast_json_fixtures/cases/109_undrop.sql b/tests/ast_json_fixtures/cases/109_undrop.sql new file mode 100644 index 000000000000..e26c762de954 --- /dev/null +++ b/tests/ast_json_fixtures/cases/109_undrop.sql @@ -0,0 +1 @@ +UNDROP TABLE t UUID '123e4567-e89b-12d3-a456-426614174000' diff --git a/tests/ast_json_fixtures/cases/10_nulls_action.json b/tests/ast_json_fixtures/cases/10_nulls_action.json new file mode 100644 index 000000000000..0c37089e0853 --- /dev/null +++ b/tests/ast_json_fixtures/cases/10_nulls_action.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "first_value", + "nulls_action": "IGNORE NULLS", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/10_nulls_action.sql b/tests/ast_json_fixtures/cases/10_nulls_action.sql new file mode 100644 index 000000000000..1dd0497eaba3 --- /dev/null +++ b/tests/ast_json_fixtures/cases/10_nulls_action.sql @@ -0,0 +1 @@ +SELECT first_value(x) IGNORE NULLS FROM t diff --git a/tests/ast_json_fixtures/cases/110_check_grant.json b/tests/ast_json_fixtures/cases/110_check_grant.json new file mode 100644 index 000000000000..95bede9bd661 --- /dev/null +++ b/tests/ast_json_fixtures/cases/110_check_grant.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "CheckGrantQuery", + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "db", + "table": "t", + "columns": ["x"] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/110_check_grant.sql b/tests/ast_json_fixtures/cases/110_check_grant.sql new file mode 100644 index 000000000000..fb695fff35ff --- /dev/null +++ b/tests/ast_json_fixtures/cases/110_check_grant.sql @@ -0,0 +1 @@ +CHECK GRANT SELECT(x) ON db.t diff --git a/tests/ast_json_fixtures/cases/111_set_role.json b/tests/ast_json_fixtures/cases/111_set_role.json new file mode 100644 index 000000000000..fc306dfb4139 --- /dev/null +++ b/tests/ast_json_fixtures/cases/111_set_role.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SetRoleQuery", + "kind": "SET_ROLE", + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1", "r2"] + } + } +} diff --git a/tests/ast_json_fixtures/cases/111_set_role.sql b/tests/ast_json_fixtures/cases/111_set_role.sql new file mode 100644 index 000000000000..59b540e0e24c --- /dev/null +++ b/tests/ast_json_fixtures/cases/111_set_role.sql @@ -0,0 +1 @@ +SET ROLE r1, r2 diff --git a/tests/ast_json_fixtures/cases/112_move_access_entity.json b/tests/ast_json_fixtures/cases/112_move_access_entity.json new file mode 100644 index 000000000000..d9f9cdbb2c20 --- /dev/null +++ b/tests/ast_json_fixtures/cases/112_move_access_entity.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "MoveAccessEntityQuery", + "entity_type": "ROLE", + "storage_name": "local_directory", + "names": ["r"] + } +} diff --git a/tests/ast_json_fixtures/cases/112_move_access_entity.sql b/tests/ast_json_fixtures/cases/112_move_access_entity.sql new file mode 100644 index 000000000000..6dfe73ea0d8d --- /dev/null +++ b/tests/ast_json_fixtures/cases/112_move_access_entity.sql @@ -0,0 +1 @@ +MOVE ROLE r TO local_directory diff --git a/tests/ast_json_fixtures/cases/113_execute_as.json b/tests/ast_json_fixtures/cases/113_execute_as.json new file mode 100644 index 000000000000..ff1428c7bc79 --- /dev/null +++ b/tests/ast_json_fixtures/cases/113_execute_as.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "ExecuteAsQuery", + "target_user": { + "type": "UserNameWithHost", + "name": "u1" + }, + "subquery": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/cases/113_execute_as.sql b/tests/ast_json_fixtures/cases/113_execute_as.sql new file mode 100644 index 000000000000..ac49235c960c --- /dev/null +++ b/tests/ast_json_fixtures/cases/113_execute_as.sql @@ -0,0 +1 @@ +EXECUTE AS u1 SELECT 1 diff --git a/tests/ast_json_fixtures/cases/114_show_create_user.json b/tests/ast_json_fixtures/cases/114_show_create_user.json new file mode 100644 index 000000000000..9b4a55b197ed --- /dev/null +++ b/tests/ast_json_fixtures/cases/114_show_create_user.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u"] + } +} diff --git a/tests/ast_json_fixtures/cases/114_show_create_user.sql b/tests/ast_json_fixtures/cases/114_show_create_user.sql new file mode 100644 index 000000000000..f25559015462 --- /dev/null +++ b/tests/ast_json_fixtures/cases/114_show_create_user.sql @@ -0,0 +1 @@ +SHOW CREATE USER u diff --git a/tests/ast_json_fixtures/cases/115_show_users.json b/tests/ast_json_fixtures/cases/115_show_users.json new file mode 100644 index 000000000000..62e99cabb29a --- /dev/null +++ b/tests/ast_json_fixtures/cases/115_show_users.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowAccessEntitiesQuery", + "entity_type": "USER", + "all": true + } +} diff --git a/tests/ast_json_fixtures/cases/115_show_users.sql b/tests/ast_json_fixtures/cases/115_show_users.sql new file mode 100644 index 000000000000..e3cffec146e4 --- /dev/null +++ b/tests/ast_json_fixtures/cases/115_show_users.sql @@ -0,0 +1 @@ +SHOW USERS diff --git a/tests/ast_json_fixtures/cases/116_create_masking_policy.json b/tests/ast_json_fixtures/cases/116_create_masking_policy.json new file mode 100644 index 000000000000..9ed217034415 --- /dev/null +++ b/tests/ast_json_fixtures/cases/116_create_masking_policy.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateMaskingPolicyQuery", + "name": "mp", + "database": "db", + "table": "t", + "update_assignments": [ + { + "type": "Assignment", + "column": "x", + "expression": { + "type": "Literal", + "value_type": "String", + "value": "masked" + } + } + ], + "where_condition": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1"] + }, + "priority": "2" + } +} diff --git a/tests/ast_json_fixtures/cases/116_create_masking_policy.sql b/tests/ast_json_fixtures/cases/116_create_masking_policy.sql new file mode 100644 index 000000000000..b50be21b7e0c --- /dev/null +++ b/tests/ast_json_fixtures/cases/116_create_masking_policy.sql @@ -0,0 +1 @@ +CREATE MASKING POLICY mp ON db.t UPDATE x = 'masked' WHERE x != '' TO r1 PRIORITY 2 diff --git a/tests/ast_json_fixtures/cases/117_user_ssh_key.json b/tests/ast_json_fixtures/cases/117_user_ssh_key.json new file mode 100644 index 000000000000..363865834e73 --- /dev/null +++ b/tests/ast_json_fixtures/cases/117_user_ssh_key.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "SSH_KEY", + "arguments": [ + { + "type": "PublicSSHKey", + "key_type": "ssh-rsa", + "key_base64": "AAAA" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/cases/117_user_ssh_key.sql b/tests/ast_json_fixtures/cases/117_user_ssh_key.sql new file mode 100644 index 000000000000..f3b822971f7b --- /dev/null +++ b/tests/ast_json_fixtures/cases/117_user_ssh_key.sql @@ -0,0 +1 @@ +CREATE USER u IDENTIFIED WITH ssh_key BY KEY 'AAAA' TYPE 'ssh-rsa' diff --git a/tests/ast_json_fixtures/cases/118_user_default_database.json b/tests/ast_json_fixtures/cases/118_user_default_database.json new file mode 100644 index 000000000000..37995598e74c --- /dev/null +++ b/tests/ast_json_fixtures/cases/118_user_default_database.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u" + } + ] + }, + "default_database": { + "type": "DatabaseOrNone", + "database": "db" + } + } +} diff --git a/tests/ast_json_fixtures/cases/118_user_default_database.sql b/tests/ast_json_fixtures/cases/118_user_default_database.sql new file mode 100644 index 000000000000..49207cefefcf --- /dev/null +++ b/tests/ast_json_fixtures/cases/118_user_default_database.sql @@ -0,0 +1 @@ +CREATE USER u DEFAULT DATABASE db diff --git a/tests/ast_json_fixtures/cases/119_user_host_valid_until.json b/tests/ast_json_fixtures/cases/119_user_host_valid_until.json new file mode 100644 index 000000000000..0508b9c0ded5 --- /dev/null +++ b/tests/ast_json_fixtures/cases/119_user_host_valid_until.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u", + "host_pattern": "%.example.com" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "contains_password": true, + "valid_until": { + "type": "Literal", + "value_type": "String", + "value": "2030-01-01" + }, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "p" + } + ] + } + ], + "replace_authentication_methods": true, + "hosts": { + "like_patterns": ["%.example.com"] + } + } +} diff --git a/tests/ast_json_fixtures/cases/119_user_host_valid_until.sql b/tests/ast_json_fixtures/cases/119_user_host_valid_until.sql new file mode 100644 index 000000000000..18ed07d7bb03 --- /dev/null +++ b/tests/ast_json_fixtures/cases/119_user_host_valid_until.sql @@ -0,0 +1 @@ +CREATE USER u@'%.example.com' IDENTIFIED BY 'p' VALID UNTIL '2030-01-01' diff --git a/tests/ast_json_fixtures/cases/11_window_named.json b/tests/ast_json_fixtures/cases/11_window_named.json new file mode 100644 index 000000000000..bb7839d66534 --- /dev/null +++ b/tests/ast_json_fixtures/cases/11_window_named.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ], + "window_name": "w" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "g" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/11_window_named.sql b/tests/ast_json_fixtures/cases/11_window_named.sql new file mode 100644 index 000000000000..07a821e5e017 --- /dev/null +++ b/tests/ast_json_fixtures/cases/11_window_named.sql @@ -0,0 +1 @@ +SELECT sum(x) OVER w FROM t WINDOW w AS (PARTITION BY g ORDER BY x) diff --git a/tests/ast_json_fixtures/cases/120_show_fs_caches.json b/tests/ast_json_fixtures/cases/120_show_fs_caches.json new file mode 100644 index 000000000000..76bcaf86357a --- /dev/null +++ b/tests/ast_json_fixtures/cases/120_show_fs_caches.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "caches": true + } +} diff --git a/tests/ast_json_fixtures/cases/120_show_fs_caches.sql b/tests/ast_json_fixtures/cases/120_show_fs_caches.sql new file mode 100644 index 000000000000..d5b1bb141179 --- /dev/null +++ b/tests/ast_json_fixtures/cases/120_show_fs_caches.sql @@ -0,0 +1 @@ +SHOW FILESYSTEM CACHES diff --git a/tests/ast_json_fixtures/cases/121_system_schema_cache.json b/tests/ast_json_fixtures/cases/121_system_schema_cache.json new file mode 100644 index 000000000000..80cdaabff378 --- /dev/null +++ b/tests/ast_json_fixtures/cases/121_system_schema_cache.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR SCHEMA CACHE", + "schema_cache_storage": "S3" + } +} diff --git a/tests/ast_json_fixtures/cases/121_system_schema_cache.sql b/tests/ast_json_fixtures/cases/121_system_schema_cache.sql new file mode 100644 index 000000000000..a22ce51ab810 --- /dev/null +++ b/tests/ast_json_fixtures/cases/121_system_schema_cache.sql @@ -0,0 +1 @@ +SYSTEM DROP SCHEMA CACHE FOR S3 diff --git a/tests/ast_json_fixtures/cases/122_system_wait_failpoint.json b/tests/ast_json_fixtures/cases/122_system_wait_failpoint.json new file mode 100644 index 000000000000..4286f2940cf2 --- /dev/null +++ b/tests/ast_json_fixtures/cases/122_system_wait_failpoint.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "WAIT FAILPOINT", + "fail_point_name": "fp", + "fail_point_action": "PAUSE" + } +} diff --git a/tests/ast_json_fixtures/cases/122_system_wait_failpoint.sql b/tests/ast_json_fixtures/cases/122_system_wait_failpoint.sql new file mode 100644 index 000000000000..1aef90949ac4 --- /dev/null +++ b/tests/ast_json_fixtures/cases/122_system_wait_failpoint.sql @@ -0,0 +1 @@ +SYSTEM WAIT FAILPOINT fp PAUSE diff --git a/tests/ast_json_fixtures/cases/123_system_fake_time.json b/tests/ast_json_fixtures/cases/123_system_fake_time.json new file mode 100644 index 000000000000..a8e063957636 --- /dev/null +++ b/tests/ast_json_fixtures/cases/123_system_fake_time.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "TEST VIEW", + "database": { + "type": "Identifier", + "name": "db" + }, + "table": { + "type": "Identifier", + "name": "v" + }, + "fake_time_for_view": "1609477200" + } +} diff --git a/tests/ast_json_fixtures/cases/123_system_fake_time.sql b/tests/ast_json_fixtures/cases/123_system_fake_time.sql new file mode 100644 index 000000000000..6c664485dce0 --- /dev/null +++ b/tests/ast_json_fixtures/cases/123_system_fake_time.sql @@ -0,0 +1 @@ +SYSTEM TEST VIEW db.v SET FAKE TIME '2021-01-01 00:00:00' diff --git a/tests/ast_json_fixtures/cases/124_named_collection_value_types.json b/tests/ast_json_fixtures/cases/124_named_collection_value_types.json new file mode 100644 index 000000000000..63d63cf0431a --- /dev/null +++ b/tests/ast_json_fixtures/cases/124_named_collection_value_types.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "CreateNamedCollectionQuery", + "collection_name": "nc", + "changes": { + "i": { + "value_type": "UInt64", + "value": "5" + }, + "s": { + "value_type": "String", + "value": "5" + }, + "neg": { + "value_type": "Int64", + "value": "-5" + }, + "one": { + "value_type": "Float64", + "value": 1 + }, + "half": { + "value_type": "Float64", + "value": 2.5 + }, + "fn": { + "value_type": "CustomType", + "value": "disk(type = 'local')" + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/124_named_collection_value_types.sql b/tests/ast_json_fixtures/cases/124_named_collection_value_types.sql new file mode 100644 index 000000000000..7cde6c9f7a85 --- /dev/null +++ b/tests/ast_json_fixtures/cases/124_named_collection_value_types.sql @@ -0,0 +1 @@ +CREATE NAMED COLLECTION nc AS i = 5, s = '5', neg = -5, one = 1.0, half = 2.5, fn = disk(type = 'local') diff --git a/tests/ast_json_fixtures/cases/125_workload_value_types.json b/tests/ast_json_fixtures/cases/125_workload_value_types.json new file mode 100644 index 000000000000..45f4177a6fce --- /dev/null +++ b/tests/ast_json_fixtures/cases/125_workload_value_types.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateWorkloadQuery", + "workload_name": { + "type": "Identifier", + "name": "w" + }, + "changes": [ + { + "name": "max_requests", + "value": { + "value_type": "UInt64", + "value": "100" + } + }, + { + "name": "max_cost", + "value": { + "value_type": "Float64", + "value": 1.5 + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/125_workload_value_types.sql b/tests/ast_json_fixtures/cases/125_workload_value_types.sql new file mode 100644 index 000000000000..54ffe7ee329d --- /dev/null +++ b/tests/ast_json_fixtures/cases/125_workload_value_types.sql @@ -0,0 +1 @@ +CREATE WORKLOAD w SETTINGS max_requests = 100, max_cost = 1.5 diff --git a/tests/ast_json_fixtures/cases/12_window_inline.json b/tests/ast_json_fixtures/cases/12_window_inline.json new file mode 100644 index 000000000000..1b64413bd934 --- /dev/null +++ b/tests/ast_json_fixtures/cases/12_window_inline.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "g" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "frame_type": "ROWS", + "frame_begin": { + "type": "Offset", + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "preceding": true + }, + "frame_end": { + "type": "Current" + } + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/12_window_inline.sql b/tests/ast_json_fixtures/cases/12_window_inline.sql new file mode 100644 index 000000000000..bf4be97c4f03 --- /dev/null +++ b/tests/ast_json_fixtures/cases/12_window_inline.sql @@ -0,0 +1 @@ +SELECT sum(x) OVER (PARTITION BY g ORDER BY x ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t diff --git a/tests/ast_json_fixtures/cases/13_select_star.json b/tests/ast_json_fixtures/cases/13_select_star.json new file mode 100644 index 000000000000..7c8c16091afd --- /dev/null +++ b/tests/ast_json_fixtures/cases/13_select_star.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "foo" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/13_select_star.sql b/tests/ast_json_fixtures/cases/13_select_star.sql new file mode 100644 index 000000000000..585e65777488 --- /dev/null +++ b/tests/ast_json_fixtures/cases/13_select_star.sql @@ -0,0 +1 @@ +SELECT * FROM foo WHERE x = 1 diff --git a/tests/ast_json_fixtures/cases/14_distinct.json b/tests/ast_json_fixtures/cases/14_distinct.json new file mode 100644 index 000000000000..55eb6e858543 --- /dev/null +++ b/tests/ast_json_fixtures/cases/14_distinct.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/14_distinct.sql b/tests/ast_json_fixtures/cases/14_distinct.sql new file mode 100644 index 000000000000..ec7947b3b693 --- /dev/null +++ b/tests/ast_json_fixtures/cases/14_distinct.sql @@ -0,0 +1 @@ +SELECT DISTINCT a, b FROM t diff --git a/tests/ast_json_fixtures/cases/15_group_by_rollup.json b/tests/ast_json_fixtures/cases/15_group_by_rollup.json new file mode 100644 index 000000000000..70a7c27b033f --- /dev/null +++ b/tests/ast_json_fixtures/cases/15_group_by_rollup.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Identifier", + "name": "g" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "g" + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/15_group_by_rollup.sql b/tests/ast_json_fixtures/cases/15_group_by_rollup.sql new file mode 100644 index 000000000000..7586d02599a9 --- /dev/null +++ b/tests/ast_json_fixtures/cases/15_group_by_rollup.sql @@ -0,0 +1 @@ +SELECT g, count() FROM t GROUP BY g WITH ROLLUP HAVING count() > 1 diff --git a/tests/ast_json_fixtures/cases/16_grouping_sets.json b/tests/ast_json_fixtures/cases/16_grouping_sets.json new file mode 100644 index 000000000000..cad09815054c --- /dev/null +++ b/tests/ast_json_fixtures/cases/16_grouping_sets.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "y" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/16_grouping_sets.sql b/tests/ast_json_fixtures/cases/16_grouping_sets.sql new file mode 100644 index 000000000000..46ae2b1a6884 --- /dev/null +++ b/tests/ast_json_fixtures/cases/16_grouping_sets.sql @@ -0,0 +1 @@ +SELECT x FROM t GROUP BY GROUPING SETS ((x), (y)) diff --git a/tests/ast_json_fixtures/cases/17_qualify.json b/tests/ast_json_fixtures/cases/17_qualify.json new file mode 100644 index 000000000000..ba85e705c3a6 --- /dev/null +++ b/tests/ast_json_fixtures/cases/17_qualify.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "alias": "r", + "name": "row_number", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "r" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/17_qualify.sql b/tests/ast_json_fixtures/cases/17_qualify.sql new file mode 100644 index 000000000000..ad34263d3f7f --- /dev/null +++ b/tests/ast_json_fixtures/cases/17_qualify.sql @@ -0,0 +1 @@ +SELECT x, row_number() OVER (ORDER BY x) AS r FROM t QUALIFY r = 1 diff --git a/tests/ast_json_fixtures/cases/18_order_by_fill.json b/tests/ast_json_fixtures/cases/18_order_by_fill.json new file mode 100644 index 000000000000..902bcc19fd46 --- /dev/null +++ b/tests/ast_json_fixtures/cases/18_order_by_fill.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "DESC", + "nulls_first": false, + "with_fill": true, + "fill_from": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "fill_to": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "fill_step": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "interpolate": [ + { + "type": "InterpolateElement", + "column": "x", + "expr": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/18_order_by_fill.sql b/tests/ast_json_fixtures/cases/18_order_by_fill.sql new file mode 100644 index 000000000000..b3e0e3c737cd --- /dev/null +++ b/tests/ast_json_fixtures/cases/18_order_by_fill.sql @@ -0,0 +1 @@ +SELECT x FROM t ORDER BY x DESC NULLS LAST WITH FILL FROM 0 TO 10 STEP 2 INTERPOLATE (x AS x + 1) diff --git a/tests/ast_json_fixtures/cases/18b_order_by_multikey.json b/tests/ast_json_fixtures/cases/18b_order_by_multikey.json new file mode 100644 index 000000000000..bf01bccc7f2c --- /dev/null +++ b/tests/ast_json_fixtures/cases/18b_order_by_multikey.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/18b_order_by_multikey.sql b/tests/ast_json_fixtures/cases/18b_order_by_multikey.sql new file mode 100644 index 000000000000..92d775baa521 --- /dev/null +++ b/tests/ast_json_fixtures/cases/18b_order_by_multikey.sql @@ -0,0 +1 @@ +SELECT x FROM t ORDER BY a, b diff --git a/tests/ast_json_fixtures/cases/18c_order_by_tuple_key.json b/tests/ast_json_fixtures/cases/18c_order_by_tuple_key.json new file mode 100644 index 000000000000..4dafaa21e1f3 --- /dev/null +++ b/tests/ast_json_fixtures/cases/18c_order_by_tuple_key.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/18c_order_by_tuple_key.sql b/tests/ast_json_fixtures/cases/18c_order_by_tuple_key.sql new file mode 100644 index 000000000000..bf00dd64a0d3 --- /dev/null +++ b/tests/ast_json_fixtures/cases/18c_order_by_tuple_key.sql @@ -0,0 +1 @@ +SELECT x FROM t ORDER BY tuple(a, b) diff --git a/tests/ast_json_fixtures/cases/19_limits.json b/tests/ast_json_fixtures/cases/19_limits.json new file mode 100644 index 000000000000..2ec9d90a34b5 --- /dev/null +++ b/tests/ast_json_fixtures/cases/19_limits.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "by": [ + { + "type": "Identifier", + "name": "g" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/19_limits.sql b/tests/ast_json_fixtures/cases/19_limits.sql new file mode 100644 index 000000000000..f613c334a86f --- /dev/null +++ b/tests/ast_json_fixtures/cases/19_limits.sql @@ -0,0 +1 @@ +SELECT x FROM t ORDER BY x LIMIT 5 BY g LIMIT 100 OFFSET 10 diff --git a/tests/ast_json_fixtures/cases/19b_limit_with_ties.json b/tests/ast_json_fixtures/cases/19b_limit_with_ties.json new file mode 100644 index 000000000000..175b61b5727a --- /dev/null +++ b/tests/ast_json_fixtures/cases/19b_limit_with_ties.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "limit_with_ties": true, + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/19b_limit_with_ties.sql b/tests/ast_json_fixtures/cases/19b_limit_with_ties.sql new file mode 100644 index 000000000000..97b121c90c81 --- /dev/null +++ b/tests/ast_json_fixtures/cases/19b_limit_with_ties.sql @@ -0,0 +1 @@ +SELECT x FROM t ORDER BY x DESC LIMIT 3 WITH TIES diff --git a/tests/ast_json_fixtures/cases/20_settings.json b/tests/ast_json_fixtures/cases/20_settings.json new file mode 100644 index 000000000000..26feb470569b --- /dev/null +++ b/tests/ast_json_fixtures/cases/20_settings.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "4", + "max_block_size": "1000" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/20_settings.sql b/tests/ast_json_fixtures/cases/20_settings.sql new file mode 100644 index 000000000000..004f4829d556 --- /dev/null +++ b/tests/ast_json_fixtures/cases/20_settings.sql @@ -0,0 +1 @@ +SELECT 1 SETTINGS max_threads = 4, max_block_size = 1000 diff --git a/tests/ast_json_fixtures/cases/21_join_on.json b/tests/ast_json_fixtures/cases/21_join_on.json new file mode 100644 index 000000000000..8db168801916 --- /dev/null +++ b/tests/ast_json_fixtures/cases/21_join_on.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.x", + "name_parts": ["a", "x"] + }, + { + "type": "Identifier", + "name": "b.x", + "name_parts": ["b", "x"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "b" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/21_join_on.sql b/tests/ast_json_fixtures/cases/21_join_on.sql new file mode 100644 index 000000000000..85810e4e5b2f --- /dev/null +++ b/tests/ast_json_fixtures/cases/21_join_on.sql @@ -0,0 +1 @@ +SELECT * FROM a INNER JOIN b ON a.x = b.x diff --git a/tests/ast_json_fixtures/cases/22_join_using.json b/tests/ast_json_fixtures/cases/22_join_using.json new file mode 100644 index 000000000000..b1b702f78e0d --- /dev/null +++ b/tests/ast_json_fixtures/cases/22_join_using.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "using": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "b" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/22_join_using.sql b/tests/ast_json_fixtures/cases/22_join_using.sql new file mode 100644 index 000000000000..b0a6aa6b7ea0 --- /dev/null +++ b/tests/ast_json_fixtures/cases/22_join_using.sql @@ -0,0 +1 @@ +SELECT * FROM a LEFT JOIN b USING (x, y) diff --git a/tests/ast_json_fixtures/cases/23_join_global_any.json b/tests/ast_json_fixtures/cases/23_join_global_any.json new file mode 100644 index 000000000000..e21f9cf205fc --- /dev/null +++ b/tests/ast_json_fixtures/cases/23_join_global_any.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "strictness": "ANY", + "locality": "GLOBAL", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.x", + "name_parts": ["a", "x"] + }, + { + "type": "Identifier", + "name": "b.x", + "name_parts": ["b", "x"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "b" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/23_join_global_any.sql b/tests/ast_json_fixtures/cases/23_join_global_any.sql new file mode 100644 index 000000000000..68d3985a4020 --- /dev/null +++ b/tests/ast_json_fixtures/cases/23_join_global_any.sql @@ -0,0 +1 @@ +SELECT * FROM a GLOBAL ANY INNER JOIN b ON a.x = b.x diff --git a/tests/ast_json_fixtures/cases/24_cross_comma.json b/tests/ast_json_fixtures/cases/24_cross_comma.json new file mode 100644 index 000000000000..82d0df296934 --- /dev/null +++ b/tests/ast_json_fixtures/cases/24_cross_comma.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "CROSS" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "b" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "c" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/24_cross_comma.sql b/tests/ast_json_fixtures/cases/24_cross_comma.sql new file mode 100644 index 000000000000..2f6442207761 --- /dev/null +++ b/tests/ast_json_fixtures/cases/24_cross_comma.sql @@ -0,0 +1 @@ +SELECT * FROM a CROSS JOIN b, c diff --git a/tests/ast_json_fixtures/cases/25_array_join.json b/tests/ast_json_fixtures/cases/25_array_join.json new file mode 100644 index 000000000000..05a5ec2bc02d --- /dev/null +++ b/tests/ast_json_fixtures/cases/25_array_join.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "LEFT", + "expressions": [ + { + "type": "Identifier", + "alias": "e", + "name": "arr" + }, + { + "type": "Identifier", + "name": "other" + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/25_array_join.sql b/tests/ast_json_fixtures/cases/25_array_join.sql new file mode 100644 index 000000000000..3f6f25d64cfc --- /dev/null +++ b/tests/ast_json_fixtures/cases/25_array_join.sql @@ -0,0 +1 @@ +SELECT * FROM t LEFT ARRAY JOIN arr AS e, other diff --git a/tests/ast_json_fixtures/cases/26_table_function.json b/tests/ast_json_fixtures/cases/26_table_function.json new file mode 100644 index 000000000000..92bb506dc550 --- /dev/null +++ b/tests/ast_json_fixtures/cases/26_table_function.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/26_table_function.sql b/tests/ast_json_fixtures/cases/26_table_function.sql new file mode 100644 index 000000000000..3b99fc0ce521 --- /dev/null +++ b/tests/ast_json_fixtures/cases/26_table_function.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(5) diff --git a/tests/ast_json_fixtures/cases/27_subquery_from.json b/tests/ast_json_fixtures/cases/27_subquery_from.json new file mode 100644 index 000000000000..adb0b706f773 --- /dev/null +++ b/tests/ast_json_fixtures/cases/27_subquery_from.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/27_subquery_from.sql b/tests/ast_json_fixtures/cases/27_subquery_from.sql new file mode 100644 index 000000000000..271418e3f0e0 --- /dev/null +++ b/tests/ast_json_fixtures/cases/27_subquery_from.sql @@ -0,0 +1 @@ +SELECT * FROM (SELECT 1 AS a) diff --git a/tests/ast_json_fixtures/cases/28_sample_final.json b/tests/ast_json_fixtures/cases/28_sample_final.json new file mode 100644 index 000000000000..00edc7d5cbc5 --- /dev/null +++ b/tests/ast_json_fixtures/cases/28_sample_final.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tbl" + }, + "final": true, + "sample_size": { + "type": "SampleRatio", + "numerator": "1", + "denominator": "10" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/28_sample_final.sql b/tests/ast_json_fixtures/cases/28_sample_final.sql new file mode 100644 index 000000000000..096a358663f1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/28_sample_final.sql @@ -0,0 +1 @@ +SELECT * FROM tbl FINAL SAMPLE 1/10 diff --git a/tests/ast_json_fixtures/cases/29_cte.json b/tests/ast_json_fixtures/cases/29_cte.json new file mode 100644 index 000000000000..972eeea99015 --- /dev/null +++ b/tests/ast_json_fixtures/cases/29_cte.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "cte", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "cte" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/29_cte.sql b/tests/ast_json_fixtures/cases/29_cte.sql new file mode 100644 index 000000000000..ae9011dbc5e4 --- /dev/null +++ b/tests/ast_json_fixtures/cases/29_cte.sql @@ -0,0 +1 @@ +WITH cte AS (SELECT 1 AS a) SELECT a FROM cte diff --git a/tests/ast_json_fixtures/cases/30_scalar_with.json b/tests/ast_json_fixtures/cases/30_scalar_with.json new file mode 100644 index 000000000000..1dfa39006308 --- /dev/null +++ b/tests/ast_json_fixtures/cases/30_scalar_with.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "m", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "m" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/30_scalar_with.sql b/tests/ast_json_fixtures/cases/30_scalar_with.sql new file mode 100644 index 000000000000..c6ffce83a251 --- /dev/null +++ b/tests/ast_json_fixtures/cases/30_scalar_with.sql @@ -0,0 +1 @@ +WITH (SELECT max(n) FROM t) AS m SELECT m diff --git a/tests/ast_json_fixtures/cases/31_union_all.json b/tests/ast_json_fixtures/cases/31_union_all.json new file mode 100644 index 000000000000..b24ca7588841 --- /dev/null +++ b/tests/ast_json_fixtures/cases/31_union_all.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/31_union_all.sql b/tests/ast_json_fixtures/cases/31_union_all.sql new file mode 100644 index 000000000000..7679fc93b191 --- /dev/null +++ b/tests/ast_json_fixtures/cases/31_union_all.sql @@ -0,0 +1 @@ +SELECT 1 UNION ALL SELECT 2 diff --git a/tests/ast_json_fixtures/cases/32_union_distinct.json b/tests/ast_json_fixtures/cases/32_union_distinct.json new file mode 100644 index 000000000000..238c5dd4b4d1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/32_union_distinct.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_DISTINCT", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/32_union_distinct.sql b/tests/ast_json_fixtures/cases/32_union_distinct.sql new file mode 100644 index 000000000000..469dfc5b2620 --- /dev/null +++ b/tests/ast_json_fixtures/cases/32_union_distinct.sql @@ -0,0 +1 @@ +SELECT 1 UNION DISTINCT SELECT 2 diff --git a/tests/ast_json_fixtures/cases/33_intersect.json b/tests/ast_json_fixtures/cases/33_intersect.json new file mode 100644 index 000000000000..c402f4af04d5 --- /dev/null +++ b/tests/ast_json_fixtures/cases/33_intersect.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "INTERSECT ALL", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/33_intersect.sql b/tests/ast_json_fixtures/cases/33_intersect.sql new file mode 100644 index 000000000000..75d49c11f20e --- /dev/null +++ b/tests/ast_json_fixtures/cases/33_intersect.sql @@ -0,0 +1 @@ +SELECT 1 INTERSECT SELECT 2 diff --git a/tests/ast_json_fixtures/cases/34_except.json b/tests/ast_json_fixtures/cases/34_except.json new file mode 100644 index 000000000000..3a5aa45ed25d --- /dev/null +++ b/tests/ast_json_fixtures/cases/34_except.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "EXCEPT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/34_except.sql b/tests/ast_json_fixtures/cases/34_except.sql new file mode 100644 index 000000000000..94c30037d85b --- /dev/null +++ b/tests/ast_json_fixtures/cases/34_except.sql @@ -0,0 +1 @@ +SELECT 1 EXCEPT SELECT 2 diff --git a/tests/ast_json_fixtures/cases/35_qualified_star.json b/tests/ast_json_fixtures/cases/35_qualified_star.json new file mode 100644 index 000000000000..01c5bd93b32f --- /dev/null +++ b/tests/ast_json_fixtures/cases/35_qualified_star.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/35_qualified_star.sql b/tests/ast_json_fixtures/cases/35_qualified_star.sql new file mode 100644 index 000000000000..27b4fe798401 --- /dev/null +++ b/tests/ast_json_fixtures/cases/35_qualified_star.sql @@ -0,0 +1 @@ +SELECT t.* FROM t diff --git a/tests/ast_json_fixtures/cases/36_except_transform.json b/tests/ast_json_fixtures/cases/36_except_transform.json new file mode 100644 index 000000000000..e708faacdee5 --- /dev/null +++ b/tests/ast_json_fixtures/cases/36_except_transform.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk", + "transformers": [ + { + "type": "ColumnsExceptTransformer", + "columns": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/36_except_transform.sql b/tests/ast_json_fixtures/cases/36_except_transform.sql new file mode 100644 index 000000000000..f21a8421b640 --- /dev/null +++ b/tests/ast_json_fixtures/cases/36_except_transform.sql @@ -0,0 +1 @@ +SELECT * EXCEPT (a, b) FROM t diff --git a/tests/ast_json_fixtures/cases/36b_except_pattern.json b/tests/ast_json_fixtures/cases/36b_except_pattern.json new file mode 100644 index 000000000000..6dc48ff436ba --- /dev/null +++ b/tests/ast_json_fixtures/cases/36b_except_pattern.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk", + "transformers": [ + { + "type": "ColumnsExceptTransformer", + "pattern": "a.*" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/36b_except_pattern.sql b/tests/ast_json_fixtures/cases/36b_except_pattern.sql new file mode 100644 index 000000000000..4208afca26a4 --- /dev/null +++ b/tests/ast_json_fixtures/cases/36b_except_pattern.sql @@ -0,0 +1 @@ +SELECT * EXCEPT 'a.*' FROM t diff --git a/tests/ast_json_fixtures/cases/37_apply_transform.json b/tests/ast_json_fixtures/cases/37_apply_transform.json new file mode 100644 index 000000000000..b1f4251a4637 --- /dev/null +++ b/tests/ast_json_fixtures/cases/37_apply_transform.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk", + "transformers": [ + { + "type": "ColumnsApplyTransformer", + "func_name": "sum" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/37_apply_transform.sql b/tests/ast_json_fixtures/cases/37_apply_transform.sql new file mode 100644 index 000000000000..625e0bfb2ca6 --- /dev/null +++ b/tests/ast_json_fixtures/cases/37_apply_transform.sql @@ -0,0 +1 @@ +SELECT * APPLY(sum) FROM t diff --git a/tests/ast_json_fixtures/cases/38_replace_transform.json b/tests/ast_json_fixtures/cases/38_replace_transform.json new file mode 100644 index 000000000000..b660a10d0c67 --- /dev/null +++ b/tests/ast_json_fixtures/cases/38_replace_transform.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk", + "transformers": [ + { + "type": "ColumnsReplaceTransformer", + "replacements": [ + { + "type": "ColumnsReplaceTransformer::Replacement", + "name": "y", + "expression": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/38_replace_transform.sql b/tests/ast_json_fixtures/cases/38_replace_transform.sql new file mode 100644 index 000000000000..fb6d0bad8e45 --- /dev/null +++ b/tests/ast_json_fixtures/cases/38_replace_transform.sql @@ -0,0 +1 @@ +SELECT * REPLACE (x + 1 AS y) FROM t diff --git a/tests/ast_json_fixtures/cases/39_columns_regexp.json b/tests/ast_json_fixtures/cases/39_columns_regexp.json new file mode 100644 index 000000000000..bd6896efc606 --- /dev/null +++ b/tests/ast_json_fixtures/cases/39_columns_regexp.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "ColumnsRegexpMatcher", + "pattern": "a.*" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/39_columns_regexp.sql b/tests/ast_json_fixtures/cases/39_columns_regexp.sql new file mode 100644 index 000000000000..aade522ae8bb --- /dev/null +++ b/tests/ast_json_fixtures/cases/39_columns_regexp.sql @@ -0,0 +1 @@ +SELECT COLUMNS('a.*') FROM t diff --git a/tests/ast_json_fixtures/cases/40_columns_list.json b/tests/ast_json_fixtures/cases/40_columns_list.json new file mode 100644 index 000000000000..d62c80b7fa0f --- /dev/null +++ b/tests/ast_json_fixtures/cases/40_columns_list.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "ColumnsListMatcher", + "columns": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/40_columns_list.sql b/tests/ast_json_fixtures/cases/40_columns_list.sql new file mode 100644 index 000000000000..96e082ecec46 --- /dev/null +++ b/tests/ast_json_fixtures/cases/40_columns_list.sql @@ -0,0 +1 @@ +SELECT COLUMNS(a, b) FROM t diff --git a/tests/ast_json_fixtures/cases/41_showcase.json b/tests/ast_json_fixtures/cases/41_showcase.json new file mode 100644 index 000000000000..a27a51d57a6a --- /dev/null +++ b/tests/ast_json_fixtures/cases/41_showcase.json @@ -0,0 +1,681 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "group_by_with_rollup": true, + "with": [ + { + "type": "WithElement", + "name": "recent", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "n", + "name": "number" + }, + { + "type": "Function", + "alias": "g", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } + } + }, + { + "type": "Subquery", + "alias": "max_n", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recent" + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "alias": "grp", + "name": "a.g", + "name_parts": ["a", "g"] + }, + { + "type": "Function", + "alias": "total", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Identifier", + "name": "b.v", + "name_parts": ["b", "v"] + } + ] + }, + { + "type": "Function", + "alias": "scaled", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e" + }, + { + "type": "Identifier", + "name": "max_n" + } + ] + } + ] + }, + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "running", + "name": "sum", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "b.v", + "name_parts": ["b", "v"] + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "a.g", + "name_parts": ["a", "g"] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + "direction": "ASC" + } + ], + "frame_type": "ROWS", + "frame_begin": { + "type": "Offset", + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "preceding": true + }, + "frame_end": { + "type": "Current" + } + } + }, + { + "type": "Function", + "alias": "cnt", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Asterisk" + } + ], + "window_name": "w" + }, + { + "type": "Function", + "alias": "bucket", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "hi" + }, + { + "type": "Literal", + "value_type": "String", + "value": "lo" + } + ] + }, + { + "type": "Function", + "alias": "nf", + "name": "CAST", + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Float64" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "a", + "name": "recent" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Identifier", + "name": "b.n", + "name_parts": ["b", "n"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "b", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Function", + "alias": "v", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recent" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recent" + } + } + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b.v", + "name_parts": ["b", "v"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b.v", + "name_parts": ["b", "v"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a.g", + "name_parts": ["a", "g"] + }, + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "b.v", + "name_parts": ["b", "v"] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "a.g", + "name_parts": ["a", "g"] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + "direction": "DESC" + } + ] + } + } + ], + "qualify": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "running" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "total" + }, + "direction": "DESC", + "nulls_first": false, + "with_fill": true, + "fill_from": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "fill_to": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + "fill_step": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "4" + } + }, + "interpolate": [ + { + "type": "InterpolateElement", + "column": "nf", + "expr": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "nf" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "by": [ + { + "type": "Identifier", + "name": "a.g", + "name_parts": ["a", "g"] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/41_showcase.sql b/tests/ast_json_fixtures/cases/41_showcase.sql new file mode 100644 index 000000000000..736593d4a501 --- /dev/null +++ b/tests/ast_json_fixtures/cases/41_showcase.sql @@ -0,0 +1 @@ +WITH recent AS (SELECT number AS n, number % 3 AS g FROM numbers(100) WHERE number > 1), (SELECT max(n) FROM recent) AS max_n SELECT DISTINCT a.g AS grp, a.n + b.v AS total, arrayMap(e -> e * max_n, groupArray(a.n)) AS scaled, sum(b.v) OVER (PARTITION BY a.g ORDER BY a.n ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS running, count(*) OVER w AS cnt, CASE WHEN a.n > 10 THEN 'hi' ELSE 'lo' END AS bucket, CAST(a.n AS Float64) AS nf FROM recent AS a INNER JOIN (SELECT n, n * 2 AS v FROM recent) AS b ON a.n = b.n PREWHERE a.n != 0 WHERE a.n IN (SELECT n FROM recent) AND b.v BETWEEN 1 AND 1000 GROUP BY a.g, a.n WITH ROLLUP HAVING sum(b.v) > 10 WINDOW w AS (PARTITION BY a.g ORDER BY a.n DESC) QUALIFY running >= 0 ORDER BY total DESC NULLS LAST WITH FILL FROM 0 TO 100 STEP 10 INTERPOLATE (nf AS nf + 1) LIMIT 5 BY a.g LIMIT 100 OFFSET 10 SETTINGS max_threads = 4 diff --git a/tests/ast_json_fixtures/cases/42_alter_move_partition.json b/tests/ast_json_fixtures/cases/42_alter_move_partition.json new file mode 100644 index 000000000000..099d1f5ee33f --- /dev/null +++ b/tests/ast_json_fixtures/cases/42_alter_move_partition.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "p" + } + }, + "move_destination_type": "DISK", + "move_destination_name": "fast" + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/42_alter_move_partition.sql b/tests/ast_json_fixtures/cases/42_alter_move_partition.sql new file mode 100644 index 000000000000..6ae57a9c9b58 --- /dev/null +++ b/tests/ast_json_fixtures/cases/42_alter_move_partition.sql @@ -0,0 +1 @@ +ALTER TABLE t MOVE PARTITION 'p' TO DISK 'fast' diff --git a/tests/ast_json_fixtures/cases/43_alter_clear_statistics.json b/tests/ast_json_fixtures/cases/43_alter_clear_statistics.json new file mode 100644 index 000000000000..d8c025362010 --- /dev/null +++ b/tests/ast_json_fixtures/cases/43_alter_clear_statistics.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_STATISTICS", + "clear_statistics": true, + "statistics_declaration": { + "type": "Stat", + "columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "s" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/43_alter_clear_statistics.sql b/tests/ast_json_fixtures/cases/43_alter_clear_statistics.sql new file mode 100644 index 000000000000..c36fd277e669 --- /dev/null +++ b/tests/ast_json_fixtures/cases/43_alter_clear_statistics.sql @@ -0,0 +1 @@ +ALTER TABLE t CLEAR STATISTICS s diff --git a/tests/ast_json_fixtures/cases/44_alter_freeze_with_name.json b/tests/ast_json_fixtures/cases/44_alter_freeze_with_name.json new file mode 100644 index 000000000000..8cc2b1c9f961 --- /dev/null +++ b/tests/ast_json_fixtures/cases/44_alter_freeze_with_name.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "FREEZE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "p" + } + }, + "with_name": "backup1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/44_alter_freeze_with_name.sql b/tests/ast_json_fixtures/cases/44_alter_freeze_with_name.sql new file mode 100644 index 000000000000..5c7d6707f3f9 --- /dev/null +++ b/tests/ast_json_fixtures/cases/44_alter_freeze_with_name.sql @@ -0,0 +1 @@ +ALTER TABLE t FREEZE PARTITION 'p' WITH NAME 'backup1' diff --git a/tests/ast_json_fixtures/cases/45_alter_replace_partition.json b/tests/ast_json_fixtures/cases/45_alter_replace_partition.json new file mode 100644 index 000000000000..9744ff301e4a --- /dev/null +++ b/tests/ast_json_fixtures/cases/45_alter_replace_partition.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "p" + } + }, + "replace": true, + "from_table": "src" + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/45_alter_replace_partition.sql b/tests/ast_json_fixtures/cases/45_alter_replace_partition.sql new file mode 100644 index 000000000000..e6718841f244 --- /dev/null +++ b/tests/ast_json_fixtures/cases/45_alter_replace_partition.sql @@ -0,0 +1 @@ +ALTER TABLE t REPLACE PARTITION 'p' FROM src diff --git a/tests/ast_json_fixtures/cases/45b_alter_attach_partition.json b/tests/ast_json_fixtures/cases/45b_alter_attach_partition.json new file mode 100644 index 000000000000..26be407032dd --- /dev/null +++ b/tests/ast_json_fixtures/cases/45b_alter_attach_partition.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "p" + } + }, + "replace": false, + "from_table": "src" + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/45b_alter_attach_partition.sql b/tests/ast_json_fixtures/cases/45b_alter_attach_partition.sql new file mode 100644 index 000000000000..413cece8c663 --- /dev/null +++ b/tests/ast_json_fixtures/cases/45b_alter_attach_partition.sql @@ -0,0 +1 @@ +ALTER TABLE t ATTACH PARTITION 'p' FROM src diff --git a/tests/ast_json_fixtures/cases/46_alter_unlock_snapshot.json b/tests/ast_json_fixtures/cases/46_alter_unlock_snapshot.json new file mode 100644 index 000000000000..2efcbb7cd1f3 --- /dev/null +++ b/tests/ast_json_fixtures/cases/46_alter_unlock_snapshot.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "UNLOCK_SNAPSHOT", + "snapshot_name": "snap" + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/46_alter_unlock_snapshot.sql b/tests/ast_json_fixtures/cases/46_alter_unlock_snapshot.sql new file mode 100644 index 000000000000..b6a4ccf65285 --- /dev/null +++ b/tests/ast_json_fixtures/cases/46_alter_unlock_snapshot.sql @@ -0,0 +1 @@ +ALTER TABLE t UNLOCK SNAPSHOT 'snap' diff --git a/tests/ast_json_fixtures/cases/47_grant.json b/tests/ast_json_fixtures/cases/47_grant.json new file mode 100644 index 000000000000..00fdcbdeb84e --- /dev/null +++ b/tests/ast_json_fixtures/cases/47_grant.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "db", + "table": "t", + "columns": ["x", "y"], + "grant_option": true + }, + { + "access_types": ["INSERT"], + "database": "db", + "table": "t", + "grant_option": true + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["user1"] + } + } +} diff --git a/tests/ast_json_fixtures/cases/47_grant.sql b/tests/ast_json_fixtures/cases/47_grant.sql new file mode 100644 index 000000000000..3c889403a727 --- /dev/null +++ b/tests/ast_json_fixtures/cases/47_grant.sql @@ -0,0 +1 @@ +GRANT SELECT(x, y), INSERT ON db.t TO user1 WITH GRANT OPTION diff --git a/tests/ast_json_fixtures/cases/48_grant_role.json b/tests/ast_json_fixtures/cases/48_grant_role.json new file mode 100644 index 000000000000..283591f734b3 --- /dev/null +++ b/tests/ast_json_fixtures/cases/48_grant_role.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "admin_option": true, + "roles": { + "type": "RolesOrUsersSet", + "names": ["role1"] + }, + "grantees": { + "type": "RolesOrUsersSet", + "names": ["user1"] + } + } +} diff --git a/tests/ast_json_fixtures/cases/48_grant_role.sql b/tests/ast_json_fixtures/cases/48_grant_role.sql new file mode 100644 index 000000000000..b71e6eeadc1c --- /dev/null +++ b/tests/ast_json_fixtures/cases/48_grant_role.sql @@ -0,0 +1 @@ +GRANT role1 TO user1 WITH ADMIN OPTION diff --git a/tests/ast_json_fixtures/cases/49_revoke.json b/tests/ast_json_fixtures/cases/49_revoke.json new file mode 100644 index 000000000000..abf5f81f48da --- /dev/null +++ b/tests/ast_json_fixtures/cases/49_revoke.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "RevokeQuery", + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "db", + "table": "t" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["user1"] + } + } +} diff --git a/tests/ast_json_fixtures/cases/49_revoke.sql b/tests/ast_json_fixtures/cases/49_revoke.sql new file mode 100644 index 000000000000..4674029b7ca2 --- /dev/null +++ b/tests/ast_json_fixtures/cases/49_revoke.sql @@ -0,0 +1 @@ +REVOKE SELECT ON db.t FROM ALL EXCEPT user1 diff --git a/tests/ast_json_fixtures/cases/50_create_user.json b/tests/ast_json_fixtures/cases/50_create_user.json new file mode 100644 index 000000000000..343174e092cd --- /dev/null +++ b/tests/ast_json_fixtures/cases/50_create_user.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "SHA256_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "secret" + } + ] + } + ], + "replace_authentication_methods": true, + "hosts": { + "local_host": true + }, + "default_roles": { + "type": "RolesOrUsersSet", + "names": ["r1"] + }, + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_threads", + "value": "4", + "writability": "CONST" + } + ] + }, + "grantees": { + "type": "RolesOrUsersSet", + "all": true, + "use_keyword_any": true + } + } +} diff --git a/tests/ast_json_fixtures/cases/50_create_user.sql b/tests/ast_json_fixtures/cases/50_create_user.sql new file mode 100644 index 000000000000..ce0808c1d5fa --- /dev/null +++ b/tests/ast_json_fixtures/cases/50_create_user.sql @@ -0,0 +1 @@ +CREATE USER u IDENTIFIED WITH sha256_password BY 'secret' HOST IP '127.0.0.1' DEFAULT ROLE r1 SETTINGS max_threads = 4 READONLY GRANTEES ANY diff --git a/tests/ast_json_fixtures/cases/51_alter_user.json b/tests/ast_json_fixtures/cases/51_alter_user.json new file mode 100644 index 000000000000..3513f3822310 --- /dev/null +++ b/tests/ast_json_fixtures/cases/51_alter_user.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u" + } + ] + }, + "new_name": "u2", + "add_hosts": { + "subnets": ["10.0.0.0\/8"] + }, + "alter_settings": { + "type": "AlterSettingsProfileElements", + "drop_settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_threads" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/51_alter_user.sql b/tests/ast_json_fixtures/cases/51_alter_user.sql new file mode 100644 index 000000000000..32ba99e25f64 --- /dev/null +++ b/tests/ast_json_fixtures/cases/51_alter_user.sql @@ -0,0 +1 @@ +ALTER USER u RENAME TO u2 ADD HOST IP '10.0.0.0/8' DROP SETTINGS max_threads diff --git a/tests/ast_json_fixtures/cases/52_create_role.json b/tests/ast_json_fixtures/cases/52_create_role.json new file mode 100644 index 000000000000..65c29195cdb1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/52_create_role.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_threads", + "value": "2" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/cases/52_create_role.sql b/tests/ast_json_fixtures/cases/52_create_role.sql new file mode 100644 index 000000000000..c1864af4b3b6 --- /dev/null +++ b/tests/ast_json_fixtures/cases/52_create_role.sql @@ -0,0 +1 @@ +CREATE ROLE r SETTINGS max_threads = 2 diff --git a/tests/ast_json_fixtures/cases/53_set_default_role.json b/tests/ast_json_fixtures/cases/53_set_default_role.json new file mode 100644 index 000000000000..eacd6a4c40b6 --- /dev/null +++ b/tests/ast_json_fixtures/cases/53_set_default_role.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SetRoleQuery", + "kind": "SET_DEFAULT_ROLE", + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1"] + }, + "to_users": { + "type": "RolesOrUsersSet", + "names": ["u1", "u2"] + } + } +} diff --git a/tests/ast_json_fixtures/cases/53_set_default_role.sql b/tests/ast_json_fixtures/cases/53_set_default_role.sql new file mode 100644 index 000000000000..5b0a72bc4b95 --- /dev/null +++ b/tests/ast_json_fixtures/cases/53_set_default_role.sql @@ -0,0 +1 @@ +SET DEFAULT ROLE r1 TO u1, u2 diff --git a/tests/ast_json_fixtures/cases/54_create_quota.json b/tests/ast_json_fixtures/cases/54_create_quota.json new file mode 100644 index 000000000000..63d7d695ca57 --- /dev/null +++ b/tests/ast_json_fixtures/cases/54_create_quota.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q"], + "key_type": "USER_NAME", + "limits": [ + { + "duration_sec": "3600", + "max": { + "QUERIES": "100", + "RESULT_ROWS": "1000" + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1"] + } + } +} diff --git a/tests/ast_json_fixtures/cases/54_create_quota.sql b/tests/ast_json_fixtures/cases/54_create_quota.sql new file mode 100644 index 000000000000..b570deb938e7 --- /dev/null +++ b/tests/ast_json_fixtures/cases/54_create_quota.sql @@ -0,0 +1 @@ +CREATE QUOTA q KEYED BY user_name FOR INTERVAL 1 HOUR MAX queries = 100, result_rows = 1000 TO r1 diff --git a/tests/ast_json_fixtures/cases/55_row_policy.json b/tests/ast_json_fixtures/cases/55_row_policy.json new file mode 100644 index 000000000000..ff926b5fae65 --- /dev/null +++ b/tests/ast_json_fixtures/cases/55_row_policy.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p", + "database": "db", + "table": "t" + } + ] + }, + "is_restrictive": true, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1"] + } + } +} diff --git a/tests/ast_json_fixtures/cases/55_row_policy.sql b/tests/ast_json_fixtures/cases/55_row_policy.sql new file mode 100644 index 000000000000..3b2a3d6ddac5 --- /dev/null +++ b/tests/ast_json_fixtures/cases/55_row_policy.sql @@ -0,0 +1 @@ +CREATE ROW POLICY p ON db.t AS restrictive FOR SELECT USING x > 0 TO r1 diff --git a/tests/ast_json_fixtures/cases/56_settings_profile.json b/tests/ast_json_fixtures/cases/56_settings_profile.json new file mode 100644 index 000000000000..eb836b21d6b9 --- /dev/null +++ b/tests/ast_json_fixtures/cases/56_settings_profile.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["sp"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_threads", + "value": "8", + "min_value": "1", + "max_value": "16" + } + ] + }, + "to_roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/cases/56_settings_profile.sql b/tests/ast_json_fixtures/cases/56_settings_profile.sql new file mode 100644 index 000000000000..73824bf3342b --- /dev/null +++ b/tests/ast_json_fixtures/cases/56_settings_profile.sql @@ -0,0 +1 @@ +CREATE SETTINGS PROFILE sp SETTINGS max_threads = 8 MIN 1 MAX 16 TO ALL diff --git a/tests/ast_json_fixtures/cases/57_drop_user.json b/tests/ast_json_fixtures/cases/57_drop_user.json new file mode 100644 index 000000000000..99351ea7ff82 --- /dev/null +++ b/tests/ast_json_fixtures/cases/57_drop_user.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["a", "b"] + } +} diff --git a/tests/ast_json_fixtures/cases/57_drop_user.sql b/tests/ast_json_fixtures/cases/57_drop_user.sql new file mode 100644 index 000000000000..1feca2ea984c --- /dev/null +++ b/tests/ast_json_fixtures/cases/57_drop_user.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS a, b diff --git a/tests/ast_json_fixtures/cases/58_show_grants.json b/tests/ast_json_fixtures/cases/58_show_grants.json new file mode 100644 index 000000000000..f50092b23871 --- /dev/null +++ b/tests/ast_json_fixtures/cases/58_show_grants.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowGrantsQuery", + "for_roles": { + "type": "RolesOrUsersSet", + "names": ["u"] + }, + "with_implicit": true + } +} diff --git a/tests/ast_json_fixtures/cases/58_show_grants.sql b/tests/ast_json_fixtures/cases/58_show_grants.sql new file mode 100644 index 000000000000..9e033815f5e9 --- /dev/null +++ b/tests/ast_json_fixtures/cases/58_show_grants.sql @@ -0,0 +1 @@ +SHOW GRANTS FOR u WITH IMPLICIT diff --git a/tests/ast_json_fixtures/cases/59_enum_data_type.json b/tests/ast_json_fixtures/cases/59_enum_data_type.json new file mode 100644 index 000000000000..278359610172 --- /dev/null +++ b/tests/ast_json_fixtures/cases/59_enum_data_type.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "e", + "data_type": { + "type": "EnumDataType", + "name": "Enum8", + "values": [ + { + "name": "a", + "value": 1 + }, + { + "name": "b", + "value": 2 + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/59_enum_data_type.sql b/tests/ast_json_fixtures/cases/59_enum_data_type.sql new file mode 100644 index 000000000000..f36a31802cf1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/59_enum_data_type.sql @@ -0,0 +1 @@ +CREATE TABLE t (e Enum8('a' = 1, 'b' = 2)) ENGINE = Memory diff --git a/tests/ast_json_fixtures/cases/60_tuple_named.json b/tests/ast_json_fixtures/cases/60_tuple_named.json new file mode 100644 index 000000000000..d735d57d15d0 --- /dev/null +++ b/tests/ast_json_fixtures/cases/60_tuple_named.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "TupleDataType", + "name": "Tuple", + "arguments": [ + { + "type": "DataType", + "name": "UInt8" + }, + { + "type": "DataType", + "name": "String" + } + ], + "element_names": ["a", "b"] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/60_tuple_named.sql b/tests/ast_json_fixtures/cases/60_tuple_named.sql new file mode 100644 index 000000000000..7148f742d5a1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/60_tuple_named.sql @@ -0,0 +1 @@ +CREATE TABLE t (x Tuple(a UInt8, b String)) ENGINE = Memory diff --git a/tests/ast_json_fixtures/cases/61_column_collate.json b/tests/ast_json_fixtures/cases/61_column_collate.json new file mode 100644 index 000000000000..9bf0276d1650 --- /dev/null +++ b/tests/ast_json_fixtures/cases/61_column_collate.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "String" + }, + "collation": { + "type": "Collation", + "name": "binary" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/61_column_collate.sql b/tests/ast_json_fixtures/cases/61_column_collate.sql new file mode 100644 index 000000000000..2885d8651578 --- /dev/null +++ b/tests/ast_json_fixtures/cases/61_column_collate.sql @@ -0,0 +1 @@ +CREATE TABLE t (s String COLLATE binary) ENGINE = Memory diff --git a/tests/ast_json_fixtures/cases/62_json_typed_path.json b/tests/ast_json_fixtures/cases/62_json_typed_path.json new file mode 100644 index 000000000000..f2dce89da917 --- /dev/null +++ b/tests/ast_json_fixtures/cases/62_json_typed_path.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "j", + "data_type": { + "type": "DataType", + "name": "JSON", + "arguments": [ + { + "type": "ObjectTypeArgument", + "path_with_type": { + "type": "ObjectTypedPath", + "name": "a.b", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + }, + { + "type": "ObjectTypeArgument", + "skip_path": { + "type": "Identifier", + "name": "x" + } + }, + { + "type": "ObjectTypeArgument", + "skip_path_regexp": { + "type": "Literal", + "value_type": "String", + "value": "y.*" + } + }, + { + "type": "ObjectTypeArgument", + "parameter": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "max_dynamic_paths" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/62_json_typed_path.sql b/tests/ast_json_fixtures/cases/62_json_typed_path.sql new file mode 100644 index 000000000000..4a8eb350cb7f --- /dev/null +++ b/tests/ast_json_fixtures/cases/62_json_typed_path.sql @@ -0,0 +1 @@ +CREATE TABLE t (j JSON(a.b UInt32, SKIP x, SKIP REGEXP 'y.*', max_dynamic_paths = 8)) ENGINE = Memory diff --git a/tests/ast_json_fixtures/cases/63_ttl_group_by.json b/tests/ast_json_fixtures/cases/63_ttl_group_by.json new file mode 100644 index 000000000000..86ebfa9d5149 --- /dev/null +++ b/tests/ast_json_fixtures/cases/63_ttl_group_by.json @@ -0,0 +1,116 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "k", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "Date" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Identifier", + "name": "a" + } + ] + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "GROUP_BY", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "group_by_key": [ + { + "type": "Identifier", + "name": "k" + } + ], + "group_by_assignments": [ + { + "type": "Assignment", + "column": "a", + "expression": { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + } + ] + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/63_ttl_group_by.sql b/tests/ast_json_fixtures/cases/63_ttl_group_by.sql new file mode 100644 index 000000000000..debefdc6bd9a --- /dev/null +++ b/tests/ast_json_fixtures/cases/63_ttl_group_by.sql @@ -0,0 +1 @@ +CREATE TABLE t (a UInt64, k UInt64, d Date) ENGINE = MergeTree ORDER BY (k, a) TTL d + INTERVAL 1 MONTH GROUP BY k SET a = max(a) diff --git a/tests/ast_json_fixtures/cases/64_projection_index.json b/tests/ast_json_fixtures/cases/64_projection_index.json new file mode 100644 index 000000000000..555d3c3696b1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/64_projection_index.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_PROJECTION", + "projection_declaration": { + "type": "Projection", + "name": "p", + "index": { + "type": "Identifier", + "name": "a" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "x": "1" + } + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/64_projection_index.sql b/tests/ast_json_fixtures/cases/64_projection_index.sql new file mode 100644 index 000000000000..e68b13b47012 --- /dev/null +++ b/tests/ast_json_fixtures/cases/64_projection_index.sql @@ -0,0 +1 @@ +ALTER TABLE t ADD PROJECTION p INDEX a TYPE minmax WITH SETTINGS (x = 1) diff --git a/tests/ast_json_fixtures/cases/65_refresh_mv.json b/tests/ast_json_fixtures/cases/65_refresh_mv.json new file mode 100644 index 000000000000..2b1960d03e12 --- /dev/null +++ b/tests/ast_json_fixtures/cases/65_refresh_mv.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "mv" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } + ] + }, + "refresh": { + "type": "RefreshStrategy", + "schedule_kind": "EVERY", + "append": true, + "period": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Day", + "value": "1" + } + ] + }, + "offset": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Hour", + "value": "1" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/65_refresh_mv.sql b/tests/ast_json_fixtures/cases/65_refresh_mv.sql new file mode 100644 index 000000000000..990d2e6d403d --- /dev/null +++ b/tests/ast_json_fixtures/cases/65_refresh_mv.sql @@ -0,0 +1 @@ +CREATE MATERIALIZED VIEW mv REFRESH EVERY 1 DAY OFFSET 1 HOUR APPEND (a UInt64) ENGINE = Memory AS SELECT 1 AS a diff --git a/tests/ast_json_fixtures/cases/66_insert_infile.json b/tests/ast_json_fixtures/cases/66_insert_infile.json new file mode 100644 index 000000000000..3f9419ce1e2b --- /dev/null +++ b/tests/ast_json_fixtures/cases/66_insert_infile.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "format": "CSV", + "infile": { + "type": "Literal", + "value_type": "String", + "value": "data.csv" + }, + "compression": { + "type": "Literal", + "value_type": "String", + "value": "gzip" + } + } +} diff --git a/tests/ast_json_fixtures/cases/66_insert_infile.sql b/tests/ast_json_fixtures/cases/66_insert_infile.sql new file mode 100644 index 000000000000..97c4fef47fb1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/66_insert_infile.sql @@ -0,0 +1 @@ +INSERT INTO t FROM INFILE 'data.csv' COMPRESSION 'gzip' FORMAT CSV diff --git a/tests/ast_json_fixtures/cases/67_tcl_begin.json b/tests/ast_json_fixtures/cases/67_tcl_begin.json new file mode 100644 index 000000000000..b58562b26eaf --- /dev/null +++ b/tests/ast_json_fixtures/cases/67_tcl_begin.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "BEGIN" + } +} diff --git a/tests/ast_json_fixtures/cases/67_tcl_begin.sql b/tests/ast_json_fixtures/cases/67_tcl_begin.sql new file mode 100644 index 000000000000..8ccb6cda374e --- /dev/null +++ b/tests/ast_json_fixtures/cases/67_tcl_begin.sql @@ -0,0 +1 @@ +BEGIN TRANSACTION diff --git a/tests/ast_json_fixtures/cases/68_tcl_commit.json b/tests/ast_json_fixtures/cases/68_tcl_commit.json new file mode 100644 index 000000000000..c405ee3a9e66 --- /dev/null +++ b/tests/ast_json_fixtures/cases/68_tcl_commit.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "COMMIT" + } +} diff --git a/tests/ast_json_fixtures/cases/68_tcl_commit.sql b/tests/ast_json_fixtures/cases/68_tcl_commit.sql new file mode 100644 index 000000000000..2a4398d82dc5 --- /dev/null +++ b/tests/ast_json_fixtures/cases/68_tcl_commit.sql @@ -0,0 +1 @@ +COMMIT diff --git a/tests/ast_json_fixtures/cases/69_tcl_rollback.json b/tests/ast_json_fixtures/cases/69_tcl_rollback.json new file mode 100644 index 000000000000..0f18cb14726e --- /dev/null +++ b/tests/ast_json_fixtures/cases/69_tcl_rollback.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "ROLLBACK" + } +} diff --git a/tests/ast_json_fixtures/cases/69_tcl_rollback.sql b/tests/ast_json_fixtures/cases/69_tcl_rollback.sql new file mode 100644 index 000000000000..61d3424233be --- /dev/null +++ b/tests/ast_json_fixtures/cases/69_tcl_rollback.sql @@ -0,0 +1 @@ +ROLLBACK diff --git a/tests/ast_json_fixtures/cases/70_tcl_set_snapshot.json b/tests/ast_json_fixtures/cases/70_tcl_set_snapshot.json new file mode 100644 index 000000000000..6f8700a33864 --- /dev/null +++ b/tests/ast_json_fixtures/cases/70_tcl_set_snapshot.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "SET_SNAPSHOT", + "snapshot": "42" + } +} diff --git a/tests/ast_json_fixtures/cases/70_tcl_set_snapshot.sql b/tests/ast_json_fixtures/cases/70_tcl_set_snapshot.sql new file mode 100644 index 000000000000..a30412fb38fe --- /dev/null +++ b/tests/ast_json_fixtures/cases/70_tcl_set_snapshot.sql @@ -0,0 +1 @@ +SET TRANSACTION SNAPSHOT 42 diff --git a/tests/ast_json_fixtures/cases/71_create_named_collection.json b/tests/ast_json_fixtures/cases/71_create_named_collection.json new file mode 100644 index 000000000000..1c6001280bf7 --- /dev/null +++ b/tests/ast_json_fixtures/cases/71_create_named_collection.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateNamedCollectionQuery", + "collection_name": "nc", + "if_not_exists": true, + "changes": { + "host": { + "value_type": "String", + "value": "localhost" + }, + "port": { + "value_type": "UInt64", + "value": "9000" + }, + "password": { + "value_type": "String", + "value": "secret" + } + }, + "overridability": { + "port": true, + "password": false + } + } +} diff --git a/tests/ast_json_fixtures/cases/71_create_named_collection.sql b/tests/ast_json_fixtures/cases/71_create_named_collection.sql new file mode 100644 index 000000000000..03e242e67c54 --- /dev/null +++ b/tests/ast_json_fixtures/cases/71_create_named_collection.sql @@ -0,0 +1 @@ +CREATE NAMED COLLECTION IF NOT EXISTS nc AS host = 'localhost', port = 9000 OVERRIDABLE, password = 'secret' NOT OVERRIDABLE diff --git a/tests/ast_json_fixtures/cases/72_create_workload.json b/tests/ast_json_fixtures/cases/72_create_workload.json new file mode 100644 index 000000000000..32a059998832 --- /dev/null +++ b/tests/ast_json_fixtures/cases/72_create_workload.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateWorkloadQuery", + "workload_name": { + "type": "Identifier", + "name": "production" + }, + "workload_parent": { + "type": "Identifier", + "name": "all" + }, + "changes": [ + { + "name": "max_requests", + "value": { + "value_type": "UInt64", + "value": "100" + } + }, + { + "name": "weight", + "value": { + "value_type": "UInt64", + "value": "5" + }, + "resource": "cpu" + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/72_create_workload.sql b/tests/ast_json_fixtures/cases/72_create_workload.sql new file mode 100644 index 000000000000..2aa942c3827a --- /dev/null +++ b/tests/ast_json_fixtures/cases/72_create_workload.sql @@ -0,0 +1 @@ +CREATE WORKLOAD production IN all SETTINGS max_requests = 100, weight = 5 FOR cpu diff --git a/tests/ast_json_fixtures/cases/73_create_resource.json b/tests/ast_json_fixtures/cases/73_create_resource.json new file mode 100644 index 000000000000..31852e8ed7dd --- /dev/null +++ b/tests/ast_json_fixtures/cases/73_create_resource.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateResourceQuery", + "or_replace": true, + "resource_name": { + "type": "Identifier", + "name": "io" + }, + "unit": "IOByte", + "operations": [ + { + "mode": "READ", + "disk": "fast" + }, + { + "mode": "WRITE" + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/73_create_resource.sql b/tests/ast_json_fixtures/cases/73_create_resource.sql new file mode 100644 index 000000000000..04ed02d0a997 --- /dev/null +++ b/tests/ast_json_fixtures/cases/73_create_resource.sql @@ -0,0 +1 @@ +CREATE OR REPLACE RESOURCE io (READ DISK fast, WRITE ANY DISK) diff --git a/tests/ast_json_fixtures/cases/74_drop_named_collection.json b/tests/ast_json_fixtures/cases/74_drop_named_collection.json new file mode 100644 index 000000000000..c58a9666d855 --- /dev/null +++ b/tests/ast_json_fixtures/cases/74_drop_named_collection.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropNamedCollectionQuery", + "collection_name": "nc", + "if_exists": true, + "cluster": "c" + } +} diff --git a/tests/ast_json_fixtures/cases/74_drop_named_collection.sql b/tests/ast_json_fixtures/cases/74_drop_named_collection.sql new file mode 100644 index 000000000000..394797d7c11e --- /dev/null +++ b/tests/ast_json_fixtures/cases/74_drop_named_collection.sql @@ -0,0 +1 @@ +DROP NAMED COLLECTION IF EXISTS nc ON CLUSTER c diff --git a/tests/ast_json_fixtures/cases/75_drop_workload.json b/tests/ast_json_fixtures/cases/75_drop_workload.json new file mode 100644 index 000000000000..9eeb73f25793 --- /dev/null +++ b/tests/ast_json_fixtures/cases/75_drop_workload.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropWorkloadQuery", + "workload_name": "production", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/cases/75_drop_workload.sql b/tests/ast_json_fixtures/cases/75_drop_workload.sql new file mode 100644 index 000000000000..13d07b4980e7 --- /dev/null +++ b/tests/ast_json_fixtures/cases/75_drop_workload.sql @@ -0,0 +1 @@ +DROP WORKLOAD IF EXISTS production diff --git a/tests/ast_json_fixtures/cases/76_drop_resource.json b/tests/ast_json_fixtures/cases/76_drop_resource.json new file mode 100644 index 000000000000..429b511414bf --- /dev/null +++ b/tests/ast_json_fixtures/cases/76_drop_resource.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropResourceQuery", + "resource_name": "io" + } +} diff --git a/tests/ast_json_fixtures/cases/76_drop_resource.sql b/tests/ast_json_fixtures/cases/76_drop_resource.sql new file mode 100644 index 000000000000..363bda929ff9 --- /dev/null +++ b/tests/ast_json_fixtures/cases/76_drop_resource.sql @@ -0,0 +1 @@ +DROP RESOURCE io diff --git a/tests/ast_json_fixtures/cases/77_show_cluster.json b/tests/ast_json_fixtures/cases/77_show_cluster.json new file mode 100644 index 000000000000..ca74a5bb02ab --- /dev/null +++ b/tests/ast_json_fixtures/cases/77_show_cluster.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "cluster": true, + "cluster_name": "c" + } +} diff --git a/tests/ast_json_fixtures/cases/77_show_cluster.sql b/tests/ast_json_fixtures/cases/77_show_cluster.sql new file mode 100644 index 000000000000..8dbc8e7c8bf7 --- /dev/null +++ b/tests/ast_json_fixtures/cases/77_show_cluster.sql @@ -0,0 +1 @@ +SHOW CLUSTER c diff --git a/tests/ast_json_fixtures/cases/78_show_changed_settings.json b/tests/ast_json_fixtures/cases/78_show_changed_settings.json new file mode 100644 index 000000000000..05e3245e73a0 --- /dev/null +++ b/tests/ast_json_fixtures/cases/78_show_changed_settings.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "show_settings": true, + "changed": true, + "like": "%mem%", + "case_insensitive_like": true + } +} diff --git a/tests/ast_json_fixtures/cases/78_show_changed_settings.sql b/tests/ast_json_fixtures/cases/78_show_changed_settings.sql new file mode 100644 index 000000000000..d20425ff1703 --- /dev/null +++ b/tests/ast_json_fixtures/cases/78_show_changed_settings.sql @@ -0,0 +1 @@ +SHOW CHANGED SETTINGS ILIKE '%mem%' diff --git a/tests/ast_json_fixtures/cases/79_show_tables_where_limit.json b/tests/ast_json_fixtures/cases/79_show_tables_where_limit.json new file mode 100644 index 000000000000..9083cdee4709 --- /dev/null +++ b/tests/ast_json_fixtures/cases/79_show_tables_where_limit.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "from": { + "type": "Identifier", + "name": "db" + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "x" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } +} diff --git a/tests/ast_json_fixtures/cases/79_show_tables_where_limit.sql b/tests/ast_json_fixtures/cases/79_show_tables_where_limit.sql new file mode 100644 index 000000000000..7c3474ad6db1 --- /dev/null +++ b/tests/ast_json_fixtures/cases/79_show_tables_where_limit.sql @@ -0,0 +1 @@ +SHOW TABLES FROM db WHERE name != 'x' LIMIT 5 diff --git a/tests/ast_json_fixtures/cases/80_show_merges.json b/tests/ast_json_fixtures/cases/80_show_merges.json new file mode 100644 index 000000000000..bac3e09b991a --- /dev/null +++ b/tests/ast_json_fixtures/cases/80_show_merges.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "merges": true + } +} diff --git a/tests/ast_json_fixtures/cases/80_show_merges.sql b/tests/ast_json_fixtures/cases/80_show_merges.sql new file mode 100644 index 000000000000..e328cb48dcf8 --- /dev/null +++ b/tests/ast_json_fixtures/cases/80_show_merges.sql @@ -0,0 +1 @@ +SHOW MERGES diff --git a/tests/ast_json_fixtures/cases/81_system_sync_replica.json b/tests/ast_json_fixtures/cases/81_system_sync_replica.json new file mode 100644 index 000000000000..96b6813d4526 --- /dev/null +++ b/tests/ast_json_fixtures/cases/81_system_sync_replica.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "SYNC REPLICA", + "database": { + "type": "Identifier", + "name": "db" + }, + "table": { + "type": "Identifier", + "name": "t" + }, + "sync_replica_mode": "LIGHTWEIGHT", + "src_replicas": ["r1", "r2"] + } +} diff --git a/tests/ast_json_fixtures/cases/81_system_sync_replica.sql b/tests/ast_json_fixtures/cases/81_system_sync_replica.sql new file mode 100644 index 000000000000..0dda26464d40 --- /dev/null +++ b/tests/ast_json_fixtures/cases/81_system_sync_replica.sql @@ -0,0 +1 @@ +SYSTEM SYNC REPLICA db.t LIGHTWEIGHT FROM 'r1', 'r2' diff --git a/tests/ast_json_fixtures/cases/82_system_drop_replica.json b/tests/ast_json_fixtures/cases/82_system_drop_replica.json new file mode 100644 index 000000000000..576bfb09b62a --- /dev/null +++ b/tests/ast_json_fixtures/cases/82_system_drop_replica.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "DROP REPLICA", + "replica": "r", + "replica_zk_path": "\/clickhouse\/tables\/t" + } +} diff --git a/tests/ast_json_fixtures/cases/82_system_drop_replica.sql b/tests/ast_json_fixtures/cases/82_system_drop_replica.sql new file mode 100644 index 000000000000..43f6b6477d54 --- /dev/null +++ b/tests/ast_json_fixtures/cases/82_system_drop_replica.sql @@ -0,0 +1 @@ +SYSTEM DROP REPLICA 'r' FROM ZKPATH '/clickhouse/tables/t' diff --git a/tests/ast_json_fixtures/cases/83_system_suspend.json b/tests/ast_json_fixtures/cases/83_system_suspend.json new file mode 100644 index 000000000000..6d01320b7760 --- /dev/null +++ b/tests/ast_json_fixtures/cases/83_system_suspend.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "SUSPEND", + "seconds": "5" + } +} diff --git a/tests/ast_json_fixtures/cases/83_system_suspend.sql b/tests/ast_json_fixtures/cases/83_system_suspend.sql new file mode 100644 index 000000000000..fcff22952120 --- /dev/null +++ b/tests/ast_json_fixtures/cases/83_system_suspend.sql @@ -0,0 +1 @@ +SYSTEM SUSPEND FOR 5 SECOND diff --git a/tests/ast_json_fixtures/cases/84_system_drop_fs_cache.json b/tests/ast_json_fixtures/cases/84_system_drop_fs_cache.json new file mode 100644 index 000000000000..9998de9db6ed --- /dev/null +++ b/tests/ast_json_fixtures/cases/84_system_drop_fs_cache.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR FILESYSTEM CACHE", + "filesystem_cache_name": "cache1", + "key_to_drop": "k", + "offset_to_drop": "10" + } +} diff --git a/tests/ast_json_fixtures/cases/84_system_drop_fs_cache.sql b/tests/ast_json_fixtures/cases/84_system_drop_fs_cache.sql new file mode 100644 index 000000000000..16ac57786db5 --- /dev/null +++ b/tests/ast_json_fixtures/cases/84_system_drop_fs_cache.sql @@ -0,0 +1 @@ +SYSTEM DROP FILESYSTEM CACHE 'cache1' KEY k OFFSET 10 diff --git a/tests/ast_json_fixtures/cases/85_system_start_listen.json b/tests/ast_json_fixtures/cases/85_system_start_listen.json new file mode 100644 index 000000000000..4127211f94fb --- /dev/null +++ b/tests/ast_json_fixtures/cases/85_system_start_listen.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "START LISTEN", + "server_type": { + "type": "QUERIES ALL", + "exclude_types": ["MYSQL", "TCP"] + } + } +} diff --git a/tests/ast_json_fixtures/cases/85_system_start_listen.sql b/tests/ast_json_fixtures/cases/85_system_start_listen.sql new file mode 100644 index 000000000000..50e3a2212cca --- /dev/null +++ b/tests/ast_json_fixtures/cases/85_system_start_listen.sql @@ -0,0 +1 @@ +SYSTEM START LISTEN QUERIES ALL EXCEPT MYSQL, TCP diff --git a/tests/ast_json_fixtures/cases/86_system_flush_logs.json b/tests/ast_json_fixtures/cases/86_system_flush_logs.json new file mode 100644 index 000000000000..466d0ad46c02 --- /dev/null +++ b/tests/ast_json_fixtures/cases/86_system_flush_logs.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "query_log" + }, + { + "table": "part_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/86_system_flush_logs.sql b/tests/ast_json_fixtures/cases/86_system_flush_logs.sql new file mode 100644 index 000000000000..dfa2777cc03f --- /dev/null +++ b/tests/ast_json_fixtures/cases/86_system_flush_logs.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS query_log, part_log diff --git a/tests/ast_json_fixtures/cases/87_backup_format.json b/tests/ast_json_fixtures/cases/87_backup_format.json new file mode 100644 index 000000000000..2e1056668a46 --- /dev/null +++ b/tests/ast_json_fixtures/cases/87_backup_format.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "BackupQuery", + "kind": "BACKUP", + "elements": [ + { + "element_type": "TABLE", + "database": "db", + "table": "t", + "new_table": "t2", + "partitions": [ + { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "p1" + } + }, + { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "p2" + } + } + ] + } + ], + "backup_name": { + "type": "Function", + "name": "Disk", + "kind": "BACKUP_NAME", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "path" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "async": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/cases/87_backup_format.sql b/tests/ast_json_fixtures/cases/87_backup_format.sql new file mode 100644 index 000000000000..efc56e999706 --- /dev/null +++ b/tests/ast_json_fixtures/cases/87_backup_format.sql @@ -0,0 +1 @@ +BACKUP TABLE db.t AS db.t2 PARTITIONS 'p1', 'p2' TO Disk('d', 'path') SETTINGS async = 1 FORMAT Null diff --git a/tests/ast_json_fixtures/cases/88_restore_except_tables.json b/tests/ast_json_fixtures/cases/88_restore_except_tables.json new file mode 100644 index 000000000000..db8f4e108864 --- /dev/null +++ b/tests/ast_json_fixtures/cases/88_restore_except_tables.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "RestoreQuery", + "kind": "RESTORE", + "elements": [ + { + "element_type": "DATABASE", + "database": "db", + "new_database": "db2", + "except_tables": [ + { + "database": "db", + "table": "t1" + } + ] + } + ], + "backup_name": { + "type": "Function", + "name": "Disk", + "kind": "BACKUP_NAME", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "p" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "async": true + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/88_restore_except_tables.sql b/tests/ast_json_fixtures/cases/88_restore_except_tables.sql new file mode 100644 index 000000000000..955753009cda --- /dev/null +++ b/tests/ast_json_fixtures/cases/88_restore_except_tables.sql @@ -0,0 +1 @@ +RESTORE DATABASE db AS db2 EXCEPT TABLES t1 FROM Disk('d', 'p') ASYNC diff --git a/tests/ast_json_fixtures/cases/89_drop_masking_policy.json b/tests/ast_json_fixtures/cases/89_drop_masking_policy.json new file mode 100644 index 000000000000..584a28964190 --- /dev/null +++ b/tests/ast_json_fixtures/cases/89_drop_masking_policy.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "MASKING POLICY", + "if_exists": true, + "masking_policy_name": { + "short_name": "mp", + "database": "db", + "table": "tbl" + } + } +} diff --git a/tests/ast_json_fixtures/cases/89_drop_masking_policy.sql b/tests/ast_json_fixtures/cases/89_drop_masking_policy.sql new file mode 100644 index 000000000000..6f88c6241359 --- /dev/null +++ b/tests/ast_json_fixtures/cases/89_drop_masking_policy.sql @@ -0,0 +1 @@ +DROP MASKING POLICY IF EXISTS mp ON db.tbl diff --git a/tests/ast_json_fixtures/cases/90_show_columns.json b/tests/ast_json_fixtures/cases/90_show_columns.json new file mode 100644 index 000000000000..3fa62c869773 --- /dev/null +++ b/tests/ast_json_fixtures/cases/90_show_columns.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "tab" + } +} diff --git a/tests/ast_json_fixtures/cases/90_show_columns.sql b/tests/ast_json_fixtures/cases/90_show_columns.sql new file mode 100644 index 000000000000..a855eaba8f7f --- /dev/null +++ b/tests/ast_json_fixtures/cases/90_show_columns.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM tab diff --git a/tests/ast_json_fixtures/cases/91_show_columns_full_like.json b/tests/ast_json_fixtures/cases/91_show_columns_full_like.json new file mode 100644 index 000000000000..088f09684be6 --- /dev/null +++ b/tests/ast_json_fixtures/cases/91_show_columns_full_like.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "extended": true, + "full": true, + "table": "t", + "database": "db", + "like": "a%" + } +} diff --git a/tests/ast_json_fixtures/cases/91_show_columns_full_like.sql b/tests/ast_json_fixtures/cases/91_show_columns_full_like.sql new file mode 100644 index 000000000000..ca50d091c949 --- /dev/null +++ b/tests/ast_json_fixtures/cases/91_show_columns_full_like.sql @@ -0,0 +1 @@ +SHOW EXTENDED FULL COLUMNS FROM t FROM db LIKE 'a%' diff --git a/tests/ast_json_fixtures/cases/92_show_columns_where_limit.json b/tests/ast_json_fixtures/cases/92_show_columns_where_limit.json new file mode 100644 index 000000000000..a145f125a42f --- /dev/null +++ b/tests/ast_json_fixtures/cases/92_show_columns_where_limit.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "t", + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } +} diff --git a/tests/ast_json_fixtures/cases/92_show_columns_where_limit.sql b/tests/ast_json_fixtures/cases/92_show_columns_where_limit.sql new file mode 100644 index 000000000000..43ca0313978a --- /dev/null +++ b/tests/ast_json_fixtures/cases/92_show_columns_where_limit.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM t WHERE x = 1 LIMIT 5 diff --git a/tests/ast_json_fixtures/cases/93_show_setting.json b/tests/ast_json_fixtures/cases/93_show_setting.json new file mode 100644 index 000000000000..c009149cf6e9 --- /dev/null +++ b/tests/ast_json_fixtures/cases/93_show_setting.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowSetting", + "setting_name": "max_threads" + } +} diff --git a/tests/ast_json_fixtures/cases/93_show_setting.sql b/tests/ast_json_fixtures/cases/93_show_setting.sql new file mode 100644 index 000000000000..60f6c317ab06 --- /dev/null +++ b/tests/ast_json_fixtures/cases/93_show_setting.sql @@ -0,0 +1 @@ +SHOW SETTING max_threads diff --git a/tests/ast_json_fixtures/cases/94_show_functions_like.json b/tests/ast_json_fixtures/cases/94_show_functions_like.json new file mode 100644 index 000000000000..a5ba487ab4e3 --- /dev/null +++ b/tests/ast_json_fixtures/cases/94_show_functions_like.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowFunctions", + "like": "a%", + "case_insensitive_like": true + } +} diff --git a/tests/ast_json_fixtures/cases/94_show_functions_like.sql b/tests/ast_json_fixtures/cases/94_show_functions_like.sql new file mode 100644 index 000000000000..1971d4d40588 --- /dev/null +++ b/tests/ast_json_fixtures/cases/94_show_functions_like.sql @@ -0,0 +1 @@ +SHOW FUNCTIONS ILIKE 'a%' diff --git a/tests/ast_json_fixtures/cases/95_show_indexes.json b/tests/ast_json_fixtures/cases/95_show_indexes.json new file mode 100644 index 000000000000..8e3a9c818bde --- /dev/null +++ b/tests/ast_json_fixtures/cases/95_show_indexes.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "ShowIndexes", + "extended": true, + "table": "t", + "database": "db", + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/cases/95_show_indexes.sql b/tests/ast_json_fixtures/cases/95_show_indexes.sql new file mode 100644 index 000000000000..737a37a2d5c8 --- /dev/null +++ b/tests/ast_json_fixtures/cases/95_show_indexes.sql @@ -0,0 +1 @@ +SHOW EXTENDED INDEXES FROM t FROM db WHERE x = 1 diff --git a/tests/ast_json_fixtures/cases/96_refresh_mv_full.json b/tests/ast_json_fixtures/cases/96_refresh_mv_full.json new file mode 100644 index 000000000000..8088741ddd4f --- /dev/null +++ b/tests/ast_json_fixtures/cases/96_refresh_mv_full.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "mv" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } + ] + }, + "refresh": { + "type": "RefreshStrategy", + "schedule_kind": "EVERY", + "append": true, + "period": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Day", + "value": "1" + } + ] + }, + "offset": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Hour", + "value": "1" + } + ] + }, + "spread": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Minute", + "value": "5" + } + ] + }, + "dependencies": { + "type": "ExpressionList", + "children": [ + { + "type": "TableIdentifier", + "name": "a" + }, + { + "type": "TableIdentifier", + "name": "b" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "x": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/cases/96_refresh_mv_full.sql b/tests/ast_json_fixtures/cases/96_refresh_mv_full.sql new file mode 100644 index 000000000000..a1e6f6d7a96b --- /dev/null +++ b/tests/ast_json_fixtures/cases/96_refresh_mv_full.sql @@ -0,0 +1 @@ +CREATE MATERIALIZED VIEW mv REFRESH EVERY 1 DAY OFFSET 1 HOUR RANDOMIZE FOR 5 MINUTE DEPENDS ON a, b SETTINGS x = 1 APPEND (a UInt64) ENGINE = Memory AS SELECT 1 AS a diff --git a/tests/ast_json_fixtures/cases/97_alter_modify_refresh.json b/tests/ast_json_fixtures/cases/97_alter_modify_refresh.json new file mode 100644 index 000000000000..865372ac240f --- /dev/null +++ b/tests/ast_json_fixtures/cases/97_alter_modify_refresh.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "mv" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_REFRESH", + "refresh": { + "type": "RefreshStrategy", + "schedule_kind": "EVERY", + "period": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Day", + "value": "1" + } + ] + }, + "offset": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Hour", + "value": "2" + } + ] + }, + "spread": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Minute", + "value": "10" + } + ] + }, + "dependencies": { + "type": "ExpressionList", + "children": [ + { + "type": "TableIdentifier", + "name": "t1" + }, + { + "type": "TableIdentifier", + "name": "t2" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "y": "2" + } + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/97_alter_modify_refresh.sql b/tests/ast_json_fixtures/cases/97_alter_modify_refresh.sql new file mode 100644 index 000000000000..bb3982a3f14b --- /dev/null +++ b/tests/ast_json_fixtures/cases/97_alter_modify_refresh.sql @@ -0,0 +1 @@ +ALTER TABLE mv MODIFY REFRESH EVERY 1 DAY OFFSET 2 HOUR RANDOMIZE FOR 10 MINUTE DEPENDS ON t1, t2 SETTINGS y = 2 diff --git a/tests/ast_json_fixtures/cases/98_projection_order_single.json b/tests/ast_json_fixtures/cases/98_projection_order_single.json new file mode 100644 index 000000000000..7ef12393fd40 --- /dev/null +++ b/tests/ast_json_fixtures/cases/98_projection_order_single.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_PROJECTION", + "projection_declaration": { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/98_projection_order_single.sql b/tests/ast_json_fixtures/cases/98_projection_order_single.sql new file mode 100644 index 000000000000..81bcb467a0b4 --- /dev/null +++ b/tests/ast_json_fixtures/cases/98_projection_order_single.sql @@ -0,0 +1 @@ +ALTER TABLE t ADD PROJECTION p (SELECT a ORDER BY a) diff --git a/tests/ast_json_fixtures/cases/99_projection_order_multi.json b/tests/ast_json_fixtures/cases/99_projection_order_multi.json new file mode 100644 index 000000000000..2228b5805bad --- /dev/null +++ b/tests/ast_json_fixtures/cases/99_projection_order_multi.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_PROJECTION", + "projection_declaration": { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "order_by": [ + { + "type": "Function", + "name": "f", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/cases/99_projection_order_multi.sql b/tests/ast_json_fixtures/cases/99_projection_order_multi.sql new file mode 100644 index 000000000000..40edb587eef3 --- /dev/null +++ b/tests/ast_json_fixtures/cases/99_projection_order_multi.sql @@ -0,0 +1 @@ +ALTER TABLE t ADD PROJECTION p (SELECT a, b GROUP BY a, b ORDER BY f(a), b) diff --git a/tests/ast_json_fixtures/generate.sh b/tests/ast_json_fixtures/generate.sh new file mode 100755 index 000000000000..0f602e454e8c --- /dev/null +++ b/tests/ast_json_fixtures/generate.sh @@ -0,0 +1,253 @@ +#!/usr/bin/env bash +# Regenerate the SQL -> JSON-AST fixture corpus. +# +# For every case it writes a pair under cases/: +# .sql the input query (one statement, source of truth) +# .json the expected `EXPLAIN AST json = 1` output (golden) +# +# Usage: +# CLICKHOUSE_BINARY=/path/to/clickhouse ./generate.sh +# Defaults to `clickhouse` on PATH. + +set -euo pipefail + +BIN="${CLICKHOUSE_BINARY:-clickhouse}" +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +OUT="$HERE/cases" + +rm -rf "$OUT" +mkdir -p "$OUT" + +emit() { + local name="$1" sql="$2" + printf '%s\n' "$sql" > "$OUT/$name.sql" + "$BIN" local --format TSVRaw -q "EXPLAIN AST json = 1 $sql" > "$OUT/$name.json" + echo " $name" +} + +echo "Generating fixtures into $OUT" + +# --- literals and scalars --- +emit 01_literals "SELECT 1, -2, 3.5, 'str', NULL, true, [1, 2], (1, 'a'), map('k', 1)" +emit 02_identifiers "SELECT a, t.b, db.tbl.c" + +# --- functions and operators --- +emit 03_function_call "SELECT f(x, y)" +emit 04_no_args "SELECT now()" +emit 05_operators "SELECT a + b, x IN (1, 2), y BETWEEN 1 AND 2, NOT z, p AND q OR r" +emit 06_subscript "SELECT arr[1], tup.2" +emit 07_cast "SELECT CAST(x AS Int64), y::String" +emit 08_lambda "SELECT arrayMap(e -> e * 2, arr)" +emit 09_parametric_agg "SELECT quantile(0.9)(x)" +emit 10_nulls_action "SELECT first_value(x) IGNORE NULLS FROM t" + +# --- window functions --- +emit 11_window_named "SELECT sum(x) OVER w FROM t WINDOW w AS (PARTITION BY g ORDER BY x)" +emit 12_window_inline "SELECT sum(x) OVER (PARTITION BY g ORDER BY x ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) FROM t" + +# --- select clauses --- +emit 13_select_star "SELECT * FROM foo WHERE x = 1" +emit 14_distinct "SELECT DISTINCT a, b FROM t" +emit 15_group_by_rollup "SELECT g, count() FROM t GROUP BY g WITH ROLLUP HAVING count() > 1" +emit 16_grouping_sets "SELECT x FROM t GROUP BY GROUPING SETS ((x), (y))" +emit 17_qualify "SELECT x, row_number() OVER (ORDER BY x) AS r FROM t QUALIFY r = 1" +emit 18_order_by_fill "SELECT x FROM t ORDER BY x DESC NULLS LAST WITH FILL FROM 0 TO 10 STEP 2 INTERPOLATE (x AS x + 1)" +# A multi-key list and a single tuple-valued key sort rows identically but are +# distinct ASTs: two OrderByElement nodes vs one whose expression is tuple(...). +emit 18b_order_by_multikey "SELECT x FROM t ORDER BY a, b" +emit 18c_order_by_tuple_key "SELECT x FROM t ORDER BY tuple(a, b)" +emit 19_limits "SELECT x FROM t ORDER BY x LIMIT 5 BY g LIMIT 100 OFFSET 10" +emit 19b_limit_with_ties "SELECT x FROM t ORDER BY x DESC LIMIT 3 WITH TIES" +emit 20_settings "SELECT 1 SETTINGS max_threads = 4, max_block_size = 1000" + +# --- FROM / JOIN --- +emit 21_join_on "SELECT * FROM a INNER JOIN b ON a.x = b.x" +emit 22_join_using "SELECT * FROM a LEFT JOIN b USING (x, y)" +emit 23_join_global_any "SELECT * FROM a GLOBAL ANY INNER JOIN b ON a.x = b.x" +emit 24_cross_comma "SELECT * FROM a CROSS JOIN b, c" +emit 25_array_join "SELECT * FROM t LEFT ARRAY JOIN arr AS e, other" +emit 26_table_function "SELECT * FROM numbers(5)" +emit 27_subquery_from "SELECT * FROM (SELECT 1 AS a)" +emit 28_sample_final "SELECT * FROM tbl FINAL SAMPLE 1/10" + +# --- WITH / set operations --- +emit 29_cte "WITH cte AS (SELECT 1 AS a) SELECT a FROM cte" +emit 30_scalar_with "WITH (SELECT max(n) FROM t) AS m SELECT m" +emit 31_union_all "SELECT 1 UNION ALL SELECT 2" +emit 32_union_distinct "SELECT 1 UNION DISTINCT SELECT 2" +emit 33_intersect "SELECT 1 INTERSECT SELECT 2" +emit 34_except "SELECT 1 EXCEPT SELECT 2" + +# --- asterisk transformers and COLUMNS --- +emit 35_qualified_star "SELECT t.* FROM t" +emit 36_except_transform "SELECT * EXCEPT (a, b) FROM t" +emit 36b_except_pattern "SELECT * EXCEPT 'a.*' FROM t" +emit 37_apply_transform "SELECT * APPLY(sum) FROM t" +emit 38_replace_transform "SELECT * REPLACE (x + 1 AS y) FROM t" +emit 39_columns_regexp "SELECT COLUMNS('a.*') FROM t" +emit 40_columns_list "SELECT COLUMNS(a, b) FROM t" + +# --- ALTER commands (fields the SQL formatter emits but are easy to drop) --- +emit 42_alter_move_partition "ALTER TABLE t MOVE PARTITION 'p' TO DISK 'fast'" +emit 43_alter_clear_statistics "ALTER TABLE t CLEAR STATISTICS s" +emit 44_alter_freeze_with_name "ALTER TABLE t FREEZE PARTITION 'p' WITH NAME 'backup1'" +# 45 vs 45b: REPLACE and ATTACH ... FROM share command_type REPLACE_PARTITION and +# differ only by the `replace` flag. +emit 45_alter_replace_partition "ALTER TABLE t REPLACE PARTITION 'p' FROM src" +emit 45b_alter_attach_partition "ALTER TABLE t ATTACH PARTITION 'p' FROM src" +emit 46_alter_unlock_snapshot "ALTER TABLE t UNLOCK SNAPSHOT 'snap'" + +# --- access management --- +emit 47_grant "GRANT SELECT(x, y), INSERT ON db.t TO user1 WITH GRANT OPTION" +emit 48_grant_role "GRANT role1 TO user1 WITH ADMIN OPTION" +emit 49_revoke "REVOKE SELECT ON db.t FROM ALL EXCEPT user1" +emit 50_create_user "CREATE USER u IDENTIFIED WITH sha256_password BY 'secret' HOST IP '127.0.0.1' DEFAULT ROLE r1 SETTINGS max_threads = 4 READONLY GRANTEES ANY" +emit 51_alter_user "ALTER USER u RENAME TO u2 ADD HOST IP '10.0.0.0/8' DROP SETTINGS max_threads" +emit 52_create_role "CREATE ROLE r SETTINGS max_threads = 2" +emit 53_set_default_role "SET DEFAULT ROLE r1 TO u1, u2" +emit 54_create_quota "CREATE QUOTA q KEYED BY user_name FOR INTERVAL 1 HOUR MAX queries = 100, result_rows = 1000 TO r1" +emit 55_row_policy "CREATE ROW POLICY p ON db.t AS restrictive FOR SELECT USING x > 0 TO r1" +emit 56_settings_profile "CREATE SETTINGS PROFILE sp SETTINGS max_threads = 8 MIN 1 MAX 16 TO ALL" +emit 57_drop_user "DROP USER IF EXISTS a, b" +emit 58_show_grants "SHOW GRANTS FOR u WITH IMPLICIT" + +# --- data types and table elements whose detail the native AST drops --- +emit 59_enum_data_type "CREATE TABLE t (e Enum8('a' = 1, 'b' = 2)) ENGINE = Memory" +emit 60_tuple_named "CREATE TABLE t (x Tuple(a UInt8, b String)) ENGINE = Memory" +emit 61_column_collate "CREATE TABLE t (s String COLLATE binary) ENGINE = Memory" +emit 62_json_typed_path "CREATE TABLE t (j JSON(a.b UInt32, SKIP x, SKIP REGEXP 'y.*', max_dynamic_paths = 8)) ENGINE = Memory" +emit 63_ttl_group_by "CREATE TABLE t (a UInt64, k UInt64, d Date) ENGINE = MergeTree ORDER BY (k, a) TTL d + INTERVAL 1 MONTH GROUP BY k SET a = max(a)" +emit 64_projection_index "ALTER TABLE t ADD PROJECTION p INDEX a TYPE minmax WITH SETTINGS (x = 1)" +emit 65_refresh_mv "CREATE MATERIALIZED VIEW mv REFRESH EVERY 1 DAY OFFSET 1 HOUR APPEND (a UInt64) ENGINE = Memory AS SELECT 1 AS a" +emit 66_insert_infile "INSERT INTO t FROM INFILE 'data.csv' COMPRESSION 'gzip' FORMAT CSV" + +# --- transaction control --- +emit 67_tcl_begin "BEGIN TRANSACTION" +emit 68_tcl_commit "COMMIT" +emit 69_tcl_rollback "ROLLBACK" +emit 70_tcl_set_snapshot "SET TRANSACTION SNAPSHOT 42" + +# --- workload / resource / named collection DDL (sparse native nodes) --- +emit 71_create_named_collection "CREATE NAMED COLLECTION IF NOT EXISTS nc AS host = 'localhost', port = 9000 OVERRIDABLE, password = 'secret' NOT OVERRIDABLE" +emit 72_create_workload "CREATE WORKLOAD production IN all SETTINGS max_requests = 100, weight = 5 FOR cpu" +emit 73_create_resource "CREATE OR REPLACE RESOURCE io (READ DISK fast, WRITE ANY DISK)" +# Named-collection / workload change values are typed `{value_type, value}` (unlike +# a Settings-clause change, whose value is an untyped string). A named collection +# has no schema to recover the type from, so the tag is what keeps the value forms +# from colliding: `i = 5` (UInt64) vs `s = '5'` (String) both stringify to "5", +# `neg = -5` (Int64) vs its string form, `fn = disk(...)` (a function stored as a +# CustomType) vs the same text as a String, and `one = 1.0` (Float64) would read +# back as an integer without the tag. `half = 2.5` is a non-integral float control. +emit 124_named_collection_value_types "CREATE NAMED COLLECTION nc AS i = 5, s = '5', neg = -5, one = 1.0, half = 2.5, fn = disk(type = 'local')" +emit 125_workload_value_types "CREATE WORKLOAD w SETTINGS max_requests = 100, max_cost = 1.5" + +# --- DROP forms of the sparse-node DDL (name + if_exists live in plain members) --- +emit 74_drop_named_collection "DROP NAMED COLLECTION IF EXISTS nc ON CLUSTER c" +emit 75_drop_workload "DROP WORKLOAD IF EXISTS production" +emit 76_drop_resource "DROP RESOURCE io" + +# --- SHOW variants: modifiers, ILIKE filter, WHERE, LIMIT, SHOW CLUSTER name --- +emit 77_show_cluster "SHOW CLUSTER c" +emit 78_show_changed_settings "SHOW CHANGED SETTINGS ILIKE '%mem%'" +emit 79_show_tables_where_limit "SHOW TABLES FROM db WHERE name != 'x' LIMIT 5" +emit 80_show_merges "SHOW MERGES" + +# --- SYSTEM operands (sparse node): sync-replica mode + source list, drop replica, +# suspend seconds, filesystem cache key/offset, START LISTEN server type, flush logs --- +emit 81_system_sync_replica "SYSTEM SYNC REPLICA db.t LIGHTWEIGHT FROM 'r1', 'r2'" +emit 82_system_drop_replica "SYSTEM DROP REPLICA 'r' FROM ZKPATH '/clickhouse/tables/t'" +emit 83_system_suspend "SYSTEM SUSPEND FOR 5 SECOND" +emit 84_system_drop_fs_cache "SYSTEM DROP FILESYSTEM CACHE 'cache1' KEY k OFFSET 10" +emit 85_system_start_listen "SYSTEM START LISTEN QUERIES ALL EXCEPT MYSQL, TCP" +emit 86_system_flush_logs "SYSTEM FLUSH LOGS query_log, part_log" + +# --- BACKUP / RESTORE: trailing FORMAT, PARTITIONS, AS, EXCEPT TABLES, async setting --- +emit 87_backup_format "BACKUP TABLE db.t AS db.t2 PARTITIONS 'p1', 'p2' TO Disk('d', 'path') SETTINGS async = 1 FORMAT Null" +emit 88_restore_except_tables "RESTORE DATABASE db AS db2 EXCEPT TABLES t1 FROM Disk('d', 'p') ASYNC" + +# --- DROP MASKING POLICY: target lives in a dedicated struct, not `names` --- +emit 89_drop_masking_policy "DROP MASKING POLICY IF EXISTS mp ON db.tbl" + +# --- SHOW COLUMNS / SHOW SETTING: irreducibly lossy in the native AST — the +# table, FROM db, LIKE, WHERE, LIMIT, EXTENDED/FULL and the setting name +# all live in plain members (empty `children`), so the serializer must +# surface them explicitly or the formatter cannot round-trip the query --- +emit 90_show_columns "SHOW COLUMNS FROM tab" +emit 91_show_columns_full_like "SHOW EXTENDED FULL COLUMNS FROM t FROM db LIKE 'a%'" +emit 92_show_columns_where_limit "SHOW COLUMNS FROM t WHERE x = 1 LIMIT 5" +emit 93_show_setting "SHOW SETTING max_threads" +# SHOW FUNCTIONS drops its LIKE natively; SHOW INDEXES is a distinct class whose +# getID is a mis-set "ShowColumns" — disambiguated to "ShowIndexes" — and drops +# table / FROM db / WHERE / EXTENDED. +emit 94_show_functions_like "SHOW FUNCTIONS ILIKE 'a%'" +emit 95_show_indexes "SHOW EXTENDED INDEXES FROM t FROM db WHERE x = 1" + +# --- REFRESH strategy: the full clause in both contexts. RANDOMIZE FOR +# (`spread`), DEPENDS ON (`dependencies`) and refresh-level SETTINGS live in +# dedicated RefreshStrategy members alongside period/offset — 65 above only +# exercised EVERY/OFFSET/APPEND, so these pin the rest, incl. the +# ALTER ... MODIFY REFRESH path (AlterCommand MODIFY_REFRESH). --- +emit 96_refresh_mv_full "CREATE MATERIALIZED VIEW mv REFRESH EVERY 1 DAY OFFSET 1 HOUR RANDOMIZE FOR 5 MINUTE DEPENDS ON a, b SETTINGS x = 1 APPEND (a UInt64) ENGINE = Memory AS SELECT 1 AS a" +emit 97_alter_modify_refresh "ALTER TABLE mv MODIFY REFRESH EVERY 1 DAY OFFSET 2 HOUR RANDOMIZE FOR 10 MINUTE DEPENDS ON t1, t2 SETTINGS y = 2" + +# --- Projection ORDER BY: stored as a single node (tuple() for multi-key, bare +# for a lone key), so it must be flattened to a key list. 98 pins the +# single-key case (bare identifier — previously serialized as []); 99 the +# multi-key case incl. a function key (previously leaked the tuple wrapper / +# dropped the function name). --- +emit 98_projection_order_single "ALTER TABLE t ADD PROJECTION p (SELECT a ORDER BY a)" +emit 99_projection_order_multi "ALTER TABLE t ADD PROJECTION p (SELECT a, b GROUP BY a, b ORDER BY f(a), b)" + +# --- output clause (ASTQueryWithOutput): the INTO OUTFILE modifiers, trailing +# FORMAT, and the settings-after-FORMAT placement (a SETTINGS before FORMAT +# lands on the operand select instead — see 20 above) --- +emit 100_outfile_format_settings "SELECT 1 INTO OUTFILE '/tmp/f.tsv' TRUNCATE AND STDOUT FORMAT TSV SETTINGS max_threads = 1" +emit 101_outfile_compression "SELECT 1 INTO OUTFILE '/tmp/f.csv.gz' APPEND COMPRESSION 'gzip' LEVEL 3 FORMAT CSV" + +# --- Map field: a map-valued setting. map('k', 1) in 01 is a function call, so +# this is the only fixture reaching the Map branch of fieldToJSON. --- +emit 102_map_setting "SELECT 1 SETTINGS additional_table_filters = {'tbl': 'x = 1'}" + +# --- TRUNCATE ALL TABLES: has_all / has_tables plus the table-name pattern --- +emit 103_truncate_all_tables "TRUNCATE ALL TABLES FROM db LIKE '%tmp%'" + +# --- CREATE / DROP FUNCTION: ON CLUSTER, and the drop form whose name and +# if_exists live in plain string members --- +emit 104_create_function_cluster "CREATE FUNCTION f ON CLUSTER c AS x -> x + 1" +emit 105_drop_function "DROP FUNCTION IF EXISTS f" + +# --- ATTACH variants and UNDROP: attach_from_path, uuid, the AS REPLICATED +# conversion marker, and the UNDROP branch (cluster + uuid fallback) --- +emit 106_attach_from_path "ATTACH TABLE t FROM '/data/t' (x UInt8) ENGINE = File(TSV)" +emit 107_attach_uuid "ATTACH TABLE t UUID '123e4567-e89b-12d3-a456-426614174000' (x UInt8) ENGINE = Memory" +emit 108_attach_as_replicated "ATTACH TABLE t AS REPLICATED" +emit 109_undrop "UNDROP TABLE t UUID '123e4567-e89b-12d3-a456-426614174000'" + +# --- access management: the statements not covered by 47-58/89 --- +emit 110_check_grant "CHECK GRANT SELECT(x) ON db.t" +emit 111_set_role "SET ROLE r1, r2" +emit 112_move_access_entity "MOVE ROLE r TO local_directory" +emit 113_execute_as "EXECUTE AS u1 SELECT 1" +emit 114_show_create_user "SHOW CREATE USER u" +emit 115_show_users "SHOW USERS" +emit 116_create_masking_policy "CREATE MASKING POLICY mp ON db.t UPDATE x = 'masked' WHERE x != '' TO r1 PRIORITY 2" + +# --- access helpers not reached above: PublicSSHKey, DatabaseOrNone, the +# name@host split, VALID UNTIL --- +emit 117_user_ssh_key "CREATE USER u IDENTIFIED WITH ssh_key BY KEY 'AAAA' TYPE 'ssh-rsa'" +emit 118_user_default_database "CREATE USER u DEFAULT DATABASE db" +emit 119_user_host_valid_until "CREATE USER u@'%.example.com' IDENTIFIED BY 'p' VALID UNTIL '2030-01-01'" + +# --- SHOW FILESYSTEM CACHES: the `caches` flag on ShowTables --- +emit 120_show_fs_caches "SHOW FILESYSTEM CACHES" + +# --- SYSTEM long tail: schema-cache source, WAIT FAILPOINT action, and the +# stringified fake_time_for_view --- +emit 121_system_schema_cache "SYSTEM DROP SCHEMA CACHE FOR S3" +emit 122_system_wait_failpoint "SYSTEM WAIT FAILPOINT fp PAUSE" +emit 123_system_fake_time "SYSTEM TEST VIEW db.v SET FAKE TIME '2021-01-01 00:00:00'" + +# --- the maximal showcase --- +emit 41_showcase "WITH recent AS (SELECT number AS n, number % 3 AS g FROM numbers(100) WHERE number > 1), (SELECT max(n) FROM recent) AS max_n SELECT DISTINCT a.g AS grp, a.n + b.v AS total, arrayMap(e -> e * max_n, groupArray(a.n)) AS scaled, sum(b.v) OVER (PARTITION BY a.g ORDER BY a.n ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS running, count(*) OVER w AS cnt, CASE WHEN a.n > 10 THEN 'hi' ELSE 'lo' END AS bucket, CAST(a.n AS Float64) AS nf FROM recent AS a INNER JOIN (SELECT n, n * 2 AS v FROM recent) AS b ON a.n = b.n PREWHERE a.n != 0 WHERE a.n IN (SELECT n FROM recent) AND b.v BETWEEN 1 AND 1000 GROUP BY a.g, a.n WITH ROLLUP HAVING sum(b.v) > 10 WINDOW w AS (PARTITION BY a.g ORDER BY a.n DESC) QUALIFY running >= 0 ORDER BY total DESC NULLS LAST WITH FILL FROM 0 TO 100 STEP 10 INTERPOLATE (nf AS nf + 1) LIMIT 5 BY a.g LIMIT 100 OFFSET 10 SETTINGS max_threads = 4" + +echo "Done: $(ls "$OUT"/*.sql | wc -l | tr -d ' ') cases." diff --git a/tests/ast_json_fixtures/harvest_stateless.py b/tests/ast_json_fixtures/harvest_stateless.py new file mode 100644 index 000000000000..88edee043d0a --- /dev/null +++ b/tests/ast_json_fixtures/harvest_stateless.py @@ -0,0 +1,283 @@ +#!/usr/bin/env python3 +"""Harvest SQL statements from tests/queries/0_stateless/*.sql and capture their +JSON AST via `EXPLAIN AST json = 1`, producing SQL -> JSON golden pairs. + +This reuses the existing stateless test corpus as parser-conformance inputs. +Statements that the reference parser rejects (or that use query-parameter +placeholders like `{x:UInt8}`, which require values) are skipped and counted. + +Usage: + CLICKHOUSE_BINARY=/path/to/clickhouse \ + ./harvest_stateless.py --out harvested --limit 0 --jobs 8 + + --limit N stop after N statements (0 = all); useful for a quick sample + --jobs N parallel EXPLAIN AST workers + --out DIR output dir (pairs go to DIR/.sql / .json) +""" +import argparse +import hashlib +import json +import os +import re +import subprocess +import sys +from concurrent.futures import ThreadPoolExecutor + +# Leaf "value" fields dropped from the structural signature: two queries that +# differ only in identifier names, literal values, aliases, settings contents, +# patterns, etc. collapse to the same AST shape. Enum/flag scalars (direction, +# kind, strictness, union_mode, frame_type, is_operator, ...) and literal +# `value_type` are kept, so each parser branch stays represented. +SHAPE_DROP_KEYS = { + "name", "name_parts", "alias", "database", "value", "cte_name", + "parent_window_name", "window_name", "column", "func_name", "lambda_arg", + "column_name_prefix", "pattern", "numerator", "denominator", "changes", + "default_settings", +} + + +def ast_shape(node, depth=0): + """A canonical structural signature of a JSON AST: node types + slot keys + + enum/flag scalars, recursing into nested nodes. Consecutive identical + children collapse, so list arity does not multiply distinct shapes. + + `depth` (0 = unlimited) caps recursion: nodes below it collapse to their + type, giving a coarser signature and fewer distinct shapes.""" + if isinstance(node, dict): + if depth == 1: + return node.get("type", "?") + "(...)" + parts = [] + for k in sorted(node): + if k == "type" or k in SHAPE_DROP_KEYS: + continue + v = node[k] + if isinstance(v, (dict, list)): + parts.append(k + "=" + ast_shape(v, depth - 1 if depth else 0)) + else: + parts.append(k + "=" + str(v)) + return node.get("type", "?") + "(" + ",".join(parts) + ")" + if isinstance(node, list): + out, prev = [], None + for e in node: + s = ast_shape(e, depth) + if s != prev: # collapse runs of identical child shapes + out.append(s) + prev = s + return "[" + ",".join(out) + "]" + return str(node) + +HERE = os.path.dirname(os.path.abspath(__file__)) +STATELESS = os.path.normpath(os.path.join(HERE, "..", "queries", "0_stateless")) + +PARAM_RE = re.compile(r"\{[A-Za-z_]\w*\s*:") # query-parameter placeholder + + +def split_statements(text): + """Split a multi-statement SQL script on top-level semicolons, respecting + string literals (', "), quoted identifiers (`), and -- / /* */ comments.""" + out, buf, i, n = [], [], 0, len(text) + while i < n: + c = text[i] + two = text[i:i + 2] + if two == "--": + j = text.find("\n", i) + i = n if j < 0 else j + continue + if two == "/*": + j = text.find("*/", i + 2) + i = n if j < 0 else j + 2 + continue + if c in "'\"`": + buf.append(c) + i += 1 + while i < n: + buf.append(text[i]) + if text[i] == c: + # doubled quote is an escape inside the same literal + if i + 1 < n and text[i + 1] == c: + buf.append(text[i + 1]) + i += 2 + continue + i += 1 + break + if text[i] == "\\" and c == "'" and i + 1 < n: + buf.append(text[i + 1]) + i += 2 + continue + i += 1 + continue + if c == ";": + stmt = "".join(buf).strip() + if stmt: + out.append(stmt) + buf = [] + i += 1 + continue + buf.append(c) + i += 1 + tail = "".join(buf).strip() + if tail: + out.append(tail) + return out + + +def collect_statements(limit): + seen, stmts = set(), [] + for fname in sorted(os.listdir(STATELESS)): + if not fname.endswith(".sql"): + continue + try: + text = open(os.path.join(STATELESS, fname), encoding="utf-8", errors="replace").read() + except OSError: + continue + for stmt in split_statements(text): + if PARAM_RE.search(stmt): + continue + key = " ".join(stmt.split()) + if key in seen: + continue + seen.add(key) + stmts.append(stmt) + if limit and len(stmts) >= limit: + return stmts + return stmts + + +def explain(binary, stmt): + try: + r = subprocess.run( + [binary, "local", "--format", "TSVRaw", "-q", "EXPLAIN AST json = 1 " + stmt], + capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=30, + ) + except subprocess.TimeoutExpired: + return None + if r.returncode != 0 or not r.stdout.strip(): + return None + return r.stdout + + +MARKER = "@@CHFIX@@" +MARKER_RE = re.compile(r"^" + re.escape(MARKER) + r" (\d+) ([BE])$") + + +def explain_batch(binary, stmts): + """EXPLAIN AST a whole batch in one process. EXPLAIN only parses (never + executes), and --ignore-error skips rejects, so the batch is safe and + self-resynchronising. Marker SELECTs delimit each result. + + Returns a list aligned with `stmts`; an entry is the JSON string or None.""" + script = [] + for i, s in enumerate(stmts): + script.append(f"SELECT '{MARKER} {i} B';") + script.append("EXPLAIN AST json = 1 " + s + ";") + script.append(f"SELECT '{MARKER} {i} E';") + try: + r = subprocess.run( + [binary, "local", "--format", "TSVRaw", "--multiquery", "--ignore-error"], + input="\n".join(script), capture_output=True, text=True, encoding="utf-8", errors="replace", timeout=600, + ) + except subprocess.TimeoutExpired: + return [None] * len(stmts) + + results = [None] * len(stmts) + cur, buf = None, [] + for line in r.stdout.splitlines(): + m = MARKER_RE.match(line) + if m: + idx, kind = int(m.group(1)), m.group(2) + if kind == "B": + cur, buf = idx, [] + elif kind == "E" and cur == idx: + text = "\n".join(buf).strip() + if text: + results[idx] = text + "\n" + cur, buf = None, [] + continue + if cur is not None: + buf.append(line) + return results + + +def main(): + ap = argparse.ArgumentParser() + ap.add_argument("--out", default=os.path.join(HERE, "harvested")) + ap.add_argument("--limit", type=int, default=0) + ap.add_argument("--jobs", type=int, default=8, help="parallel batches") + ap.add_argument("--batch", type=int, default=500, help="statements per process (1 = per-statement)") + ap.add_argument("--binary", default=os.environ.get("CLICKHOUSE_BINARY", "clickhouse")) + ap.add_argument("--dedupe", choices=["text", "shape"], default="text", + help="text = unique statement text (default); " + "shape = one representative per distinct AST shape") + ap.add_argument("--shape-depth", type=int, default=0, + help="shape dedup: cap signature depth (0 = unlimited); " + "smaller = coarser shapes, fewer representatives") + ap.add_argument("--write", action="store_true", help="write pairs (otherwise dry-run stats only)") + args = ap.parse_args() + + stmts = collect_statements(args.limit) + print(f"collected {len(stmts)} unique, param-free statements") + + if args.write: + os.makedirs(args.out, exist_ok=True) + + ok = fail = 0 + + def write_pair(stmt, js): + h = hashlib.sha1(stmt.encode()).hexdigest()[:16] + with open(os.path.join(args.out, h + ".sql"), "w") as f: + f.write(stmt + "\n") + with open(os.path.join(args.out, h + ".json"), "w") as f: + f.write(js) + + def run_batch(batch): + results = ([explain(args.binary, batch[0])] if args.batch == 1 + else explain_batch(args.binary, batch)) + pairs = [(s, js) for s, js in zip(batch, results) if js is not None] + return len(pairs), len(batch) - len(pairs), pairs + + # shape dedup keeps one representative per AST shape: the shortest + # statement (ties broken lexicographically) so the choice is deterministic + # regardless of batch completion order. + reps = {} + written = 0 + + batches = [stmts[i:i + max(1, args.batch)] for i in range(0, len(stmts), max(1, args.batch))] + with ThreadPoolExecutor(max_workers=args.jobs) as ex: + for n_ok, n_fail, pairs in ex.map(run_batch, batches): + ok += n_ok + fail += n_fail + for stmt, js in pairs: + if args.dedupe == "shape": + try: + doc = json.loads(js) + except json.JSONDecodeError: + continue + # Shape the AST itself, not the { version, ast } wrapper, so + # depth granularity is measured from the real root. + root = doc["ast"] if isinstance(doc, dict) and "ast" in doc else doc + sig = ast_shape(root, args.shape_depth) + cand = (len(stmt), stmt) + if sig not in reps or cand < reps[sig][0]: + reps[sig] = (cand, js) + continue + written += 1 + if args.write: + write_pair(stmt, js) + + if args.dedupe == "shape": + for (_, stmt), js in reps.values(): + written += 1 + if args.write: + write_pair(stmt, js) + + total = ok + fail + rate = (100.0 * ok / total) if total else 0.0 + print(f"parsed OK: {ok} failed: {fail} yield: {rate:.1f}%") + if args.dedupe == "shape": + print(f"distinct AST shapes: {len(reps)}") + print(f"{'wrote' if args.write else 'would write'} {written} pairs" + + (f" to {args.out}" if args.write else "")) + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/ast_json_fixtures/shapes/00055d0bc9091d31.json b/tests/ast_json_fixtures/shapes/00055d0bc9091d31.json new file mode 100644 index 000000000000..008b0a8202d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00055d0bc9091d31.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "function_name": { + "type": "Identifier", + "name": "02148_test_function" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/00055d0bc9091d31.sql b/tests/ast_json_fixtures/shapes/00055d0bc9091d31.sql new file mode 100644 index 000000000000..29e3e88240db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00055d0bc9091d31.sql @@ -0,0 +1 @@ +CREATE FUNCTION 02148_test_function AS () -> (SELECT 1) diff --git a/tests/ast_json_fixtures/shapes/0012952bee038f50.json b/tests/ast_json_fixtures/shapes/0012952bee038f50.json new file mode 100644 index 000000000000..0ba3903dfe41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0012952bee038f50.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s5_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "parent_profile": "default" + }, + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "0" + }, + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "max_value": "6000000", + "writability": "WRITABLE" + } + ] + }, + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["u1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0012952bee038f50.sql b/tests/ast_json_fixtures/shapes/0012952bee038f50.sql new file mode 100644 index 000000000000..ed5e23049dce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0012952bee038f50.sql @@ -0,0 +1 @@ +CREATE PROFILE s5_01294 SETTINGS INHERIT default, readonly=0, max_memory_usage MAX 6000000 WRITABLE TO u1_01294 diff --git a/tests/ast_json_fixtures/shapes/00448ec8087afa3e.json b/tests/ast_json_fixtures/shapes/00448ec8087afa3e.json new file mode 100644 index 000000000000..5da9948d456b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00448ec8087afa3e.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "nameGroup6", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "val" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1_00729" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "notEmpty", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "nameGroup6" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "nameGroup6" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "nameGroup6" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/00448ec8087afa3e.sql b/tests/ast_json_fixtures/shapes/00448ec8087afa3e.sql new file mode 100644 index 000000000000..49726cbd3084 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00448ec8087afa3e.sql @@ -0,0 +1 @@ +select arrayJoin(val) as nameGroup6 from t1_00729 prewhere notEmpty(toString(nameGroup6)) group by nameGroup6 order by nameGroup6 diff --git a/tests/ast_json_fixtures/shapes/005282bedbc03037.json b/tests/ast_json_fixtures/shapes/005282bedbc03037.json new file mode 100644 index 000000000000..93d6dcf2089a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/005282bedbc03037.json @@ -0,0 +1,106 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "user_id" + }, + { + "type": "Function", + "alias": "count", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "user_id" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "user_id" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "my_first_table" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "user_id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "101" + } + ] + } + ] + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "by": [ + { + "type": "Identifier", + "name": "user_id" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/005282bedbc03037.sql b/tests/ast_json_fixtures/shapes/005282bedbc03037.sql new file mode 100644 index 000000000000..6640752224fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/005282bedbc03037.sql @@ -0,0 +1,6 @@ +SELECT + user_id + , (count(user_id) OVER (PARTITION BY user_id)) AS count +FROM my_first_table +WHERE timestamp > 0 and user_id IN (101) +LIMIT 2 BY user_id diff --git a/tests/ast_json_fixtures/shapes/007c4621b4d20dd0.json b/tests/ast_json_fixtures/shapes/007c4621b4d20dd0.json new file mode 100644 index 000000000000..a7c77a9ca09b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/007c4621b4d20dd0.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "192" + }, + "limit": { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/007c4621b4d20dd0.sql b/tests/ast_json_fixtures/shapes/007c4621b4d20dd0.sql new file mode 100644 index 000000000000..92b5352b32b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/007c4621b4d20dd0.sql @@ -0,0 +1 @@ +SELECT * FROM test ORDER BY i LIMIT 2*2 OFFSET 192 diff --git a/tests/ast_json_fixtures/shapes/007e54133c24707b.json b/tests/ast_json_fixtures/shapes/007e54133c24707b.json new file mode 100644 index 000000000000..31d7fd0d9aac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/007e54133c24707b.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "if_exists": true, + "names": ["s1_01418", "s2_01418"] + } +} diff --git a/tests/ast_json_fixtures/shapes/007e54133c24707b.sql b/tests/ast_json_fixtures/shapes/007e54133c24707b.sql new file mode 100644 index 000000000000..021d189660ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/007e54133c24707b.sql @@ -0,0 +1 @@ +DROP SETTINGS PROFILE IF EXISTS s1_01418, s2_01418 diff --git a/tests/ast_json_fixtures/shapes/0083bdfda9d4f127.json b/tests/ast_json_fixtures/shapes/0083bdfda9d4f127.json new file mode 100644 index 000000000000..c882c375bd43 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0083bdfda9d4f127.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "null_subcolumns" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "n.null", + "name_parts": ["n", "null"] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0083bdfda9d4f127.sql b/tests/ast_json_fixtures/shapes/0083bdfda9d4f127.sql new file mode 100644 index 000000000000..d5ee25b5ac5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0083bdfda9d4f127.sql @@ -0,0 +1 @@ +SELECT count() FROM null_subcolumns WHERE n.null diff --git a/tests/ast_json_fixtures/shapes/008a7375b6567575.json b/tests/ast_json_fixtures/shapes/008a7375b6567575.json new file mode 100644 index 000000000000..182ded455c85 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/008a7375b6567575.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "or_replace": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/008a7375b6567575.sql b/tests/ast_json_fixtures/shapes/008a7375b6567575.sql new file mode 100644 index 000000000000..8e28983c496e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/008a7375b6567575.sql @@ -0,0 +1 @@ +CREATE USER OR REPLACE u1_01292 diff --git a/tests/ast_json_fixtures/shapes/00aecd16dc447d15.json b/tests/ast_json_fixtures/shapes/00aecd16dc447d15.json new file mode 100644 index 000000000000..c9c9ce8ca619 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00aecd16dc447d15.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "lag", + "name": "lag", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8472" + } + ], + "window_definition": { + "type": "WindowDefinition" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/00aecd16dc447d15.sql b/tests/ast_json_fixtures/shapes/00aecd16dc447d15.sql new file mode 100644 index 000000000000..2495151c7704 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00aecd16dc447d15.sql @@ -0,0 +1,5 @@ +SELECT number + ,lag(number, 1, 8472) OVER () lag +FROM numbers(5) +ORDER BY number +FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/00ba073c1ebff2ef.json b/tests/ast_json_fixtures/shapes/00ba073c1ebff2ef.json new file mode 100644 index 000000000000..88f191a73d63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00ba073c1ebff2ef.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_rollup": true, + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + { + "type": "Function", + "name": "count", + "nulls_action": "IGNORE NULLS", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Function", + "alias": "key", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/00ba073c1ebff2ef.sql b/tests/ast_json_fixtures/shapes/00ba073c1ebff2ef.sql new file mode 100644 index 000000000000..15302763b06a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00ba073c1ebff2ef.sql @@ -0,0 +1 @@ +SELECT 4, count(4) IGNORE NULLS, number % 2 AS key FROM numbers(10) GROUP BY key WITH ROLLUP WITH TOTALS QUALIFY key = materialize(0) diff --git a/tests/ast_json_fixtures/shapes/00bb8bed07701908.json b/tests/ast_json_fixtures/shapes/00bb8bed07701908.json new file mode 100644 index 000000000000..e9d10bc516e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00bb8bed07701908.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["sqllt_role"] + } +} diff --git a/tests/ast_json_fixtures/shapes/00bb8bed07701908.sql b/tests/ast_json_fixtures/shapes/00bb8bed07701908.sql new file mode 100644 index 000000000000..d307934e518c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00bb8bed07701908.sql @@ -0,0 +1 @@ +CREATE ROLE sqllt_role diff --git a/tests/ast_json_fixtures/shapes/00e69af933c0b82d.json b/tests/ast_json_fixtures/shapes/00e69af933c0b82d.json new file mode 100644 index 000000000000..6294c5cec788 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00e69af933c0b82d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u9_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/00e69af933c0b82d.sql b/tests/ast_json_fixtures/shapes/00e69af933c0b82d.sql new file mode 100644 index 000000000000..335e2e02931b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/00e69af933c0b82d.sql @@ -0,0 +1 @@ +SHOW CREATE USER u9_01292 diff --git a/tests/ast_json_fixtures/shapes/0100edb11921e311.json b/tests/ast_json_fixtures/shapes/0100edb11921e311.json new file mode 100644 index 000000000000..e8b452dba32f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0100edb11921e311.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "src_table" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_database": "system", + "as_table": "numbers" + } +} diff --git a/tests/ast_json_fixtures/shapes/0100edb11921e311.sql b/tests/ast_json_fixtures/shapes/0100edb11921e311.sql new file mode 100644 index 000000000000..4310af276d21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0100edb11921e311.sql @@ -0,0 +1 @@ +create table src_table Engine=Memory as system.numbers diff --git a/tests/ast_json_fixtures/shapes/010f5933510ef197.json b/tests/ast_json_fixtures/shapes/010f5933510ef197.json new file mode 100644 index 000000000000..c8a9d17a8916 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/010f5933510ef197.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "n" + }, + "sample_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/010f5933510ef197.sql b/tests/ast_json_fixtures/shapes/010f5933510ef197.sql new file mode 100644 index 000000000000..4bfb82673621 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/010f5933510ef197.sql @@ -0,0 +1 @@ +CREATE TABLE t (n UInt8) ENGINE=MergeTree ORDER BY n SAMPLE BY tuple() diff --git a/tests/ast_json_fixtures/shapes/01191b42f6480ef3.json b/tests/ast_json_fixtures/shapes/01191b42f6480ef3.json new file mode 100644 index 000000000000..874538480da5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01191b42f6480ef3.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "TruncateQuery", + "kind": "TRUNCATE", + "database": { + "type": "Identifier", + "name": "test_truncate_database" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/01191b42f6480ef3.sql b/tests/ast_json_fixtures/shapes/01191b42f6480ef3.sql new file mode 100644 index 000000000000..9fb0073599b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01191b42f6480ef3.sql @@ -0,0 +1 @@ +TRUNCATE DATABASE test_truncate_database diff --git a/tests/ast_json_fixtures/shapes/016ab809dda65cf0.json b/tests/ast_json_fixtures/shapes/016ab809dda65cf0.json new file mode 100644 index 000000000000..2ac80214014f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/016ab809dda65cf0.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "expr", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_validation" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "expr" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "expr" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/016ab809dda65cf0.sql b/tests/ast_json_fixtures/shapes/016ab809dda65cf0.sql new file mode 100644 index 000000000000..0a1e2f9ac974 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/016ab809dda65cf0.sql @@ -0,0 +1 @@ +SELECT c0 + 1 as expr FROM test_limit_by_validation GROUP BY c0 + 1 ORDER BY expr LIMIT 1 BY expr diff --git a/tests/ast_json_fixtures/shapes/016acb99b3fda78c.json b/tests/ast_json_fixtures/shapes/016acb99b3fda78c.json new file mode 100644 index 000000000000..c85cdf8be443 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/016acb99b3fda78c.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "null_02230_column_ttl" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Null", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "data_02230_column_ttl" + } +} diff --git a/tests/ast_json_fixtures/shapes/016acb99b3fda78c.sql b/tests/ast_json_fixtures/shapes/016acb99b3fda78c.sql new file mode 100644 index 000000000000..ffac8121ddf9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/016acb99b3fda78c.sql @@ -0,0 +1 @@ +create table null_02230_column_ttl engine=Null() as data_02230_column_ttl diff --git a/tests/ast_json_fixtures/shapes/016ae4fcde68fed6.json b/tests/ast_json_fixtures/shapes/016ae4fcde68fed6.json new file mode 100644 index 000000000000..484498b5ff54 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/016ae4fcde68fed6.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateDatabaseQuery", + "database": { + "type": "Identifier", + "name": "t_2710_db" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/016ae4fcde68fed6.sql b/tests/ast_json_fixtures/shapes/016ae4fcde68fed6.sql new file mode 100644 index 000000000000..057042023367 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/016ae4fcde68fed6.sql @@ -0,0 +1 @@ +SHOW DATABASE t_2710_db diff --git a/tests/ast_json_fixtures/shapes/016d2e3b3689d667.json b/tests/ast_json_fixtures/shapes/016d2e3b3689d667.json new file mode 100644 index 000000000000..d7044f87c235 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/016d2e3b3689d667.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r2_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/016d2e3b3689d667.sql b/tests/ast_json_fixtures/shapes/016d2e3b3689d667.sql new file mode 100644 index 000000000000..c3c88d581f57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/016d2e3b3689d667.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r2_01293 diff --git a/tests/ast_json_fixtures/shapes/0191193b5354cee0.json b/tests/ast_json_fixtures/shapes/0191193b5354cee0.json new file mode 100644 index 000000000000..5e53b8672431 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0191193b5354cee0.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "name", + "value_type": "String", + "value": "John" + }, + { + "type": "Function", + "alias": "birthdate", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1990-01-01" + } + ] + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Identifier", + "name": "birthdate" + } + ] + }, + { + "type": "Identifier", + "name": "userid_set2" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0191193b5354cee0.sql b/tests/ast_json_fixtures/shapes/0191193b5354cee0.sql new file mode 100644 index 000000000000..0f75e3c514bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0191193b5354cee0.sql @@ -0,0 +1,3 @@ +WITH 'John' AS name, toDate('1990-01-01') AS birthdate +SELECT * FROM numbers(10) +WHERE (number, name, birthdate) IN (userid_set2) diff --git a/tests/ast_json_fixtures/shapes/0193ddc57aae6e08.json b/tests/ast_json_fixtures/shapes/0193ddc57aae6e08.json new file mode 100644 index 000000000000..d6039b188374 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0193ddc57aae6e08.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t10" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sign", + "arguments": [ + { + "type": "Identifier", + "name": "t10.c0", + "name_parts": ["t10", "c0"] + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0193ddc57aae6e08.sql b/tests/ast_json_fixtures/shapes/0193ddc57aae6e08.sql new file mode 100644 index 000000000000..77f938c56e54 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0193ddc57aae6e08.sql @@ -0,0 +1 @@ +SELECT 1 FROM t10 GROUP BY -sign(t10.c0) diff --git a/tests/ast_json_fixtures/shapes/0195068fec89c1d3.json b/tests/ast_json_fixtures/shapes/0195068fec89c1d3.json new file mode 100644 index 000000000000..49e881e5a730 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0195068fec89c1d3.json @@ -0,0 +1,353 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "x", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "a", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "y", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "a", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "z", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "w", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "y" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "y" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "z" + } + } + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "w" + } + } + } + ] + } + } + ] + } + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x.a", + "name_parts": ["x", "a"] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0195068fec89c1d3.sql b/tests/ast_json_fixtures/shapes/0195068fec89c1d3.sql new file mode 100644 index 000000000000..b34d5a5c6315 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0195068fec89c1d3.sql @@ -0,0 +1,7 @@ +WITH +x AS (SELECT number AS a FROM numbers(10)), +y AS (SELECT number AS a FROM numbers(5)), +z AS (SELECT * FROM x WHERE a % 2), +w AS (SELECT * FROM y WHERE a > 0) +SELECT a FROM x JOIN y USING a WHERE a in (SELECT * FROM z) AND a <= (SELECT max(a) FROM w) +ORDER BY x.a diff --git a/tests/ast_json_fixtures/shapes/01973ba4cc26495d.json b/tests/ast_json_fixtures/shapes/01973ba4cc26495d.json new file mode 100644 index 000000000000..c5dfcf847230 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01973ba4cc26495d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01293", "r2_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/01973ba4cc26495d.sql b/tests/ast_json_fixtures/shapes/01973ba4cc26495d.sql new file mode 100644 index 000000000000..733d41958b36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01973ba4cc26495d.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r1_01293, r2_01293 diff --git a/tests/ast_json_fixtures/shapes/01c143c205c8dc2a.json b/tests/ast_json_fixtures/shapes/01c143c205c8dc2a.json new file mode 100644 index 000000000000..87ad1570d2a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01c143c205c8dc2a.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt16" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/01c143c205c8dc2a.sql b/tests/ast_json_fixtures/shapes/01c143c205c8dc2a.sql new file mode 100644 index 000000000000..c730271f593f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01c143c205c8dc2a.sql @@ -0,0 +1 @@ +SELECT [1], 0::UInt16 diff --git a/tests/ast_json_fixtures/shapes/01ca709499a4674f.json b/tests/ast_json_fixtures/shapes/01ca709499a4674f.json new file mode 100644 index 000000000000..115362cf6e1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01ca709499a4674f.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r6_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "writability": "CONST" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/01ca709499a4674f.sql b/tests/ast_json_fixtures/shapes/01ca709499a4674f.sql new file mode 100644 index 000000000000..6a90caf14d2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01ca709499a4674f.sql @@ -0,0 +1 @@ +CREATE ROLE r6_01293 SETTINGS max_memory_usage CONST diff --git a/tests/ast_json_fixtures/shapes/01cf15a602672374.json b/tests/ast_json_fixtures/shapes/01cf15a602672374.json new file mode 100644 index 000000000000..07df3764bad0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01cf15a602672374.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tt_m" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/01cf15a602672374.sql b/tests/ast_json_fixtures/shapes/01cf15a602672374.sql new file mode 100644 index 000000000000..be847254cda5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01cf15a602672374.sql @@ -0,0 +1 @@ +SELECT b FROM tt_m order by b LIMIT 1 BY b diff --git a/tests/ast_json_fixtures/shapes/01dcb57b102c6ee7.json b/tests/ast_json_fixtures/shapes/01dcb57b102c6ee7.json new file mode 100644 index 000000000000..0c460a498467 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01dcb57b102c6ee7.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + } + } + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "Int64", + "value": "-446744073709551615" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "18446744073709551615" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/01dcb57b102c6ee7.sql b/tests/ast_json_fixtures/shapes/01dcb57b102c6ee7.sql new file mode 100644 index 000000000000..95eecb31af20 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01dcb57b102c6ee7.sql @@ -0,0 +1 @@ +SELECT DISTINCT number FROM numbers(20) LIMIT 18446744073709551615 OFFSET -446744073709551615 diff --git a/tests/ast_json_fixtures/shapes/01f27f100c1301a9.json b/tests/ast_json_fixtures/shapes/01f27f100c1301a9.json new file mode 100644 index 000000000000..2296c0a3e5f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01f27f100c1301a9.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u14_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/01f27f100c1301a9.sql b/tests/ast_json_fixtures/shapes/01f27f100c1301a9.sql new file mode 100644 index 000000000000..083422b4ede5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/01f27f100c1301a9.sql @@ -0,0 +1 @@ +SHOW CREATE USER u14_01292 diff --git a/tests/ast_json_fixtures/shapes/0206011c9209842c.json b/tests/ast_json_fixtures/shapes/0206011c9209842c.json new file mode 100644 index 000000000000..56d34853ec52 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0206011c9209842c.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "count" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0206011c9209842c.sql b/tests/ast_json_fixtures/shapes/0206011c9209842c.sql new file mode 100644 index 000000000000..d3701c6454ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0206011c9209842c.sql @@ -0,0 +1 @@ +SELECT count() FROM count WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/020e6e190e7b79c6.json b/tests/ast_json_fixtures/shapes/020e6e190e7b79c6.json new file mode 100644 index 000000000000..b920cabb342a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/020e6e190e7b79c6.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "data" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/020e6e190e7b79c6.sql b/tests/ast_json_fixtures/shapes/020e6e190e7b79c6.sql new file mode 100644 index 000000000000..9b2713ffa90a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/020e6e190e7b79c6.sql @@ -0,0 +1 @@ +INSERT INTO data SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/021711afdd2bc059.json b/tests/ast_json_fixtures/shapes/021711afdd2bc059.json new file mode 100644 index 000000000000..6637c1fe4e3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/021711afdd2bc059.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u15_01292" + } + ] + }, + "hosts": { + "addresses": ["2001:db8:11a3:9d7:1f34:8a2e:7a0:765d"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/021711afdd2bc059.sql b/tests/ast_json_fixtures/shapes/021711afdd2bc059.sql new file mode 100644 index 000000000000..9f794f3ae4df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/021711afdd2bc059.sql @@ -0,0 +1 @@ +CREATE USER u15_01292 HOST IP '2001:0db8:11a3:09d7:1f34:8a2e:07a0:765d' diff --git a/tests/ast_json_fixtures/shapes/0237649b7b027b2d.json b/tests/ast_json_fixtures/shapes/0237649b7b027b2d.json new file mode 100644 index 000000000000..8e8edf5abfc3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0237649b7b027b2d.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "1" + } + } + } + ], + "format": "Hash" + } +} diff --git a/tests/ast_json_fixtures/shapes/0237649b7b027b2d.sql b/tests/ast_json_fixtures/shapes/0237649b7b027b2d.sql new file mode 100644 index 000000000000..b64ad6bbcf33 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0237649b7b027b2d.sql @@ -0,0 +1 @@ +SELECT number, number + 1 FROM numbers(2) SETTINGS max_block_size = 1 FORMAT Hash diff --git a/tests/ast_json_fixtures/shapes/0243e76bc82cb510.json b/tests/ast_json_fixtures/shapes/0243e76bc82cb510.json new file mode 100644 index 000000000000..5e19d846f901 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0243e76bc82cb510.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "02416_rocksdb" + }, + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0243e76bc82cb510.sql b/tests/ast_json_fixtures/shapes/0243e76bc82cb510.sql new file mode 100644 index 000000000000..78ce25eaf4a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0243e76bc82cb510.sql @@ -0,0 +1 @@ +DELETE FROM 02416_rocksdb WHERE 1 = 1 diff --git a/tests/ast_json_fixtures/shapes/0248e058189b13e8.json b/tests/ast_json_fixtures/shapes/0248e058189b13e8.json new file mode 100644 index 000000000000..3720c61675c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0248e058189b13e8.json @@ -0,0 +1,114 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "ad", + "name": "number" + }, + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "alias": "pd", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "direction": "ASC", + "with_fill": true + } + ], + "interpolate": [ + { + "type": "InterpolateElement", + "column": "pd", + "expr": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "pd" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + }, + { + "type": "InterpolateElement", + "column": "ad", + "expr": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ad" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0248e058189b13e8.sql b/tests/ast_json_fixtures/shapes/0248e058189b13e8.sql new file mode 100644 index 000000000000..f953208d116a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0248e058189b13e8.sql @@ -0,0 +1 @@ +select number as ad, number, number as pd from numbers(5) order by number*10 with fill interpolate (pd as pd+100, ad as ad+1000) diff --git a/tests/ast_json_fixtures/shapes/0248e52bcfd6802c.json b/tests/ast_json_fixtures/shapes/0248e52bcfd6802c.json new file mode 100644 index 000000000000..5a359bd22a51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0248e52bcfd6802c.json @@ -0,0 +1,119 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "id", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.id", + "name_parts": ["t2", "id"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "_1" + } + ] + }, + { + "type": "Identifier", + "name": "t1.val", + "name_parts": ["t1", "val"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.id", + "name_parts": ["t1", "id"] + }, + { + "type": "Identifier", + "name": "t2.id", + "name_parts": ["t2", "id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "using": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t3" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.val", + "name_parts": ["t1", "val"] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "join_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0248e52bcfd6802c.sql b/tests/ast_json_fixtures/shapes/0248e52bcfd6802c.sql new file mode 100644 index 000000000000..42672036778a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0248e52bcfd6802c.sql @@ -0,0 +1,6 @@ +SELECT t2.id || '_1' AS id, t1.val +FROM t1 +FULL JOIN t2 ON t1.id = t2.id +FULL JOIN t3 USING (id) +ORDER BY t1.val +SETTINGS join_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/026c008cfa35d043.json b/tests/ast_json_fixtures/shapes/026c008cfa35d043.json new file mode 100644 index 000000000000..02aec22609bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/026c008cfa35d043.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "attach_partition_t6" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "replace": false, + "from_table": "attach_partition_t5" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/026c008cfa35d043.sql b/tests/ast_json_fixtures/shapes/026c008cfa35d043.sql new file mode 100644 index 000000000000..812ccbf9360a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/026c008cfa35d043.sql @@ -0,0 +1 @@ +ALTER TABLE attach_partition_t6 ATTACH PARTITION tuple() FROM attach_partition_t5 diff --git a/tests/ast_json_fixtures/shapes/026d83dc8dc49157.json b/tests/ast_json_fixtures/shapes/026d83dc8dc49157.json new file mode 100644 index 000000000000..84aa6e2e6f19 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/026d83dc8dc49157.json @@ -0,0 +1,371 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "tan", + "arguments": [ + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + } + ] + }, + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1017248723" + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + }, + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t3" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + } + ], + "having": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tan", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1017248723" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "sqrt", + "arguments": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1017248723" + } + ] + } + ] + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "tan", + "arguments": [ + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + } + ] + }, + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1017248723" + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + }, + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t3" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + } + ], + "having": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tan", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1017248723" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "sqrt", + "arguments": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1017248723" + } + ] + } + ] + } + ] + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "tan", + "arguments": [ + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + } + ] + }, + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1017248723" + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + }, + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t3" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t3.c0", + "name_parts": ["t3", "c0"] + } + ], + "having": { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tan", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1017248723" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "sqrt", + "arguments": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1017248723" + } + ] + } + ] + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "aggregate_functions_null_for_empty": "1", + "enable_optimize_predicate_expression": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/026d83dc8dc49157.sql b/tests/ast_json_fixtures/shapes/026d83dc8dc49157.sql new file mode 100644 index 000000000000..0cf8f6d6da2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/026d83dc8dc49157.sql @@ -0,0 +1 @@ +SELECT (tan (t3.c0)), SUM(-1017248723), ((t3.c0)%(t3.c0)) FROM t3 GROUP BY t3.c0 HAVING ((tan ((- (SUM(-1017248723)))))) and ((sqrt (SUM(-1017248723)))) UNION ALL SELECT (tan (t3.c0)), SUM(-1017248723), ((t3.c0)%(t3.c0)) FROM t3 GROUP BY t3.c0 HAVING (NOT (((tan ((- (SUM(-1017248723)))))) and ((sqrt (SUM(-1017248723)))))) UNION ALL SELECT (tan (t3.c0)), SUM(-1017248723), ((t3.c0)%(t3.c0)) FROM t3 GROUP BY t3.c0 HAVING ((((tan ((- (SUM(-1017248723)))))) and ((sqrt (SUM(-1017248723))))) IS NULL) SETTINGS aggregate_functions_null_for_empty=1, enable_optimize_predicate_expression=0 diff --git a/tests/ast_json_fixtures/shapes/0272d20a3ae12391.json b/tests/ast_json_fixtures/shapes/0272d20a3ae12391.json new file mode 100644 index 000000000000..d949e985854e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0272d20a3ae12391.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "where": { + "type": "Asterisk" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0272d20a3ae12391.sql b/tests/ast_json_fixtures/shapes/0272d20a3ae12391.sql new file mode 100644 index 000000000000..06696bb88e9e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0272d20a3ae12391.sql @@ -0,0 +1 @@ +SELECT * WHERE * diff --git a/tests/ast_json_fixtures/shapes/029d81a936030eb3.json b/tests/ast_json_fixtures/shapes/029d81a936030eb3.json new file mode 100644 index 000000000000..ba9b0c39ad92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/029d81a936030eb3.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "cluster": "test_shard_localhost", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "02911_user" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/029d81a936030eb3.sql b/tests/ast_json_fixtures/shapes/029d81a936030eb3.sql new file mode 100644 index 000000000000..0b93ebb58bef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/029d81a936030eb3.sql @@ -0,0 +1 @@ +CREATE USER 02911_user ON CLUSTER test_shard_localhost diff --git a/tests/ast_json_fixtures/shapes/029f8e2f09f435dd.json b/tests/ast_json_fixtures/shapes/029f8e2f09f435dd.json new file mode 100644 index 000000000000..f28efbe83112 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/029f8e2f09f435dd.json @@ -0,0 +1,139 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "table": { + "type": "Identifier", + "name": "bloom_filter_idx_good" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "u64", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "i32", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "f64", + "data_type": { + "type": "DataType", + "name": "Float64" + } + }, + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "Decimal", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "e", + "data_type": { + "type": "EnumDataType", + "name": "Enum8", + "values": [ + { + "name": "a", + "value": 1 + }, + { + "name": "b", + "value": 2 + }, + { + "name": "c", + "value": 3 + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "dt", + "data_type": { + "type": "DataType", + "name": "Date" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "bloom_filter_a", + "expression": { + "type": "Identifier", + "name": "i32" + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": -0.1 + } + ] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "u64" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/029f8e2f09f435dd.sql b/tests/ast_json_fixtures/shapes/029f8e2f09f435dd.sql new file mode 100644 index 000000000000..200b0548aac0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/029f8e2f09f435dd.sql @@ -0,0 +1 @@ +ATTACH TABLE bloom_filter_idx_good(`u64` UInt64, `i32` Int32, `f64` Float64, `d` Decimal(10, 2), `s` String, `e` Enum8('a' = 1, 'b' = 2, 'c' = 3), `dt` Date, INDEX bloom_filter_a i32 TYPE bloom_filter(-0.1) GRANULARITY 1) ENGINE = MergeTree() ORDER BY u64 SETTINGS index_granularity = 8192 diff --git a/tests/ast_json_fixtures/shapes/02bf9865810a330d.json b/tests/ast_json_fixtures/shapes/02bf9865810a330d.json new file mode 100644 index 000000000000..25217694ee4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02bf9865810a330d.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_table": "alias_a_exchange", + "to_table": "alias_b_exchange" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/02bf9865810a330d.sql b/tests/ast_json_fixtures/shapes/02bf9865810a330d.sql new file mode 100644 index 000000000000..14db4f994817 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02bf9865810a330d.sql @@ -0,0 +1 @@ +EXCHANGE TABLES alias_a_exchange AND alias_b_exchange diff --git a/tests/ast_json_fixtures/shapes/02cf84c802cfa539.json b/tests/ast_json_fixtures/shapes/02cf84c802cfa539.json new file mode 100644 index 000000000000..4e9163467333 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02cf84c802cfa539.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "partition_all2" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "UPDATE", + "partition": { + "type": "Partition_ID", + "all": true + }, + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "p" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "assignments": [ + { + "type": "Assignment", + "column": "q", + "expression": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "q" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/02cf84c802cfa539.sql b/tests/ast_json_fixtures/shapes/02cf84c802cfa539.sql new file mode 100644 index 000000000000..b8208397c54f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02cf84c802cfa539.sql @@ -0,0 +1 @@ +ALTER TABLE partition_all2 UPDATE q = q + 1 IN PARTITION ALL where p = 1 diff --git a/tests/ast_json_fixtures/shapes/02d4020f7eacacde.json b/tests/ast_json_fixtures/shapes/02d4020f7eacacde.json new file mode 100644 index 000000000000..8516ca88cf3a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02d4020f7eacacde.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toUInt32", + "arguments": [ + { + "type": "Identifier", + "name": "metadata_modification_time" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Identifier", + "name": "engine_full" + }, + { + "type": "Identifier", + "name": "create_table_query" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tables", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSVRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/02d4020f7eacacde.sql b/tests/ast_json_fixtures/shapes/02d4020f7eacacde.sql new file mode 100644 index 000000000000..5a369439ae02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02d4020f7eacacde.sql @@ -0,0 +1 @@ +SELECT name, toUInt32(metadata_modification_time) > 0, engine_full, create_table_query FROM system.tables WHERE database = currentDatabase() ORDER BY name FORMAT TSVRaw diff --git a/tests/ast_json_fixtures/shapes/02dfb843ff554bd2.json b/tests/ast_json_fixtures/shapes/02dfb843ff554bd2.json new file mode 100644 index 000000000000..478c882cf46c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02dfb843ff554bd2.json @@ -0,0 +1,209 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "v", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "111111111111111111111111111111111111111" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "39" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "39" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "39" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt128" + } + ] + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Function", + "name": "coalesce", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "v" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test__fuzz_21" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "coalesce", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "coalesce", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/02dfb843ff554bd2.sql b/tests/ast_json_fixtures/shapes/02dfb843ff554bd2.sql new file mode 100644 index 000000000000..81d845a09f86 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02dfb843ff554bd2.sql @@ -0,0 +1,10 @@ +WITH ( + SELECT CAST(toFixedString(toFixedString(materialize(toFixedString('111111111111111111111111111111111111111', 39)), 39), 39), 'UInt128') + ) AS v +SELECT + coalesce(materialize(toLowCardinality(toNullable(1))), 10, NULL), + max(v) +FROM remote('127.0.0.{1,2}', currentDatabase(), test__fuzz_21) +GROUP BY + coalesce(NULL), + coalesce(1, 10, 10, materialize(NULL)) diff --git a/tests/ast_json_fixtures/shapes/02e8ce1f1144ee79.json b/tests/ast_json_fixtures/shapes/02e8ce1f1144ee79.json new file mode 100644 index 000000000000..839017d2f0e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02e8ce1f1144ee79.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "outer_distributed" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "outer" + }, + { + "type": "Function", + "name": "intHash64", + "arguments": [ + { + "type": "Identifier", + "name": "organization_id" + } + ] + } + ] + } + }, + "as_table": "outer" + } +} diff --git a/tests/ast_json_fixtures/shapes/02e8ce1f1144ee79.sql b/tests/ast_json_fixtures/shapes/02e8ce1f1144ee79.sql new file mode 100644 index 000000000000..87d79e00a512 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02e8ce1f1144ee79.sql @@ -0,0 +1,2 @@ +CREATE TABLE outer_distributed AS outer +ENGINE = Distributed('test_cluster_two_shards', currentDatabase(), 'outer', intHash64(organization_id)) diff --git a/tests/ast_json_fixtures/shapes/02ea3f31c73fe50e.json b/tests/ast_json_fixtures/shapes/02ea3f31c73fe50e.json new file mode 100644 index 000000000000..365525013521 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02ea3f31c73fe50e.json @@ -0,0 +1,591 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "bad_cnt", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv4" + } + ] + } + ] + }, + { + "type": "Function", + "name": "notIn", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv4", + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv4" + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv4", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0.0.0.0" + } + ] + }, + { + "type": "Function", + "name": "toIPv4", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "192.168.0.1" + } + ] + } + ] + } + ] + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv6" + } + ] + } + ] + }, + { + "type": "Function", + "name": "notIn", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv6" + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "::" + } + ] + }, + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "::1" + } + ] + }, + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "::ffff:192.168.0.1" + } + ] + } + ] + } + ] + } + ] + } + } + ] + } + } + ] + } + ], + "select": [ + { + "type": "Literal", + "alias": "tag", + "value_type": "String", + "value": "ch_dbg_offenders" + }, + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "src_type", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "alias": "v4", + "name": "toIPv4", + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv4" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "v6", + "name": "toIPv6", + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv6" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "raw_d", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bad_cnt" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv4" + } + ] + } + ] + }, + { + "type": "Function", + "name": "notIn", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv4", + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv4" + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv4", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0.0.0.0" + } + ] + }, + { + "type": "Function", + "name": "toIPv4", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "192.168.0.1" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv6" + } + ] + } + ] + }, + { + "type": "Function", + "name": "notIn", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv6" + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "::" + } + ] + }, + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "::1" + } + ] + }, + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "::ffff:192.168.0.1" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/02ea3f31c73fe50e.sql b/tests/ast_json_fixtures/shapes/02ea3f31c73fe50e.sql new file mode 100644 index 000000000000..240eb88a7fce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02ea3f31c73fe50e.sql @@ -0,0 +1,28 @@ +WITH + (SELECT count() + FROM t + WHERE accurateCastOrNull(d,'IPv4') IS NOT NULL + AND toIPv4(accurateCastOrNull(d,'IPv4')) NOT IN (toIPv4('0.0.0.0'), toIPv4('192.168.0.1')) + ) + + (SELECT count() + FROM t + WHERE accurateCastOrNull(d,'IPv6') IS NOT NULL + AND toIPv6(accurateCastOrNull(d,'IPv6')) NOT IN (toIPv6('::'), toIPv6('::1'), toIPv6('::ffff:192.168.0.1')) + ) AS bad_cnt +SELECT + 'ch_dbg_offenders' AS tag, + id, + toTypeName(d) AS src_type, + toIPv4(accurateCastOrNull(d,'IPv4')) AS v4, + toIPv6(accurateCastOrNull(d,'IPv6')) AS v6, + toString(d) AS raw_d +FROM t +WHERE bad_cnt > 0 + AND ( + (accurateCastOrNull(d,'IPv4') IS NOT NULL + AND toIPv4(accurateCastOrNull(d,'IPv4')) NOT IN (toIPv4('0.0.0.0'), toIPv4('192.168.0.1'))) + OR (accurateCastOrNull(d,'IPv6') IS NOT NULL + AND toIPv6(accurateCastOrNull(d,'IPv6')) NOT IN (toIPv6('::'), toIPv6('::1'), toIPv6('::ffff:192.168.0.1'))) + ) +ORDER BY id +LIMIT 20 diff --git a/tests/ast_json_fixtures/shapes/02ec7bb5b93665ca.json b/tests/ast_json_fixtures/shapes/02ec7bb5b93665ca.json new file mode 100644 index 000000000000..adce81c22ec5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02ec7bb5b93665ca.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "03271_parametrized_v" + } +} diff --git a/tests/ast_json_fixtures/shapes/02ec7bb5b93665ca.sql b/tests/ast_json_fixtures/shapes/02ec7bb5b93665ca.sql new file mode 100644 index 000000000000..66dfb9d4717e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/02ec7bb5b93665ca.sql @@ -0,0 +1 @@ +SHOW COLUMNS IN 03271_parametrized_v diff --git a/tests/ast_json_fixtures/shapes/0304dc912d05ff2c.json b/tests/ast_json_fixtures/shapes/0304dc912d05ff2c.json new file mode 100644 index 000000000000..5799574e036f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0304dc912d05ff2c.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "mergeTreeIndex", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "t_mt_params" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/0304dc912d05ff2c.sql b/tests/ast_json_fixtures/shapes/0304dc912d05ff2c.sql new file mode 100644 index 000000000000..b62b20f0f609 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0304dc912d05ff2c.sql @@ -0,0 +1 @@ +SELECT * FROM mergeTreeIndex(currentDatabase(), 't_mt_params') ORDER BY ALL FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/030b441c6db279d2.json b/tests/ast_json_fixtures/shapes/030b441c6db279d2.json new file mode 100644 index 000000000000..dd7eaed773cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/030b441c6db279d2.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "t_lwu_deletes_3" + }, + "predicate": { + "type": "Function", + "name": "notEmpty", + "arguments": [ + { + "type": "Identifier", + "name": "v2" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/030b441c6db279d2.sql b/tests/ast_json_fixtures/shapes/030b441c6db279d2.sql new file mode 100644 index 000000000000..b5fa621e0b7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/030b441c6db279d2.sql @@ -0,0 +1 @@ +DELETE FROM t_lwu_deletes_3 WHERE notEmpty(v2) diff --git a/tests/ast_json_fixtures/shapes/03133f40b00da65a.json b/tests/ast_json_fixtures/shapes/03133f40b00da65a.json new file mode 100644 index 000000000000..91e1c4363034 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03133f40b00da65a.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": true + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/03133f40b00da65a.sql b/tests/ast_json_fixtures/shapes/03133f40b00da65a.sql new file mode 100644 index 000000000000..64fde8c5e2fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03133f40b00da65a.sql @@ -0,0 +1 @@ +SHOW TABLES SETTINGS use_query_cache = true diff --git a/tests/ast_json_fixtures/shapes/0332375a5b184b25.json b/tests/ast_json_fixtures/shapes/0332375a5b184b25.json new file mode 100644 index 000000000000..98341634cda6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0332375a5b184b25.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q1_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "QUERY_SELECTS": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0332375a5b184b25.sql b/tests/ast_json_fixtures/shapes/0332375a5b184b25.sql new file mode 100644 index 000000000000..a57f1988a6b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0332375a5b184b25.sql @@ -0,0 +1 @@ +CREATE QUOTA q1_01297 FOR INTERVAL 1 MINUTE MAX query_selects = '0' diff --git a/tests/ast_json_fixtures/shapes/0333cdb87e8994df.json b/tests/ast_json_fixtures/shapes/0333cdb87e8994df.json new file mode 100644 index 000000000000..2be56be1ef7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0333cdb87e8994df.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/0333cdb87e8994df.sql b/tests/ast_json_fixtures/shapes/0333cdb87e8994df.sql new file mode 100644 index 000000000000..c82f5078f15b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0333cdb87e8994df.sql @@ -0,0 +1 @@ +SELECT * FROM system.numbers WHERE number % 2 = 0 LIMIT 100 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/03404222a50a48f0.json b/tests/ast_json_fixtures/shapes/03404222a50a48f0.json new file mode 100644 index 000000000000..abeca064766f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03404222a50a48f0.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "if_exists": true, + "names": ["r2_01293_renamed"] + } +} diff --git a/tests/ast_json_fixtures/shapes/03404222a50a48f0.sql b/tests/ast_json_fixtures/shapes/03404222a50a48f0.sql new file mode 100644 index 000000000000..3d4a8cbd4aff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03404222a50a48f0.sql @@ -0,0 +1 @@ +DROP ROLE IF EXISTS r2_01293_renamed diff --git a/tests/ast_json_fixtures/shapes/03546fcd69853b9e.json b/tests/ast_json_fixtures/shapes/03546fcd69853b9e.json new file mode 100644 index 000000000000..bff37c53bf23 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03546fcd69853b9e.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "y_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "y" + } + ] + } + }, + "as_table": "y" + } +} diff --git a/tests/ast_json_fixtures/shapes/03546fcd69853b9e.sql b/tests/ast_json_fixtures/shapes/03546fcd69853b9e.sql new file mode 100644 index 000000000000..f969473f11ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03546fcd69853b9e.sql @@ -0,0 +1 @@ +CREATE TABLE y_dist as y ENGINE = Distributed('test_cluster_two_shards_localhost', currentDatabase(), y) diff --git a/tests/ast_json_fixtures/shapes/037065f8cebf06d6.json b/tests/ast_json_fixtures/shapes/037065f8cebf06d6.json new file mode 100644 index 000000000000..8c027a0a1492 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/037065f8cebf06d6.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01755" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01755" + }, + { + "type": "Identifier", + "name": "i" + } + ] + } + }, + "as_table": "data_01755" + } +} diff --git a/tests/ast_json_fixtures/shapes/037065f8cebf06d6.sql b/tests/ast_json_fixtures/shapes/037065f8cebf06d6.sql new file mode 100644 index 000000000000..3f4639806887 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/037065f8cebf06d6.sql @@ -0,0 +1 @@ +create table dist_01755 as data_01755 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01755, i) diff --git a/tests/ast_json_fixtures/shapes/03939542c239d755.json b/tests/ast_json_fixtures/shapes/03939542c239d755.json new file mode 100644 index 000000000000..d06a89d03a63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03939542c239d755.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "String", + "value": "str" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/03939542c239d755.sql b/tests/ast_json_fixtures/shapes/03939542c239d755.sql new file mode 100644 index 000000000000..1bc8a7b9e17e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03939542c239d755.sql @@ -0,0 +1 @@ +select * from test group by grouping sets ((d), ('str')) diff --git a/tests/ast_json_fixtures/shapes/03cb3cbf9161328e.json b/tests/ast_json_fixtures/shapes/03cb3cbf9161328e.json new file mode 100644 index 000000000000..54e7c4b165dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03cb3cbf9161328e.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "FORMAT" + } + } + } + ] + } + } + ], + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/03cb3cbf9161328e.sql b/tests/ast_json_fixtures/shapes/03cb3cbf9161328e.sql new file mode 100644 index 000000000000..002ee7a86d1c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03cb3cbf9161328e.sql @@ -0,0 +1 @@ +SELECT * FROM FORMAT FORMAT Values diff --git a/tests/ast_json_fixtures/shapes/03d43b0ea066964e.json b/tests/ast_json_fixtures/shapes/03d43b0ea066964e.json new file mode 100644 index 000000000000..6be873935fc2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03d43b0ea066964e.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Hello, world!" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "merge_view_00270" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/03d43b0ea066964e.sql b/tests/ast_json_fixtures/shapes/03d43b0ea066964e.sql new file mode 100644 index 000000000000..4f3255b5e50e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03d43b0ea066964e.sql @@ -0,0 +1 @@ +SELECT 'Hello, world!' FROM merge_view_00270 LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/03e442d81a392846.json b/tests/ast_json_fixtures/shapes/03e442d81a392846.json new file mode 100644 index 000000000000..c94f3205eaf9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03e442d81a392846.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_skip_indexes": "0" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/03e442d81a392846.sql b/tests/ast_json_fixtures/shapes/03e442d81a392846.sql new file mode 100644 index 000000000000..6b1f4f3825f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03e442d81a392846.sql @@ -0,0 +1 @@ +SELECT 1 SETTINGS use_skip_indexes = 0 Format Null diff --git a/tests/ast_json_fixtures/shapes/03f10ba0064d951f.json b/tests/ast_json_fixtures/shapes/03f10ba0064d951f.json new file mode 100644 index 000000000000..25ed1bfc901b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03f10ba0064d951f.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_move_partition_src" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + "move_destination_type": "TABLE", + "to_table": "test_move_partition_dest" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/03f10ba0064d951f.sql b/tests/ast_json_fixtures/shapes/03f10ba0064d951f.sql new file mode 100644 index 000000000000..d2d0825fdbf1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03f10ba0064d951f.sql @@ -0,0 +1 @@ +ALTER TABLE test_move_partition_src MOVE PARTITION 1 TO TABLE test_move_partition_dest diff --git a/tests/ast_json_fixtures/shapes/03fe3fb0b5c78c00.json b/tests/ast_json_fixtures/shapes/03fe3fb0b5c78c00.json new file mode 100644 index 000000000000..855f823a1266 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03fe3fb0b5c78c00.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mt" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "n" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/03fe3fb0b5c78c00.sql b/tests/ast_json_fixtures/shapes/03fe3fb0b5c78c00.sql new file mode 100644 index 000000000000..a66c3814e2aa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/03fe3fb0b5c78c00.sql @@ -0,0 +1 @@ +create table mt (n UInt64) engine=MergeTree order by n partition by n % 10 diff --git a/tests/ast_json_fixtures/shapes/0413c2df70c93c4e.json b/tests/ast_json_fixtures/shapes/0413c2df70c93c4e.json new file mode 100644 index 000000000000..7a4facdaa657 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0413c2df70c93c4e.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + ], + "format": "PrettySpaceNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/0413c2df70c93c4e.sql b/tests/ast_json_fixtures/shapes/0413c2df70c93c4e.sql new file mode 100644 index 000000000000..f9e00127289e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0413c2df70c93c4e.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a FORMAT PrettySpaceNoEscapes diff --git a/tests/ast_json_fixtures/shapes/041b1eb6ca995712.json b/tests/ast_json_fixtures/shapes/041b1eb6ca995712.json new file mode 100644 index 000000000000..1ba50d8b0a06 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/041b1eb6ca995712.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s2_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [] + }, + "to_roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/041b1eb6ca995712.sql b/tests/ast_json_fixtures/shapes/041b1eb6ca995712.sql new file mode 100644 index 000000000000..becae0262c1d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/041b1eb6ca995712.sql @@ -0,0 +1 @@ +CREATE SETTINGS PROFILE s2_01294 SETTINGS NONE TO NONE diff --git a/tests/ast_json_fixtures/shapes/041d73e1b2af1f1a.json b/tests/ast_json_fixtures/shapes/041d73e1b2af1f1a.json new file mode 100644 index 000000000000..2f1e7590d625 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/041d73e1b2af1f1a.json @@ -0,0 +1,113 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".03004_data.bsonEachRow" + } + ] + }, + { + "type": "Identifier", + "name": "auto" + }, + { + "type": "Literal", + "value_type": "String", + "value": "null Nullable(UInt32)" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/041d73e1b2af1f1a.sql b/tests/ast_json_fixtures/shapes/041d73e1b2af1f1a.sql new file mode 100644 index 000000000000..7b923f1a8f46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/041d73e1b2af1f1a.sql @@ -0,0 +1 @@ +insert into function file(concat(currentDatabase(), '.03004_data.bsonEachRow'), auto, 'null Nullable(UInt32)') select number % 2 ? NULL : number from numbers(5) settings engine_file_truncate_on_insert=1 diff --git a/tests/ast_json_fixtures/shapes/0439c617de55da22.json b/tests/ast_json_fixtures/shapes/0439c617de55da22.json new file mode 100644 index 000000000000..b29ed12b06bf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0439c617de55da22.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "predicate": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "y" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0439c617de55da22.sql b/tests/ast_json_fixtures/shapes/0439c617de55da22.sql new file mode 100644 index 000000000000..ceda77f0926f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0439c617de55da22.sql @@ -0,0 +1 @@ +DELETE FROM t WHERE x in (SELECT y FROM t) diff --git a/tests/ast_json_fixtures/shapes/0459dd28ac2c0a38.json b/tests/ast_json_fixtures/shapes/0459dd28ac2c0a38.json new file mode 100644 index 000000000000..51447ab6b085 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0459dd28ac2c0a38.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s3_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "parent_profile": "readonly" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0459dd28ac2c0a38.sql b/tests/ast_json_fixtures/shapes/0459dd28ac2c0a38.sql new file mode 100644 index 000000000000..8effdab1bfb7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0459dd28ac2c0a38.sql @@ -0,0 +1 @@ +CREATE PROFILE s3_01294 SETTINGS profile readonly diff --git a/tests/ast_json_fixtures/shapes/048d4dec919c762d.json b/tests/ast_json_fixtures/shapes/048d4dec919c762d.json new file mode 100644 index 000000000000..89219680b4ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/048d4dec919c762d.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_shard_localhost", + "table": { + "type": "Identifier", + "name": "test_repl" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/clickhouse\/test_01181\/{database}\/test_repl" + }, + { + "type": "Literal", + "value_type": "String", + "value": "r1" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/048d4dec919c762d.sql b/tests/ast_json_fixtures/shapes/048d4dec919c762d.sql new file mode 100644 index 000000000000..6782f01f5de3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/048d4dec919c762d.sql @@ -0,0 +1 @@ +CREATE TABLE test_repl ON CLUSTER test_shard_localhost (n UInt64) ENGINE ReplicatedMergeTree('/clickhouse/test_01181/{database}/test_repl','r1') ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/0493161700ec00a8.json b/tests/ast_json_fixtures/shapes/0493161700ec00a8.json new file mode 100644 index 000000000000..a939c971888c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0493161700ec00a8.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR TEXT INDEX POSTINGS CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/0493161700ec00a8.sql b/tests/ast_json_fixtures/shapes/0493161700ec00a8.sql new file mode 100644 index 000000000000..659f53d8e325 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0493161700ec00a8.sql @@ -0,0 +1 @@ +SYSTEM CLEAR TEXT INDEX POSTINGS CACHE diff --git a/tests/ast_json_fixtures/shapes/049b1babc46f56e9.json b/tests/ast_json_fixtures/shapes/049b1babc46f56e9.json new file mode 100644 index 000000000000..ab9905e599fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/049b1babc46f56e9.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "foo_with_projection" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "ts", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "pj", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "ts" + }, + { + "type": "Identifier", + "name": "x" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMMDD", + "arguments": [ + { + "type": "Identifier", + "name": "ts" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "ts" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/049b1babc46f56e9.sql b/tests/ast_json_fixtures/shapes/049b1babc46f56e9.sql new file mode 100644 index 000000000000..05c79cdd6664 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/049b1babc46f56e9.sql @@ -0,0 +1,2 @@ +CREATE TABLE foo_with_projection (ts DateTime, x UInt64, PROJECTION pj (SELECT ts, x ORDER BY x)) + ENGINE = MergeTree PARTITION BY toYYYYMMDD(ts) ORDER BY (ts) diff --git a/tests/ast_json_fixtures/shapes/04a6e9ba4aa54e67.json b/tests/ast_json_fixtures/shapes/04a6e9ba4aa54e67.json new file mode 100644 index 000000000000..2c899b2b128e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04a6e9ba4aa54e67.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "mv_no_indexes" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx", + "expression": { + "type": "Identifier", + "name": "key" + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [] + }, + "granularity": 1 + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Null", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/04a6e9ba4aa54e67.sql b/tests/ast_json_fixtures/shapes/04a6e9ba4aa54e67.sql new file mode 100644 index 000000000000..630c91cff413 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04a6e9ba4aa54e67.sql @@ -0,0 +1,7 @@ +CREATE MATERIALIZED VIEW mv_no_indexes +( + key String, + INDEX idx key TYPE bloom_filter GRANULARITY 1 +) +ENGINE = Null +AS SELECT * FROM data diff --git a/tests/ast_json_fixtures/shapes/04cc45c7f5261d89.json b/tests/ast_json_fixtures/shapes/04cc45c7f5261d89.json new file mode 100644 index 000000000000..2dee92ea56c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04cc45c7f5261d89.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettyMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/04cc45c7f5261d89.sql b/tests/ast_json_fixtures/shapes/04cc45c7f5261d89.sql new file mode 100644 index 000000000000..c3c05a41dcf0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04cc45c7f5261d89.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettyMonoBlock diff --git a/tests/ast_json_fixtures/shapes/04cf232556d3bbb1.json b/tests/ast_json_fixtures/shapes/04cf232556d3bbb1.json new file mode 100644 index 000000000000..47022e95090e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04cf232556d3bbb1.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/04cf232556d3bbb1.sql b/tests/ast_json_fixtures/shapes/04cf232556d3bbb1.sql new file mode 100644 index 000000000000..049d79ef9b80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04cf232556d3bbb1.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/04ea0b4a89d7efae.json b/tests/ast_json_fixtures/shapes/04ea0b4a89d7efae.json new file mode 100644 index 000000000000..e49c68b0ff26 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04ea0b4a89d7efae.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "maxDt", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "dt" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "maxDt" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/04ea0b4a89d7efae.sql b/tests/ast_json_fixtures/shapes/04ea0b4a89d7efae.sql new file mode 100644 index 000000000000..5f7944204460 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04ea0b4a89d7efae.sql @@ -0,0 +1,3 @@ +WITH max(dt) AS maxDt +SELECT maxDt +FROM test diff --git a/tests/ast_json_fixtures/shapes/04f29f7d87cbbc03.json b/tests/ast_json_fixtures/shapes/04f29f7d87cbbc03.json new file mode 100644 index 000000000000..29f4654a15fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04f29f7d87cbbc03.json @@ -0,0 +1,93 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "9223372036854775806" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03031_test" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + } + ] + }, + "where": { + "type": "Literal", + "value_type": "Float64", + "value": 0.0001 + }, + "group_by": [ + { + "type": "Literal", + "value_type": "String", + "value": "0.03" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_primary_key": "1", + "force_data_skipping_indices": "value_1_idx, value_2_idx", + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/04f29f7d87cbbc03.sql b/tests/ast_json_fixtures/shapes/04f29f7d87cbbc03.sql new file mode 100644 index 000000000000..de9114bd719d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04f29f7d87cbbc03.sql @@ -0,0 +1,9 @@ +SELECT + count('9223372036854775806'), + 7 +FROM 03031_test +PREWHERE (id = NULL) AND 1024 +WHERE 0.0001 +GROUP BY '0.03' + WITH ROLLUP +SETTINGS force_primary_key = 1, force_data_skipping_indices = 'value_1_idx, value_2_idx', enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/04fd0b300dbbb1c3.json b/tests/ast_json_fixtures/shapes/04fd0b300dbbb1c3.json new file mode 100644 index 000000000000..01bf7a1a2cf7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04fd0b300dbbb1c3.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01756" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "0" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/04fd0b300dbbb1c3.sql b/tests/ast_json_fixtures/shapes/04fd0b300dbbb1c3.sql new file mode 100644 index 000000000000..acdbf6db6e77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/04fd0b300dbbb1c3.sql @@ -0,0 +1 @@ +select (2 IN (2,)), * from dist_01756 where dummy in (0, 2) format Null diff --git a/tests/ast_json_fixtures/shapes/051e7939bdb72e79.json b/tests/ast_json_fixtures/shapes/051e7939bdb72e79.json new file mode 100644 index 000000000000..619033efbdd8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/051e7939bdb72e79.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "alias": "x", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/051e7939bdb72e79.sql b/tests/ast_json_fixtures/shapes/051e7939bdb72e79.sql new file mode 100644 index 000000000000..6c9c46d8481e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/051e7939bdb72e79.sql @@ -0,0 +1 @@ +SELECT tuple(number) AS x FROM numbers(10) GROUP BY GROUPING SETS (number) order by x diff --git a/tests/ast_json_fixtures/shapes/05209f734a1e3134.json b/tests/ast_json_fixtures/shapes/05209f734a1e3134.json new file mode 100644 index 000000000000..34106b99a4af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05209f734a1e3134.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d1" + }, + { + "type": "Identifier", + "name": "f1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "f1" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/05209f734a1e3134.sql b/tests/ast_json_fixtures/shapes/05209f734a1e3134.sql new file mode 100644 index 000000000000..7b694b63da63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05209f734a1e3134.sql @@ -0,0 +1 @@ +SELECT d1 > f1 FROM t ORDER BY f1 diff --git a/tests/ast_json_fixtures/shapes/052507744f8ba3a3.json b/tests/ast_json_fixtures/shapes/052507744f8ba3a3.json new file mode 100644 index 000000000000..085c7051a7ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/052507744f8ba3a3.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "10" + } + ], + "select": [ + { + "type": "Function", + "alias": "a", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/052507744f8ba3a3.sql b/tests/ast_json_fixtures/shapes/052507744f8ba3a3.sql new file mode 100644 index 000000000000..734a2afd9040 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/052507744f8ba3a3.sql @@ -0,0 +1 @@ +with 10 as a select a + 1 as a diff --git a/tests/ast_json_fixtures/shapes/05578b8404ccbed6.json b/tests/ast_json_fixtures/shapes/05578b8404ccbed6.json new file mode 100644 index 000000000000..bf46951b403d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05578b8404ccbed6.json @@ -0,0 +1,93 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "CounterID", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "EventDate", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "UserID", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "EventDate" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Identifier", + "name": "EventDate" + }, + { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + } + ] + }, + "sample_by": { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/05578b8404ccbed6.sql b/tests/ast_json_fixtures/shapes/05578b8404ccbed6.sql new file mode 100644 index 000000000000..a593ee10be19 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05578b8404ccbed6.sql @@ -0,0 +1 @@ +CREATE TABLE x (`CounterID` UInt32, `EventDate` Date, `UserID` UInt64) ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) diff --git a/tests/ast_json_fixtures/shapes/055aba75412a6ee9.json b/tests/ast_json_fixtures/shapes/055aba75412a6ee9.json new file mode 100644 index 000000000000..f1adf79da08f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/055aba75412a6ee9.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "01856_test_function_0" + } +} diff --git a/tests/ast_json_fixtures/shapes/055aba75412a6ee9.sql b/tests/ast_json_fixtures/shapes/055aba75412a6ee9.sql new file mode 100644 index 000000000000..60875cbe59ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/055aba75412a6ee9.sql @@ -0,0 +1 @@ +DROP FUNCTION 01856_test_function_0 diff --git a/tests/ast_json_fixtures/shapes/055b7f1f90c56377.json b/tests/ast_json_fixtures/shapes/055b7f1f90c56377.json new file mode 100644 index 000000000000..0ca141719b2b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/055b7f1f90c56377.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk", + "transformers": [ + { + "type": "ColumnsExceptTransformer", + "pattern": "bytes" + } + ] + }, + { + "type": "ColumnsRegexpMatcher", + "pattern": "bytes", + "transformers": [ + { + "type": "ColumnsApplyTransformer", + "func_name": "formatReadableSize" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "columns_transformers" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/055b7f1f90c56377.sql b/tests/ast_json_fixtures/shapes/055b7f1f90c56377.sql new file mode 100644 index 000000000000..2a4a6f51ace1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/055b7f1f90c56377.sql @@ -0,0 +1 @@ +SELECT * EXCEPT 'bytes', COLUMNS('bytes') APPLY formatReadableSize FROM columns_transformers diff --git a/tests/ast_json_fixtures/shapes/0570f414d17e72a9.json b/tests/ast_json_fixtures/shapes/0570f414d17e72a9.json new file mode 100644 index 000000000000..1275c4d398a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0570f414d17e72a9.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH ASYNC INSERT QUEUE", + "tables": [ + { + "table": "03720_table" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0570f414d17e72a9.sql b/tests/ast_json_fixtures/shapes/0570f414d17e72a9.sql new file mode 100644 index 000000000000..1516989003dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0570f414d17e72a9.sql @@ -0,0 +1 @@ +SYSTEM FLUSH ASYNC INSERT QUEUE 03720_table diff --git a/tests/ast_json_fixtures/shapes/05a7c9036139e418.json b/tests/ast_json_fixtures/shapes/05a7c9036139e418.json new file mode 100644 index 000000000000..2060c9859aec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05a7c9036139e418.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "alias": "l", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab_00717" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "l" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/05a7c9036139e418.sql b/tests/ast_json_fixtures/shapes/05a7c9036139e418.sql new file mode 100644 index 000000000000..29e55d4c44b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05a7c9036139e418.sql @@ -0,0 +1 @@ +select a, length(b) as l from tab_00717 group by a, l, l + 1 order by a diff --git a/tests/ast_json_fixtures/shapes/05ade90fc7763027.json b/tests/ast_json_fixtures/shapes/05ade90fc7763027.json new file mode 100644 index 000000000000..b90d80d7a808 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05ade90fc7763027.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "01686_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "EmbeddedRocksDB", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "key" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_for_bulk_insert": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/05ade90fc7763027.sql b/tests/ast_json_fixtures/shapes/05ade90fc7763027.sql new file mode 100644 index 000000000000..aee8b3c54559 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05ade90fc7763027.sql @@ -0,0 +1 @@ +CREATE TABLE 01686_test (key UInt64, value String) Engine=EmbeddedRocksDB PRIMARY KEY(key) SETTINGS optimize_for_bulk_insert = 0 diff --git a/tests/ast_json_fixtures/shapes/05c4a0dfefa0c5ae.json b/tests/ast_json_fixtures/shapes/05c4a0dfefa0c5ae.json new file mode 100644 index 000000000000..b61136c3c8e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05c4a0dfefa0c5ae.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["test_role_01999_1"] + } +} diff --git a/tests/ast_json_fixtures/shapes/05c4a0dfefa0c5ae.sql b/tests/ast_json_fixtures/shapes/05c4a0dfefa0c5ae.sql new file mode 100644 index 000000000000..c751ee2b8685 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05c4a0dfefa0c5ae.sql @@ -0,0 +1 @@ +CREATE role test_role_01999_1 diff --git a/tests/ast_json_fixtures/shapes/05f2f5cc2a56b53d.json b/tests/ast_json_fixtures/shapes/05f2f5cc2a56b53d.json new file mode 100644 index 000000000000..c2bec721738c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05f2f5cc2a56b53d.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "i1", + "expression": { + "type": "Identifier", + "name": "c0" + }, + "index_type": { + "type": "Function", + "name": "set", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "SummingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "c0" + }, + "order_by": { + "type": "Identifier", + "name": "c0" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/05f2f5cc2a56b53d.sql b/tests/ast_json_fixtures/shapes/05f2f5cc2a56b53d.sql new file mode 100644 index 000000000000..285bcc0c842a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/05f2f5cc2a56b53d.sql @@ -0,0 +1,5 @@ +CREATE TABLE t0 +( + c0 Int64, + INDEX i1 c0 TYPE set(0) +) ENGINE = SummingMergeTree() PARTITION BY (c0) ORDER BY (c0) diff --git a/tests/ast_json_fixtures/shapes/0603bf91d08f9e19.json b/tests/ast_json_fixtures/shapes/0603bf91d08f9e19.json new file mode 100644 index 000000000000..8645d6ed7afe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0603bf91d08f9e19.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_max_rows_to_read" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "12" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/0603bf91d08f9e19.sql b/tests/ast_json_fixtures/shapes/0603bf91d08f9e19.sql new file mode 100644 index 000000000000..962e0eeda0e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0603bf91d08f9e19.sql @@ -0,0 +1 @@ +SELECT a FROM t_max_rows_to_read ORDER BY a LIMIT 20 FORMAT Null SETTINGS max_rows_to_read = 12 diff --git a/tests/ast_json_fixtures/shapes/060f0dcbcc78695f.json b/tests/ast_json_fixtures/shapes/060f0dcbcc78695f.json new file mode 100644 index 000000000000..c698ef3448f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/060f0dcbcc78695f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q11_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/060f0dcbcc78695f.sql b/tests/ast_json_fixtures/shapes/060f0dcbcc78695f.sql new file mode 100644 index 000000000000..aab616dd1239 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/060f0dcbcc78695f.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q11_01297 diff --git a/tests/ast_json_fixtures/shapes/0611bd871292d310.json b/tests/ast_json_fixtures/shapes/0611bd871292d310.json new file mode 100644 index 000000000000..71059b2e9a62 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0611bd871292d310.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_data" + } + } + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/0611bd871292d310.sql b/tests/ast_json_fixtures/shapes/0611bd871292d310.sql new file mode 100644 index 000000000000..2e627f69c324 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0611bd871292d310.sql @@ -0,0 +1 @@ +SELECT * FROM test_data FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/063486138cb929da.json b/tests/ast_json_fixtures/shapes/063486138cb929da.json new file mode 100644 index 000000000000..3512d98b993b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/063486138cb929da.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01295"] + } +} diff --git a/tests/ast_json_fixtures/shapes/063486138cb929da.sql b/tests/ast_json_fixtures/shapes/063486138cb929da.sql new file mode 100644 index 000000000000..5864747b20d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/063486138cb929da.sql @@ -0,0 +1 @@ +DROP USER u1_01295 diff --git a/tests/ast_json_fixtures/shapes/065f644d9900a692.json b/tests/ast_json_fixtures/shapes/065f644d9900a692.json new file mode 100644 index 000000000000..1c4876ef2d5e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/065f644d9900a692.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "database": { + "type": "Identifier", + "name": "db_01530_atomic" + }, + "sync": true + } +} diff --git a/tests/ast_json_fixtures/shapes/065f644d9900a692.sql b/tests/ast_json_fixtures/shapes/065f644d9900a692.sql new file mode 100644 index 000000000000..99a6c2a6f750 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/065f644d9900a692.sql @@ -0,0 +1 @@ +drop database db_01530_atomic sync diff --git a/tests/ast_json_fixtures/shapes/06653d70af91ce11.json b/tests/ast_json_fixtures/shapes/06653d70af91ce11.json new file mode 100644 index 000000000000..9daccc774df5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06653d70af91ce11.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u2_01292" + } + ] + }, + "hosts": { + } + } +} diff --git a/tests/ast_json_fixtures/shapes/06653d70af91ce11.sql b/tests/ast_json_fixtures/shapes/06653d70af91ce11.sql new file mode 100644 index 000000000000..8b5b590b7c69 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06653d70af91ce11.sql @@ -0,0 +1 @@ +CREATE USER u2_01292 HOST NONE diff --git a/tests/ast_json_fixtures/shapes/067b5f877d8f6e9c.json b/tests/ast_json_fixtures/shapes/067b5f877d8f6e9c.json new file mode 100644 index 000000000000..e49db7862fd0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/067b5f877d8f6e9c.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_INDEX", + "clear_index": true, + "index": { + "type": "Identifier", + "name": "idx_text" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/067b5f877d8f6e9c.sql b/tests/ast_json_fixtures/shapes/067b5f877d8f6e9c.sql new file mode 100644 index 000000000000..79c7ab504f46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/067b5f877d8f6e9c.sql @@ -0,0 +1 @@ +ALTER TABLE tab CLEAR INDEX idx_text diff --git a/tests/ast_json_fixtures/shapes/06a5f0c9d8cfe566.json b/tests/ast_json_fixtures/shapes/06a5f0c9d8cfe566.json new file mode 100644 index 000000000000..21f1b6712df5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06a5f0c9d8cfe566.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "col1.a", + "name_parts": ["col1", "a"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "nested" + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/06a5f0c9d8cfe566.sql b/tests/ast_json_fixtures/shapes/06a5f0c9d8cfe566.sql new file mode 100644 index 000000000000..3d0921ddb8b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06a5f0c9d8cfe566.sql @@ -0,0 +1 @@ +SELECT col1.a FROM nested FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/06b0f921716126f2.json b/tests/ast_json_fixtures/shapes/06b0f921716126f2.json new file mode 100644 index 000000000000..9eedf931b990 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06b0f921716126f2.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_table": "t1", + "to_table": "t2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/06b0f921716126f2.sql b/tests/ast_json_fixtures/shapes/06b0f921716126f2.sql new file mode 100644 index 000000000000..bdca714f3b66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06b0f921716126f2.sql @@ -0,0 +1 @@ +EXCHANGE TABLES t1 AND t2 diff --git a/tests/ast_json_fixtures/shapes/06b1341077edb2ca.json b/tests/ast_json_fixtures/shapes/06b1341077edb2ca.json new file mode 100644 index 000000000000..391e0e68b990 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06b1341077edb2ca.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "b", + "database": "a", + "like": "a' or 1=1;--" + } +} diff --git a/tests/ast_json_fixtures/shapes/06b1341077edb2ca.sql b/tests/ast_json_fixtures/shapes/06b1341077edb2ca.sql new file mode 100644 index 000000000000..3675d867e70c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06b1341077edb2ca.sql @@ -0,0 +1 @@ +show columns from a.b like 'a\' or 1=1;--' diff --git a/tests/ast_json_fixtures/shapes/06c766c9b8fdc1df.json b/tests/ast_json_fixtures/shapes/06c766c9b8fdc1df.json new file mode 100644 index 000000000000..3bc3241d61d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06c766c9b8fdc1df.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "addr", + "value_type": "String", + "value": "192.168.100.1" + }, + { + "type": "Function", + "alias": "prefix", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "192.168.100.0\/22" + }, + { + "value_type": "String", + "value": "192.168.100.0\/24" + }, + { + "value_type": "String", + "value": "192.168.100.0\/32" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "addr" + }, + { + "type": "Identifier", + "name": "prefix" + }, + { + "type": "Function", + "name": "isIPAddressInRange", + "arguments": [ + { + "type": "Identifier", + "name": "addr" + }, + { + "type": "Identifier", + "name": "prefix" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/06c766c9b8fdc1df.sql b/tests/ast_json_fixtures/shapes/06c766c9b8fdc1df.sql new file mode 100644 index 000000000000..504b8d87923b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06c766c9b8fdc1df.sql @@ -0,0 +1 @@ +WITH '192.168.100.1' as addr, arrayJoin(['192.168.100.0/22', '192.168.100.0/24', '192.168.100.0/32']) as prefix SELECT addr, prefix, isIPAddressInRange(addr, prefix) diff --git a/tests/ast_json_fixtures/shapes/06d437b06bc57532.json b/tests/ast_json_fixtures/shapes/06d437b06bc57532.json new file mode 100644 index 000000000000..0c493ee549df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06d437b06bc57532.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q3_01297"], + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/06d437b06bc57532.sql b/tests/ast_json_fixtures/shapes/06d437b06bc57532.sql new file mode 100644 index 000000000000..a3e3dbd4ac96 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06d437b06bc57532.sql @@ -0,0 +1 @@ +CREATE QUOTA q3_01297 TO r1_01297 diff --git a/tests/ast_json_fixtures/shapes/06dd4d6e75557e9a.json b/tests/ast_json_fixtures/shapes/06dd4d6e75557e9a.json new file mode 100644 index 000000000000..d0410b6c968b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06dd4d6e75557e9a.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "hello", + "name": "number" + }, + { + "type": "Function", + "alias": "world", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Identifier", + "name": "world" + } + ] + }, + { + "type": "Function", + "alias": "sometimes_nulls", + "name": "nullIf", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "5" + } + } + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/06dd4d6e75557e9a.sql b/tests/ast_json_fixtures/shapes/06dd4d6e75557e9a.sql new file mode 100644 index 000000000000..f0676ee6210a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06dd4d6e75557e9a.sql @@ -0,0 +1 @@ +SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 10 SETTINGS max_block_size = 5 FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/06e271e186169155.json b/tests/ast_json_fixtures/shapes/06e271e186169155.json new file mode 100644 index 000000000000..6f12862df2c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06e271e186169155.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "modify_sample" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_SAMPLE_BY", + "sample_by": { + "type": "Identifier", + "name": "x" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/06e271e186169155.sql b/tests/ast_json_fixtures/shapes/06e271e186169155.sql new file mode 100644 index 000000000000..3f04b82b8d28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06e271e186169155.sql @@ -0,0 +1 @@ +ALTER TABLE modify_sample MODIFY SAMPLE BY x diff --git a/tests/ast_json_fixtures/shapes/06ef4f384ed242e1.json b/tests/ast_json_fixtures/shapes/06ef4f384ed242e1.json new file mode 100644 index 000000000000..a7846b514ac1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06ef4f384ed242e1.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s1_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/06ef4f384ed242e1.sql b/tests/ast_json_fixtures/shapes/06ef4f384ed242e1.sql new file mode 100644 index 000000000000..068cc6541efe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/06ef4f384ed242e1.sql @@ -0,0 +1 @@ +CREATE PROFILE s1_01294 diff --git a/tests/ast_json_fixtures/shapes/072233b7d87942d4.json b/tests/ast_json_fixtures/shapes/072233b7d87942d4.json new file mode 100644 index 000000000000..dc3e610b5893 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/072233b7d87942d4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["02294_profile2"] + } +} diff --git a/tests/ast_json_fixtures/shapes/072233b7d87942d4.sql b/tests/ast_json_fixtures/shapes/072233b7d87942d4.sql new file mode 100644 index 000000000000..22c38b21b5ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/072233b7d87942d4.sql @@ -0,0 +1 @@ +SHOW CREATE SETTINGS PROFILE 02294_profile2 diff --git a/tests/ast_json_fixtures/shapes/072b733b2bbff37e.json b/tests/ast_json_fixtures/shapes/072b733b2bbff37e.json new file mode 100644 index 000000000000..5905372cabad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/072b733b2bbff37e.json @@ -0,0 +1,564 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "inf" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-inf" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "INF" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-INF" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Infinity" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-Infinity" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "nan" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-nan" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "NAN" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-NAN" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "NaN" + } + ] + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-NaN" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "in" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-in" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "INFi" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-INFi" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Infinit" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-Infinit" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "na" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-na" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "NANo" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-NANo" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "NaN+" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-NaNa" + } + ] + }, + { + "type": "Function", + "name": "toFloat64OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "+Na" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "inf" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-inf" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "INF" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-INF" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Infinity" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-Infinity" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "nan" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-nan" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "NAN" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-NAN" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "NaN" + } + ] + }, + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-NaN" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "in" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-in" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "INFi" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-INFi" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Infinit" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-Infinit" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "na" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-na" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "NANo" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-NANo" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "NaN+" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-NaNa" + } + ] + }, + { + "type": "Function", + "name": "toFloat32OrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "+Na" + } + ] + } + ] + } + ], + "format": "TabSeparated" + } +} diff --git a/tests/ast_json_fixtures/shapes/072b733b2bbff37e.sql b/tests/ast_json_fixtures/shapes/072b733b2bbff37e.sql new file mode 100644 index 000000000000..a50825f624d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/072b733b2bbff37e.sql @@ -0,0 +1,56 @@ +SELECT +toFloat64('inf'), +toFloat64('-inf'), +toFloat64('INF'), +toFloat64('-INF'), +toFloat64('Infinity'), +toFloat64('-Infinity'), +toFloat64('nan'), +toFloat64('-nan'), +toFloat64('NAN'), +toFloat64('-NAN'), +toFloat64('NaN'), +toFloat64('-NaN'), + +toFloat64OrZero('in'), +toFloat64OrZero('-in'), +toFloat64OrZero('INFi'), +toFloat64OrZero('-INFi'), +toFloat64OrZero('Infinit'), +toFloat64OrZero('-Infinit'), +toFloat64OrZero('na'), +toFloat64OrZero('-na'), +toFloat64OrZero('NANo'), +toFloat64OrZero('-NANo'), +toFloat64OrZero('NaN+'), +toFloat64OrZero('-NaNa'), +toFloat64OrZero('+Na'), + +toFloat32('inf'), +toFloat32('-inf'), +toFloat32('INF'), +toFloat32('-INF'), +toFloat32('Infinity'), +toFloat32('-Infinity'), +toFloat32('nan'), +toFloat32('-nan'), +toFloat32('NAN'), +toFloat32('-NAN'), +toFloat32('NaN'), +toFloat32('-NaN'), + +toFloat32OrZero('in'), +toFloat32OrZero('-in'), +toFloat32OrZero('INFi'), +toFloat32OrZero('-INFi'), +toFloat32OrZero('Infinit'), +toFloat32OrZero('-Infinit'), +toFloat32OrZero('na'), +toFloat32OrZero('-na'), +toFloat32OrZero('NANo'), +toFloat32OrZero('-NANo'), +toFloat32OrZero('NaN+'), +toFloat32OrZero('-NaNa'), +toFloat32OrZero('+Na') + +FORMAT TabSeparated diff --git a/tests/ast_json_fixtures/shapes/0744e006878070b1.json b/tests/ast_json_fixtures/shapes/0744e006878070b1.json new file mode 100644 index 000000000000..1c80a12fefac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0744e006878070b1.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["test_01605"] + } +} diff --git a/tests/ast_json_fixtures/shapes/0744e006878070b1.sql b/tests/ast_json_fixtures/shapes/0744e006878070b1.sql new file mode 100644 index 000000000000..7b5287d53234 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0744e006878070b1.sql @@ -0,0 +1 @@ +DROP SETTINGS PROFILE 'test_01605' diff --git a/tests/ast_json_fixtures/shapes/07692c5a1a23e7e1.json b/tests/ast_json_fixtures/shapes/07692c5a1a23e7e1.json new file mode 100644 index 000000000000..eb62144833c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/07692c5a1a23e7e1.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/07692c5a1a23e7e1.sql b/tests/ast_json_fixtures/shapes/07692c5a1a23e7e1.sql new file mode 100644 index 000000000000..4b847796202f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/07692c5a1a23e7e1.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number with totals diff --git a/tests/ast_json_fixtures/shapes/076bab7b4cebe5fc.json b/tests/ast_json_fixtures/shapes/076bab7b4cebe5fc.json new file mode 100644 index 000000000000..004bc6dcab74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/076bab7b4cebe5fc.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ], + "format": "PrettyNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/076bab7b4cebe5fc.sql b/tests/ast_json_fixtures/shapes/076bab7b4cebe5fc.sql new file mode 100644 index 000000000000..bb5fc9d1dbfc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/076bab7b4cebe5fc.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) FORMAT PrettyNoEscapes diff --git a/tests/ast_json_fixtures/shapes/078f163b97c452e2.json b/tests/ast_json_fixtures/shapes/078f163b97c452e2.json new file mode 100644 index 000000000000..3c0f86674b07 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/078f163b97c452e2.json @@ -0,0 +1,143 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "max", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "EXCEPT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_DISTINCT", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "max" + } + ] + } + ] + } + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/078f163b97c452e2.sql b/tests/ast_json_fixtures/shapes/078f163b97c452e2.sql new file mode 100644 index 000000000000..0219f580d674 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/078f163b97c452e2.sql @@ -0,0 +1,2 @@ +with (select count() from (select 1 union distinct select 2 except select 1)) as max +select count() from (select 1 union all select max) limit 100 diff --git a/tests/ast_json_fixtures/shapes/079520c5f899cc72.json b/tests/ast_json_fixtures/shapes/079520c5f899cc72.json new file mode 100644 index 000000000000..3c5c7c65c166 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/079520c5f899cc72.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/079520c5f899cc72.sql b/tests/ast_json_fixtures/shapes/079520c5f899cc72.sql new file mode 100644 index 000000000000..cfc8f8b68a40 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/079520c5f899cc72.sql @@ -0,0 +1 @@ +SELECT 1 AS n WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/07f8151ab25838f5.json b/tests/ast_json_fixtures/shapes/07f8151ab25838f5.json new file mode 100644 index 000000000000..f682033bfc41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/07f8151ab25838f5.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SYSTEM", + "system_type": "CLEAR FORMAT SCHEMA CACHE", + "schema_cache_format": "Protobuf" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/07f8151ab25838f5.sql b/tests/ast_json_fixtures/shapes/07f8151ab25838f5.sql new file mode 100644 index 000000000000..d43fe0eb66f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/07f8151ab25838f5.sql @@ -0,0 +1 @@ +EXPLAIN SYNTAX SYSTEM CLEAR FORMAT SCHEMA CACHE FOR Protobuf diff --git a/tests/ast_json_fixtures/shapes/07fc780efdf73ef1.json b/tests/ast_json_fixtures/shapes/07fc780efdf73ef1.json new file mode 100644 index 000000000000..bd657bf41625 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/07fc780efdf73ef1.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_INDEX", + "index": { + "type": "Identifier", + "name": "idx_vec" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/07fc780efdf73ef1.sql b/tests/ast_json_fixtures/shapes/07fc780efdf73ef1.sql new file mode 100644 index 000000000000..b394aae41952 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/07fc780efdf73ef1.sql @@ -0,0 +1 @@ +ALTER TABLE tab MATERIALIZE INDEX idx_vec SETTINGS mutations_sync=2 diff --git a/tests/ast_json_fixtures/shapes/0803c6e3ce1d5966.json b/tests/ast_json_fixtures/shapes/0803c6e3ce1d5966.json new file mode 100644 index 000000000000..3959a4dc42d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0803c6e3ce1d5966.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "� �" + } + ] + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/0803c6e3ce1d5966.sql b/tests/ast_json_fixtures/shapes/0803c6e3ce1d5966.sql new file mode 100644 index 000000000000..6be86492e59d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0803c6e3ce1d5966.sql @@ -0,0 +1 @@ +SELECT '\xED\x20\xA8' AS s FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/082f56ea039776d1.json b/tests/ast_json_fixtures/shapes/082f56ea039776d1.json new file mode 100644 index 000000000000..7c59565258bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/082f56ea039776d1.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "function_name": { + "type": "Identifier", + "name": "02126_function" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/082f56ea039776d1.sql b/tests/ast_json_fixtures/shapes/082f56ea039776d1.sql new file mode 100644 index 000000000000..684efd256386 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/082f56ea039776d1.sql @@ -0,0 +1 @@ +CREATE FUNCTION 02126_function AS x -> x diff --git a/tests/ast_json_fixtures/shapes/082f5da597a8da34.json b/tests/ast_json_fixtures/shapes/082f5da597a8da34.json new file mode 100644 index 000000000000..8db26c950403 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/082f5da597a8da34.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "data", + "value_type": "String", + "value": "{\"1\":{\"key\":\"value\"}}" + }, + { + "type": "Function", + "alias": "parsed_json", + "name": "JSONExtract", + "arguments": [ + { + "type": "Identifier", + "name": "data" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple(\"1\" Tuple(key String))" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "alias": "ssid", + "name": "parsed_json" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/082f5da597a8da34.sql b/tests/ast_json_fixtures/shapes/082f5da597a8da34.sql new file mode 100644 index 000000000000..d421cf5d85d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/082f5da597a8da34.sql @@ -0,0 +1,4 @@ +WITH + '{"1":{"key":"value"}}' AS data, + JSONExtract(data, 'Tuple("1" Tuple(key String))') AS parsed_json +SELECT parsed_json AS ssid diff --git a/tests/ast_json_fixtures/shapes/0830f5fe2239467d.json b/tests/ast_json_fixtures/shapes/0830f5fe2239467d.json new file mode 100644 index 000000000000..fb8ac19605f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0830f5fe2239467d.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t2_all" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards_localhost" + }, + { + "type": "Identifier", + "name": "test_02115" + }, + { + "type": "Identifier", + "name": "t2_local" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "t2_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/0830f5fe2239467d.sql b/tests/ast_json_fixtures/shapes/0830f5fe2239467d.sql new file mode 100644 index 000000000000..9f1bcbf2b216 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0830f5fe2239467d.sql @@ -0,0 +1 @@ +create table t2_all as t2_local engine Distributed(test_cluster_two_shards_localhost, test_02115, t2_local, rand()) diff --git a/tests/ast_json_fixtures/shapes/083914d608fb907d.json b/tests/ast_json_fixtures/shapes/083914d608fb907d.json new file mode 100644 index 000000000000..a970b9ff3792 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/083914d608fb907d.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Looking_at_transaction_id_False" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "implicit_transaction": "0" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/083914d608fb907d.sql b/tests/ast_json_fixtures/shapes/083914d608fb907d.sql new file mode 100644 index 000000000000..97b29a1cc69b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/083914d608fb907d.sql @@ -0,0 +1 @@ +SELECT 'Looking_at_transaction_id_False' FORMAT Null SETTINGS implicit_transaction=0 diff --git a/tests/ast_json_fixtures/shapes/0847ac760608276c.json b/tests/ast_json_fixtures/shapes/0847ac760608276c.json new file mode 100644 index 000000000000..58b33fcb8394 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0847ac760608276c.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "ColumnsRegexpMatcher", + "pattern": "" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0847ac760608276c.sql b/tests/ast_json_fixtures/shapes/0847ac760608276c.sql new file mode 100644 index 000000000000..1a4fad6a0bae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0847ac760608276c.sql @@ -0,0 +1 @@ +SELECT number, COLUMNS('') FROM numbers(2) diff --git a/tests/ast_json_fixtures/shapes/085816edeab61655.json b/tests/ast_json_fixtures/shapes/085816edeab61655.json new file mode 100644 index 000000000000..466ddc277c30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/085816edeab61655.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u2_01292", "u3_01292", "u4_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/085816edeab61655.sql b/tests/ast_json_fixtures/shapes/085816edeab61655.sql new file mode 100644 index 000000000000..0dd4a7da2767 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/085816edeab61655.sql @@ -0,0 +1 @@ +DROP USER u1_01292, u2_01292, u3_01292, u4_01292 diff --git a/tests/ast_json_fixtures/shapes/08678f95dfa4d15f.json b/tests/ast_json_fixtures/shapes/08678f95dfa4d15f.json new file mode 100644 index 000000000000..64ece4f7341b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/08678f95dfa4d15f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "f1", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/08678f95dfa4d15f.sql b/tests/ast_json_fixtures/shapes/08678f95dfa4d15f.sql new file mode 100644 index 000000000000..1d34848c345b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/08678f95dfa4d15f.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS f1 diff --git a/tests/ast_json_fixtures/shapes/088b0e3859ef18d1.json b/tests/ast_json_fixtures/shapes/088b0e3859ef18d1.json new file mode 100644 index 000000000000..9fba481ab6c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/088b0e3859ef18d1.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "constF64", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/088b0e3859ef18d1.sql b/tests/ast_json_fixtures/shapes/088b0e3859ef18d1.sql new file mode 100644 index 000000000000..f5e77ab49e7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/088b0e3859ef18d1.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS constF64 diff --git a/tests/ast_json_fixtures/shapes/088efaad72417993.json b/tests/ast_json_fixtures/shapes/088efaad72417993.json new file mode 100644 index 000000000000..db83730d2636 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/088efaad72417993.json @@ -0,0 +1,224 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 10000000000 + }, + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_having" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "c0" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_optimize_predicate_expression": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/088efaad72417993.sql b/tests/ast_json_fixtures/shapes/088efaad72417993.sql new file mode 100644 index 000000000000..28077543fb36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/088efaad72417993.sql @@ -0,0 +1 @@ +SELECT c0 + -1, sum(intDivOrZero(intDivOrZero(NULL, NULL), '2'), intDivOrZero(10000000000., intDivOrZero(intDivOrZero(intDivOrZero(NULL, NULL), 10), NULL))) FROM t_having GROUP BY c0 = 2, c0 = 10, intDivOrZero(intDivOrZero(intDivOrZero(NULL, NULL), NULL), NULL), c0 HAVING c0 = 2 SETTINGS enable_optimize_predicate_expression = 0 diff --git a/tests/ast_json_fixtures/shapes/089275b53e3932a0.json b/tests/ast_json_fixtures/shapes/089275b53e3932a0.json new file mode 100644 index 000000000000..091b5adf254e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/089275b53e3932a0.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "rand64", + "arguments": [] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "use_query_condition_cache": true + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/089275b53e3932a0.sql b/tests/ast_json_fixtures/shapes/089275b53e3932a0.sql new file mode 100644 index 000000000000..2b1afe53a2c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/089275b53e3932a0.sql @@ -0,0 +1 @@ +SELECT count(*) FROM tab WHERE b = rand64() SETTINGS use_query_condition_cache = true FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/08a242eaa21a94d3.json b/tests/ast_json_fixtures/shapes/08a242eaa21a94d3.json new file mode 100644 index 000000000000..2e31bf7c3bbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/08a242eaa21a94d3.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "z" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "alias": "b", + "name": "COUNT", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_lwu_defaults" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/08a242eaa21a94d3.sql b/tests/ast_json_fixtures/shapes/08a242eaa21a94d3.sql new file mode 100644 index 000000000000..c58d7b91a4ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/08a242eaa21a94d3.sql @@ -0,0 +1 @@ +SELECT intDiv(z, 100) AS a, COUNT() AS b FROM t_lwu_defaults GROUP BY a ORDER BY a LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/08c8aca06f774b25.json b/tests/ast_json_fixtures/shapes/08c8aca06f774b25.json new file mode 100644 index 000000000000..724832521d56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/08c8aca06f774b25.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "EXCEPT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/08c8aca06f774b25.sql b/tests/ast_json_fixtures/shapes/08c8aca06f774b25.sql new file mode 100644 index 000000000000..062462375a62 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/08c8aca06f774b25.sql @@ -0,0 +1 @@ +explain syntax select 1 except select 1 diff --git a/tests/ast_json_fixtures/shapes/08ca61f01e81b740.json b/tests/ast_json_fixtures/shapes/08ca61f01e81b740.json new file mode 100644 index 000000000000..bff1ca28e835 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/08ca61f01e81b740.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "arr", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "arr" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/08ca61f01e81b740.sql b/tests/ast_json_fixtures/shapes/08ca61f01e81b740.sql new file mode 100644 index 000000000000..4a8c689857d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/08ca61f01e81b740.sql @@ -0,0 +1 @@ +WITH [1, 2, 3] AS arr SELECT arr.* diff --git a/tests/ast_json_fixtures/shapes/08dc8fb545306a16.json b/tests/ast_json_fixtures/shapes/08dc8fb545306a16.json new file mode 100644 index 000000000000..326f66136edb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/08dc8fb545306a16.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "u64_countmin" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3500" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "u64_countmin" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3600" + } + ] + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_statistics_cache": "0", + "log_comment": "03904_empty" + } + }, + "format": "NULL" + } +} diff --git a/tests/ast_json_fixtures/shapes/08dc8fb545306a16.sql b/tests/ast_json_fixtures/shapes/08dc8fb545306a16.sql new file mode 100644 index 000000000000..272298bca413 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/08dc8fb545306a16.sql @@ -0,0 +1,4 @@ +SELECT * FROM tab +WHERE u64_countmin > 3500 and u64_countmin < 3600 +FORMAT NULL +SETTINGS use_statistics_cache = 0, log_comment = '03904_empty' diff --git a/tests/ast_json_fixtures/shapes/09049a04308ecaad.json b/tests/ast_json_fixtures/shapes/09049a04308ecaad.json new file mode 100644 index 000000000000..878aa200c3de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09049a04308ecaad.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "hostName", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "merge", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^merge_host_remote_tab_" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/09049a04308ecaad.sql b/tests/ast_json_fixtures/shapes/09049a04308ecaad.sql new file mode 100644 index 000000000000..43cf853922a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09049a04308ecaad.sql @@ -0,0 +1 @@ +SELECT hostName(), * FROM merge(currentDatabase(), '^merge_host_remote_tab_') ORDER BY number FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/090747378b6be738.json b/tests/ast_json_fixtures/shapes/090747378b6be738.json new file mode 100644 index 000000000000..e38aea2eec87 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/090747378b6be738.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q1_01297"], + "limits": [ + { + "duration_sec": "432000", + "max": { + "ERRORS": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/090747378b6be738.sql b/tests/ast_json_fixtures/shapes/090747378b6be738.sql new file mode 100644 index 000000000000..ab0b91741859 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/090747378b6be738.sql @@ -0,0 +1 @@ +CREATE QUOTA q1_01297 FOR INTERVAL 5 DAY MAX ERRORS = 3 diff --git a/tests/ast_json_fixtures/shapes/092efe1b724268ee.json b/tests/ast_json_fixtures/shapes/092efe1b724268ee.json new file mode 100644 index 000000000000..e85bc780408c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/092efe1b724268ee.json @@ -0,0 +1,125 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "maxMap", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/092efe1b724268ee.sql b/tests/ast_json_fixtures/shapes/092efe1b724268ee.sql new file mode 100644 index 000000000000..eaa9f79a10ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/092efe1b724268ee.sql @@ -0,0 +1 @@ +SELECT maxMap([number % 3, number % 4 - 1], [number, NULL]) FROM numbers(3) GROUP BY number WITH CUBE ORDER BY number diff --git a/tests/ast_json_fixtures/shapes/095d39d7e7260f5c.json b/tests/ast_json_fixtures/shapes/095d39d7e7260f5c.json new file mode 100644 index 000000000000..bc23e452e96e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/095d39d7e7260f5c.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "b1_01361" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Buffer", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "t1_01361" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + }, + "as_table": "t1_01361" + } +} diff --git a/tests/ast_json_fixtures/shapes/095d39d7e7260f5c.sql b/tests/ast_json_fixtures/shapes/095d39d7e7260f5c.sql new file mode 100644 index 000000000000..7b554d8e5e7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/095d39d7e7260f5c.sql @@ -0,0 +1,2 @@ +CREATE TABLE b1_01361 AS t1_01361 +ENGINE = Buffer(currentDatabase(), t1_01361, 1, 0, 0, 1, 1, 1, 1) diff --git a/tests/ast_json_fixtures/shapes/0979bb7964344ecb.json b/tests/ast_json_fixtures/shapes/0979bb7964344ecb.json new file mode 100644 index 000000000000..3320d90cc301 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0979bb7964344ecb.json @@ -0,0 +1,319 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "r1", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "r2", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "220" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "t", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "intDiv", + "arguments": [ + { + "type": "Function", + "name": "toUInt32", + "arguments": [ + { + "type": "Identifier", + "name": "rtime" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + }, + { + "type": "Function", + "alias": "m", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "r1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "r1" + }, + { + "type": "Identifier", + "name": "r2" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "cluster", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test_alias" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2022-01-01" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0979bb7964344ecb.sql b/tests/ast_json_fixtures/shapes/0979bb7964344ecb.sql new file mode 100644 index 000000000000..431fd606a518 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0979bb7964344ecb.sql @@ -0,0 +1,10 @@ +WITH + sum(if((a >= 0) AND (b != 100) AND (c = 0), 1, 0)) AS r1, + sum(if((a >= 0) AND (b != 100) AND (c > 220), 1, 0)) AS r2 +SELECT + (intDiv(toUInt32(rtime), 20) * 20) * 1000 AS t, + (r1 * 100) / (r1 + r2) AS m +FROM cluster('test_cluster_two_shards', currentDatabase(), test_alias) +WHERE day = '2022-01-01' +GROUP BY t +ORDER BY t ASC diff --git a/tests/ast_json_fixtures/shapes/09801f90bda18bdc.json b/tests/ast_json_fixtures/shapes/09801f90bda18bdc.json new file mode 100644 index 000000000000..ca27a0c83f56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09801f90bda18bdc.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "02356_destination" + }, + "columns": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1", + "max_block_size": "100" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "generateRandom", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a Int64, b String" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1", + "max_block_size": "100" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/09801f90bda18bdc.sql b/tests/ast_json_fixtures/shapes/09801f90bda18bdc.sql new file mode 100644 index 000000000000..9d653003d3e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09801f90bda18bdc.sql @@ -0,0 +1 @@ +INSERT INTO 02356_destination (a, b) SELECT * FROM generateRandom('a Int64, b String') LIMIT 100 SETTINGS max_threads=1, max_block_size=100 diff --git a/tests/ast_json_fixtures/shapes/0983095d746fb900.json b/tests/ast_json_fixtures/shapes/0983095d746fb900.json new file mode 100644 index 000000000000..a4726d5904b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0983095d746fb900.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k1", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "arr.k1.:`Array(JSON)`", + "name_parts": ["arr", "k1", ":`Array(JSON)`"] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_json_array" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "k1" + } + ] + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/0983095d746fb900.sql b/tests/ast_json_fixtures/shapes/0983095d746fb900.sql new file mode 100644 index 000000000000..46c7e5a78450 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0983095d746fb900.sql @@ -0,0 +1 @@ +SELECT arrayJoin(arrayJoin(arr.k1[])) AS k1 FROM t_json_array ORDER BY toString(k1) FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/0986f71c304ebc36.json b/tests/ast_json_fixtures/shapes/0986f71c304ebc36.json new file mode 100644 index 000000000000..49888d606595 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0986f71c304ebc36.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table_02184" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "primary_key": { + "type": "Identifier", + "name": "x" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0986f71c304ebc36.sql b/tests/ast_json_fixtures/shapes/0986f71c304ebc36.sql new file mode 100644 index 000000000000..b58b692df67c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0986f71c304ebc36.sql @@ -0,0 +1 @@ +CREATE TABLE table_02184 (x UInt8) PRIMARY KEY x diff --git a/tests/ast_json_fixtures/shapes/09b96fc0956ff7ad.json b/tests/ast_json_fixtures/shapes/09b96fc0956ff7ad.json new file mode 100644 index 000000000000..6e8447e64ac4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09b96fc0956ff7ad.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "IcebergS3", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "s3_conn" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "filename" + }, + { + "type": "Literal", + "value_type": "String", + "value": "issue87414\/test\/t0" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "iceberg_metadata_file_path": "metadata\/v2.metadata.json" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/09b96fc0956ff7ad.sql b/tests/ast_json_fixtures/shapes/09b96fc0956ff7ad.sql new file mode 100644 index 000000000000..1e7bf68951bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09b96fc0956ff7ad.sql @@ -0,0 +1 @@ +CREATE TABLE t0 ENGINE = IcebergS3(s3_conn, filename = 'issue87414/test/t0') settings iceberg_metadata_file_path = 'metadata/v2.metadata.json' diff --git a/tests/ast_json_fixtures/shapes/09c15fabf212d9a3.json b/tests/ast_json_fixtures/shapes/09c15fabf212d9a3.json new file mode 100644 index 000000000000..f7b75a1d9605 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09c15fabf212d9a3.json @@ -0,0 +1,148 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "splitByChar", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "intHash64", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "lim", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Function", + "alias": "sorted", + "name": "arrayResize", + "arguments": [ + { + "type": "Function", + "name": "arrayPartialSort", + "arguments": [ + { + "type": "Identifier", + "name": "lim" + }, + { + "type": "Identifier", + "name": "arr" + } + ] + }, + { + "type": "Identifier", + "name": "lim" + } + ] + }, + { + "type": "Function", + "alias": "sorted_nums", + "name": "arrayResize", + "arguments": [ + { + "type": "Function", + "name": "arrayPartialSort", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "toUInt64OrZero", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "lim" + }, + { + "type": "Identifier", + "name": "arr" + } + ] + }, + { + "type": "Identifier", + "name": "lim" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/09c15fabf212d9a3.sql b/tests/ast_json_fixtures/shapes/09c15fabf212d9a3.sql new file mode 100644 index 000000000000..df6c282ed5fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09c15fabf212d9a3.sql @@ -0,0 +1 @@ +SELECT splitByChar('0', toString(intHash64(number))) AS arr, 3 AS lim, arrayResize(arrayPartialSort(lim, arr), lim) AS sorted, arrayResize(arrayPartialSort(x -> toUInt64OrZero(x), lim, arr), lim) AS sorted_nums FROM system.numbers LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/09da61070a5c753d.json b/tests/ast_json_fixtures/shapes/09da61070a5c753d.json new file mode 100644 index 000000000000..961f7f4e4864 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09da61070a5c753d.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "merged" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "short|long" + } + ] + } + }, + "as_table": "short" + } +} diff --git a/tests/ast_json_fixtures/shapes/09da61070a5c753d.sql b/tests/ast_json_fixtures/shapes/09da61070a5c753d.sql new file mode 100644 index 000000000000..15351298e202 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09da61070a5c753d.sql @@ -0,0 +1 @@ +CREATE TABLE merged as short ENGINE = Merge(currentDatabase(), 'short|long') diff --git a/tests/ast_json_fixtures/shapes/09ee74bdc924ba3a.json b/tests/ast_json_fixtures/shapes/09ee74bdc924ba3a.json new file mode 100644 index 000000000000..54704aa2f8f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09ee74bdc924ba3a.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "json", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "{\"a.b\" : 42, \"a\" : {\"b\" : \"Hello World!\"}}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "JSON(`a%2Eb` UInt8)" + } + ] + }, + { + "type": "Identifier", + "name": "json.a%2Eb", + "name_parts": ["json", "a%2Eb"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "json.a%2Eb", + "name_parts": ["json", "a%2Eb"] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/09ee74bdc924ba3a.sql b/tests/ast_json_fixtures/shapes/09ee74bdc924ba3a.sql new file mode 100644 index 000000000000..a60af42d294e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09ee74bdc924ba3a.sql @@ -0,0 +1 @@ +SELECT '{"a.b" : 42, "a" : {"b" : "Hello World!"}}'::JSON(`a%2Eb` UInt8) as json, json.`a%2Eb`, toTypeName(json.`a%2Eb`) diff --git a/tests/ast_json_fixtures/shapes/09ef7a9f4e4855b0.json b/tests/ast_json_fixtures/shapes/09ef7a9f4e4855b0.json new file mode 100644 index 000000000000..a908c065b677 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09ef7a9f4e4855b0.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02126_function" + } +} diff --git a/tests/ast_json_fixtures/shapes/09ef7a9f4e4855b0.sql b/tests/ast_json_fixtures/shapes/09ef7a9f4e4855b0.sql new file mode 100644 index 000000000000..1fe993322d33 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09ef7a9f4e4855b0.sql @@ -0,0 +1 @@ +DROP FUNCTION 02126_function diff --git a/tests/ast_json_fixtures/shapes/09f73b89374cf6e0.json b/tests/ast_json_fixtures/shapes/09f73b89374cf6e0.json new file mode 100644 index 000000000000..b9422db38c81 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09f73b89374cf6e0.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q10_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/09f73b89374cf6e0.sql b/tests/ast_json_fixtures/shapes/09f73b89374cf6e0.sql new file mode 100644 index 000000000000..83de25b01ec8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/09f73b89374cf6e0.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q10_01297 diff --git a/tests/ast_json_fixtures/shapes/0a04a423046dbc34.json b/tests/ast_json_fixtures/shapes/0a04a423046dbc34.json new file mode 100644 index 000000000000..9e7e2260ef5c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a04a423046dbc34.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t3" + }, + "as_table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.1" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0a04a423046dbc34.sql b/tests/ast_json_fixtures/shapes/0a04a423046dbc34.sql new file mode 100644 index 000000000000..7aa9b8ef58a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a04a423046dbc34.sql @@ -0,0 +1 @@ +CREATE TABLE t3 AS remote('127.0.0.1', numbers(100)) diff --git a/tests/ast_json_fixtures/shapes/0a2b8b6f1e83981f.json b/tests/ast_json_fixtures/shapes/0a2b8b6f1e83981f.json new file mode 100644 index 000000000000..a6db87d180b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a2b8b6f1e83981f.json @@ -0,0 +1,103 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "operand", + "name": "toInt64", + "arguments": [ + { + "type": "Identifier", + "name": "operand" + } + ] + }, + { + "type": "Function", + "alias": "low", + "name": "toInt32", + "arguments": [ + { + "type": "Identifier", + "name": "low" + } + ] + }, + { + "type": "Function", + "alias": "high", + "name": "toInt16", + "arguments": [ + { + "type": "Identifier", + "name": "high" + } + ] + }, + { + "type": "Identifier", + "name": "count" + }, + { + "type": "Function", + "name": "WIDTH_BUCKET", + "arguments": [ + { + "type": "Identifier", + "name": "operand" + }, + { + "type": "Identifier", + "name": "low" + }, + { + "type": "Identifier", + "name": "high" + }, + { + "type": "Identifier", + "name": "count" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "mytable" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "count" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0a2b8b6f1e83981f.sql b/tests/ast_json_fixtures/shapes/0a2b8b6f1e83981f.sql new file mode 100644 index 000000000000..4a734d5f7d5e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a2b8b6f1e83981f.sql @@ -0,0 +1 @@ +SELECT toInt64(operand) AS operand, toInt32(low) AS low, toInt16(high) AS high, count, WIDTH_BUCKET(operand, low, high, count) FROM mytable WHERE count != 0 diff --git a/tests/ast_json_fixtures/shapes/0a31c90c7b5ace87.json b/tests/ast_json_fixtures/shapes/0a31c90c7b5ace87.json new file mode 100644 index 000000000000..35281bc9dfa8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a31c90c7b5ace87.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "test4" + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0a31c90c7b5ace87.sql b/tests/ast_json_fixtures/shapes/0a31c90c7b5ace87.sql new file mode 100644 index 000000000000..ecace0d8a827 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a31c90c7b5ace87.sql @@ -0,0 +1 @@ +SELECT 'test4', number FROM numbers(1000) GROUP BY number ORDER BY number diff --git a/tests/ast_json_fixtures/shapes/0a5164dca69bbd7c.json b/tests/ast_json_fixtures/shapes/0a5164dca69bbd7c.json new file mode 100644 index 000000000000..b099e247b467 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a5164dca69bbd7c.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "distributed_0" + }, + { + "type": "Identifier", + "name": "_shard_num" + }, + { + "type": "Function", + "alias": "dummy", + "name": "toUInt8", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "o", + "name": "d_one" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "o.dummy", + "name_parts": ["o", "dummy"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "_shard_num" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0a5164dca69bbd7c.sql b/tests/ast_json_fixtures/shapes/0a5164dca69bbd7c.sql new file mode 100644 index 000000000000..35513fb72deb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a5164dca69bbd7c.sql @@ -0,0 +1 @@ +SELECT 'distributed_0', _shard_num, toUInt8(1) AS dummy FROM d_one AS o WHERE o.dummy = 0 ORDER BY _shard_num diff --git a/tests/ast_json_fixtures/shapes/0a524369ea622b0f.json b/tests/ast_json_fixtures/shapes/0a524369ea622b0f.json new file mode 100644 index 000000000000..39bfc901e3ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a524369ea622b0f.json @@ -0,0 +1,109 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "dt_close" + }, + { + "type": "Identifier", + "name": "close" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "fx_5m" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "symbol" + }, + { + "type": "Literal", + "value_type": "String", + "value": "EURUSD" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt_close" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2022-12-11" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt_close" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2022-12-13" + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "dt_close" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/0a524369ea622b0f.sql b/tests/ast_json_fixtures/shapes/0a524369ea622b0f.sql new file mode 100644 index 000000000000..06eefdd6ab18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a524369ea622b0f.sql @@ -0,0 +1,7 @@ +SELECT + dt_close, + close +FROM fx_5m +where symbol = 'EURUSD' and dt_close between '2022-12-11' and '2022-12-13' +order by dt_close +format Null diff --git a/tests/ast_json_fixtures/shapes/0a54f12f17380a02.json b/tests/ast_json_fixtures/shapes/0a54f12f17380a02.json new file mode 100644 index 000000000000..de4f5f66143c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a54f12f17380a02.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowGrantsQuery", + "for_roles": { + "type": "RolesOrUsersSet", + "names": ["sqllt_user"] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/0a54f12f17380a02.sql b/tests/ast_json_fixtures/shapes/0a54f12f17380a02.sql new file mode 100644 index 000000000000..ddaa257328d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a54f12f17380a02.sql @@ -0,0 +1 @@ +SHOW GRANTS FOR sqllt_user FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/0a97baeec7923243.json b/tests/ast_json_fixtures/shapes/0a97baeec7923243.json new file mode 100644 index 000000000000..1b12e29b269b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a97baeec7923243.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/0a97baeec7923243.sql b/tests/ast_json_fixtures/shapes/0a97baeec7923243.sql new file mode 100644 index 000000000000..24e6c56db100 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a97baeec7923243.sql @@ -0,0 +1 @@ +DROP USER u1_01294 diff --git a/tests/ast_json_fixtures/shapes/0a9fe61383f9f20a.json b/tests/ast_json_fixtures/shapes/0a9fe61383f9f20a.json new file mode 100644 index 000000000000..898aba131ebb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a9fe61383f9f20a.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers_mt", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0a9fe61383f9f20a.sql b/tests/ast_json_fixtures/shapes/0a9fe61383f9f20a.sql new file mode 100644 index 000000000000..52e1b03255e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0a9fe61383f9f20a.sql @@ -0,0 +1 @@ +SELECT * FROM system.numbers_mt WHERE number = 1000000 OFFSET -1 diff --git a/tests/ast_json_fixtures/shapes/0aa1ee0a94cae7da.json b/tests/ast_json_fixtures/shapes/0aa1ee0a94cae7da.json new file mode 100644 index 000000000000..3d4265a76b2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0aa1ee0a94cae7da.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "replace_granted_roles": true, + "roles": { + "type": "RolesOrUsersSet", + "names": ["test_role_01999_1"] + }, + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0aa1ee0a94cae7da.sql b/tests/ast_json_fixtures/shapes/0aa1ee0a94cae7da.sql new file mode 100644 index 000000000000..0eb727d410f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0aa1ee0a94cae7da.sql @@ -0,0 +1 @@ +GRANT NONE, test_role_01999_1 TO test_user_01999 WITH REPLACE OPTION diff --git a/tests/ast_json_fixtures/shapes/0aa386d70cb76057.json b/tests/ast_json_fixtures/shapes/0aa386d70cb76057.json new file mode 100644 index 000000000000..83773a7a6775 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0aa386d70cb76057.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Float64", + "value": null + } + ] + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/0aa386d70cb76057.sql b/tests/ast_json_fixtures/shapes/0aa386d70cb76057.sql new file mode 100644 index 000000000000..0302c04076bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0aa386d70cb76057.sql @@ -0,0 +1 @@ +SELECT inf FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/0ab77ec1408a9a16.json b/tests/ast_json_fixtures/shapes/0ab77ec1408a9a16.json new file mode 100644 index 000000000000..1944e8c9e274 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ab77ec1408a9a16.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test__fuzz_2_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test__fuzz_2_local" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "test__fuzz_2_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/0ab77ec1408a9a16.sql b/tests/ast_json_fixtures/shapes/0ab77ec1408a9a16.sql new file mode 100644 index 000000000000..0c9c6126e15a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ab77ec1408a9a16.sql @@ -0,0 +1,2 @@ +CREATE TABLE test__fuzz_2_dist AS test__fuzz_2_local +ENGINE = Distributed(test_cluster_two_shards, currentDatabase(), test__fuzz_2_local, rand()) diff --git a/tests/ast_json_fixtures/shapes/0abc69bcec3d8cef.json b/tests/ast_json_fixtures/shapes/0abc69bcec3d8cef.json new file mode 100644 index 000000000000..d3d26f91e41f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0abc69bcec3d8cef.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c0" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_const_name_size": "0" + } + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "c0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0abc69bcec3d8cef.sql b/tests/ast_json_fixtures/shapes/0abc69bcec3d8cef.sql new file mode 100644 index 000000000000..b710a6a406d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0abc69bcec3d8cef.sql @@ -0,0 +1 @@ +SELECT c0 FROM t1 ORDER BY c0 LIMIT 1 BY c0 SETTINGS optimize_const_name_size = 0 diff --git a/tests/ast_json_fixtures/shapes/0ac4b1393ec520fe.json b/tests/ast_json_fixtures/shapes/0ac4b1393ec520fe.json new file mode 100644 index 000000000000..67f34518bcad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ac4b1393ec520fe.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0ac4b1393ec520fe.sql b/tests/ast_json_fixtures/shapes/0ac4b1393ec520fe.sql new file mode 100644 index 000000000000..09960c92eb4f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ac4b1393ec520fe.sql @@ -0,0 +1 @@ +SELECT count() GROUP BY 1 WITH TOTALS LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/0ae0c88691e50662.json b/tests/ast_json_fixtures/shapes/0ae0c88691e50662.json new file mode 100644 index 000000000000..752a04de0839 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ae0c88691e50662.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "input", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(String)" + } + ] + }, + { + "type": "Literal", + "alias": "mode", + "value_type": "String", + "value": "aes-256-ofb" + } + ], + "select": [ + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "input" + } + ] + }, + { + "type": "Function", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "aes_encrypt_mysql", + "arguments": [ + { + "type": "Identifier", + "name": "mode" + }, + { + "type": "Identifier", + "name": "input" + }, + { + "type": "Identifier", + "name": "key32" + }, + { + "type": "Identifier", + "name": "iv" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "encryption_test" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0ae0c88691e50662.sql b/tests/ast_json_fixtures/shapes/0ae0c88691e50662.sql new file mode 100644 index 000000000000..be302c95a385 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ae0c88691e50662.sql @@ -0,0 +1 @@ +WITH CAST(NULL as Nullable(String)) as input, 'aes-256-ofb' as mode SELECT toTypeName(input), hex(aes_encrypt_mysql(mode, input, key32,iv)) FROM encryption_test LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/0aee8c1ed52dd386.json b/tests/ast_json_fixtures/shapes/0aee8c1ed52dd386.json new file mode 100644 index 000000000000..8e33370f6696 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0aee8c1ed52dd386.json @@ -0,0 +1,132 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "range_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "CountryID", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "StartDate", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "EndDate", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "Tax", + "data_type": { + "type": "DataType", + "name": "Float64" + }, + "default_value": { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "CountryID" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "user", + "value": { + "type": "Literal", + "value_type": "String", + "value": "default" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "date_table" + } + }, + { + "type": "pair", + "key": "db", + "value": { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 1, + "max_sec": 1000 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "range_hashed", + "parameters": [] + }, + "range": { + "type": "DictionaryRange", + "min_attr_name": "StartDate", + "max_attr_name": "EndDate" + }, + "settings": { + "type": "DictionarySettings", + "changes": { + "dictionary_use_async_executor": "1", + "max_threads": "8" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0aee8c1ed52dd386.sql b/tests/ast_json_fixtures/shapes/0aee8c1ed52dd386.sql new file mode 100644 index 000000000000..5e0deae93a17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0aee8c1ed52dd386.sql @@ -0,0 +1,13 @@ +CREATE DICTIONARY range_dictionary +( + CountryID UInt64, + StartDate Date, + EndDate Date, + Tax Float64 DEFAULT 0.2 +) +PRIMARY KEY CountryID +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'date_table' DB currentDatabase())) +LIFETIME(MIN 1 MAX 1000) +LAYOUT(RANGE_HASHED()) +RANGE(MIN StartDate MAX EndDate) +SETTINGS(dictionary_use_async_executor=1, max_threads=8) diff --git a/tests/ast_json_fixtures/shapes/0afbd390e48ce7a2.json b/tests/ast_json_fixtures/shapes/0afbd390e48ce7a2.json new file mode 100644 index 000000000000..4a9acf2f183d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0afbd390e48ce7a2.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "mutation_table" + }, + "assignments": [ + { + "type": "Assignment", + "column": "dt", + "expression": { + "type": "Function", + "name": "toDateOrNull", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2020-08-04" + } + ] + } + } + ], + "predicate": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "car" + } + ] + }, + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0afbd390e48ce7a2.sql b/tests/ast_json_fixtures/shapes/0afbd390e48ce7a2.sql new file mode 100644 index 000000000000..d8aff5ddcbec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0afbd390e48ce7a2.sql @@ -0,0 +1 @@ +update mutation_table set dt = toDateOrNull('2020-08-04') where name = 'car' or dt is null diff --git a/tests/ast_json_fixtures/shapes/0b2e08f900552d40.json b/tests/ast_json_fixtures/shapes/0b2e08f900552d40.json new file mode 100644 index 000000000000..bae988e33acf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b2e08f900552d40.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "as_foo" + }, + "as_table": "foo" + } +} diff --git a/tests/ast_json_fixtures/shapes/0b2e08f900552d40.sql b/tests/ast_json_fixtures/shapes/0b2e08f900552d40.sql new file mode 100644 index 000000000000..acfd20d8cf0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b2e08f900552d40.sql @@ -0,0 +1 @@ +CREATE TABLE as_foo AS foo diff --git a/tests/ast_json_fixtures/shapes/0b3c385b625cdb64.json b/tests/ast_json_fixtures/shapes/0b3c385b625cdb64.json new file mode 100644 index 000000000000..50bfeb7ef05b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b3c385b625cdb64.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "database_123456789abcde" + }, + "table": { + "type": "Identifier", + "name": "tbl" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "mmi_idx", + "expression": { + "type": "Identifier", + "name": "b" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "a" + }, + "settings": { + "type": "Settings", + "changes": { + "add_minmax_index_for_numeric_columns": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0b3c385b625cdb64.sql b/tests/ast_json_fixtures/shapes/0b3c385b625cdb64.sql new file mode 100644 index 000000000000..ffa070bfaf4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b3c385b625cdb64.sql @@ -0,0 +1,9 @@ +CREATE TABLE database_123456789abcde.tbl +( + a UInt64, + b UInt64, + INDEX mmi_idx b TYPE minmax +) +ENGINE = MergeTree +PRIMARY KEY a +SETTINGS add_minmax_index_for_numeric_columns=0 diff --git a/tests/ast_json_fixtures/shapes/0b60fa0d336551f8.json b/tests/ast_json_fixtures/shapes/0b60fa0d336551f8.json new file mode 100644 index 000000000000..253b8d064f4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b60fa0d336551f8.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "name", + "name": "b.name", + "name_parts": ["b", "name"] + }, + { + "type": "Identifier", + "alias": "a_col", + "name": "a.a_col", + "name_parts": ["a", "a_col"] + }, + { + "type": "Identifier", + "alias": "b_col", + "name": "b.b_col", + "name_parts": ["b", "b_col"] + }, + { + "type": "Literal", + "alias": "some_val", + "value_type": "String", + "value": "N" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "a", + "name": "test_a_table" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.name", + "name_parts": ["a", "name"] + }, + { + "type": "Identifier", + "name": "b.name", + "name_parts": ["b", "name"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "b", + "name": "test_b_table" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b.some_val", + "name_parts": ["b", "some_val"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Y" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0b60fa0d336551f8.sql b/tests/ast_json_fixtures/shapes/0b60fa0d336551f8.sql new file mode 100644 index 000000000000..edd14534ce25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b60fa0d336551f8.sql @@ -0,0 +1,8 @@ +SELECT + b.name name, + a.a_col a_col, + b.b_col b_col, + 'N' some_val +from test_a_table a +join test_b_table b on a.name = b.name +where b.some_val = 'Y' diff --git a/tests/ast_json_fixtures/shapes/0b648d096bf8aa4b.json b/tests/ast_json_fixtures/shapes/0b648d096bf8aa4b.json new file mode 100644 index 000000000000..d5e0766d470f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b648d096bf8aa4b.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "or_replace": true, + "function_name": { + "type": "Identifier", + "name": "02148_test_function" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0b648d096bf8aa4b.sql b/tests/ast_json_fixtures/shapes/0b648d096bf8aa4b.sql new file mode 100644 index 000000000000..be2d4e544580 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b648d096bf8aa4b.sql @@ -0,0 +1 @@ +CREATE OR REPLACE FUNCTION 02148_test_function AS () -> (SELECT 2) diff --git a/tests/ast_json_fixtures/shapes/0b6ed7a8dc0b537f.json b/tests/ast_json_fixtures/shapes/0b6ed7a8dc0b537f.json new file mode 100644 index 000000000000..4060b0d7e2a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b6ed7a8dc0b537f.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "replace_table": true, + "create_or_replace": true, + "table": { + "type": "Identifier", + "name": "tmp" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0b6ed7a8dc0b537f.sql b/tests/ast_json_fixtures/shapes/0b6ed7a8dc0b537f.sql new file mode 100644 index 000000000000..3bfe67d2c0bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b6ed7a8dc0b537f.sql @@ -0,0 +1 @@ +CREATE OR REPLACE TEMPORARY TABLE tmp (n UInt32) AS SELECT * FROM numbers(10) diff --git a/tests/ast_json_fixtures/shapes/0b76e6a74a639a23.json b/tests/ast_json_fixtures/shapes/0b76e6a74a639a23.json new file mode 100644 index 000000000000..eea5a219ff78 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b76e6a74a639a23.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01293", "r2_01293_renamed"] + } +} diff --git a/tests/ast_json_fixtures/shapes/0b76e6a74a639a23.sql b/tests/ast_json_fixtures/shapes/0b76e6a74a639a23.sql new file mode 100644 index 000000000000..98f3e0f95be4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b76e6a74a639a23.sql @@ -0,0 +1 @@ +DROP ROLE r1_01293, r2_01293_renamed diff --git a/tests/ast_json_fixtures/shapes/0b7edc49cac09187.json b/tests/ast_json_fixtures/shapes/0b7edc49cac09187.json new file mode 100644 index 000000000000..00612583cd47 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b7edc49cac09187.json @@ -0,0 +1,476 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "bad_v4", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv4" + } + ] + } + ] + }, + { + "type": "Function", + "name": "notIn", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv4", + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv4" + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv4", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0.0.0.0" + } + ] + }, + { + "type": "Function", + "name": "toIPv4", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "192.168.0.1" + } + ] + } + ] + } + ] + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "bad_v6", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv6" + } + ] + } + ] + }, + { + "type": "Function", + "name": "notIn", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv6" + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "::" + } + ] + }, + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "::1" + } + ] + }, + { + "type": "Function", + "name": "toIPv6", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "::ffff:192.168.0.1" + } + ] + } + ] + } + ] + } + ] + } + } + ] + } + }, + { + "type": "Function", + "alias": "bad_cnt", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bad_v4" + }, + { + "type": "Identifier", + "name": "bad_v6" + } + ] + } + ], + "select": [ + { + "type": "Literal", + "alias": "tag", + "value_type": "String", + "value": "ch_dbg_summary" + }, + { + "type": "Subquery", + "alias": "total", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "typed_v4", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv4" + } + ] + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "typed_v6", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "IPv6" + } + ] + } + ] + } + } + ] + } + }, + { + "type": "Identifier", + "name": "bad_v4" + }, + { + "type": "Identifier", + "name": "bad_v6" + }, + { + "type": "Function", + "alias": "ver", + "name": "version", + "arguments": [] + }, + { + "type": "Function", + "alias": "tz", + "name": "getSetting", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "session_timezone" + } + ] + } + ], + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bad_cnt" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0b7edc49cac09187.sql b/tests/ast_json_fixtures/shapes/0b7edc49cac09187.sql new file mode 100644 index 000000000000..6b5ce613920a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b7edc49cac09187.sql @@ -0,0 +1,21 @@ +WITH + (SELECT count() + FROM t + WHERE accurateCastOrNull(d,'IPv4') IS NOT NULL + AND toIPv4(accurateCastOrNull(d,'IPv4')) NOT IN (toIPv4('0.0.0.0'), toIPv4('192.168.0.1')) + ) AS bad_v4, + (SELECT count() + FROM t + WHERE accurateCastOrNull(d,'IPv6') IS NOT NULL + AND toIPv6(accurateCastOrNull(d,'IPv6')) NOT IN (toIPv6('::'), toIPv6('::1'), toIPv6('::ffff:192.168.0.1')) + ) AS bad_v6, + bad_v4 + bad_v6 AS bad_cnt +SELECT + 'ch_dbg_summary' AS tag, + (SELECT count() FROM t) AS total, + (SELECT count() FROM t WHERE accurateCastOrNull(d,'IPv4') IS NOT NULL) AS typed_v4, + (SELECT count() FROM t WHERE accurateCastOrNull(d,'IPv6') IS NOT NULL) AS typed_v6, + bad_v4, bad_v6, + version() AS ver, + getSetting('session_timezone') AS tz +WHERE bad_cnt > 0 diff --git a/tests/ast_json_fixtures/shapes/0b9c6332b62b5051.json b/tests/ast_json_fixtures/shapes/0b9c6332b62b5051.json new file mode 100644 index 000000000000..70e3d17abd6b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b9c6332b62b5051.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "temporary": true, + "like": "temp_tab" + } +} diff --git a/tests/ast_json_fixtures/shapes/0b9c6332b62b5051.sql b/tests/ast_json_fixtures/shapes/0b9c6332b62b5051.sql new file mode 100644 index 000000000000..4d93f1ae601f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0b9c6332b62b5051.sql @@ -0,0 +1 @@ +SHOW TEMPORARY TABLES LIKE 'temp_tab' diff --git a/tests/ast_json_fixtures/shapes/0ba2799e039c4ea6.json b/tests/ast_json_fixtures/shapes/0ba2799e039c4ea6.json new file mode 100644 index 000000000000..2a0a20ba4dc3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ba2799e039c4ea6.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "t_merge_tree" + }, + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "2024-08-01" + } + }, + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0ba2799e039c4ea6.sql b/tests/ast_json_fixtures/shapes/0ba2799e039c4ea6.sql new file mode 100644 index 000000000000..85fd77a9ebbd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ba2799e039c4ea6.sql @@ -0,0 +1 @@ +DELETE FROM t_merge_tree IN PARTITION '2024-08-01' WHERE id = '1' diff --git a/tests/ast_json_fixtures/shapes/0bb275408ea6e5b8.json b/tests/ast_json_fixtures/shapes/0bb275408ea6e5b8.json new file mode 100644 index 000000000000..aa23540e41a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0bb275408ea6e5b8.json @@ -0,0 +1,145 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "row", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k1" + }, + { + "type": "Identifier", + "name": "v" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k2" + }, + { + "type": "Identifier", + "name": "v" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "k", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "row" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + }, + "final": true + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "row" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_vertical_final": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0bb275408ea6e5b8.sql b/tests/ast_json_fixtures/shapes/0bb275408ea6e5b8.sql new file mode 100644 index 000000000000..d1a2ae317926 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0bb275408ea6e5b8.sql @@ -0,0 +1 @@ +SELECT arrayJoin([(k1, v), (k2, v)]) AS row, row.1 as k FROM t FINAL WHERE k1 != 3 AND k = 1 ORDER BY row SETTINGS enable_vertical_final = 0 diff --git a/tests/ast_json_fixtures/shapes/0bb384624ec05f31.json b/tests/ast_json_fixtures/shapes/0bb384624ec05f31.json new file mode 100644 index 000000000000..9320c5275bf7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0bb384624ec05f31.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "merge_table" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^(table_to_merge_[a-z])$" + } + ] + } + }, + "as_table": "table_to_merge_a" + } +} diff --git a/tests/ast_json_fixtures/shapes/0bb384624ec05f31.sql b/tests/ast_json_fixtures/shapes/0bb384624ec05f31.sql new file mode 100644 index 000000000000..fe152b859431 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0bb384624ec05f31.sql @@ -0,0 +1 @@ +CREATE TABLE merge_table Engine=Merge(currentDatabase(), '^(table_to_merge_[a-z])$') AS table_to_merge_a diff --git a/tests/ast_json_fixtures/shapes/0bb8865e3f635939.json b/tests/ast_json_fixtures/shapes/0bb8865e3f635939.json new file mode 100644 index 000000000000..9c06db064076 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0bb8865e3f635939.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "START FETCHES", + "table": { + "type": "Identifier", + "name": "r2" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0bb8865e3f635939.sql b/tests/ast_json_fixtures/shapes/0bb8865e3f635939.sql new file mode 100644 index 000000000000..c4100898154d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0bb8865e3f635939.sql @@ -0,0 +1 @@ +SYSTEM START FETCHES r2 diff --git a/tests/ast_json_fixtures/shapes/0be2952ff8a02bee.json b/tests/ast_json_fixtures/shapes/0be2952ff8a02bee.json new file mode 100644 index 000000000000..601ce566bea7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0be2952ff8a02bee.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC", + "nulls_first": false + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "PRETTY" + } +} diff --git a/tests/ast_json_fixtures/shapes/0be2952ff8a02bee.sql b/tests/ast_json_fixtures/shapes/0be2952ff8a02bee.sql new file mode 100644 index 000000000000..ba1166ed58e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0be2952ff8a02bee.sql @@ -0,0 +1 @@ +SELECT * FROM test ORDER BY ALL ASC NULLS LAST LIMIT 1 FORMAT PRETTY diff --git a/tests/ast_json_fixtures/shapes/0c046740822bce9c.json b/tests/ast_json_fixtures/shapes/0c046740822bce9c.json new file mode 100644 index 000000000000..dc237f16a2fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c046740822bce9c.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "i" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/0c046740822bce9c.sql b/tests/ast_json_fixtures/shapes/0c046740822bce9c.sql new file mode 100644 index 000000000000..ec95c496ea32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c046740822bce9c.sql @@ -0,0 +1 @@ +select * from test where i < 10 group by i order by i FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/0c116594c4e41c20.json b/tests/ast_json_fixtures/shapes/0c116594c4e41c20.json new file mode 100644 index 000000000000..a250da6617b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c116594c4e41c20.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u4_01292" + } + ] + }, + "default_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01292", "r2_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0c116594c4e41c20.sql b/tests/ast_json_fixtures/shapes/0c116594c4e41c20.sql new file mode 100644 index 000000000000..5139a7c42d30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c116594c4e41c20.sql @@ -0,0 +1 @@ +CREATE USER u4_01292 DEFAULT ROLE r1_01292, r2_01292 diff --git a/tests/ast_json_fixtures/shapes/0c4e052afe13b579.json b/tests/ast_json_fixtures/shapes/0c4e052afe13b579.json new file mode 100644 index 000000000000..41b1b4ae7a68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c4e052afe13b579.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropWorkloadQuery", + "workload_name": "all", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/0c4e052afe13b579.sql b/tests/ast_json_fixtures/shapes/0c4e052afe13b579.sql new file mode 100644 index 000000000000..fc788d9c3f96 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c4e052afe13b579.sql @@ -0,0 +1 @@ +drop workload if exists all diff --git a/tests/ast_json_fixtures/shapes/0c52d3a0505ff931.json b/tests/ast_json_fixtures/shapes/0c52d3a0505ff931.json new file mode 100644 index 000000000000..e85eefde1a3a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c52d3a0505ff931.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "dst" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + "replace": true, + "from_table": "src" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0c52d3a0505ff931.sql b/tests/ast_json_fixtures/shapes/0c52d3a0505ff931.sql new file mode 100644 index 000000000000..04b786b2fd38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c52d3a0505ff931.sql @@ -0,0 +1 @@ +ALTER TABLE dst REPLACE PARTITION 1 FROM src diff --git a/tests/ast_json_fixtures/shapes/0c612d90b983eb78.json b/tests/ast_json_fixtures/shapes/0c612d90b983eb78.json new file mode 100644 index 000000000000..d7536e48cb30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c612d90b983eb78.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "merge_tf" + }, + "as_table_function": { + "type": "Function", + "name": "merge", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".*" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0c612d90b983eb78.sql b/tests/ast_json_fixtures/shapes/0c612d90b983eb78.sql new file mode 100644 index 000000000000..9c715f0f0929 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c612d90b983eb78.sql @@ -0,0 +1 @@ +CREATE TABLE merge_tf as merge(currentDatabase(), '.*') diff --git a/tests/ast_json_fixtures/shapes/0c7210a91c80d005.json b/tests/ast_json_fixtures/shapes/0c7210a91c80d005.json new file mode 100644 index 000000000000..a7a97bd82231 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c7210a91c80d005.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "function_name": { + "type": "Identifier", + "name": "cast" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0c7210a91c80d005.sql b/tests/ast_json_fixtures/shapes/0c7210a91c80d005.sql new file mode 100644 index 000000000000..e64ca673eb41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c7210a91c80d005.sql @@ -0,0 +1 @@ +CREATE FUNCTION cast AS a -> a + 1 diff --git a/tests/ast_json_fixtures/shapes/0c7d62622027a1dc.json b/tests/ast_json_fixtures/shapes/0c7d62622027a1dc.json new file mode 100644 index 000000000000..b187a7322203 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c7d62622027a1dc.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_test_01040" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test_01040" + }, + { + "type": "Identifier", + "name": "key" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "background_insert_batch": "1", + "background_insert_sleep_time_ms": "10", + "background_insert_max_sleep_time_ms": "100" + } + } + }, + "as_table": "test_01040" + } +} diff --git a/tests/ast_json_fixtures/shapes/0c7d62622027a1dc.sql b/tests/ast_json_fixtures/shapes/0c7d62622027a1dc.sql new file mode 100644 index 000000000000..2dc6c074ee8f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0c7d62622027a1dc.sql @@ -0,0 +1,4 @@ +CREATE TABLE dist_test_01040 AS test_01040 Engine=Distributed(test_cluster_two_shards, currentDatabase(), test_01040, key) SETTINGS + background_insert_batch=1, + background_insert_sleep_time_ms=10, + background_insert_max_sleep_time_ms=100 diff --git a/tests/ast_json_fixtures/shapes/0ca0ddf9951cac01.json b/tests/ast_json_fixtures/shapes/0ca0ddf9951cac01.json new file mode 100644 index 000000000000..c406d210eb65 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ca0ddf9951cac01.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0ca0ddf9951cac01.sql b/tests/ast_json_fixtures/shapes/0ca0ddf9951cac01.sql new file mode 100644 index 000000000000..128b8dfe0714 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ca0ddf9951cac01.sql @@ -0,0 +1 @@ +SELECT x, 1 + (2 + (3 AS x)) diff --git a/tests/ast_json_fixtures/shapes/0cb07a15c8966122.json b/tests/ast_json_fixtures/shapes/0cb07a15c8966122.json new file mode 100644 index 000000000000..932cf10fe051 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0cb07a15c8966122.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-1" + } + ] + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-2147483648" + }, + { + "type": "Function", + "name": "h3CellAreaM2", + "arguments": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "9223372036854775807" + }, + { + "value_type": "UInt64", + "value": "65535" + }, + { + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0cb07a15c8966122.sql b/tests/ast_json_fixtures/shapes/0cb07a15c8966122.sql new file mode 100644 index 000000000000..86733a464170 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0cb07a15c8966122.sql @@ -0,0 +1 @@ +SELECT NULL, toFloat64('-1'), -2147483648, h3CellAreaM2(arrayJoin([9223372036854775807, 65535, NULL])) diff --git a/tests/ast_json_fixtures/shapes/0cbdfe82bcb3235d.json b/tests/ast_json_fixtures/shapes/0cbdfe82bcb3235d.json new file mode 100644 index 000000000000..9d0b46b3ed61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0cbdfe82bcb3235d.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "a", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "randConstant", + "arguments": [] + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0cbdfe82bcb3235d.sql b/tests/ast_json_fixtures/shapes/0cbdfe82bcb3235d.sql new file mode 100644 index 000000000000..ded7855f2c8f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0cbdfe82bcb3235d.sql @@ -0,0 +1 @@ +with (select randConstant()) as a select a = a diff --git a/tests/ast_json_fixtures/shapes/0cbe3c52d4bdd965.json b/tests/ast_json_fixtures/shapes/0cbe3c52d4bdd965.json new file mode 100644 index 000000000000..e430ee17dff5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0cbe3c52d4bdd965.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "enum" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "y" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/0cbe3c52d4bdd965.sql b/tests/ast_json_fixtures/shapes/0cbe3c52d4bdd965.sql new file mode 100644 index 000000000000..dfffd267a89e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0cbe3c52d4bdd965.sql @@ -0,0 +1 @@ +SELECT * FROM enum ORDER BY x, y FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/0cd6770ec127bcc9.json b/tests/ast_json_fixtures/shapes/0cd6770ec127bcc9.json new file mode 100644 index 000000000000..c4ab627c5aab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0cd6770ec127bcc9.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u2_01292" + } + ] + }, + "default_roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0cd6770ec127bcc9.sql b/tests/ast_json_fixtures/shapes/0cd6770ec127bcc9.sql new file mode 100644 index 000000000000..1f4e025543e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0cd6770ec127bcc9.sql @@ -0,0 +1 @@ +CREATE USER u2_01292 DEFAULT ROLE NONE diff --git a/tests/ast_json_fixtures/shapes/0d183ee37fa407eb.json b/tests/ast_json_fixtures/shapes/0d183ee37fa407eb.json new file mode 100644 index 000000000000..fe312a41ebf4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d183ee37fa407eb.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettyCompactNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/0d183ee37fa407eb.sql b/tests/ast_json_fixtures/shapes/0d183ee37fa407eb.sql new file mode 100644 index 000000000000..ea0be8b8c29f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d183ee37fa407eb.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettyCompactNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/0d1e0f23fadceada.json b/tests/ast_json_fixtures/shapes/0d1e0f23fadceada.json new file mode 100644 index 000000000000..69befe931d85 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d1e0f23fadceada.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "sample_merge_00314" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^sample_00314_\\d$" + } + ] + } + }, + "as_table": "sample_00314_1" + } +} diff --git a/tests/ast_json_fixtures/shapes/0d1e0f23fadceada.sql b/tests/ast_json_fixtures/shapes/0d1e0f23fadceada.sql new file mode 100644 index 000000000000..6b62de877b89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d1e0f23fadceada.sql @@ -0,0 +1 @@ +CREATE TABLE sample_merge_00314 AS sample_00314_1 ENGINE = Merge(currentDatabase(), '^sample_00314_\\d$') diff --git a/tests/ast_json_fixtures/shapes/0d29ee0d866c24ce.json b/tests/ast_json_fixtures/shapes/0d29ee0d866c24ce.json new file mode 100644 index 000000000000..237a89db7bf4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d29ee0d866c24ce.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_ordinary_view": true, + "table": { + "type": "Identifier", + "name": "test_view_03280" + }, + "aliases": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0d29ee0d866c24ce.sql b/tests/ast_json_fixtures/shapes/0d29ee0d866c24ce.sql new file mode 100644 index 000000000000..1c0f7c13e9e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d29ee0d866c24ce.sql @@ -0,0 +1 @@ +CREATE VIEW test_view_03280 (a,b) AS SELECT 1, 2 diff --git a/tests/ast_json_fixtures/shapes/0d60f14b3941cf03.json b/tests/ast_json_fixtures/shapes/0d60f14b3941cf03.json new file mode 100644 index 000000000000..d2d596d06ab7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d60f14b3941cf03.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "Null", + "value": null + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/0d60f14b3941cf03.sql b/tests/ast_json_fixtures/shapes/0d60f14b3941cf03.sql new file mode 100644 index 000000000000..127532a470e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d60f14b3941cf03.sql @@ -0,0 +1 @@ +select * from numbers(1) where null format JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/0d640bafb2fecede.json b/tests/ast_json_fixtures/shapes/0d640bafb2fecede.json new file mode 100644 index 000000000000..3b2e6a9c9284 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d640bafb2fecede.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "other_table_2" + }, + "as_table": "mv_from_base_to_target" + } +} diff --git a/tests/ast_json_fixtures/shapes/0d640bafb2fecede.sql b/tests/ast_json_fixtures/shapes/0d640bafb2fecede.sql new file mode 100644 index 000000000000..a0385f153e28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d640bafb2fecede.sql @@ -0,0 +1 @@ +CREATE TABLE other_table_2 AS mv_from_base_to_target diff --git a/tests/ast_json_fixtures/shapes/0d669133337dd5b1.json b/tests/ast_json_fixtures/shapes/0d669133337dd5b1.json new file mode 100644 index 000000000000..c9dd0d6b36f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d669133337dd5b1.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s5_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/0d669133337dd5b1.sql b/tests/ast_json_fixtures/shapes/0d669133337dd5b1.sql new file mode 100644 index 000000000000..adaa9b54b941 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d669133337dd5b1.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s5_01294 diff --git a/tests/ast_json_fixtures/shapes/0d67d7b36d5e2a8f.json b/tests/ast_json_fixtures/shapes/0d67d7b36d5e2a8f.json new file mode 100644 index 000000000000..fdf888aa91e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d67d7b36d5e2a8f.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_result_rows": "10", + "output_format_write_statistics": "0" + } + }, + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/0d67d7b36d5e2a8f.sql b/tests/ast_json_fixtures/shapes/0d67d7b36d5e2a8f.sql new file mode 100644 index 000000000000..863118d4216c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d67d7b36d5e2a8f.sql @@ -0,0 +1 @@ +select * from numbers(10) FORMAT JSONCompact settings max_result_rows = 10, output_format_write_statistics = 0 diff --git a/tests/ast_json_fixtures/shapes/0d6aed41fb5f3038.json b/tests/ast_json_fixtures/shapes/0d6aed41fb5f3038.json new file mode 100644 index 000000000000..162843f77a21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d6aed41fb5f3038.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "alter_00061" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "n.d" + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0d6aed41fb5f3038.sql b/tests/ast_json_fixtures/shapes/0d6aed41fb5f3038.sql new file mode 100644 index 000000000000..f404ec2b4dc4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d6aed41fb5f3038.sql @@ -0,0 +1 @@ +ALTER TABLE alter_00061 DROP COLUMN `n.d`, MODIFY COLUMN s Int64 diff --git a/tests/ast_json_fixtures/shapes/0d7d7c2e99c9bd20.json b/tests/ast_json_fixtures/shapes/0d7d7c2e99c9bd20.json new file mode 100644 index 000000000000..c628a494d7d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d7d7c2e99c9bd20.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "p", + "name": "h3ToGeo", + "arguments": [ + { + "type": "Identifier", + "name": "h3_index" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "p" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "p" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "h3_indexes" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "h3_index" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0d7d7c2e99c9bd20.sql b/tests/ast_json_fixtures/shapes/0d7d7c2e99c9bd20.sql new file mode 100644 index 000000000000..c0a81ee1fcc6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d7d7c2e99c9bd20.sql @@ -0,0 +1 @@ +WITH h3ToGeo(h3_index) AS p SELECT round(p.1, 3), round(p.2, 3) FROM h3_indexes ORDER BY h3_index diff --git a/tests/ast_json_fixtures/shapes/0d86204b294c97d1.json b/tests/ast_json_fixtures/shapes/0d86204b294c97d1.json new file mode 100644 index 000000000000..3c7b80b881d9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d86204b294c97d1.json @@ -0,0 +1,116 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_having" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0d86204b294c97d1.sql b/tests/ast_json_fixtures/shapes/0d86204b294c97d1.sql new file mode 100644 index 000000000000..90e971eed23a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0d86204b294c97d1.sql @@ -0,0 +1,2 @@ +SELECT sum(c0 = 0), min(c0 + 1), sum(c0 + 2) FROM t_having +GROUP BY c0 HAVING c0 = 0 diff --git a/tests/ast_json_fixtures/shapes/0db39562b750acd5.json b/tests/ast_json_fixtures/shapes/0db39562b750acd5.json new file mode 100644 index 000000000000..a3884fbbcd0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0db39562b750acd5.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR TEXT INDEX DICTIONARY CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/0db39562b750acd5.sql b/tests/ast_json_fixtures/shapes/0db39562b750acd5.sql new file mode 100644 index 000000000000..fba48bb669d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0db39562b750acd5.sql @@ -0,0 +1 @@ +SYSTEM CLEAR TEXT INDEX DICTIONARY CACHE diff --git a/tests/ast_json_fixtures/shapes/0dc3dbdda58fa5ee.json b/tests/ast_json_fixtures/shapes/0dc3dbdda58fa5ee.json new file mode 100644 index 000000000000..905d565dab29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0dc3dbdda58fa5ee.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "RESTORE REPLICA", + "table": { + "type": "Identifier", + "name": "hourly_data" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0dc3dbdda58fa5ee.sql b/tests/ast_json_fixtures/shapes/0dc3dbdda58fa5ee.sql new file mode 100644 index 000000000000..acb1628640f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0dc3dbdda58fa5ee.sql @@ -0,0 +1 @@ +SYSTEM RESTORE REPLICA hourly_data diff --git a/tests/ast_json_fixtures/shapes/0de41cfd7a95226c.json b/tests/ast_json_fixtures/shapes/0de41cfd7a95226c.json new file mode 100644 index 000000000000..a3704ac15751 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0de41cfd7a95226c.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_read_in_order": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0de41cfd7a95226c.sql b/tests/ast_json_fixtures/shapes/0de41cfd7a95226c.sql new file mode 100644 index 000000000000..0577fb5c5a36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0de41cfd7a95226c.sql @@ -0,0 +1 @@ +SELECT * FROM tab ORDER BY x LIMIT 3 SETTINGS optimize_read_in_order=1 diff --git a/tests/ast_json_fixtures/shapes/0e0e2ce247260a44.json b/tests/ast_json_fixtures/shapes/0e0e2ce247260a44.json new file mode 100644 index 000000000000..ee77464561c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e0e2ce247260a44.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_02175" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "local_02175" + } + ] + } + }, + "as_table": "local_02175" + } +} diff --git a/tests/ast_json_fixtures/shapes/0e0e2ce247260a44.sql b/tests/ast_json_fixtures/shapes/0e0e2ce247260a44.sql new file mode 100644 index 000000000000..1a50df1671df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e0e2ce247260a44.sql @@ -0,0 +1 @@ +create table dist_02175 as local_02175 engine=Distributed(test_cluster_two_shards, currentDatabase(), local_02175) diff --git a/tests/ast_json_fixtures/shapes/0e10a47b690968d8.json b/tests/ast_json_fixtures/shapes/0e10a47b690968d8.json new file mode 100644 index 000000000000..2736c4044d98 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e10a47b690968d8.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN AST", + "query": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t1" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DELETE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "date" + }, + { + "type": "Function", + "name": "today", + "arguments": [] + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0e10a47b690968d8.sql b/tests/ast_json_fixtures/shapes/0e10a47b690968d8.sql new file mode 100644 index 000000000000..413acb789e00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e10a47b690968d8.sql @@ -0,0 +1 @@ +explain ast alter table t1 delete where date = today() diff --git a/tests/ast_json_fixtures/shapes/0e1f4e951e373688.json b/tests/ast_json_fixtures/shapes/0e1f4e951e373688.json new file mode 100644 index 000000000000..adb8b239dce4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e1f4e951e373688.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx", + "expression": { + "type": "Identifier", + "name": "s" + }, + "index_type": { + "type": "Function", + "name": "text", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tokenizer" + }, + { + "type": "Identifier", + "name": "sparseGrams" + } + ] + } + ] + }, + "granularity": 100000000 + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "s" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "s" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0e1f4e951e373688.sql b/tests/ast_json_fixtures/shapes/0e1f4e951e373688.sql new file mode 100644 index 000000000000..bfdfc504cc5c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e1f4e951e373688.sql @@ -0,0 +1,7 @@ +CREATE TABLE tab +( + s Array(String), + INDEX idx s TYPE text(tokenizer = sparseGrams), + PROJECTION p (SELECT s ORDER BY s) +) +ENGINE = MergeTree() ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/0e219eac35b3bcfb.json b/tests/ast_json_fixtures/shapes/0e219eac35b3bcfb.json new file mode 100644 index 000000000000..161522d7c556 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e219eac35b3bcfb.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q16_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/0e219eac35b3bcfb.sql b/tests/ast_json_fixtures/shapes/0e219eac35b3bcfb.sql new file mode 100644 index 000000000000..e68ac1718289 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e219eac35b3bcfb.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q16_01297 diff --git a/tests/ast_json_fixtures/shapes/0e3647b2fec88eb6.json b/tests/ast_json_fixtures/shapes/0e3647b2fec88eb6.json new file mode 100644 index 000000000000..86cd4c3970af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e3647b2fec88eb6.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "x" + } + }, + "format": "NULL" + } +} diff --git a/tests/ast_json_fixtures/shapes/0e3647b2fec88eb6.sql b/tests/ast_json_fixtures/shapes/0e3647b2fec88eb6.sql new file mode 100644 index 000000000000..d46adf197f86 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e3647b2fec88eb6.sql @@ -0,0 +1 @@ +CREATE TABLE t1 (x UInt8, y String) ENGINE=ReplicatedMergeTree ORDER BY x FORMAT NULL diff --git a/tests/ast_json_fixtures/shapes/0e86de77df2d2b78.json b/tests/ast_json_fixtures/shapes/0e86de77df2d2b78.json new file mode 100644 index 000000000000..6738c61f9ea6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e86de77df2d2b78.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "t_light" + }, + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0e86de77df2d2b78.sql b/tests/ast_json_fixtures/shapes/0e86de77df2d2b78.sql new file mode 100644 index 000000000000..b9492e3bef2b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e86de77df2d2b78.sql @@ -0,0 +1 @@ +DELETE FROM t_light WHERE c%5=1 diff --git a/tests/ast_json_fixtures/shapes/0e8c2dfc4d9b523a.json b/tests/ast_json_fixtures/shapes/0e8c2dfc4d9b523a.json new file mode 100644 index 000000000000..3cef8affe74f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e8c2dfc4d9b523a.json @@ -0,0 +1,237 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "roundBankers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775808" + }, + { + "type": "Function", + "name": "roundBankers", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "result" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "result", + "name": "studentTTest", + "arguments": [ + { + "type": "Identifier", + "name": "sample" + }, + { + "type": "Identifier", + "name": "variant" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "sample", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "alias": "variant", + "value_type": "UInt64", + "value": "0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1025" + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "sample", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775807" + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": null + } + ] + }, + { + "type": "Literal", + "alias": "variant", + "value_type": "Int64", + "value": "-9223372036854775808" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + } + } + ] + } + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/0e8c2dfc4d9b523a.sql b/tests/ast_json_fixtures/shapes/0e8c2dfc4d9b523a.sql new file mode 100644 index 000000000000..0427866c2f98 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e8c2dfc4d9b523a.sql @@ -0,0 +1,23 @@ +SELECT + roundBankers(100), + -9223372036854775808, + roundBankers(result.2, 256) +FROM + ( + SELECT studentTTest(sample, variant) AS result + FROM + ( + SELECT + toFloat64(number) % NULL AS sample, + 0 AS variant + FROM system.numbers + LIMIT 1025 + UNION ALL + SELECT + (toFloat64(number) % 9223372036854775807) + nan AS sample, + -9223372036854775808 AS variant + FROM system.numbers + LIMIT 1024 + ) + ) +FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/0e97897e8000fce0.json b/tests/ast_json_fixtures/shapes/0e97897e8000fce0.json new file mode 100644 index 000000000000..7fcf8ecd8a0b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e97897e8000fce0.json @@ -0,0 +1,140 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "bs" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "bs", + "name": "blockSize", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.a", + "name_parts": ["t1", "a"] + }, + { + "type": "Identifier", + "name": "t2.a", + "name_parts": ["t2", "a"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "b" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_joined_block_size_rows": "5" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0e97897e8000fce0.sql b/tests/ast_json_fixtures/shapes/0e97897e8000fce0.sql new file mode 100644 index 000000000000..c1db7b3146cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0e97897e8000fce0.sql @@ -0,0 +1,5 @@ +SELECT max(bs) <= 5, b FROM ( + SELECT blockSize() as bs, * FROM t1 JOIN t2 ON t1.a = t2.a +) GROUP BY b +ORDER BY b +SETTINGS max_joined_block_size_rows = 5 diff --git a/tests/ast_json_fixtures/shapes/0eafce5cabb1a12a.json b/tests/ast_json_fixtures/shapes/0eafce5cabb1a12a.json new file mode 100644 index 000000000000..871ff7490358 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0eafce5cabb1a12a.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "d", + "name": "toStartOfMonth", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + { + "type": "Identifier", + "name": "i" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_read_in_order" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0eafce5cabb1a12a.sql b/tests/ast_json_fixtures/shapes/0eafce5cabb1a12a.sql new file mode 100644 index 000000000000..b66a9f6c868b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0eafce5cabb1a12a.sql @@ -0,0 +1 @@ +SELECT toStartOfMonth(date) as d, i FROM t_read_in_order ORDER BY d, i LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/0ebe2562f41041ea.json b/tests/ast_json_fixtures/shapes/0ebe2562f41041ea.json new file mode 100644 index 000000000000..d0bed67b2a6e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ebe2562f41041ea.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "3" + }, + { + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "legacy_column_name_of_tuple_literal": "1" + } + }, + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/0ebe2562f41041ea.sql b/tests/ast_json_fixtures/shapes/0ebe2562f41041ea.sql new file mode 100644 index 000000000000..6b2c1c758b23 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ebe2562f41041ea.sql @@ -0,0 +1 @@ +SELECT ((1, 2), (2, 3), (3, 4)) FORMAT TSVWithNames SETTINGS legacy_column_name_of_tuple_literal = 1 diff --git a/tests/ast_json_fixtures/shapes/0ec35e77bf4fae3f.json b/tests/ast_json_fixtures/shapes/0ec35e77bf4fae3f.json new file mode 100644 index 000000000000..ee00d80e0f7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ec35e77bf4fae3f.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateTableQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "tmp" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0ec35e77bf4fae3f.sql b/tests/ast_json_fixtures/shapes/0ec35e77bf4fae3f.sql new file mode 100644 index 000000000000..5f1bb2af1b0b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ec35e77bf4fae3f.sql @@ -0,0 +1 @@ +SHOW CREATE TEMPORARY TABLE tmp diff --git a/tests/ast_json_fixtures/shapes/0ed19d5def89395c.json b/tests/ast_json_fixtures/shapes/0ed19d5def89395c.json new file mode 100644 index 000000000000..fd7a5caa58c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ed19d5def89395c.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "dictionary": true, + "elements": [ + { + "from_database": "test_01191", + "from_table": "dict1", + "to_database": "test_01191", + "to_table": "dict2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0ed19d5def89395c.sql b/tests/ast_json_fixtures/shapes/0ed19d5def89395c.sql new file mode 100644 index 000000000000..154a64f48f1f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ed19d5def89395c.sql @@ -0,0 +1 @@ +RENAME DICTIONARY test_01191.dict1 TO test_01191.dict2 diff --git a/tests/ast_json_fixtures/shapes/0ed886fb55d6cb8c.json b/tests/ast_json_fixtures/shapes/0ed886fb55d6cb8c.json new file mode 100644 index 000000000000..c9d903ad8301 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ed886fb55d6cb8c.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0ed886fb55d6cb8c.sql b/tests/ast_json_fixtures/shapes/0ed886fb55d6cb8c.sql new file mode 100644 index 000000000000..e4b8a4841901 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ed886fb55d6cb8c.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number order by number limit 1 diff --git a/tests/ast_json_fixtures/shapes/0ede3fdf3cb704af.json b/tests/ast_json_fixtures/shapes/0ede3fdf3cb704af.json new file mode 100644 index 000000000000..afe4447420e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ede3fdf3cb704af.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "replace_access": true, + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "db3", + "table": "table3", + "columns": ["col3"] + }, + { + "access_types": ["SELECT"], + "database": "db4", + "table": "table4", + "columns": ["col1", "col2"] + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0ede3fdf3cb704af.sql b/tests/ast_json_fixtures/shapes/0ede3fdf3cb704af.sql new file mode 100644 index 000000000000..08713406ea5d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ede3fdf3cb704af.sql @@ -0,0 +1 @@ +GRANT SELECT(col3) ON db3.table3, SELECT(col1, col2) ON db4.table4 TO test_user_01999 WITH REPLACE OPTION diff --git a/tests/ast_json_fixtures/shapes/0f0d55a0e5b42104.json b/tests/ast_json_fixtures/shapes/0f0d55a0e5b42104.json new file mode 100644 index 000000000000..f2f17f6c3596 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f0d55a0e5b42104.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "alter_00061" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "n.d", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "Date" + } + ] + } + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0f0d55a0e5b42104.sql b/tests/ast_json_fixtures/shapes/0f0d55a0e5b42104.sql new file mode 100644 index 000000000000..3c3cadafd477 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f0d55a0e5b42104.sql @@ -0,0 +1 @@ +ALTER TABLE alter_00061 ADD COLUMN `n.d` Array(Date), MODIFY COLUMN s UInt32 diff --git a/tests/ast_json_fixtures/shapes/0f13586fbbf6c0d3.json b/tests/ast_json_fixtures/shapes/0f13586fbbf6c0d3.json new file mode 100644 index 000000000000..5946d22b0416 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f13586fbbf6c0d3.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "SET_SNAPSHOT", + "snapshot": "5" + } +} diff --git a/tests/ast_json_fixtures/shapes/0f13586fbbf6c0d3.sql b/tests/ast_json_fixtures/shapes/0f13586fbbf6c0d3.sql new file mode 100644 index 000000000000..b5e797f88e37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f13586fbbf6c0d3.sql @@ -0,0 +1 @@ +set transaction snapshot 5 diff --git a/tests/ast_json_fixtures/shapes/0f148c69f0d29d1c.json b/tests/ast_json_fixtures/shapes/0f148c69f0d29d1c.json new file mode 100644 index 000000000000..b05d2ddc6c67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f148c69f0d29d1c.json @@ -0,0 +1,206 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "data", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "[\n(1600000000, 10),\n(1600000010, 20),\n(1600000020, 30),\n(1600000030, 40),\n(1600000040, 10),\n(1600000050, 70),\n(1600000060, 90),\n(1600000270, 20),\n(1600000330, 10)\n]" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Array(Tuple(UInt32, Float64))" + } + ] + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "name", + "value_type": "String", + "value": "delta" + }, + { + "type": "Function", + "name": "timeSeriesDeltaToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "data" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "data" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1600000010" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1600000320" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "300" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "name", + "value_type": "String", + "value": "idelta" + }, + { + "type": "Function", + "name": "timeSeriesInstantDeltaToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "data" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "data" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1600000010" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1600000320" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "300" + } + ] + } + ] + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0f148c69f0d29d1c.sql b/tests/ast_json_fixtures/shapes/0f148c69f0d29d1c.sql new file mode 100644 index 000000000000..ba0e125e1042 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f148c69f0d29d1c.sql @@ -0,0 +1,16 @@ +WITH [ +(1600000000, 10), +(1600000010, 20), +(1600000020, 30), +(1600000030, 40), +(1600000040, 10), +(1600000050, 70), +(1600000060, 90), +(1600000270, 20), +(1600000330, 10) +]::Array(Tuple(UInt32, Float64)) AS data +SELECT * FROM ( + SELECT 'delta' as name, timeSeriesDeltaToGrid(1600000010, 1600000320, 10, 300)(data.1, data.2) + UNION ALL + SELECT 'idelta' as name, timeSeriesInstantDeltaToGrid(1600000010, 1600000320, 10, 300)(data.1, data.2) +) ORDER BY name diff --git a/tests/ast_json_fixtures/shapes/0f160e5c0a951d21.json b/tests/ast_json_fixtures/shapes/0f160e5c0a951d21.json new file mode 100644 index 000000000000..ac4e11069b1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f160e5c0a951d21.json @@ -0,0 +1,248 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "38" + }, + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "position", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "position", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "ca" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "NULLIF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "ca" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "NULLIF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "set_index_not__fuzz_0" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "NULLIF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0f160e5c0a951d21.sql b/tests/ast_json_fixtures/shapes/0f160e5c0a951d21.sql new file mode 100644 index 000000000000..1e55a92835ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f160e5c0a951d21.sql @@ -0,0 +1,8 @@ +SELECT + 38, + concat(position(concat(concat(position(concat(toUInt256(3)), 'ca', 2), 3),NULLIF(1, materialize(toLowCardinality(1)))), toLowCardinality(toNullable('ca'))), concat(NULLIF(1, 1), concat(3), toNullable(3))) +FROM set_index_not__fuzz_0 +GROUP BY + toNullable(3), + concat(concat(NULLIF(1, 1), toNullable(toNullable(3)))) +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/0f3aaa5bc0124559.json b/tests/ast_json_fixtures/shapes/0f3aaa5bc0124559.json new file mode 100644 index 000000000000..403f50e2af2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f3aaa5bc0124559.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "parallel_replicas_wait_for_unused_replicas" + } +} diff --git a/tests/ast_json_fixtures/shapes/0f3aaa5bc0124559.sql b/tests/ast_json_fixtures/shapes/0f3aaa5bc0124559.sql new file mode 100644 index 000000000000..24e2845077c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f3aaa5bc0124559.sql @@ -0,0 +1 @@ +SYSTEM ENABLE FAILPOINT parallel_replicas_wait_for_unused_replicas diff --git a/tests/ast_json_fixtures/shapes/0f3eca8c5b35fc5c.json b/tests/ast_json_fixtures/shapes/0f3eca8c5b35fc5c.json new file mode 100644 index 000000000000..908dfa969793 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f3eca8c5b35fc5c.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "EXCEPT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectIntersectExceptQuery", + "operator": "INTERSECT ALL", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0f3eca8c5b35fc5c.sql b/tests/ast_json_fixtures/shapes/0f3eca8c5b35fc5c.sql new file mode 100644 index 000000000000..4ecd1d49be63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f3eca8c5b35fc5c.sql @@ -0,0 +1 @@ +select 1 except select 2 intersect select 1 diff --git a/tests/ast_json_fixtures/shapes/0f5eab1c39411751.json b/tests/ast_json_fixtures/shapes/0f5eab1c39411751.json new file mode 100644 index 000000000000..c32e68930499 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f5eab1c39411751.json @@ -0,0 +1,170 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "u1", + "name": "users" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "age" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + }, + { + "type": "Function", + "name": "exists", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "u2", + "name": "users2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "u1.age", + "name_parts": ["u1", "age"] + }, + { + "type": "Identifier", + "name": "u2.age", + "name_parts": ["u2", "age"] + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "u2", + "name": "users2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "u1.age", + "name_parts": ["u1", "age"] + }, + { + "type": "Identifier", + "name": "u2.age", + "name_parts": ["u2", "age"] + } + ] + } + } + ] + } + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_correlated_subqueries": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/0f5eab1c39411751.sql b/tests/ast_json_fixtures/shapes/0f5eab1c39411751.sql new file mode 100644 index 000000000000..cbc2b796baba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f5eab1c39411751.sql @@ -0,0 +1,14 @@ +SELECT * +FROM users AS u1 +WHERE (age = 50) OR exists(( + SELECT * + FROM users2 AS u2 + WHERE u1.age = u2.age + UNION ALL + SELECT * + FROM users2 AS u2 + WHERE u1.age != u2.age +)) +ORDER BY ALL +FORMAT Null +SETTINGS allow_experimental_correlated_subqueries = 1 diff --git a/tests/ast_json_fixtures/shapes/0f6ac15652dafce1.json b/tests/ast_json_fixtures/shapes/0f6ac15652dafce1.json new file mode 100644 index 000000000000..1d41e39996ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f6ac15652dafce1.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q1_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/0f6ac15652dafce1.sql b/tests/ast_json_fixtures/shapes/0f6ac15652dafce1.sql new file mode 100644 index 000000000000..04a4fc76329e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f6ac15652dafce1.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q1_01297 diff --git a/tests/ast_json_fixtures/shapes/0f78c4bfa6f37b57.json b/tests/ast_json_fixtures/shapes/0f78c4bfa6f37b57.json new file mode 100644 index 000000000000..9ce0e8c4f1c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f78c4bfa6f37b57.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "s" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rowNumberInBlock", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0f78c4bfa6f37b57.sql b/tests/ast_json_fixtures/shapes/0f78c4bfa6f37b57.sql new file mode 100644 index 000000000000..873a75356eef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0f78c4bfa6f37b57.sql @@ -0,0 +1 @@ +select s from t prewhere a != 1 where rowNumberInBlock() % 2 = 0 limit 1 diff --git a/tests/ast_json_fixtures/shapes/0fb38cb899f66d15.json b/tests/ast_json_fixtures/shapes/0fb38cb899f66d15.json new file mode 100644 index 000000000000..88ccde61e003 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0fb38cb899f66d15.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_shard_localhost", + "database": { + "type": "Identifier", + "name": "02028_db" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0fb38cb899f66d15.sql b/tests/ast_json_fixtures/shapes/0fb38cb899f66d15.sql new file mode 100644 index 000000000000..cabe9ab76d7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0fb38cb899f66d15.sql @@ -0,0 +1 @@ +CREATE DATABASE 02028_db ON CLUSTER test_shard_localhost diff --git a/tests/ast_json_fixtures/shapes/0fd340ae5f655eaf.json b/tests/ast_json_fixtures/shapes/0fd340ae5f655eaf.json new file mode 100644 index 000000000000..dc918e521d02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0fd340ae5f655eaf.json @@ -0,0 +1,172 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "decimal_dict" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "KeyField", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "9999999" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "Decimal32_", + "data_type": { + "type": "DataType", + "name": "Decimal", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + "default_value": { + "type": "Literal", + "value_type": "Float64", + "value": 0.11 + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "Decimal64_", + "data_type": { + "type": "DataType", + "name": "Decimal", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "18" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + "default_value": { + "type": "Literal", + "value_type": "Float64", + "value": 0.11 + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "Decimal128_", + "data_type": { + "type": "DataType", + "name": "Decimal", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "25" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + "default_value": { + "type": "Literal", + "value_type": "Float64", + "value": 0.11 + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "KeyField" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "user", + "value": { + "type": "Literal", + "value_type": "String", + "value": "default" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "table_decimal_dict" + } + }, + { + "type": "pair", + "key": "db", + "value": { + "type": "Function", + "name": "current_database", + "arguments": [] + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 0 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "sparse_hashed", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0fd340ae5f655eaf.sql b/tests/ast_json_fixtures/shapes/0fd340ae5f655eaf.sql new file mode 100644 index 000000000000..420fc75547e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0fd340ae5f655eaf.sql @@ -0,0 +1,10 @@ +CREATE DICTIONARY IF NOT EXISTS decimal_dict ( + KeyField UInt64 DEFAULT 9999999, + Decimal32_ Decimal(5,4) DEFAULT 0.11, + Decimal64_ Decimal(18,8) DEFAULT 0.11, + Decimal128_ Decimal(25,8) DEFAULT 0.11 + +) +PRIMARY KEY KeyField +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_decimal_dict' DB current_database())) +LIFETIME(0) LAYOUT(SPARSE_HASHED) diff --git a/tests/ast_json_fixtures/shapes/0fe1ef6ea1b99517.json b/tests/ast_json_fixtures/shapes/0fe1ef6ea1b99517.json new file mode 100644 index 000000000000..92f7ac527c08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0fe1ef6ea1b99517.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s1_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "0" + } + ] + }, + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/0fe1ef6ea1b99517.sql b/tests/ast_json_fixtures/shapes/0fe1ef6ea1b99517.sql new file mode 100644 index 000000000000..69043f9f5ee8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0fe1ef6ea1b99517.sql @@ -0,0 +1 @@ +CREATE SETTINGS PROFILE s1_01294 SETTINGS readonly=0 TO r1_01294 diff --git a/tests/ast_json_fixtures/shapes/0ff71c8517e6a985.json b/tests/ast_json_fixtures/shapes/0ff71c8517e6a985.json new file mode 100644 index 000000000000..3b18e1a7d57e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ff71c8517e6a985.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.{2..11}" + }, + { + "type": "Function", + "name": "view", + "arguments": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1000000 + } + ] + } + } + } + ] + } + } + ] + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + }, + "settings": { + "type": "Settings", + "changes": { + "distributed_group_by_no_merge": "0", + "max_memory_usage": "100Mi" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/0ff71c8517e6a985.sql b/tests/ast_json_fixtures/shapes/0ff71c8517e6a985.sql new file mode 100644 index 000000000000..cfdf5c352cb0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/0ff71c8517e6a985.sql @@ -0,0 +1 @@ +select * from remote('127.{2..11}', view(select * from numbers(1e6))) group by number order by number limit 20 settings distributed_group_by_no_merge=0, max_memory_usage='100Mi' diff --git a/tests/ast_json_fixtures/shapes/100b2b0d888b1f7d.json b/tests/ast_json_fixtures/shapes/100b2b0d888b1f7d.json new file mode 100644 index 000000000000..da2893dd5cb0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/100b2b0d888b1f7d.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["sqllt_user"], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/100b2b0d888b1f7d.sql b/tests/ast_json_fixtures/shapes/100b2b0d888b1f7d.sql new file mode 100644 index 000000000000..caaf1953ba01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/100b2b0d888b1f7d.sql @@ -0,0 +1 @@ +SHOW CREATE USER sqllt_user FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/101ef7b156a8c49d.json b/tests/ast_json_fixtures/shapes/101ef7b156a8c49d.json new file mode 100644 index 000000000000..88e295d4095d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/101ef7b156a8c49d.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CheckQuery", + "table": { + "type": "Identifier", + "name": "mt_table" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/101ef7b156a8c49d.sql b/tests/ast_json_fixtures/shapes/101ef7b156a8c49d.sql new file mode 100644 index 000000000000..d2d12296160a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/101ef7b156a8c49d.sql @@ -0,0 +1 @@ +CHECK TABLE mt_table SETTINGS max_threads = 1 diff --git a/tests/ast_json_fixtures/shapes/103e5b3cac16175f.json b/tests/ast_json_fixtures/shapes/103e5b3cac16175f.json new file mode 100644 index 000000000000..d06df2f38259 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/103e5b3cac16175f.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/103e5b3cac16175f.sql b/tests/ast_json_fixtures/shapes/103e5b3cac16175f.sql new file mode 100644 index 000000000000..237325c61880 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/103e5b3cac16175f.sql @@ -0,0 +1 @@ +SELECT SUM(value) FROM t WHERE value = 42 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/103f1fadf191b712.json b/tests/ast_json_fixtures/shapes/103f1fadf191b712.json new file mode 100644 index 000000000000..951e025c965f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/103f1fadf191b712.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "a" + }, + "if_exists": true, + "sync": true + } +} diff --git a/tests/ast_json_fixtures/shapes/103f1fadf191b712.sql b/tests/ast_json_fixtures/shapes/103f1fadf191b712.sql new file mode 100644 index 000000000000..d15002f2434f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/103f1fadf191b712.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS a SYNC diff --git a/tests/ast_json_fixtures/shapes/106b3ece09262a39.json b/tests/ast_json_fixtures/shapes/106b3ece09262a39.json new file mode 100644 index 000000000000..a987ffef7bd3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/106b3ece09262a39.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "id3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id2" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/106b3ece09262a39.sql b/tests/ast_json_fixtures/shapes/106b3ece09262a39.sql new file mode 100644 index 000000000000..d0c62c1e4109 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/106b3ece09262a39.sql @@ -0,0 +1 @@ +SELECT sum(id3) FROM t GROUP BY id2 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/107ba9d838cecaab.json b/tests/ast_json_fixtures/shapes/107ba9d838cecaab.json new file mode 100644 index 000000000000..a6fd95bf03d9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/107ba9d838cecaab.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "test_move_partition_src" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "pk", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "val", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "pk" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "pk" + }, + { + "type": "Identifier", + "name": "val" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192", + "index_granularity_bytes": "10Mi" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/107ba9d838cecaab.sql b/tests/ast_json_fixtures/shapes/107ba9d838cecaab.sql new file mode 100644 index 000000000000..4d6c18052ac3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/107ba9d838cecaab.sql @@ -0,0 +1,6 @@ +CREATE TABLE IF NOT EXISTS test_move_partition_src ( + pk UInt8, + val UInt32 +) Engine = MergeTree() + PARTITION BY pk + ORDER BY (pk, val) SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi' diff --git a/tests/ast_json_fixtures/shapes/1087b75eb27c4a4a.json b/tests/ast_json_fixtures/shapes/1087b75eb27c4a4a.json new file mode 100644 index 000000000000..467f71e75cd0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1087b75eb27c4a4a.json @@ -0,0 +1,424 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "a32", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "384" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "a16", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toBFloat16", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "384" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "a32_1", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "a32" + } + ] + }, + { + "type": "Function", + "alias": "a16_1", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "a16" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "a32" + }, + { + "type": "Identifier", + "name": "a16" + }, + { + "type": "Identifier", + "name": "a32_1" + }, + { + "type": "Identifier", + "name": "a16_1" + }, + { + "type": "Function", + "name": "dotProduct", + "arguments": [ + { + "type": "Identifier", + "name": "a32" + }, + { + "type": "Identifier", + "name": "a32_1" + } + ] + }, + { + "type": "Function", + "name": "dotProduct", + "arguments": [ + { + "type": "Identifier", + "name": "a16" + }, + { + "type": "Identifier", + "name": "a16_1" + } + ] + }, + { + "type": "Function", + "name": "cosineDistance", + "arguments": [ + { + "type": "Identifier", + "name": "a32" + }, + { + "type": "Identifier", + "name": "a32_1" + } + ] + }, + { + "type": "Function", + "name": "cosineDistance", + "arguments": [ + { + "type": "Identifier", + "name": "a16" + }, + { + "type": "Identifier", + "name": "a16_1" + } + ] + }, + { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "a32" + }, + { + "type": "Identifier", + "name": "a32_1" + } + ] + }, + { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "a16" + }, + { + "type": "Identifier", + "name": "a16_1" + } + ] + }, + { + "type": "Function", + "name": "L1Distance", + "arguments": [ + { + "type": "Identifier", + "name": "a32" + }, + { + "type": "Identifier", + "name": "a32_1" + } + ] + }, + { + "type": "Function", + "name": "L1Distance", + "arguments": [ + { + "type": "Identifier", + "name": "a16" + }, + { + "type": "Identifier", + "name": "a16_1" + } + ] + }, + { + "type": "Function", + "name": "LinfDistance", + "arguments": [ + { + "type": "Identifier", + "name": "a32" + }, + { + "type": "Identifier", + "name": "a32_1" + } + ] + }, + { + "type": "Function", + "name": "LinfDistance", + "arguments": [ + { + "type": "Identifier", + "name": "a16" + }, + { + "type": "Identifier", + "name": "a16_1" + } + ] + }, + { + "type": "Function", + "name": "LpDistance", + "arguments": [ + { + "type": "Identifier", + "name": "a32" + }, + { + "type": "Identifier", + "name": "a32_1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "LpDistance", + "arguments": [ + { + "type": "Identifier", + "name": "a16" + }, + { + "type": "Identifier", + "name": "a16_1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/1087b75eb27c4a4a.sql b/tests/ast_json_fixtures/shapes/1087b75eb27c4a4a.sql new file mode 100644 index 000000000000..1e889a94ec3b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1087b75eb27c4a4a.sql @@ -0,0 +1,13 @@ +WITH + arrayMap(x -> toFloat32(x) / 2, range(384)) AS a32, + arrayMap(x -> toBFloat16(x) / 2, range(384)) AS a16, + arrayMap(x -> x + 1, a32) AS a32_1, + arrayMap(x -> x + 1, a16) AS a16_1 +SELECT a32, a16, a32_1, a16_1, + dotProduct(a32, a32_1), dotProduct(a16, a16_1), + cosineDistance(a32, a32_1), cosineDistance(a16, a16_1), + L2Distance(a32, a32_1), L2Distance(a16, a16_1), + L1Distance(a32, a32_1), L1Distance(a16, a16_1), + LinfDistance(a32, a32_1), LinfDistance(a16, a16_1), + LpDistance(a32, a32_1, 5), LpDistance(a16, a16_1, 5) +FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/10a95c8304e432d1.json b/tests/ast_json_fixtures/shapes/10a95c8304e432d1.json new file mode 100644 index 000000000000..53cf76088711 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/10a95c8304e432d1.json @@ -0,0 +1,154 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "alias": "i0", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "alias": "u0", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "alias": "ip", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775807" + } + ] + }, + { + "type": "Function", + "alias": "in", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775808" + } + ] + }, + { + "type": "Function", + "alias": "up", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "18446744073709551615" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "i0" + }, + { + "type": "Identifier", + "name": "u0" + }, + { + "type": "Identifier", + "name": "ip" + }, + { + "type": "Identifier", + "name": "in" + }, + { + "type": "Identifier", + "name": "up" + }, + { + "type": "Identifier", + "name": "arr" + }, + { + "type": "Identifier", + "name": "tuple" + } + ] + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/10a95c8304e432d1.sql b/tests/ast_json_fixtures/shapes/10a95c8304e432d1.sql new file mode 100644 index 000000000000..5f2b36e223a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/10a95c8304e432d1.sql @@ -0,0 +1 @@ +SELECT toInt64(0) as i0, toUInt64(0) as u0, toInt64(9223372036854775807) as ip, toInt64(-9223372036854775808) as in, toUInt64(18446744073709551615) as up, [toInt64(0)] as arr, (toUInt64(0), toUInt64(0)) as tuple GROUP BY i0, u0, ip, in, up, arr, tuple WITH TOTALS FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/10d02371f655acd0.json b/tests/ast_json_fixtures/shapes/10d02371f655acd0.json new file mode 100644 index 000000000000..9c6cd5569530 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/10d02371f655acd0.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "temporary": true, + "table": { + "type": "Identifier", + "name": "t1" + }, + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/10d02371f655acd0.sql b/tests/ast_json_fixtures/shapes/10d02371f655acd0.sql new file mode 100644 index 000000000000..a7abb380965f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/10d02371f655acd0.sql @@ -0,0 +1 @@ +DROP TEMPORARY TABLE IF EXISTS t1 diff --git a/tests/ast_json_fixtures/shapes/10e0ed6a36e077eb.json b/tests/ast_json_fixtures/shapes/10e0ed6a36e077eb.json new file mode 100644 index 000000000000..64039dec8bc1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/10e0ed6a36e077eb.json @@ -0,0 +1,103 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "age" + } + ] + } + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "users" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "query_plan_merge_filter_into_join_condition": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/10e0ed6a36e077eb.sql b/tests/ast_json_fixtures/shapes/10e0ed6a36e077eb.sql new file mode 100644 index 000000000000..eae55ad178be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/10e0ed6a36e077eb.sql @@ -0,0 +1,4 @@ +SELECT name, (SELECT count() FROM numbers(50) WHERE number = age) +FROM users +ORDER BY name +SETTINGS query_plan_merge_filter_into_join_condition = 0 diff --git a/tests/ast_json_fixtures/shapes/10e5e1e60d362f36.json b/tests/ast_json_fixtures/shapes/10e5e1e60d362f36.json new file mode 100644 index 000000000000..6be090e9be8f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/10e5e1e60d362f36.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s2_01418"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "custom_null", + "value": null + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/10e5e1e60d362f36.sql b/tests/ast_json_fixtures/shapes/10e5e1e60d362f36.sql new file mode 100644 index 000000000000..b4dd5acab946 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/10e5e1e60d362f36.sql @@ -0,0 +1 @@ +CREATE SETTINGS PROFILE s2_01418 SETTINGS custom_null = NULL diff --git a/tests/ast_json_fixtures/shapes/1103aa5f917a9cf0.json b/tests/ast_json_fixtures/shapes/1103aa5f917a9cf0.json new file mode 100644 index 000000000000..d95002e3f975 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1103aa5f917a9cf0.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table", + "database": "sqllt" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/1103aa5f917a9cf0.sql b/tests/ast_json_fixtures/shapes/1103aa5f917a9cf0.sql new file mode 100644 index 000000000000..c27ea34ce2fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1103aa5f917a9cf0.sql @@ -0,0 +1 @@ +DESCRIBE TABLE sqllt.table FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/110e5dcaa9c8915d.json b/tests/ast_json_fixtures/shapes/110e5dcaa9c8915d.json new file mode 100644 index 000000000000..91d751d422d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/110e5dcaa9c8915d.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "32213" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/110e5dcaa9c8915d.sql b/tests/ast_json_fixtures/shapes/110e5dcaa9c8915d.sql new file mode 100644 index 000000000000..fddd1b660bea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/110e5dcaa9c8915d.sql @@ -0,0 +1 @@ +select d from test order by d::String limit 32213 format Null diff --git a/tests/ast_json_fixtures/shapes/1116ec2028c6b08f.json b/tests/ast_json_fixtures/shapes/1116ec2028c6b08f.json new file mode 100644 index 000000000000..da315ebbc525 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1116ec2028c6b08f.json @@ -0,0 +1,119 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "test_aliases", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "alias2", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_aliases" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "alias2" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_global_with_statement": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1116ec2028c6b08f.sql b/tests/ast_json_fixtures/shapes/1116ec2028c6b08f.sql new file mode 100644 index 000000000000..3eeb634b3f6c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1116ec2028c6b08f.sql @@ -0,0 +1,2 @@ +WITH test_aliases AS (SELECT number FROM numbers(20)), alias2 AS (SELECT number FROM test_aliases) +SELECT number FROM alias2 SETTINGS enable_global_with_statement = 0 diff --git a/tests/ast_json_fixtures/shapes/113e96128f2196e7.json b/tests/ast_json_fixtures/shapes/113e96128f2196e7.json new file mode 100644 index 000000000000..d5172e7dfe75 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/113e96128f2196e7.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateWorkloadQuery", + "or_replace": true, + "workload_name": { + "type": "Identifier", + "name": "all" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/113e96128f2196e7.sql b/tests/ast_json_fixtures/shapes/113e96128f2196e7.sql new file mode 100644 index 000000000000..c23d97d3e567 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/113e96128f2196e7.sql @@ -0,0 +1 @@ +CREATE OR REPLACE WORKLOAD all diff --git a/tests/ast_json_fixtures/shapes/113f6d8f0a91fe03.json b/tests/ast_json_fixtures/shapes/113f6d8f0a91fe03.json new file mode 100644 index 000000000000..17ead3fdec00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/113f6d8f0a91fe03.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_merge" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "default" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test1" + } + ] + } + }, + "as_table": "test1" + } +} diff --git a/tests/ast_json_fixtures/shapes/113f6d8f0a91fe03.sql b/tests/ast_json_fixtures/shapes/113f6d8f0a91fe03.sql new file mode 100644 index 000000000000..de4a0cfa9bfa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/113f6d8f0a91fe03.sql @@ -0,0 +1 @@ +CREATE TABLE test_merge AS test1 ENGINE = Merge('default', 'test1') diff --git a/tests/ast_json_fixtures/shapes/11419887055247c0.json b/tests/ast_json_fixtures/shapes/11419887055247c0.json new file mode 100644 index 000000000000..4d85cbec5dd1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/11419887055247c0.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Hello" + }, + { + "type": "Function", + "alias": "x", + "name": "format", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\u001B[38;2;{0};{1};{2}m█\u001B[0m test \u001B[38;2;{0};{1};{2}m█\u001B[0m" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "255" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "128" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "128" + } + ] + } + ] + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/11419887055247c0.sql b/tests/ast_json_fixtures/shapes/11419887055247c0.sql new file mode 100644 index 000000000000..2e60a4b16922 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/11419887055247c0.sql @@ -0,0 +1 @@ +SELECT 'Hello', format('\x1b[38;2;{0};{1};{2}m█\x1b[0m test \x1b[38;2;{0};{1};{2}m█\x1b[0m', 255, 128, 128) AS x FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/114260beaa0c9458.json b/tests/ast_json_fixtures/shapes/114260beaa0c9458.json new file mode 100644 index 000000000000..dbb6d1b0d06d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/114260beaa0c9458.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p5_01295", + "database": "db", + "table": "table" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01295", "u1_01295"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/114260beaa0c9458.sql b/tests/ast_json_fixtures/shapes/114260beaa0c9458.sql new file mode 100644 index 000000000000..a062c76ba82c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/114260beaa0c9458.sql @@ -0,0 +1 @@ +CREATE POLICY p5_01295 ON db.table TO r1_01295, u1_01295 diff --git a/tests/ast_json_fixtures/shapes/114cc2703d1da1c8.json b/tests/ast_json_fixtures/shapes/114cc2703d1da1c8.json new file mode 100644 index 000000000000..05e6f7f4c4c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/114cc2703d1da1c8.json @@ -0,0 +1,133 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "b", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "randConstant", + "arguments": [] + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Identifier", + "name": "a=a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "a", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "randConstant", + "arguments": [] + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "alias": "a=a", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/114cc2703d1da1c8.sql b/tests/ast_json_fixtures/shapes/114cc2703d1da1c8.sql new file mode 100644 index 000000000000..cc43ecc34507 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/114cc2703d1da1c8.sql @@ -0,0 +1 @@ +with (select randConstant()) as b select b = b, a = b, `a=a` from (with (select randConstant()) as a select a, a = a as `a=a`) diff --git a/tests/ast_json_fixtures/shapes/114e6bfd62ddcd68.json b/tests/ast_json_fixtures/shapes/114e6bfd62ddcd68.json new file mode 100644 index 000000000000..81eb861a43fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/114e6bfd62ddcd68.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tbl" + }, + "settings": { + "type": "Settings", + "changes": { + "allow_suspicious_indices": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_INDEX", + "index_declaration": { + "type": "Index", + "name": "idx", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/114e6bfd62ddcd68.sql b/tests/ast_json_fixtures/shapes/114e6bfd62ddcd68.sql new file mode 100644 index 000000000000..78c65e8bfaf5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/114e6bfd62ddcd68.sql @@ -0,0 +1 @@ +ALTER TABLE tbl ADD INDEX idx (id+1, id, id+1) TYPE minmax SETTINGS allow_suspicious_indices = 1 diff --git a/tests/ast_json_fixtures/shapes/11542d29cc994438.json b/tests/ast_json_fixtures/shapes/11542d29cc994438.json new file mode 100644 index 000000000000..6ed4b78fd5ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/11542d29cc994438.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/11542d29cc994438.sql b/tests/ast_json_fixtures/shapes/11542d29cc994438.sql new file mode 100644 index 000000000000..978e70a2a7b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/11542d29cc994438.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/117b592d09f71442.json b/tests/ast_json_fixtures/shapes/117b592d09f71442.json new file mode 100644 index 000000000000..119de098740a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/117b592d09f71442.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r9_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "parent_profile": "default" + }, + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "value": "5000000", + "writability": "WRITABLE" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/117b592d09f71442.sql b/tests/ast_json_fixtures/shapes/117b592d09f71442.sql new file mode 100644 index 000000000000..912a62311f35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/117b592d09f71442.sql @@ -0,0 +1 @@ +CREATE ROLE r9_01293 SETTINGS PROFILE 'default', max_memory_usage=5000000 WRITABLE diff --git a/tests/ast_json_fixtures/shapes/1198daac3e4071bc.json b/tests/ast_json_fixtures/shapes/1198daac3e4071bc.json new file mode 100644 index 000000000000..d65c428eee74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1198daac3e4071bc.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "INNER", + "expressions": [ + { + "type": "Identifier", + "name": "arr" + } + ] + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "where": { + "type": "Identifier", + "name": "arr" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1198daac3e4071bc.sql b/tests/ast_json_fixtures/shapes/1198daac3e4071bc.sql new file mode 100644 index 000000000000..ccbda14f7cb2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1198daac3e4071bc.sql @@ -0,0 +1 @@ +select x from tab array join arr prewhere x != 0 where arr diff --git a/tests/ast_json_fixtures/shapes/11a854d63252d17d.json b/tests/ast_json_fixtures/shapes/11a854d63252d17d.json new file mode 100644 index 000000000000..dc47db425561 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/11a854d63252d17d.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_shard_localhost", + "database": { + "type": "Identifier", + "name": "test_01148_atomic" + }, + "table": { + "type": "Identifier", + "name": "rmt4" + }, + "as_database": "test_01148_atomic", + "as_table": "rmt2" + } +} diff --git a/tests/ast_json_fixtures/shapes/11a854d63252d17d.sql b/tests/ast_json_fixtures/shapes/11a854d63252d17d.sql new file mode 100644 index 000000000000..ffce5d6305d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/11a854d63252d17d.sql @@ -0,0 +1 @@ +CREATE TABLE test_01148_atomic.rmt4 ON CLUSTER test_shard_localhost AS test_01148_atomic.rmt2 diff --git a/tests/ast_json_fixtures/shapes/11d86b4ab6e0f9e3.json b/tests/ast_json_fixtures/shapes/11d86b4ab6e0f9e3.json new file mode 100644 index 000000000000..f4a16f2b414e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/11d86b4ab6e0f9e3.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "18446744073709551611" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "number" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/11d86b4ab6e0f9e3.sql b/tests/ast_json_fixtures/shapes/11d86b4ab6e0f9e3.sql new file mode 100644 index 000000000000..87bbd7bb3774 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/11d86b4ab6e0f9e3.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(18446744073709551611, 2) WHERE number diff --git a/tests/ast_json_fixtures/shapes/11f8793bf7acb6bb.json b/tests/ast_json_fixtures/shapes/11f8793bf7acb6bb.json new file mode 100644 index 000000000000..30b692bc9375 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/11f8793bf7acb6bb.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "_part" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "02581_trips" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "description" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "_part" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "_part" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/11f8793bf7acb6bb.sql b/tests/ast_json_fixtures/shapes/11f8793bf7acb6bb.sql new file mode 100644 index 000000000000..b61ecdc9f99d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/11f8793bf7acb6bb.sql @@ -0,0 +1 @@ +SELECT count(), _part FROM 02581_trips WHERE description = '' GROUP BY _part ORDER BY _part diff --git a/tests/ast_json_fixtures/shapes/1204e2f46df4b1f7.json b/tests/ast_json_fixtures/shapes/1204e2f46df4b1f7.json new file mode 100644 index 000000000000..933cf8eae1a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1204e2f46df4b1f7.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "lwu_on_fly" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "0" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DELETE", + "predicate": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1204e2f46df4b1f7.sql b/tests/ast_json_fixtures/shapes/1204e2f46df4b1f7.sql new file mode 100644 index 000000000000..470b5ad0ccd2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1204e2f46df4b1f7.sql @@ -0,0 +1 @@ +ALTER TABLE lwu_on_fly DELETE WHERE 1 SETTINGS mutations_sync = 0 diff --git a/tests/ast_json_fixtures/shapes/120945f4573a02f6.json b/tests/ast_json_fixtures/shapes/120945f4573a02f6.json new file mode 100644 index 000000000000..7ad42a2a3783 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/120945f4573a02f6.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "final": true + } +} diff --git a/tests/ast_json_fixtures/shapes/120945f4573a02f6.sql b/tests/ast_json_fixtures/shapes/120945f4573a02f6.sql new file mode 100644 index 000000000000..1b673d9c6577 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/120945f4573a02f6.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE t FINAL diff --git a/tests/ast_json_fixtures/shapes/122d9ff35ef9561c.json b/tests/ast_json_fixtures/shapes/122d9ff35ef9561c.json new file mode 100644 index 000000000000..268957d4e82c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/122d9ff35ef9561c.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "RELOAD DICTIONARIES", + "cluster": "test_shard_localhost" + } +} diff --git a/tests/ast_json_fixtures/shapes/122d9ff35ef9561c.sql b/tests/ast_json_fixtures/shapes/122d9ff35ef9561c.sql new file mode 100644 index 000000000000..46bd284a4229 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/122d9ff35ef9561c.sql @@ -0,0 +1 @@ +SYSTEM RELOAD DICTIONARIES ON CLUSTER test_shard_localhost diff --git a/tests/ast_json_fixtures/shapes/12377932abf97ee3.json b/tests/ast_json_fixtures/shapes/12377932abf97ee3.json new file mode 100644 index 000000000000..d5d75a9da461 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12377932abf97ee3.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Bool" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "EmbeddedRocksDB", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "c0" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/12377932abf97ee3.sql b/tests/ast_json_fixtures/shapes/12377932abf97ee3.sql new file mode 100644 index 000000000000..3c6ce14dfbcf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12377932abf97ee3.sql @@ -0,0 +1 @@ +CREATE TABLE t0 (c0 Bool) ENGINE = EmbeddedRocksDB PRIMARY KEY (c0) diff --git a/tests/ast_json_fixtures/shapes/12a12cc7da112784.json b/tests/ast_json_fixtures/shapes/12a12cc7da112784.json new file mode 100644 index 000000000000..8a34c58596af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12a12cc7da112784.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02483_plustwo" + } +} diff --git a/tests/ast_json_fixtures/shapes/12a12cc7da112784.sql b/tests/ast_json_fixtures/shapes/12a12cc7da112784.sql new file mode 100644 index 000000000000..b4354efa1c6a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12a12cc7da112784.sql @@ -0,0 +1 @@ +DROP FUNCTION 02483_plustwo diff --git a/tests/ast_json_fixtures/shapes/12a7933447f79a5f.json b/tests/ast_json_fixtures/shapes/12a7933447f79a5f.json new file mode 100644 index 000000000000..147559f7601f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12a7933447f79a5f.json @@ -0,0 +1,177 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "right_0.c0", + "name_parts": ["right_0", "c0"] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Identifier", + "name": "right_1.c1", + "name_parts": ["right_1", "c1"] + }, + { + "type": "Identifier", + "name": "t1.c2", + "name_parts": ["t1", "c2"] + } + ] + }, + { + "type": "Function", + "name": "sign", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c2", + "name_parts": ["t1", "c2"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c2", + "name_parts": ["t1", "c2"] + }, + { + "type": "Identifier", + "name": "t1.c2", + "name_parts": ["t1", "c2"] + } + ] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "t1.c1", + "name_parts": ["t1", "c1"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "RIGHT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": ".D" + }, + { + "type": "Literal", + "value_type": "String", + "value": "m'X" + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "right_0", + "name": "t0" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "RIGHT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c1", + "name_parts": ["t1", "c1"] + }, + { + "type": "Identifier", + "name": "right_1.c1", + "name_parts": ["right_1", "c1"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "right_1", + "name": "t3" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/12a7933447f79a5f.sql b/tests/ast_json_fixtures/shapes/12a7933447f79a5f.sql new file mode 100644 index 000000000000..1b28c6aa2a84 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12a7933447f79a5f.sql @@ -0,0 +1 @@ +SELECT right_0.c0, ((pow(pow(right_1.c1,t1.c2),(sign (t1.c2))))*((- (((t1.c2)/(t1.c2)))))), t1.c1 FROM t1 RIGHT OUTER JOIN t0 AS right_0 ON (('.D')=('m\'X')) RIGHT OUTER JOIN t3 AS right_1 ON ((t1.c1)=(right_1.c1)) ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/12aa3b4afed0aa9c.json b/tests/ast_json_fixtures/shapes/12aa3b4afed0aa9c.json new file mode 100644 index 000000000000..74fff57d9d7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12aa3b4afed0aa9c.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pr_t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "500" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/12aa3b4afed0aa9c.sql b/tests/ast_json_fixtures/shapes/12aa3b4afed0aa9c.sql new file mode 100644 index 000000000000..41a76670d220 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12aa3b4afed0aa9c.sql @@ -0,0 +1 @@ +select a, count() from pr_t group by a order by a limit 5 offset 500 diff --git a/tests/ast_json_fixtures/shapes/12bcfbb8126468c9.json b/tests/ast_json_fixtures/shapes/12bcfbb8126468c9.json new file mode 100644 index 000000000000..944bdbef45f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12bcfbb8126468c9.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "log" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Log", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "val" + } +} diff --git a/tests/ast_json_fixtures/shapes/12bcfbb8126468c9.sql b/tests/ast_json_fixtures/shapes/12bcfbb8126468c9.sql new file mode 100644 index 000000000000..09c40bf1bd12 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12bcfbb8126468c9.sql @@ -0,0 +1 @@ +CREATE TABLE log ENGINE=Log AS val diff --git a/tests/ast_json_fixtures/shapes/12faf440e3fc4f7c.json b/tests/ast_json_fixtures/shapes/12faf440e3fc4f7c.json new file mode 100644 index 000000000000..9600ee451ab0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12faf440e3fc4f7c.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "force_optimize_projection": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/12faf440e3fc4f7c.sql b/tests/ast_json_fixtures/shapes/12faf440e3fc4f7c.sql new file mode 100644 index 000000000000..05e1193f2c92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12faf440e3fc4f7c.sql @@ -0,0 +1 @@ +SELECT 1 FROM t0 WHERE materialize(1) SETTINGS force_optimize_projection = 1 diff --git a/tests/ast_json_fixtures/shapes/12fbe7fb95a8ce3b.json b/tests/ast_json_fixtures/shapes/12fbe7fb95a8ce3b.json new file mode 100644 index 000000000000..85b0be3fab31 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12fbe7fb95a8ce3b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u2_01292", "u3_01292", "u4_01292", "u5_01292", "u6_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/12fbe7fb95a8ce3b.sql b/tests/ast_json_fixtures/shapes/12fbe7fb95a8ce3b.sql new file mode 100644 index 000000000000..ec645faf475a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/12fbe7fb95a8ce3b.sql @@ -0,0 +1 @@ +DROP USER u1_01292, u2_01292, u3_01292, u4_01292, u5_01292, u6_01292 diff --git a/tests/ast_json_fixtures/shapes/13402a3ed4dd5eba.json b/tests/ast_json_fixtures/shapes/13402a3ed4dd5eba.json new file mode 100644 index 000000000000..c9756ec273f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/13402a3ed4dd5eba.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "ParallelWithQuery", + "children": [ + { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "test_table" + }, + "final": true, + "deduplicate": true, + "deduplicate_by_columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value" + } + ] + } + }, + { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "t2" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "10" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/13402a3ed4dd5eba.sql b/tests/ast_json_fixtures/shapes/13402a3ed4dd5eba.sql new file mode 100644 index 000000000000..eb5fb68a613e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/13402a3ed4dd5eba.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE test_table FINAL DEDUPLICATE BY key, value PARALLEL WITH OPTIMIZE TABLE t2 SETTINGS max_threads=10 diff --git a/tests/ast_json_fixtures/shapes/1343844b7620d04f.json b/tests/ast_json_fixtures/shapes/1343844b7620d04f.json new file mode 100644 index 000000000000..c912962b54b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1343844b7620d04f.json @@ -0,0 +1,191 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "1947 #3 QUERY - FALSE" + }, + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "delta", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "src.value", + "name_parts": ["src", "value"] + }, + { + "type": "Identifier", + "name": "deltas_sum" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "src" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "using": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "_a", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "deltas_sum", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "delta" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dst" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "src" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sleepEachRow", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.001 + } + ] + } + ] + } + } + ] + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/1343844b7620d04f.sql b/tests/ast_json_fixtures/shapes/1343844b7620d04f.sql new file mode 100644 index 000000000000..dcd2e8d47dfc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1343844b7620d04f.sql @@ -0,0 +1,12 @@ +DESCRIBE ( SELECT '1947 #3 QUERY - FALSE', + id, + src.value - deltas_sum as delta + FROM src + LEFT JOIN + ( + SELECT id, sum(delta) as deltas_sum FROM dst + WHERE id IN (SELECT id FROM src WHERE not sleepEachRow(0.001)) + GROUP BY id + ) _a + USING (id) + ) FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/13749c5384206e87.json b/tests/ast_json_fixtures/shapes/13749c5384206e87.json new file mode 100644 index 000000000000..2e3210cd2fc3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/13749c5384206e87.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q11_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/13749c5384206e87.sql b/tests/ast_json_fixtures/shapes/13749c5384206e87.sql new file mode 100644 index 000000000000..e5de3aafe2ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/13749c5384206e87.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q11_01297 diff --git a/tests/ast_json_fixtures/shapes/1380ee24648ea6fe.json b/tests/ast_json_fixtures/shapes/1380ee24648ea6fe.json new file mode 100644 index 000000000000..051d646588f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1380ee24648ea6fe.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "constBF16", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/1380ee24648ea6fe.sql b/tests/ast_json_fixtures/shapes/1380ee24648ea6fe.sql new file mode 100644 index 000000000000..90b3da7b0bb7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1380ee24648ea6fe.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS constBF16 diff --git a/tests/ast_json_fixtures/shapes/1394d8873eeae9aa.json b/tests/ast_json_fixtures/shapes/1394d8873eeae9aa.json new file mode 100644 index 000000000000..5bd99bf85f61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1394d8873eeae9aa.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "CAST" + } +} diff --git a/tests/ast_json_fixtures/shapes/1394d8873eeae9aa.sql b/tests/ast_json_fixtures/shapes/1394d8873eeae9aa.sql new file mode 100644 index 000000000000..68b6678cb53c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1394d8873eeae9aa.sql @@ -0,0 +1 @@ +DROP FUNCTION CAST diff --git a/tests/ast_json_fixtures/shapes/13c5c4623e3c9af2.json b/tests/ast_json_fixtures/shapes/13c5c4623e3c9af2.json new file mode 100644 index 000000000000..35f06fa74d18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/13c5c4623e3c9af2.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropResourceQuery", + "resource_name": "03232_read", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/13c5c4623e3c9af2.sql b/tests/ast_json_fixtures/shapes/13c5c4623e3c9af2.sql new file mode 100644 index 000000000000..57ad2c97ffe6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/13c5c4623e3c9af2.sql @@ -0,0 +1 @@ +drop resource if exists 03232_read diff --git a/tests/ast_json_fixtures/shapes/13cd8f48e05cbb53.json b/tests/ast_json_fixtures/shapes/13cd8f48e05cbb53.json new file mode 100644 index 000000000000..baa201b7039f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/13cd8f48e05cbb53.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "database": true, + "elements": [ + { + "from_database": "db_hang_temp", + "to_database": "db_hang" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/13cd8f48e05cbb53.sql b/tests/ast_json_fixtures/shapes/13cd8f48e05cbb53.sql new file mode 100644 index 000000000000..3055d26f0f80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/13cd8f48e05cbb53.sql @@ -0,0 +1 @@ +rename database db_hang_temp to db_hang diff --git a/tests/ast_json_fixtures/shapes/140c2e7aa589081e.json b/tests/ast_json_fixtures/shapes/140c2e7aa589081e.json new file mode 100644 index 000000000000..dbc75ebca9a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/140c2e7aa589081e.json @@ -0,0 +1,261 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "d", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "24" + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "k", + "name": "toStartOfDay", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "alias": "v", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "y" + } + ] + }, + { + "type": "Function", + "alias": "est", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "z" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "z" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "alias": "z", + "name": "toUInt64", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "z" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "delta", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "est" + }, + { + "type": "Identifier", + "name": "v" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + }, + "final": true + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "8", + "optimize_aggregation_in_order": "1", + "split_parts_ranges_into_intersecting_and_non_intersecting_final": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/140c2e7aa589081e.sql b/tests/ast_json_fixtures/shapes/140c2e7aa589081e.sql new file mode 100644 index 000000000000..f9c77360c1a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/140c2e7aa589081e.sql @@ -0,0 +1,6 @@ +WITH (60 * 60) * 24 AS d +select toStartOfDay(x) as k, sum(y) as v, + (z + d) * (z + d - 1) / 2 - (toUInt64(k - toDateTime('2000-01-01', 'UTC')) as z) * (z - 1) / 2 as est, + est - v as delta +from tab final group by k order by k +settings max_threads=8, optimize_aggregation_in_order=1, split_parts_ranges_into_intersecting_and_non_intersecting_final=1 diff --git a/tests/ast_json_fixtures/shapes/141018500bdfd76f.json b/tests/ast_json_fixtures/shapes/141018500bdfd76f.json new file mode 100644 index 000000000000..1a13c5decad9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/141018500bdfd76f.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tb" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tabc" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/141018500bdfd76f.sql b/tests/ast_json_fixtures/shapes/141018500bdfd76f.sql new file mode 100644 index 000000000000..771a78008a37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/141018500bdfd76f.sql @@ -0,0 +1 @@ +SELECT 1 AS a FROM tb JOIN tabc USING (a) ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/1427cc4ef179eaec.json b/tests/ast_json_fixtures/shapes/1427cc4ef179eaec.json new file mode 100644 index 000000000000..c00a47299329 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1427cc4ef179eaec.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN PIPELINE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/1427cc4ef179eaec.sql b/tests/ast_json_fixtures/shapes/1427cc4ef179eaec.sql new file mode 100644 index 000000000000..5dd893d6f4b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1427cc4ef179eaec.sql @@ -0,0 +1 @@ +EXPLAIN PIPELINE SELECT number FROM numbers_mt(1000) GROUP BY number FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/14516eb85691158e.json b/tests/ast_json_fixtures/shapes/14516eb85691158e.json new file mode 100644 index 000000000000..fb31043b7709 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/14516eb85691158e.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["test_user_03593"] + } +} diff --git a/tests/ast_json_fixtures/shapes/14516eb85691158e.sql b/tests/ast_json_fixtures/shapes/14516eb85691158e.sql new file mode 100644 index 000000000000..5b70e3f905ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/14516eb85691158e.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS test_user_03593 diff --git a/tests/ast_json_fixtures/shapes/145d1775308211d2.json b/tests/ast_json_fixtures/shapes/145d1775308211d2.json new file mode 100644 index 000000000000..89bfbcf45805 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/145d1775308211d2.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettyNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/145d1775308211d2.sql b/tests/ast_json_fixtures/shapes/145d1775308211d2.sql new file mode 100644 index 000000000000..fa79f37614f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/145d1775308211d2.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettyNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/146cde9839fbabd3.json b/tests/ast_json_fixtures/shapes/146cde9839fbabd3.json new file mode 100644 index 000000000000..6969b532b613 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/146cde9839fbabd3.json @@ -0,0 +1,169 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "limit_with_ties": true, + "select": [ + { + "type": "Function", + "alias": "name", + "name": "transform", + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "Henry" + }, + { + "value_type": "String", + "value": "Irene" + }, + { + "value_type": "String", + "value": "Dave" + }, + { + "value_type": "String", + "value": "Cindy" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "Henry or Irene" + }, + { + "value_type": "String", + "value": "Henry or Irene" + }, + { + "value_type": "String", + "value": "Dave or Cindy" + }, + { + "value_type": "String", + "value": "Dave or Cindy" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "department" + }, + { + "type": "Identifier", + "name": "salary" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "employees" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "department" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "salary" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "salary" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/146cde9839fbabd3.sql b/tests/ast_json_fixtures/shapes/146cde9839fbabd3.sql new file mode 100644 index 000000000000..fb513b9fb224 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/146cde9839fbabd3.sql @@ -0,0 +1,4 @@ +select transform(name, ['Henry', 'Irene', 'Dave', 'Cindy'], ['Henry or Irene', 'Henry or Irene', 'Dave or Cindy', 'Dave or Cindy']) AS name, department, salary from (SELECT * FROM employees ORDER BY id, name, department, salary) +order by salary desc +fetch first 5 rows with ties +format PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/146fbf6efec4685d.json b/tests/ast_json_fixtures/shapes/146fbf6efec4685d.json new file mode 100644 index 000000000000..3d5621841e55 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/146fbf6efec4685d.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "id_2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Identifier", + "name": "id_2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01756" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/146fbf6efec4685d.sql b/tests/ast_json_fixtures/shapes/146fbf6efec4685d.sql new file mode 100644 index 000000000000..30ce89368ff9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/146fbf6efec4685d.sql @@ -0,0 +1 @@ +with (select currentDatabase()) as id_2 select *, ignore(id_2) from dist_01756 where dummy in (2) diff --git a/tests/ast_json_fixtures/shapes/147bb6854b1ce9ea.json b/tests/ast_json_fixtures/shapes/147bb6854b1ce9ea.json new file mode 100644 index 000000000000..ecf409009c96 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/147bb6854b1ce9ea.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "parallel_replicas_check_read_mode_always" + } +} diff --git a/tests/ast_json_fixtures/shapes/147bb6854b1ce9ea.sql b/tests/ast_json_fixtures/shapes/147bb6854b1ce9ea.sql new file mode 100644 index 000000000000..1079075ce658 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/147bb6854b1ce9ea.sql @@ -0,0 +1 @@ +SYSTEM ENABLE FAILPOINT parallel_replicas_check_read_mode_always diff --git a/tests/ast_json_fixtures/shapes/147d78f0cc96febd.json b/tests/ast_json_fixtures/shapes/147d78f0cc96febd.json new file mode 100644 index 000000000000..5c18e2b343f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/147d78f0cc96febd.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u4_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "DOUBLE_SHA1_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwe123" + } + ] + } + ], + "replace_authentication_methods": true, + "hosts": { + "any_host": true + }, + "default_roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r1_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/147d78f0cc96febd.sql b/tests/ast_json_fixtures/shapes/147d78f0cc96febd.sql new file mode 100644 index 000000000000..098afadb48fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/147d78f0cc96febd.sql @@ -0,0 +1 @@ +CREATE USER u4_01292 IDENTIFIED WITH double_sha1_password BY 'qwe123' HOST ANY DEFAULT ROLE ALL EXCEPT r1_01292 diff --git a/tests/ast_json_fixtures/shapes/14871ee550fbd956.json b/tests/ast_json_fixtures/shapes/14871ee550fbd956.json new file mode 100644 index 000000000000..e1afb43e8339 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/14871ee550fbd956.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "uuid" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "created_at", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UUID" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + }, + { + "type": "Identifier", + "name": "id" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/14871ee550fbd956.sql b/tests/ast_json_fixtures/shapes/14871ee550fbd956.sql new file mode 100644 index 000000000000..0011e0519d2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/14871ee550fbd956.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS uuid +( + created_at DateTime, + id UUID +) +ENGINE = MergeTree +PARTITION BY toDate(created_at) +ORDER BY (created_at, id) diff --git a/tests/ast_json_fixtures/shapes/14b0989aa05ff32c.json b/tests/ast_json_fixtures/shapes/14b0989aa05ff32c.json new file mode 100644 index 000000000000..35ec710d2895 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/14b0989aa05ff32c.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR QUERY CACHE", + "query_result_cache_tag": "tag" + } +} diff --git a/tests/ast_json_fixtures/shapes/14b0989aa05ff32c.sql b/tests/ast_json_fixtures/shapes/14b0989aa05ff32c.sql new file mode 100644 index 000000000000..db1b81e8bc08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/14b0989aa05ff32c.sql @@ -0,0 +1 @@ +SYSTEM CLEAR QUERY CACHE TAG 'tag' diff --git a/tests/ast_json_fixtures/shapes/14dbadae7c356928.json b/tests/ast_json_fixtures/shapes/14dbadae7c356928.json new file mode 100644 index 000000000000..86f764c94167 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/14dbadae7c356928.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "m" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "f" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/14dbadae7c356928.sql b/tests/ast_json_fixtures/shapes/14dbadae7c356928.sql new file mode 100644 index 000000000000..65171707aa76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/14dbadae7c356928.sql @@ -0,0 +1 @@ +SELECT * FROM m PREWHERE f = 0 diff --git a/tests/ast_json_fixtures/shapes/14f6a15c20b3ca46.json b/tests/ast_json_fixtures/shapes/14f6a15c20b3ca46.json new file mode 100644 index 000000000000..1f413e32726e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/14f6a15c20b3ca46.json @@ -0,0 +1,116 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/14f6a15c20b3ca46.sql b/tests/ast_json_fixtures/shapes/14f6a15c20b3ca46.sql new file mode 100644 index 000000000000..d09774b6a0ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/14f6a15c20b3ca46.sql @@ -0,0 +1,6 @@ +WITH RECURSIVE t AS ( + SELECT 1 AS n +UNION ALL + SELECT n+1 FROM t WHERE n < 100 +) +SELECT sum(n) FROM t diff --git a/tests/ast_json_fixtures/shapes/150a01a28326548f.json b/tests/ast_json_fixtures/shapes/150a01a28326548f.json new file mode 100644 index 000000000000..0df9179a6f23 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/150a01a28326548f.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_table" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "eventType", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "timestamp", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "eventType" + }, + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "eventType" + }, + { + "type": "Identifier", + "name": "timestamp" + }, + { + "type": "Identifier", + "name": "key" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/150a01a28326548f.sql b/tests/ast_json_fixtures/shapes/150a01a28326548f.sql new file mode 100644 index 000000000000..16ad385dc56e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/150a01a28326548f.sql @@ -0,0 +1,10 @@ +CREATE TABLE test_table +( + `eventType` String, + `timestamp` UInt64, + `key` UInt64 +) +ENGINE = ReplacingMergeTree +PRIMARY KEY (eventType, timestamp) +ORDER BY (eventType, timestamp, key) +SETTINGS index_granularity = 1 diff --git a/tests/ast_json_fixtures/shapes/1511a0c65a317ea9.json b/tests/ast_json_fixtures/shapes/1511a0c65a317ea9.json new file mode 100644 index 000000000000..fe69fc75d61b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1511a0c65a317ea9.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettyMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/1511a0c65a317ea9.sql b/tests/ast_json_fixtures/shapes/1511a0c65a317ea9.sql new file mode 100644 index 000000000000..b31ad2d1f25d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1511a0c65a317ea9.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettyMonoBlock diff --git a/tests/ast_json_fixtures/shapes/15159fcac9e3a95f.json b/tests/ast_json_fixtures/shapes/15159fcac9e3a95f.json new file mode 100644 index 000000000000..feae3db96cd5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15159fcac9e3a95f.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "_02269_data" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "RowBinary" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/15159fcac9e3a95f.sql b/tests/ast_json_fixtures/shapes/15159fcac9e3a95f.sql new file mode 100644 index 000000000000..5d0d8cb6d6f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15159fcac9e3a95f.sql @@ -0,0 +1 @@ +insert into function file(currentDatabase() || '_02269_data', 'RowBinary') select 1 settings engine_file_truncate_on_insert=1 diff --git a/tests/ast_json_fixtures/shapes/151ef36e554c2507.json b/tests/ast_json_fixtures/shapes/151ef36e554c2507.json new file mode 100644 index 000000000000..b754ec1ca869 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/151ef36e554c2507.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s2_01294_renamed"] + } +} diff --git a/tests/ast_json_fixtures/shapes/151ef36e554c2507.sql b/tests/ast_json_fixtures/shapes/151ef36e554c2507.sql new file mode 100644 index 000000000000..100c612b6ed1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/151ef36e554c2507.sql @@ -0,0 +1 @@ +SHOW CREATE SETTINGS PROFILE s2_01294_renamed diff --git a/tests/ast_json_fixtures/shapes/152008e49133e5db.json b/tests/ast_json_fixtures/shapes/152008e49133e5db.json new file mode 100644 index 000000000000..ec288c4befac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/152008e49133e5db.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "distinct_in_order" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "10", + "max_threads": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/152008e49133e5db.sql b/tests/ast_json_fixtures/shapes/152008e49133e5db.sql new file mode 100644 index 000000000000..e70290066815 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/152008e49133e5db.sql @@ -0,0 +1 @@ +select distinct * from distinct_in_order settings max_block_size=10, max_threads=1 diff --git a/tests/ast_json_fixtures/shapes/152e4fe2a148bb1c.json b/tests/ast_json_fixtures/shapes/152e4fe2a148bb1c.json new file mode 100644 index 000000000000..727ea4ae3a05 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/152e4fe2a148bb1c.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "constF64" + } +} diff --git a/tests/ast_json_fixtures/shapes/152e4fe2a148bb1c.sql b/tests/ast_json_fixtures/shapes/152e4fe2a148bb1c.sql new file mode 100644 index 000000000000..7df81d47abc0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/152e4fe2a148bb1c.sql @@ -0,0 +1 @@ +DROP FUNCTION constF64 diff --git a/tests/ast_json_fixtures/shapes/15436f4cba19f2d8.json b/tests/ast_json_fixtures/shapes/15436f4cba19f2d8.json new file mode 100644 index 000000000000..fe37e818153b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15436f4cba19f2d8.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "JSONExtract", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "{\"a\":1, \"b\":\"test\"}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple(a UInt8, b String)" + } + ] + }, + { + "type": "Identifier", + "name": "x.a", + "name_parts": ["x", "a"] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/15436f4cba19f2d8.sql b/tests/ast_json_fixtures/shapes/15436f4cba19f2d8.sql new file mode 100644 index 000000000000..599f80510b7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15436f4cba19f2d8.sql @@ -0,0 +1,4 @@ +SELECT + JSONExtract('{"a":1, "b":"test"}', 'Tuple(a UInt8, b String)') AS x, + x.a +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/15736413080a69ef.json b/tests/ast_json_fixtures/shapes/15736413080a69ef.json new file mode 100644 index 000000000000..794d1005272a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15736413080a69ef.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "s3", + "arguments": [ + { + "type": "Identifier", + "name": "s3_conn" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "filename" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test.zip::03215_archive.csv" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_archive_path_syntax": "0" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/15736413080a69ef.sql b/tests/ast_json_fixtures/shapes/15736413080a69ef.sql new file mode 100644 index 000000000000..4dd9ec722e7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15736413080a69ef.sql @@ -0,0 +1 @@ +INSERT INTO FUNCTION s3(s3_conn, filename='test.zip::03215_archive.csv') SETTINGS allow_archive_path_syntax=0 SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/15745cef7730a40f.json b/tests/ast_json_fixtures/shapes/15745cef7730a40f.json new file mode 100644 index 000000000000..7c2d1c2c14f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15745cef7730a40f.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateResourceQuery", + "or_replace": true, + "resource_name": { + "type": "Identifier", + "name": "03232_read" + }, + "unit": "IOByte", + "operations": [ + { + "mode": "READ", + "disk": "03232_fake_disk_2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/15745cef7730a40f.sql b/tests/ast_json_fixtures/shapes/15745cef7730a40f.sql new file mode 100644 index 000000000000..72a1078735c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15745cef7730a40f.sql @@ -0,0 +1 @@ +create or replace resource 03232_read (read disk 03232_fake_disk_2) diff --git a/tests/ast_json_fixtures/shapes/15906b2cea0c2184.json b/tests/ast_json_fixtures/shapes/15906b2cea0c2184.json new file mode 100644 index 000000000000..1504ef4e96b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15906b2cea0c2184.json @@ -0,0 +1,192 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "explain", + "name": "trimLeft", + "arguments": [ + { + "type": "Identifier", + "name": "explain" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "viewExplain", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "EXPLAIN" + }, + { + "type": "Literal", + "value_type": "String", + "value": "indexes = 1" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": null + } + ] + } + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "explain" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%Description:%" + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "explain" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%Parts:%" + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "explain" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%Granules:%" + } + ] + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/15906b2cea0c2184.sql b/tests/ast_json_fixtures/shapes/15906b2cea0c2184.sql new file mode 100644 index 000000000000..5ded46534aaa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15906b2cea0c2184.sql @@ -0,0 +1,6 @@ +SELECT trimLeft(explain) AS explain FROM ( + EXPLAIN indexes=1 + SELECT count() FROM tab WHERE col = nan +) +WHERE explain LIKE '%Description:%' OR explain LIKE '%Parts:%' OR explain LIKE '%Granules:%' +LIMIT 2, 3 diff --git a/tests/ast_json_fixtures/shapes/15a138e337d54e2d.json b/tests/ast_json_fixtures/shapes/15a138e337d54e2d.json new file mode 100644 index 000000000000..7fdb2d5636e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15a138e337d54e2d.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "test_sequenceNextNode" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "dt", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "action", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "dt" + }, + "order_by": { + "type": "Identifier", + "name": "id" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/15a138e337d54e2d.sql b/tests/ast_json_fixtures/shapes/15a138e337d54e2d.sql new file mode 100644 index 000000000000..d25107ddf332 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15a138e337d54e2d.sql @@ -0,0 +1 @@ +CREATE TABLE IF NOT EXISTS test_sequenceNextNode (dt DateTime, id int, action String) ENGINE = MergeTree() PARTITION BY dt ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/15b5e047f621cc2c.json b/tests/ast_json_fixtures/shapes/15b5e047f621cc2c.json new file mode 100644 index 000000000000..4c39d9a8a4e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15b5e047f621cc2c.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Literal", + "alias": "a", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/15b5e047f621cc2c.sql b/tests/ast_json_fixtures/shapes/15b5e047f621cc2c.sql new file mode 100644 index 000000000000..1329252cfeaf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15b5e047f621cc2c.sql @@ -0,0 +1 @@ +SELECT count(NULL as a), a FROM t1 WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/15c0b572da0800e3.json b/tests/ast_json_fixtures/shapes/15c0b572da0800e3.json new file mode 100644 index 000000000000..4ea498d11433 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15c0b572da0800e3.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u4_01292" + } + ] + }, + "remove_hosts": { + "names": ["myhost.com"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/15c0b572da0800e3.sql b/tests/ast_json_fixtures/shapes/15c0b572da0800e3.sql new file mode 100644 index 000000000000..a812ebe259e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15c0b572da0800e3.sql @@ -0,0 +1 @@ +ALTER USER u4_01292 DROP HOST NAME 'myhost.com' diff --git a/tests/ast_json_fixtures/shapes/15dda850c1c9e962.json b/tests/ast_json_fixtures/shapes/15dda850c1c9e962.json new file mode 100644 index 000000000000..75e77f9a3e36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15dda850c1c9e962.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "Settings", + "changes": { + "final": "1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/15dda850c1c9e962.sql b/tests/ast_json_fixtures/shapes/15dda850c1c9e962.sql new file mode 100644 index 000000000000..01a6821e623d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15dda850c1c9e962.sql @@ -0,0 +1 @@ +set final=1 diff --git a/tests/ast_json_fixtures/shapes/15e4b603e46a44ea.json b/tests/ast_json_fixtures/shapes/15e4b603e46a44ea.json new file mode 100644 index 000000000000..2938dd12f70a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15e4b603e46a44ea.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q7_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/15e4b603e46a44ea.sql b/tests/ast_json_fixtures/shapes/15e4b603e46a44ea.sql new file mode 100644 index 000000000000..9884ca285044 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15e4b603e46a44ea.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q7_01297 diff --git a/tests/ast_json_fixtures/shapes/15e57592f3e2d4dd.json b/tests/ast_json_fixtures/shapes/15e57592f3e2d4dd.json new file mode 100644 index 000000000000..17c757939ce7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15e57592f3e2d4dd.json @@ -0,0 +1,178 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Function", + "name": "sipHash64", + "arguments": [ + { + "type": "Function", + "name": "sipHash64", + "arguments": [ + { + "type": "Function", + "name": "sipHash64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "name": "sipHash64", + "arguments": [ + { + "type": "Function", + "name": "sipHash64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "29103473" + }, + { + "type": "Function", + "name": "sipHash64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "3" + }, + { + "type": "Function", + "name": "sipHash64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/15e57592f3e2d4dd.sql b/tests/ast_json_fixtures/shapes/15e57592f3e2d4dd.sql new file mode 100644 index 000000000000..7572ba868074 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15e57592f3e2d4dd.sql @@ -0,0 +1,7 @@ +SELECT DISTINCT number * 1 +FROM numbers(10, sipHash64(sipHash64(sipHash64(2), 1), 1, 2, *), sipHash64(sipHash64(29103473, sipHash64(1), '3', sipHash64(1), 1))) +GROUP BY + 1, + isNullable(1) + WITH TOTALS +ORDER BY 1 ASC SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/15ee90e0dde040f0.json b/tests/ast_json_fixtures/shapes/15ee90e0dde040f0.json new file mode 100644 index 000000000000..ff94a23ab91e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15ee90e0dde040f0.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "test_deletes" + }, + "settings": { + "type": "Settings", + "changes": { + "lightweight_deletes_sync": "0" + } + }, + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/15ee90e0dde040f0.sql b/tests/ast_json_fixtures/shapes/15ee90e0dde040f0.sql new file mode 100644 index 000000000000..e6dd7b057a69 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15ee90e0dde040f0.sql @@ -0,0 +1 @@ +DELETE FROM test_deletes WHERE a = 2 SETTINGS lightweight_deletes_sync = 0 diff --git a/tests/ast_json_fixtures/shapes/15f1990c040176e6.json b/tests/ast_json_fixtures/shapes/15f1990c040176e6.json new file mode 100644 index 000000000000..75a1ae8a5cb9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15f1990c040176e6.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "check_system_tables" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "check_system_tables_null" + } + ] + } + }, + "as_table": "check_system_tables_null" + } +} diff --git a/tests/ast_json_fixtures/shapes/15f1990c040176e6.sql b/tests/ast_json_fixtures/shapes/15f1990c040176e6.sql new file mode 100644 index 000000000000..c6bece930344 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/15f1990c040176e6.sql @@ -0,0 +1 @@ +CREATE TABLE check_system_tables AS check_system_tables_null Engine=Distributed(test_shard_localhost, currentDatabase(), check_system_tables_null) diff --git a/tests/ast_json_fixtures/shapes/163316d274ce2bad.json b/tests/ast_json_fixtures/shapes/163316d274ce2bad.json new file mode 100644 index 000000000000..44a3e84e2ca9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/163316d274ce2bad.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "test_01457" + }, + "table": { + "type": "Identifier", + "name": "tf_numbers" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "number", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "as_table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/163316d274ce2bad.sql b/tests/ast_json_fixtures/shapes/163316d274ce2bad.sql new file mode 100644 index 000000000000..8175308f7d60 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/163316d274ce2bad.sql @@ -0,0 +1 @@ +CREATE TABLE test_01457.tf_numbers (number String) AS numbers(1) diff --git a/tests/ast_json_fixtures/shapes/163bf0d6a951e484.json b/tests/ast_json_fixtures/shapes/163bf0d6a951e484.json new file mode 100644 index 000000000000..bed32a59d6f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/163bf0d6a951e484.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "test_00209" + }, + "settings": { + "type": "Settings", + "changes": { + "extremes": "1" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "extremes": "1" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/163bf0d6a951e484.sql b/tests/ast_json_fixtures/shapes/163bf0d6a951e484.sql new file mode 100644 index 000000000000..cb40d10964f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/163bf0d6a951e484.sql @@ -0,0 +1 @@ +INSERT INTO test_00209 SELECT 1 AS x SETTINGS extremes = 1 diff --git a/tests/ast_json_fixtures/shapes/166c32415c348dcc.json b/tests/ast_json_fixtures/shapes/166c32415c348dcc.json new file mode 100644 index 000000000000..fe5b790a08fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/166c32415c348dcc.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "TruncateQuery", + "kind": "TRUNCATE", + "temporary": true, + "table": { + "type": "Identifier", + "name": "test_00670" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/166c32415c348dcc.sql b/tests/ast_json_fixtures/shapes/166c32415c348dcc.sql new file mode 100644 index 000000000000..d42aeaf39009 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/166c32415c348dcc.sql @@ -0,0 +1 @@ +truncate temporary table test_00670 diff --git a/tests/ast_json_fixtures/shapes/16c4e3bc2cf3549f.json b/tests/ast_json_fixtures/shapes/16c4e3bc2cf3549f.json new file mode 100644 index 000000000000..0f5034e83f2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16c4e3bc2cf3549f.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "dictionaries": true, + "from": { + "type": "Identifier", + "name": "db_01018" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/16c4e3bc2cf3549f.sql b/tests/ast_json_fixtures/shapes/16c4e3bc2cf3549f.sql new file mode 100644 index 000000000000..cf4b29253c5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16c4e3bc2cf3549f.sql @@ -0,0 +1 @@ +SHOW DICTIONARIES FROM db_01018 diff --git a/tests/ast_json_fixtures/shapes/16d148d098fba568.json b/tests/ast_json_fixtures/shapes/16d148d098fba568.json new file mode 100644 index 000000000000..af302b19fce4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16d148d098fba568.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_display_footer_column_names": "0" + } + }, + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/16d148d098fba568.sql b/tests/ast_json_fixtures/shapes/16d148d098fba568.sql new file mode 100644 index 000000000000..277820d62fdd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16d148d098fba568.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT Pretty SETTINGS output_format_pretty_display_footer_column_names=0 diff --git a/tests/ast_json_fixtures/shapes/16d64a1dc2e65877.json b/tests/ast_json_fixtures/shapes/16d64a1dc2e65877.json new file mode 100644 index 000000000000..50461c2beed7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16d64a1dc2e65877.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "tid", + "arguments": [] + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/16d64a1dc2e65877.sql b/tests/ast_json_fixtures/shapes/16d64a1dc2e65877.sql new file mode 100644 index 000000000000..3415eff4b074 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16d64a1dc2e65877.sql @@ -0,0 +1 @@ +SELECT tid() FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/16df0a7695b32bd0.json b/tests/ast_json_fixtures/shapes/16df0a7695b32bd0.json new file mode 100644 index 000000000000..c0fb554fe73c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16df0a7695b32bd0.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettySpaceMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/16df0a7695b32bd0.sql b/tests/ast_json_fixtures/shapes/16df0a7695b32bd0.sql new file mode 100644 index 000000000000..58c5fd35c7c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16df0a7695b32bd0.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettySpaceMonoBlock diff --git a/tests/ast_json_fixtures/shapes/16e14f741ea3a62f.json b/tests/ast_json_fixtures/shapes/16e14f741ea3a62f.json new file mode 100644 index 000000000000..2f46912a8a12 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16e14f741ea3a62f.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "t.parquet" + }, + { + "type": "Identifier", + "name": "Parquet" + }, + { + "type": "Literal", + "value_type": "String", + "value": "x String" + } + ] + }, + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/16e14f741ea3a62f.sql b/tests/ast_json_fixtures/shapes/16e14f741ea3a62f.sql new file mode 100644 index 000000000000..822afea4afa8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16e14f741ea3a62f.sql @@ -0,0 +1 @@ +insert into function file('t.parquet', Parquet, 'x String') values ('1'), ('100'), ('2') diff --git a/tests/ast_json_fixtures/shapes/16ebacb5d201029c.json b/tests/ast_json_fixtures/shapes/16ebacb5d201029c.json new file mode 100644 index 000000000000..4baf000f323d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16ebacb5d201029c.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "u1.uid", + "name_parts": ["u1", "uid"] + }, + { + "type": "Identifier", + "alias": "name", + "name": "u1.spouse_name", + "name_parts": ["u1", "spouse_name"] + }, + { + "type": "Identifier", + "name": "u2.uid", + "name_parts": ["u2", "uid"] + }, + { + "type": "Identifier", + "name": "u2.name", + "name_parts": ["u2", "name"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "u1", + "name": "users" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "name" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "u2", + "name": "users" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "u1.uid", + "name_parts": ["u1", "uid"] + }, + "direction": "ASC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + }, + "format": "TSVWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/16ebacb5d201029c.sql b/tests/ast_json_fixtures/shapes/16ebacb5d201029c.sql new file mode 100644 index 000000000000..91b72b48d971 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16ebacb5d201029c.sql @@ -0,0 +1,5 @@ +SELECT u1.uid, u1.spouse_name as name, u2.uid, u2.name +FROM users u1 JOIN users u2 USING (name) +ORDER BY u1.uid +FORMAT TSVWithNamesAndTypes +SETTINGS enable_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/16ef3890c1435cdd.json b/tests/ast_json_fixtures/shapes/16ef3890c1435cdd.json new file mode 100644 index 000000000000..8cb9143601be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16ef3890c1435cdd.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "mv_01210" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Log", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/16ef3890c1435cdd.sql b/tests/ast_json_fixtures/shapes/16ef3890c1435cdd.sql new file mode 100644 index 000000000000..d5d4194e54ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16ef3890c1435cdd.sql @@ -0,0 +1 @@ +CREATE MATERIALIZED VIEW IF NOT EXISTS mv_01210 ENGINE Log AS SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/16f4cb013867f67a.json b/tests/ast_json_fixtures/shapes/16f4cb013867f67a.json new file mode 100644 index 000000000000..817563ec62e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16f4cb013867f67a.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/16f4cb013867f67a.sql b/tests/ast_json_fixtures/shapes/16f4cb013867f67a.sql new file mode 100644 index 000000000000..5f91d3fe7e68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/16f4cb013867f67a.sql @@ -0,0 +1 @@ +SELECT number FROM numbers(10) ORDER BY number OFFSET -0 diff --git a/tests/ast_json_fixtures/shapes/17227e7de9fc9442.json b/tests/ast_json_fixtures/shapes/17227e7de9fc9442.json new file mode 100644 index 000000000000..7199f4180e8c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17227e7de9fc9442.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateWorkloadQuery", + "or_replace": true, + "workload_name": { + "type": "Identifier", + "name": "all" + }, + "workload_parent": { + "type": "Identifier", + "name": "production" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/17227e7de9fc9442.sql b/tests/ast_json_fixtures/shapes/17227e7de9fc9442.sql new file mode 100644 index 000000000000..8b287fbe1244 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17227e7de9fc9442.sql @@ -0,0 +1 @@ +create or replace workload all in production diff --git a/tests/ast_json_fixtures/shapes/17403540ce02b3c7.json b/tests/ast_json_fixtures/shapes/17403540ce02b3c7.json new file mode 100644 index 000000000000..9d679e95bbca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17403540ce02b3c7.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "t_insert_select_parens" + }, + "columns": [ + { + "type": "Identifier", + "name": "x" + } + ], + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "EXCEPT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ] + }, + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + } + ] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/17403540ce02b3c7.sql b/tests/ast_json_fixtures/shapes/17403540ce02b3c7.sql new file mode 100644 index 000000000000..400e4ce96be3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17403540ce02b3c7.sql @@ -0,0 +1 @@ +INSERT INTO t_insert_select_parens (x) (SELECT * FROM numbers(5)) EXCEPT (SELECT * FROM numbers(3)) diff --git a/tests/ast_json_fixtures/shapes/17491521d16c4d45.json b/tests/ast_json_fixtures/shapes/17491521d16c4d45.json new file mode 100644 index 000000000000..4a1ae8ae711f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17491521d16c4d45.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CheckQuery", + "table": { + "type": "Identifier", + "name": "mt_table" + }, + "part_name": "201801_1_1_2" + } +} diff --git a/tests/ast_json_fixtures/shapes/17491521d16c4d45.sql b/tests/ast_json_fixtures/shapes/17491521d16c4d45.sql new file mode 100644 index 000000000000..c8a27d6b4758 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17491521d16c4d45.sql @@ -0,0 +1 @@ +CHECK TABLE mt_table PART '201801_1_1_2' diff --git a/tests/ast_json_fixtures/shapes/174f1bae71247cb0.json b/tests/ast_json_fixtures/shapes/174f1bae71247cb0.json new file mode 100644 index 000000000000..0c931df82194 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/174f1bae71247cb0.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "set" + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "set" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/174f1bae71247cb0.sql b/tests/ast_json_fixtures/shapes/174f1bae71247cb0.sql new file mode 100644 index 000000000000..5e404e40dfce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/174f1bae71247cb0.sql @@ -0,0 +1 @@ +SELECT * FROM tab PREWHERE x IN (set) WHERE x IN (set) LIMIT 1 settings enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/175318c00c2da6f7.json b/tests/ast_json_fixtures/shapes/175318c00c2da6f7.json new file mode 100644 index 000000000000..b8466b888444 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/175318c00c2da6f7.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_shard_localhost", + "table": { + "type": "Identifier", + "name": "ORDERS_shard" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "O_ORDERKEY", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "O_ORDERPRIORITY", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "O_ORDERKEY" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/175318c00c2da6f7.sql b/tests/ast_json_fixtures/shapes/175318c00c2da6f7.sql new file mode 100644 index 000000000000..91343ca43218 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/175318c00c2da6f7.sql @@ -0,0 +1,7 @@ +CREATE TABLE ORDERS_shard ON CLUSTER test_shard_localhost +( + O_ORDERKEY UInt64, + O_ORDERPRIORITY UInt32 +) +ENGINE = MergeTree() +ORDER BY O_ORDERKEY diff --git a/tests/ast_json_fixtures/shapes/175a6ff22a9c4655.json b/tests/ast_json_fixtures/shapes/175a6ff22a9c4655.json new file mode 100644 index 000000000000..ba81f2e68d80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/175a6ff22a9c4655.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateViewQuery", + "table": { + "type": "Identifier", + "name": "view" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/175a6ff22a9c4655.sql b/tests/ast_json_fixtures/shapes/175a6ff22a9c4655.sql new file mode 100644 index 000000000000..e990a6281a27 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/175a6ff22a9c4655.sql @@ -0,0 +1 @@ +SHOW CREATE VIEW view diff --git a/tests/ast_json_fixtures/shapes/176840492defcb20.json b/tests/ast_json_fixtures/shapes/176840492defcb20.json new file mode 100644 index 000000000000..a1d3ff0e8e51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/176840492defcb20.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/176840492defcb20.sql b/tests/ast_json_fixtures/shapes/176840492defcb20.sql new file mode 100644 index 000000000000..99501f255a72 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/176840492defcb20.sql @@ -0,0 +1 @@ +CREATE TABLE t1 (x int) diff --git a/tests/ast_json_fixtures/shapes/178e542d039086d5.json b/tests/ast_json_fixtures/shapes/178e542d039086d5.json new file mode 100644 index 000000000000..07613fe9e341 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/178e542d039086d5.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_tmp" + }, + "as_table": "test" + } +} diff --git a/tests/ast_json_fixtures/shapes/178e542d039086d5.sql b/tests/ast_json_fixtures/shapes/178e542d039086d5.sql new file mode 100644 index 000000000000..ff07986ead36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/178e542d039086d5.sql @@ -0,0 +1 @@ +CREATE TABLE test_tmp as test diff --git a/tests/ast_json_fixtures/shapes/17b4b94f3ada05e5.json b/tests/ast_json_fixtures/shapes/17b4b94f3ada05e5.json new file mode 100644 index 000000000000..a736742a24ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17b4b94f3ada05e5.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "s" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "prewhere": { + "type": "Identifier", + "name": "e" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/17b4b94f3ada05e5.sql b/tests/ast_json_fixtures/shapes/17b4b94f3ada05e5.sql new file mode 100644 index 000000000000..fd1154225779 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17b4b94f3ada05e5.sql @@ -0,0 +1 @@ +SELECT s FROM t1 PREWHERE e diff --git a/tests/ast_json_fixtures/shapes/17b5157ad9ae4867.json b/tests/ast_json_fixtures/shapes/17b5157ad9ae4867.json new file mode 100644 index 000000000000..ae801b71cb8f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17b5157ad9ae4867.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "alias": "y", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/17b5157ad9ae4867.sql b/tests/ast_json_fixtures/shapes/17b5157ad9ae4867.sql new file mode 100644 index 000000000000..17fd6da6cf1d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17b5157ad9ae4867.sql @@ -0,0 +1 @@ +SELECT NULL AS x, tuple(NULL) AS y FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/17bd9513c43051ef.json b/tests/ast_json_fixtures/shapes/17bd9513c43051ef.json new file mode 100644 index 000000000000..1f3b1abb8597 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17bd9513c43051ef.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "blob_storage_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/17bd9513c43051ef.sql b/tests/ast_json_fixtures/shapes/17bd9513c43051ef.sql new file mode 100644 index 000000000000..86278995a471 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17bd9513c43051ef.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS blob_storage_log diff --git a/tests/ast_json_fixtures/shapes/17d94a3e7ac17194.json b/tests/ast_json_fixtures/shapes/17d94a3e7ac17194.json new file mode 100644 index 000000000000..d6da918f8d2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17d94a3e7ac17194.json @@ -0,0 +1,133 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "arr1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "0" + }, + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Function", + "alias": "common", + "name": "arraySort", + "arguments": [ + { + "type": "Function", + "name": "arrayIntersect", + "arguments": [ + { + "type": "Function", + "name": "argMax", + "arguments": [ + { + "type": "Identifier", + "name": "seqs" + }, + { + "type": "Identifier", + "name": "create_time" + } + ] + }, + { + "type": "Identifier", + "name": "arr1" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tags" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "id%" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/17d94a3e7ac17194.sql b/tests/ast_json_fixtures/shapes/17d94a3e7ac17194.sql new file mode 100644 index 000000000000..b48e1e70f47b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/17d94a3e7ac17194.sql @@ -0,0 +1,7 @@ +WITH + (SELECT [0, 1, 2, 3]) AS arr1 +SELECT arraySort(arrayIntersect(argMax(seqs, create_time), arr1)) AS common, id +FROM tags +WHERE id LIKE 'id%' +GROUP BY id +ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/1801101634eddbc2.json b/tests/ast_json_fixtures/shapes/1801101634eddbc2.json new file mode 100644 index 000000000000..9c001d9ee4e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1801101634eddbc2.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1", + "enable_positional_arguments": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1801101634eddbc2.sql b/tests/ast_json_fixtures/shapes/1801101634eddbc2.sql new file mode 100644 index 000000000000..bec8685ef14e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1801101634eddbc2.sql @@ -0,0 +1 @@ +SELECT (2,) = tuple(materialize(1)) GROUP BY 1 WITH ROLLUP SETTINGS group_by_use_nulls = 1, enable_positional_arguments = 1 diff --git a/tests/ast_json_fixtures/shapes/1804a8ca693d84b2.json b/tests/ast_json_fixtures/shapes/1804a8ca693d84b2.json new file mode 100644 index 000000000000..edb1181ade56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1804a8ca693d84b2.json @@ -0,0 +1,480 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "formats", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "String", + "value": "Arrow" + }, + { + "value_type": "String", + "value": "ArrowStream" + }, + { + "value_type": "String", + "value": "Avro" + }, + { + "value_type": "String", + "value": "AvroConfluent" + }, + { + "value_type": "String", + "value": "BSONEachRow" + }, + { + "value_type": "String", + "value": "Buffers" + }, + { + "value_type": "String", + "value": "CSV" + }, + { + "value_type": "String", + "value": "CSVWithNames" + }, + { + "value_type": "String", + "value": "CSVWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "CapnProto" + }, + { + "value_type": "String", + "value": "CustomSeparated" + }, + { + "value_type": "String", + "value": "CustomSeparatedIgnoreSpaces" + }, + { + "value_type": "String", + "value": "CustomSeparatedIgnoreSpacesWithNames" + }, + { + "value_type": "String", + "value": "CustomSeparatedIgnoreSpacesWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "CustomSeparatedWithNames" + }, + { + "value_type": "String", + "value": "CustomSeparatedWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "Form" + }, + { + "value_type": "String", + "value": "HiveText" + }, + { + "value_type": "String", + "value": "JSON" + }, + { + "value_type": "String", + "value": "JSONAsObject" + }, + { + "value_type": "String", + "value": "JSONAsString" + }, + { + "value_type": "String", + "value": "JSONColumns" + }, + { + "value_type": "String", + "value": "JSONColumnsWithMetadata" + }, + { + "value_type": "String", + "value": "JSONCompact" + }, + { + "value_type": "String", + "value": "JSONCompactColumns" + }, + { + "value_type": "String", + "value": "JSONCompactEachRow" + }, + { + "value_type": "String", + "value": "JSONCompactEachRowWithNames" + }, + { + "value_type": "String", + "value": "JSONCompactEachRowWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "JSONCompactEachRowWithProgress" + }, + { + "value_type": "String", + "value": "JSONCompactStrings" + }, + { + "value_type": "String", + "value": "JSONCompactStringsEachRow" + }, + { + "value_type": "String", + "value": "JSONCompactStringsEachRowWithNames" + }, + { + "value_type": "String", + "value": "JSONCompactStringsEachRowWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "JSONCompactStringsEachRowWithProgress" + }, + { + "value_type": "String", + "value": "JSONEachRow" + }, + { + "value_type": "String", + "value": "JSONEachRowWithProgress" + }, + { + "value_type": "String", + "value": "JSONLines" + }, + { + "value_type": "String", + "value": "JSONObjectEachRow" + }, + { + "value_type": "String", + "value": "JSONStrings" + }, + { + "value_type": "String", + "value": "JSONStringsEachRow" + }, + { + "value_type": "String", + "value": "JSONStringsEachRowWithProgress" + }, + { + "value_type": "String", + "value": "LineAsString" + }, + { + "value_type": "String", + "value": "LineAsStringWithNames" + }, + { + "value_type": "String", + "value": "LineAsStringWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "Markdown" + }, + { + "value_type": "String", + "value": "MsgPack" + }, + { + "value_type": "String", + "value": "MySQLDump" + }, + { + "value_type": "String", + "value": "MySQLWire" + }, + { + "value_type": "String", + "value": "NDJSON" + }, + { + "value_type": "String", + "value": "Native" + }, + { + "value_type": "String", + "value": "Npy" + }, + { + "value_type": "String", + "value": "Null" + }, + { + "value_type": "String", + "value": "ODBCDriver2" + }, + { + "value_type": "String", + "value": "ORC" + }, + { + "value_type": "String", + "value": "One" + }, + { + "value_type": "String", + "value": "Parquet" + }, + { + "value_type": "String", + "value": "ParquetMetadata" + }, + { + "value_type": "String", + "value": "PostgreSQLWire" + }, + { + "value_type": "String", + "value": "Pretty" + }, + { + "value_type": "String", + "value": "PrettyCompact" + }, + { + "value_type": "String", + "value": "PrettyCompactMonoBlock" + }, + { + "value_type": "String", + "value": "PrettyCompactNoEscapes" + }, + { + "value_type": "String", + "value": "PrettyCompactNoEscapesMonoBlock" + }, + { + "value_type": "String", + "value": "PrettyJSONEachRow" + }, + { + "value_type": "String", + "value": "PrettyJSONLines" + }, + { + "value_type": "String", + "value": "PrettyMonoBlock" + }, + { + "value_type": "String", + "value": "PrettyNDJSON" + }, + { + "value_type": "String", + "value": "PrettyNoEscapes" + }, + { + "value_type": "String", + "value": "PrettyNoEscapesMonoBlock" + }, + { + "value_type": "String", + "value": "PrettySpace" + }, + { + "value_type": "String", + "value": "PrettySpaceMonoBlock" + }, + { + "value_type": "String", + "value": "PrettySpaceNoEscapes" + }, + { + "value_type": "String", + "value": "PrettySpaceNoEscapesMonoBlock" + }, + { + "value_type": "String", + "value": "Prometheus" + }, + { + "value_type": "String", + "value": "Protobuf" + }, + { + "value_type": "String", + "value": "ProtobufList" + }, + { + "value_type": "String", + "value": "ProtobufSingle" + }, + { + "value_type": "String", + "value": "Raw" + }, + { + "value_type": "String", + "value": "RawBLOB" + }, + { + "value_type": "String", + "value": "RawWithNames" + }, + { + "value_type": "String", + "value": "RawWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "Regexp" + }, + { + "value_type": "String", + "value": "RowBinary" + }, + { + "value_type": "String", + "value": "RowBinaryWithDefaults" + }, + { + "value_type": "String", + "value": "RowBinaryWithNames" + }, + { + "value_type": "String", + "value": "RowBinaryWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "SQLInsert" + }, + { + "value_type": "String", + "value": "TSKV" + }, + { + "value_type": "String", + "value": "TSV" + }, + { + "value_type": "String", + "value": "TSVRaw" + }, + { + "value_type": "String", + "value": "TSVRawWithNames" + }, + { + "value_type": "String", + "value": "TSVRawWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "TSVWithNames" + }, + { + "value_type": "String", + "value": "TSVWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "TabSeparated" + }, + { + "value_type": "String", + "value": "TabSeparatedRaw" + }, + { + "value_type": "String", + "value": "TabSeparatedRawWithNames" + }, + { + "value_type": "String", + "value": "TabSeparatedRawWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "TabSeparatedWithNames" + }, + { + "value_type": "String", + "value": "TabSeparatedWithNamesAndTypes" + }, + { + "value_type": "String", + "value": "Template" + }, + { + "value_type": "String", + "value": "TemplateIgnoreSpaces" + }, + { + "value_type": "String", + "value": "Values" + }, + { + "value_type": "String", + "value": "Vertical" + }, + { + "value_type": "String", + "value": "XML" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/1804a8ca693d84b2.sql b/tests/ast_json_fixtures/shapes/1804a8ca693d84b2.sql new file mode 100644 index 000000000000..88e3e55061fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1804a8ca693d84b2.sql @@ -0,0 +1,4 @@ +SELECT * FROM system.formats +WHERE name IN ('Arrow','ArrowStream','Avro','AvroConfluent','BSONEachRow', 'Buffers', 'CSV','CSVWithNames','CSVWithNamesAndTypes','CapnProto','CustomSeparated','CustomSeparatedIgnoreSpaces','CustomSeparatedIgnoreSpacesWithNames','CustomSeparatedIgnoreSpacesWithNamesAndTypes','CustomSeparatedWithNames','CustomSeparatedWithNamesAndTypes','Form','HiveText','JSON','JSONAsObject','JSONAsString','JSONColumns','JSONColumnsWithMetadata','JSONCompact','JSONCompactColumns','JSONCompactEachRow','JSONCompactEachRowWithNames','JSONCompactEachRowWithNamesAndTypes','JSONCompactEachRowWithProgress','JSONCompactStrings','JSONCompactStringsEachRow','JSONCompactStringsEachRowWithNames','JSONCompactStringsEachRowWithNamesAndTypes','JSONCompactStringsEachRowWithProgress','JSONEachRow','JSONEachRowWithProgress','JSONLines','JSONObjectEachRow','JSONStrings','JSONStringsEachRow','JSONStringsEachRowWithProgress','LineAsString','LineAsStringWithNames','LineAsStringWithNamesAndTypes','Markdown','MsgPack','MySQLDump','MySQLWire','NDJSON','Native','Npy','Null','ODBCDriver2','ORC','One','Parquet','ParquetMetadata','PostgreSQLWire','Pretty','PrettyCompact','PrettyCompactMonoBlock','PrettyCompactNoEscapes','PrettyCompactNoEscapesMonoBlock','PrettyJSONEachRow','PrettyJSONLines','PrettyMonoBlock','PrettyNDJSON','PrettyNoEscapes','PrettyNoEscapesMonoBlock','PrettySpace','PrettySpaceMonoBlock','PrettySpaceNoEscapes','PrettySpaceNoEscapesMonoBlock','Prometheus','Protobuf','ProtobufList','ProtobufSingle','Raw','RawBLOB','RawWithNames','RawWithNamesAndTypes','Regexp','RowBinary','RowBinaryWithDefaults','RowBinaryWithNames','RowBinaryWithNamesAndTypes','SQLInsert','TSKV','TSV','TSVRaw','TSVRawWithNames','TSVRawWithNamesAndTypes','TSVWithNames','TSVWithNamesAndTypes','TabSeparated','TabSeparatedRaw','TabSeparatedRawWithNames','TabSeparatedRawWithNamesAndTypes','TabSeparatedWithNames','TabSeparatedWithNamesAndTypes','Template','TemplateIgnoreSpaces','Values','Vertical','XML') +ORDER BY name +FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/180a0098c105b3a1.json b/tests/ast_json_fixtures/shapes/180a0098c105b3a1.json new file mode 100644 index 000000000000..4225ad23baa8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/180a0098c105b3a1.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "01902_db_repr" + }, + "table": { + "type": "Identifier", + "name": "t_merge1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "01902_db_repr" + }, + { + "type": "Literal", + "value_type": "String", + "value": "^t$" + } + ] + } + }, + "as_database": "01902_db_repr", + "as_table": "t" + } +} diff --git a/tests/ast_json_fixtures/shapes/180a0098c105b3a1.sql b/tests/ast_json_fixtures/shapes/180a0098c105b3a1.sql new file mode 100644 index 000000000000..c763d812fad6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/180a0098c105b3a1.sql @@ -0,0 +1 @@ +CREATE TABLE 01902_db_repr.t_merge1 as 01902_db_repr.t ENGINE=Merge('01902_db_repr', '^t$') diff --git a/tests/ast_json_fixtures/shapes/1827adb451bef038.json b/tests/ast_json_fixtures/shapes/1827adb451bef038.json new file mode 100644 index 000000000000..9689e79a8c86 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1827adb451bef038.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_atomic", + "from_table": "mv1", + "to_database": "test_01155_ordinary", + "to_table": "mv1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1827adb451bef038.sql b/tests/ast_json_fixtures/shapes/1827adb451bef038.sql new file mode 100644 index 000000000000..4dae69ae3276 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1827adb451bef038.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_atomic.mv1 TO test_01155_ordinary.mv1 diff --git a/tests/ast_json_fixtures/shapes/182d374d5e58f1dd.json b/tests/ast_json_fixtures/shapes/182d374d5e58f1dd.json new file mode 100644 index 000000000000..dbfcc7daf77d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/182d374d5e58f1dd.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "format", + "arguments": [ + { + "type": "Identifier", + "name": "TSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "0123" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/182d374d5e58f1dd.sql b/tests/ast_json_fixtures/shapes/182d374d5e58f1dd.sql new file mode 100644 index 000000000000..e19046d1d7f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/182d374d5e58f1dd.sql @@ -0,0 +1 @@ +select toTypeName(*), * from format(TSV, '0123') diff --git a/tests/ast_json_fixtures/shapes/182f3022d7358f02.json b/tests/ast_json_fixtures/shapes/182f3022d7358f02.json new file mode 100644 index 000000000000..119bd8798663 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/182f3022d7358f02.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "t1", + "to_table": "t2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/182f3022d7358f02.sql b/tests/ast_json_fixtures/shapes/182f3022d7358f02.sql new file mode 100644 index 000000000000..1ab86608fc68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/182f3022d7358f02.sql @@ -0,0 +1 @@ +rename table t1 to t2 diff --git a/tests/ast_json_fixtures/shapes/183b8d9ed8414420.json b/tests/ast_json_fixtures/shapes/183b8d9ed8414420.json new file mode 100644 index 000000000000..1c5f1ed781d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/183b8d9ed8414420.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_ALL", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/183b8d9ed8414420.sql b/tests/ast_json_fixtures/shapes/183b8d9ed8414420.sql new file mode 100644 index 000000000000..5ace399e2d3e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/183b8d9ed8414420.sql @@ -0,0 +1,14 @@ +EXPLAIN SYNTAX +SELECT 1 +UNION ALL +( + SELECT 1 + UNION DISTINCT + ( + SELECT 1 + UNION ALL + SELECT 1 + ) + UNION ALL + SELECT 1 +) diff --git a/tests/ast_json_fixtures/shapes/18425da8e3255ab2.json b/tests/ast_json_fixtures/shapes/18425da8e3255ab2.json new file mode 100644 index 000000000000..b455d257747c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18425da8e3255ab2.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "with": [ + { + "type": "Function", + "alias": "lat", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "90" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greatCircleAngle", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Identifier", + "name": "lat" + } + ] + }, + { + "type": "Function", + "name": "abs", + "arguments": [ + { + "type": "Identifier", + "name": "lat" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "180" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/18425da8e3255ab2.sql b/tests/ast_json_fixtures/shapes/18425da8e3255ab2.sql new file mode 100644 index 000000000000..d592b65e1a9f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18425da8e3255ab2.sql @@ -0,0 +1 @@ +WITH number - 90 AS lat SELECT DISTINCT greatCircleAngle(0, 0, 0, lat) = abs(lat) FROM numbers(180) diff --git a/tests/ast_json_fixtures/shapes/184a820b078ec424.json b/tests/ast_json_fixtures/shapes/184a820b078ec424.json new file mode 100644 index 000000000000..d73425ba9db7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/184a820b078ec424.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tt_m" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "b" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/184a820b078ec424.sql b/tests/ast_json_fixtures/shapes/184a820b078ec424.sql new file mode 100644 index 000000000000..90287260906a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/184a820b078ec424.sql @@ -0,0 +1 @@ +SELECT max(a) FROM tt_m group by b order by b diff --git a/tests/ast_json_fixtures/shapes/187487d012ec625a.json b/tests/ast_json_fixtures/shapes/187487d012ec625a.json new file mode 100644 index 000000000000..95c93260e2cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/187487d012ec625a.json @@ -0,0 +1,120 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "index_append_test_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "constraints": [ + { + "type": "Constraint", + "name": "c1", + "constraint_type": "ASSUME", + "expression": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "40" + } + ] + }, + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "i" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/187487d012ec625a.sql b/tests/ast_json_fixtures/shapes/187487d012ec625a.sql new file mode 100644 index 000000000000..7be923a096f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/187487d012ec625a.sql @@ -0,0 +1 @@ +CREATE TABLE index_append_test_test (i Int64, a UInt32, b UInt64, CONSTRAINT c1 ASSUME i <= 2 * b AND i + 40 > a) ENGINE = MergeTree() ORDER BY i diff --git a/tests/ast_json_fixtures/shapes/187e1ce34371e0d1.json b/tests/ast_json_fixtures/shapes/187e1ce34371e0d1.json new file mode 100644 index 000000000000..1a9db9755abb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/187e1ce34371e0d1.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "s", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "bytes" + } + ] + }, + { + "type": "WithElement", + "name": "data", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "formatReadableSize", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Identifier", + "name": "table" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "another_fake" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "table" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/187e1ce34371e0d1.sql b/tests/ast_json_fixtures/shapes/187e1ce34371e0d1.sql new file mode 100644 index 000000000000..0c4cb65f4959 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/187e1ce34371e0d1.sql @@ -0,0 +1,12 @@ +WITH + sum(bytes) as s, + data as ( + SELECT + formatReadableSize(s), + table + FROM another_fake + GROUP BY table + ORDER BY s + ) +select * from data +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/18994acd116339a3.json b/tests/ast_json_fixtures/shapes/18994acd116339a3.json new file mode 100644 index 000000000000..d020853d8364 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18994acd116339a3.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "alias10" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "alias_local10" + }, + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "Id" + } + ] + } + ] + } + }, + "as_table": "alias_local10" + } +} diff --git a/tests/ast_json_fixtures/shapes/18994acd116339a3.sql b/tests/ast_json_fixtures/shapes/18994acd116339a3.sql new file mode 100644 index 000000000000..156780c98c76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18994acd116339a3.sql @@ -0,0 +1 @@ +CREATE TABLE alias10 AS alias_local10 ENGINE = Distributed(test_shard_localhost, currentDatabase(), alias_local10, cityHash64(Id)) diff --git a/tests/ast_json_fixtures/shapes/18a03411b10d7ac8.json b/tests/ast_json_fixtures/shapes/18a03411b10d7ac8.json new file mode 100644 index 000000000000..10fa359e8d30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18a03411b10d7ac8.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "val" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03408_dist" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "1", + "exact_rows_before_limit": "1", + "distributed_group_by_no_merge": "2" + } + }, + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/18a03411b10d7ac8.sql b/tests/ast_json_fixtures/shapes/18a03411b10d7ac8.sql new file mode 100644 index 000000000000..31b11a4eae0e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18a03411b10d7ac8.sql @@ -0,0 +1,2 @@ +SELECT id, max(val) FROM 03408_dist GROUP BY id ORDER BY id LIMIT 1 BY id LIMIT 4 +FORMAT JSONCompact SETTINGS max_block_size=1, exact_rows_before_limit = 1, distributed_group_by_no_merge=2 diff --git a/tests/ast_json_fixtures/shapes/18ba597dbcc6359a.json b/tests/ast_json_fixtures/shapes/18ba597dbcc6359a.json new file mode 100644 index 000000000000..4374de5af0b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18ba597dbcc6359a.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "tab" + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/18ba597dbcc6359a.sql b/tests/ast_json_fixtures/shapes/18ba597dbcc6359a.sql new file mode 100644 index 000000000000..aa8f5c008e7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18ba597dbcc6359a.sql @@ -0,0 +1 @@ +INSERT INTO FUNCTION remote('localhost', currentDatabase(), tab) SELECT * FROM numbers(1) LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/18cb59b6bb0443ea.json b/tests/ast_json_fixtures/shapes/18cb59b6bb0443ea.json new file mode 100644 index 000000000000..2c08453a2616 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18cb59b6bb0443ea.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateTableQuery", + "table": { + "type": "Identifier", + "name": "data_r2" + }, + "format": "LineAsString" + } +} diff --git a/tests/ast_json_fixtures/shapes/18cb59b6bb0443ea.sql b/tests/ast_json_fixtures/shapes/18cb59b6bb0443ea.sql new file mode 100644 index 000000000000..6a9cd2594639 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18cb59b6bb0443ea.sql @@ -0,0 +1 @@ +show create data_r2 format LineAsString diff --git a/tests/ast_json_fixtures/shapes/18d405d3c15ae6e8.json b/tests/ast_json_fixtures/shapes/18d405d3c15ae6e8.json new file mode 100644 index 000000000000..611c22df437e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18d405d3c15ae6e8.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "value", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "i" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "alias": "i", + "name": "value" + }, + { + "type": "Identifier", + "alias": "j", + "name": "value" + }, + { + "type": "Identifier", + "alias": "k", + "name": "value" + }, + { + "type": "Identifier", + "alias": "l", + "name": "value" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/18d405d3c15ae6e8.sql b/tests/ast_json_fixtures/shapes/18d405d3c15ae6e8.sql new file mode 100644 index 000000000000..17d24d585a2d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/18d405d3c15ae6e8.sql @@ -0,0 +1,10 @@ +WITH ( + SELECT max(i) + FROM t1 + ) AS value +SELECT + value AS i, + value AS j, + value AS k, + value AS l +FROM t1 diff --git a/tests/ast_json_fixtures/shapes/190ce5748e62e7e7.json b/tests/ast_json_fixtures/shapes/190ce5748e62e7e7.json new file mode 100644 index 000000000000..880a1dc9777f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/190ce5748e62e7e7.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_detach_attach_patches" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "APPLY_PATCHES", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/190ce5748e62e7e7.sql b/tests/ast_json_fixtures/shapes/190ce5748e62e7e7.sql new file mode 100644 index 000000000000..181562019460 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/190ce5748e62e7e7.sql @@ -0,0 +1 @@ +ALTER TABLE t_detach_attach_patches APPLY PATCHES IN PARTITION 0 diff --git a/tests/ast_json_fixtures/shapes/190f31f3714efb19.json b/tests/ast_json_fixtures/shapes/190f31f3714efb19.json new file mode 100644 index 000000000000..4f2454b46536 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/190f31f3714efb19.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "if_not_exists": true, + "function_name": { + "type": "Identifier", + "name": "02102_test_function" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/190f31f3714efb19.sql b/tests/ast_json_fixtures/shapes/190f31f3714efb19.sql new file mode 100644 index 000000000000..c20f83a00e41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/190f31f3714efb19.sql @@ -0,0 +1 @@ +CREATE FUNCTION IF NOT EXISTS 02102_test_function AS x -> x + 1 diff --git a/tests/ast_json_fixtures/shapes/193201c41e7223a4.json b/tests/ast_json_fixtures/shapes/193201c41e7223a4.json new file mode 100644 index 000000000000..398d95f8b85f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/193201c41e7223a4.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "rmt" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "0" + } + }, + "replace": true, + "from_table": "rmt2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/193201c41e7223a4.sql b/tests/ast_json_fixtures/shapes/193201c41e7223a4.sql new file mode 100644 index 000000000000..ee7bb029ce27 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/193201c41e7223a4.sql @@ -0,0 +1 @@ +alter table rmt replace partition id '0' from rmt2 diff --git a/tests/ast_json_fixtures/shapes/19642a20c9d9d08e.json b/tests/ast_json_fixtures/shapes/19642a20c9d9d08e.json new file mode 100644 index 000000000000..644a84fc8502 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/19642a20c9d9d08e.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "t2", + "to_table": "t1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/19642a20c9d9d08e.sql b/tests/ast_json_fixtures/shapes/19642a20c9d9d08e.sql new file mode 100644 index 000000000000..d862eca7860c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/19642a20c9d9d08e.sql @@ -0,0 +1 @@ +rename table t2 to t1 diff --git a/tests/ast_json_fixtures/shapes/196ff6bc089d82bc.json b/tests/ast_json_fixtures/shapes/196ff6bc089d82bc.json new file mode 100644 index 000000000000..524eb77c6409 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/196ff6bc089d82bc.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowSetting", + "setting_name": "max_threads' OR name = 'max_memory_usage" + } +} diff --git a/tests/ast_json_fixtures/shapes/196ff6bc089d82bc.sql b/tests/ast_json_fixtures/shapes/196ff6bc089d82bc.sql new file mode 100644 index 000000000000..b98ed8f91bd1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/196ff6bc089d82bc.sql @@ -0,0 +1 @@ +SHOW SETTING `max_threads' OR name = 'max_memory_usage` diff --git a/tests/ast_json_fixtures/shapes/197aead58e802802.json b/tests/ast_json_fixtures/shapes/197aead58e802802.json new file mode 100644 index 000000000000..eb4b492767a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/197aead58e802802.json @@ -0,0 +1,263 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "arr_s", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + }, + { + "type": "Function", + "alias": "arr_arr", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + }, + { + "type": "Function", + "alias": "arr_arr_s", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "y" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr_arr" + } + ] + }, + { + "type": "Function", + "alias": "arr_fs", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr_s" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/197aead58e802802.sql b/tests/ast_json_fixtures/shapes/197aead58e802802.sql new file mode 100644 index 000000000000..821baff4d29b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/197aead58e802802.sql @@ -0,0 +1,10 @@ +SELECT + number, + toString(number), + range(number) AS arr, + arrayMap(x -> toString(x), arr) AS arr_s, + arrayMap(x -> range(x), arr) AS arr_arr, + arrayMap(x -> arrayMap(y -> toString(y), x), arr_arr) AS arr_arr_s, + arrayMap(x -> toFixedString(x, 3), arr_s) AS arr_fs +FROM system.numbers +LIMIT 5, 10 diff --git a/tests/ast_json_fixtures/shapes/197e9516827c9d5f.json b/tests/ast_json_fixtures/shapes/197e9516827c9d5f.json new file mode 100644 index 000000000000..ec0de4b1c398 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/197e9516827c9d5f.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_part" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_not_found_column_nothing" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col001" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "_part" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "_part" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/197e9516827c9d5f.sql b/tests/ast_json_fixtures/shapes/197e9516827c9d5f.sql new file mode 100644 index 000000000000..42271ff2d223 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/197e9516827c9d5f.sql @@ -0,0 +1 @@ +SELECT _part, count() FROM test_not_found_column_nothing PREWHERE col001 % 3 != 0 GROUP BY _part ORDER BY _part diff --git a/tests/ast_json_fixtures/shapes/19ab6555bae6ad28.json b/tests/ast_json_fixtures/shapes/19ab6555bae6ad28.json new file mode 100644 index 000000000000..ba8c2205f0de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/19ab6555bae6ad28.json @@ -0,0 +1,225 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483647" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 1.0001 + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Identifier", + "name": "system" + }, + { + "type": "Identifier", + "name": "one" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "makeDateTime64", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "257" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "-1" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "0.2147483647" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "257" + } + ] + }, + { + "type": "Function", + "name": "makeDateTime64", + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "21474836.46" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "0.0000065535" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048577" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "922337203685477580.6" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 1.0001 + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65536" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/19ab6555bae6ad28.sql b/tests/ast_json_fixtures/shapes/19ab6555bae6ad28.sql new file mode 100644 index 000000000000..ec305e32d5a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/19ab6555bae6ad28.sql @@ -0,0 +1,9 @@ +SELECT + 2147483647, + count(pow(NULL, 1.0001)) +FROM remote(test_cluster_two_shards, system, one) +GROUP BY + makeDateTime64(NULL, NULL, pow(NULL, '257') - '-1', '0.2147483647', 257), + makeDateTime64(pow(pow(NULL, '21474836.46') - '0.0000065535', 1048577), '922337203685477580.6', NULL, NULL, pow(NULL, 1.0001) - 65536, NULL) +WITH CUBE + SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/19d244282519fda9.json b/tests/ast_json_fixtures/shapes/19d244282519fda9.json new file mode 100644 index 000000000000..ca5d341f0888 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/19d244282519fda9.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "limit_with_ties": true, + "select": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/19d244282519fda9.sql b/tests/ast_json_fixtures/shapes/19d244282519fda9.sql new file mode 100644 index 000000000000..69f4dfc937ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/19d244282519fda9.sql @@ -0,0 +1 @@ +SELECT () ORDER BY 1 LIMIT 1 WITH TIES diff --git a/tests/ast_json_fixtures/shapes/19fdee92a93025a1.json b/tests/ast_json_fixtures/shapes/19fdee92a93025a1.json new file mode 100644 index 000000000000..aa5a0391e82b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/19fdee92a93025a1.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "ColumnsRegexpMatcher", + "pattern": "d" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/19fdee92a93025a1.sql b/tests/ast_json_fixtures/shapes/19fdee92a93025a1.sql new file mode 100644 index 000000000000..b7a040f3cb8f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/19fdee92a93025a1.sql @@ -0,0 +1 @@ +SELECT COLUMNS('d') diff --git a/tests/ast_json_fixtures/shapes/1a191c2e1919a7c2.json b/tests/ast_json_fixtures/shapes/1a191c2e1919a7c2.json new file mode 100644 index 000000000000..578f4ff97b12 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a191c2e1919a7c2.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p1_01296", + "table": "table" + }, + { + "short_name": "p2_01296", + "table": "table" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1a191c2e1919a7c2.sql b/tests/ast_json_fixtures/shapes/1a191c2e1919a7c2.sql new file mode 100644 index 000000000000..9f94c484dc31 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a191c2e1919a7c2.sql @@ -0,0 +1 @@ +CREATE ROW POLICY p1_01296, p2_01296 ON table USING 1 diff --git a/tests/ast_json_fixtures/shapes/1a2086690a54c538.json b/tests/ast_json_fixtures/shapes/1a2086690a54c538.json new file mode 100644 index 000000000000..f90265c7ebe2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a2086690a54c538.json @@ -0,0 +1,119 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "shard_num", + "name": "any", + "arguments": [ + { + "type": "Identifier", + "name": "_shard_num" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "shard_num" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "distributed_group_by_no_merge": "2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1a2086690a54c538.sql b/tests/ast_json_fixtures/shapes/1a2086690a54c538.sql new file mode 100644 index 000000000000..4cf1e4cc8b5e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a2086690a54c538.sql @@ -0,0 +1 @@ +SELECT * FROM (SELECT any(_shard_num) shard_num, count(), uniq(dummy) FROM remote('127.0.0.{2,3}', system.one)) ORDER BY shard_num LIMIT 1, 1 SETTINGS distributed_group_by_no_merge=2 diff --git a/tests/ast_json_fixtures/shapes/1a4bbc88dd310a2b.json b/tests/ast_json_fixtures/shapes/1a4bbc88dd310a2b.json new file mode 100644 index 000000000000..4753255ea230 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a4bbc88dd310a2b.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "format": "TSV", + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "input", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "x UInt32" + } + ] + } + } + } + ] + } + } + ] + }, + "infile": { + "type": "Literal", + "value_type": "String", + "value": "data.file" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1a4bbc88dd310a2b.sql b/tests/ast_json_fixtures/shapes/1a4bbc88dd310a2b.sql new file mode 100644 index 000000000000..f505ec3e67aa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a4bbc88dd310a2b.sql @@ -0,0 +1 @@ +EXPLAIN SYNTAX INSERT INTO test FROM INFILE 'data.file' SELECT x from input('x UInt32') FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/1a553b505fcc41e6.json b/tests/ast_json_fixtures/shapes/1a553b505fcc41e6.json new file mode 100644 index 000000000000..bf111436db6e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a553b505fcc41e6.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1a553b505fcc41e6.sql b/tests/ast_json_fixtures/shapes/1a553b505fcc41e6.sql new file mode 100644 index 000000000000..c8afc7913364 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a553b505fcc41e6.sql @@ -0,0 +1,3 @@ +WITH + t as (SELECT sum(number) as x FROM numbers(10)) +SELECT t.* diff --git a/tests/ast_json_fixtures/shapes/1a9baa3c50ddf84c.json b/tests/ast_json_fixtures/shapes/1a9baa3c50ddf84c.json new file mode 100644 index 000000000000..b4afecabcd76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a9baa3c50ddf84c.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tmp_mv3" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "tmp_mv" + } +} diff --git a/tests/ast_json_fixtures/shapes/1a9baa3c50ddf84c.sql b/tests/ast_json_fixtures/shapes/1a9baa3c50ddf84c.sql new file mode 100644 index 000000000000..373a7f6f2051 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a9baa3c50ddf84c.sql @@ -0,0 +1 @@ +CREATE TABLE tmp_mv3 AS tmp_mv ENGINE = Memory diff --git a/tests/ast_json_fixtures/shapes/1a9d3aaa5d9944cd.json b/tests/ast_json_fixtures/shapes/1a9d3aaa5d9944cd.json new file mode 100644 index 000000000000..2360bb5614d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a9d3aaa5d9944cd.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "mem1" + } + ] + } + }, + "as_table": "mem1" + } +} diff --git a/tests/ast_json_fixtures/shapes/1a9d3aaa5d9944cd.sql b/tests/ast_json_fixtures/shapes/1a9d3aaa5d9944cd.sql new file mode 100644 index 000000000000..05b69eb3c63f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1a9d3aaa5d9944cd.sql @@ -0,0 +1 @@ +CREATE TABLE dist_1 AS mem1 Engine=Distributed(test_shard_localhost, currentDatabase(), mem1) diff --git a/tests/ast_json_fixtures/shapes/1ab4c4bc7b247332.json b/tests/ast_json_fixtures/shapes/1ab4c4bc7b247332.json new file mode 100644 index 000000000000..5e591b082b03 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1ab4c4bc7b247332.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u3_01292", + "host_pattern": "192.168.%.%" + } + ] + }, + "hosts": { + "like_patterns": ["192.168.%.%"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1ab4c4bc7b247332.sql b/tests/ast_json_fixtures/shapes/1ab4c4bc7b247332.sql new file mode 100644 index 000000000000..7fbf5b62743f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1ab4c4bc7b247332.sql @@ -0,0 +1 @@ +CREATE USER u3_01292@'192.168.%.%' diff --git a/tests/ast_json_fixtures/shapes/1aece719d37698e4.json b/tests/ast_json_fixtures/shapes/1aece719d37698e4.json new file mode 100644 index 000000000000..2f655718d958 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1aece719d37698e4.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ], + "format": "JSONCompactStringsEachRowWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/1aece719d37698e4.sql b/tests/ast_json_fixtures/shapes/1aece719d37698e4.sql new file mode 100644 index 000000000000..922fc98ac71f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1aece719d37698e4.sql @@ -0,0 +1 @@ +SELECT * FROM test_table FORMAT JSONCompactStringsEachRowWithNames diff --git a/tests/ast_json_fixtures/shapes/1b05f1ac4f848cb4.json b/tests/ast_json_fixtures/shapes/1b05f1ac4f848cb4.json new file mode 100644 index 000000000000..5292215abd15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b05f1ac4f848cb4.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "ExistsViewQuery", + "database": { + "type": "Identifier", + "name": "db_01048" + }, + "table": { + "type": "Identifier", + "name": "v_01048" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1b05f1ac4f848cb4.sql b/tests/ast_json_fixtures/shapes/1b05f1ac4f848cb4.sql new file mode 100644 index 000000000000..9cb1f941b6fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b05f1ac4f848cb4.sql @@ -0,0 +1 @@ +EXISTS VIEW db_01048.v_01048 diff --git a/tests/ast_json_fixtures/shapes/1b3e2bac212aaaaa.json b/tests/ast_json_fixtures/shapes/1b3e2bac212aaaaa.json new file mode 100644 index 000000000000..523f72fab13a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b3e2bac212aaaaa.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "alter": true, + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p2_01295", + "database": "db", + "table": "table" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1b3e2bac212aaaaa.sql b/tests/ast_json_fixtures/shapes/1b3e2bac212aaaaa.sql new file mode 100644 index 000000000000..8107772ea3bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b3e2bac212aaaaa.sql @@ -0,0 +1 @@ +ALTER POLICY p2_01295 ON db.table TO NONE diff --git a/tests/ast_json_fixtures/shapes/1b50776fb808788c.json b/tests/ast_json_fixtures/shapes/1b50776fb808788c.json new file mode 100644 index 000000000000..993c50f694e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b50776fb808788c.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t1" + } + }, + { + "type": "Identifier", + "name": "t1.dt", + "name_parts": ["t1", "dt"] + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t2" + } + }, + { + "type": "Identifier", + "name": "t2.dt", + "name_parts": ["t2", "dt"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.foo", + "name_parts": ["t1", "foo"] + }, + { + "type": "Identifier", + "name": "t2.bar", + "name_parts": ["t2", "bar"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.dt", + "name_parts": ["t2", "dt"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "2020-02-01" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1b50776fb808788c.sql b/tests/ast_json_fixtures/shapes/1b50776fb808788c.sql new file mode 100644 index 000000000000..78f2952b5304 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b50776fb808788c.sql @@ -0,0 +1 @@ +SELECT t1.*, t1.dt, t2.*, t2.dt FROM t1 JOIN t2 ON t1.foo = t2.bar WHERE t2.dt >= '2020-02-01' diff --git a/tests/ast_json_fixtures/shapes/1b578e0f7f2c2427.json b/tests/ast_json_fixtures/shapes/1b578e0f7f2c2427.json new file mode 100644 index 000000000000..b8160b6766da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b578e0f7f2c2427.json @@ -0,0 +1,119 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "column" + }, + { + "type": "Subquery", + "alias": "d", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "d", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + }, + { + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "TestTable" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "column" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "column" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1b578e0f7f2c2427.sql b/tests/ast_json_fixtures/shapes/1b578e0f7f2c2427.sql new file mode 100644 index 000000000000..d82f3199b3e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b578e0f7f2c2427.sql @@ -0,0 +1,5 @@ +SELECT column, +(SELECT d from (select [1, 2, 3, 4] as d)) as d +FROM TestTable +where column == 'test' +GROUP BY column diff --git a/tests/ast_json_fixtures/shapes/1b5db7cf35ec1899.json b/tests/ast_json_fixtures/shapes/1b5db7cf35ec1899.json new file mode 100644 index 000000000000..8a1164b1b1c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b5db7cf35ec1899.json @@ -0,0 +1,129 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "t1.x", + "name_parts": ["t1", "x"] + }, + { + "type": "Identifier", + "name": "t2.number", + "name_parts": ["t2", "number"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "CROSS" + }, + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "t2", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000000" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1b5db7cf35ec1899.sql b/tests/ast_json_fixtures/shapes/1b5db7cf35ec1899.sql new file mode 100644 index 000000000000..c9975f824cd1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b5db7cf35ec1899.sql @@ -0,0 +1,8 @@ +SELECT x, sum(number), count(), FROM ( + SELECT t1.x, t2.number + FROM t1 + CROSS JOIN numbers_mt(10_000_000) t2 + WHERE number <= x +) +GROUP BY ALL +ORDER BY x diff --git a/tests/ast_json_fixtures/shapes/1b6729013d8ff961.json b/tests/ast_json_fixtures/shapes/1b6729013d8ff961.json new file mode 100644 index 000000000000..b57f9ab9a6cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b6729013d8ff961.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "STOP DISTRIBUTED SENDS", + "database": { + "type": "Identifier", + "name": "db_01294" + }, + "table": { + "type": "Identifier", + "name": "dist_01294" + }, + "cluster": "test_shard_localhost" + } +} diff --git a/tests/ast_json_fixtures/shapes/1b6729013d8ff961.sql b/tests/ast_json_fixtures/shapes/1b6729013d8ff961.sql new file mode 100644 index 000000000000..3767d5a91389 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b6729013d8ff961.sql @@ -0,0 +1 @@ +system stop distributed sends on cluster test_shard_localhost db_01294.dist_01294 diff --git a/tests/ast_json_fixtures/shapes/1b7344670b7f4ab6.json b/tests/ast_json_fixtures/shapes/1b7344670b7f4ab6.json new file mode 100644 index 000000000000..b35221c4e18c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b7344670b7f4ab6.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_database": "test_01191", + "from_table": "dict", + "to_database": "test_01191", + "to_table": "t" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1b7344670b7f4ab6.sql b/tests/ast_json_fixtures/shapes/1b7344670b7f4ab6.sql new file mode 100644 index 000000000000..65aa98d67ad0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b7344670b7f4ab6.sql @@ -0,0 +1 @@ +EXCHANGE TABLES test_01191.dict AND test_01191.t diff --git a/tests/ast_json_fixtures/shapes/1b7ad25db3d3b423.json b/tests/ast_json_fixtures/shapes/1b7ad25db3d3b423.json new file mode 100644 index 000000000000..9e7681d0c256 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b7ad25db3d3b423.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_shard_localhost", + "table": { + "type": "Identifier", + "name": "t_l5ydey" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "local_t_l5ydey" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "local_t_l5ydey" + } +} diff --git a/tests/ast_json_fixtures/shapes/1b7ad25db3d3b423.sql b/tests/ast_json_fixtures/shapes/1b7ad25db3d3b423.sql new file mode 100644 index 000000000000..649390356d95 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b7ad25db3d3b423.sql @@ -0,0 +1,2 @@ +create table t_l5ydey on cluster test_shard_localhost as local_t_l5ydey + engine=Distributed('test_shard_localhost', currentDatabase(),'local_t_l5ydey', rand()) diff --git a/tests/ast_json_fixtures/shapes/1b7f00fe5e67d8b4.json b/tests/ast_json_fixtures/shapes/1b7f00fe5e67d8b4.json new file mode 100644 index 000000000000..d34ba7dc7590 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b7f00fe5e67d8b4.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r2_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "parent_profile": "default" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1b7f00fe5e67d8b4.sql b/tests/ast_json_fixtures/shapes/1b7f00fe5e67d8b4.sql new file mode 100644 index 000000000000..f7c35a5ffecf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1b7f00fe5e67d8b4.sql @@ -0,0 +1 @@ +CREATE ROLE r2_01293 SETTINGS PROFILE 'default' diff --git a/tests/ast_json_fixtures/shapes/1ba21af5d0aeb6f5.json b/tests/ast_json_fixtures/shapes/1ba21af5d0aeb6f5.json new file mode 100644 index 000000000000..0136e4078233 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1ba21af5d0aeb6f5.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "dst" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1ba21af5d0aeb6f5.sql b/tests/ast_json_fixtures/shapes/1ba21af5d0aeb6f5.sql new file mode 100644 index 000000000000..a838166d6208 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1ba21af5d0aeb6f5.sql @@ -0,0 +1 @@ +ALTER TABLE dst DROP PARTITION 1 diff --git a/tests/ast_json_fixtures/shapes/1bd054695bbc2547.json b/tests/ast_json_fixtures/shapes/1bd054695bbc2547.json new file mode 100644 index 000000000000..29f38db9fd50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1bd054695bbc2547.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + } + } + } + ] + } + } + ], + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/1bd054695bbc2547.sql b/tests/ast_json_fixtures/shapes/1bd054695bbc2547.sql new file mode 100644 index 000000000000..ad4124648bfb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1bd054695bbc2547.sql @@ -0,0 +1 @@ +SELECT sleep(0.01), number FROM numbers(11) FORMAT PrettySpace diff --git a/tests/ast_json_fixtures/shapes/1bda728d19905e97.json b/tests/ast_json_fixtures/shapes/1bda728d19905e97.json new file mode 100644 index 000000000000..4d37812478dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1bda728d19905e97.json @@ -0,0 +1,218 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 10000000000 + }, + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_having" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "c0" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1bda728d19905e97.sql b/tests/ast_json_fixtures/shapes/1bda728d19905e97.sql new file mode 100644 index 000000000000..8cfbd40cbc92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1bda728d19905e97.sql @@ -0,0 +1,10 @@ +SELECT + c0 + -1, + sum(intDivOrZero(intDivOrZero(NULL, NULL), '2'), intDivOrZero(10000000000., intDivOrZero(intDivOrZero(intDivOrZero(NULL, NULL), 10), NULL))) +FROM t_having +GROUP BY + c0 = 2, + c0 = 10, + intDivOrZero(intDivOrZero(intDivOrZero(NULL, NULL), NULL), NULL), + c0 +HAVING c0 = 2 diff --git a/tests/ast_json_fixtures/shapes/1be6cebe272bf93b.json b/tests/ast_json_fixtures/shapes/1be6cebe272bf93b.json new file mode 100644 index 000000000000..4753630d0b6d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1be6cebe272bf93b.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ExistsViewQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "tview_basic" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1be6cebe272bf93b.sql b/tests/ast_json_fixtures/shapes/1be6cebe272bf93b.sql new file mode 100644 index 000000000000..2f82fdcde019 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1be6cebe272bf93b.sql @@ -0,0 +1 @@ +EXISTS TEMPORARY VIEW tview_basic diff --git a/tests/ast_json_fixtures/shapes/1bf6de7052a87993.json b/tests/ast_json_fixtures/shapes/1bf6de7052a87993.json new file mode 100644 index 000000000000..20cafa95bb33 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1bf6de7052a87993.json @@ -0,0 +1,138 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lc_00931" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50000" + } + ] + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "has", + "arguments": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "8192", + "max_threads": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1bf6de7052a87993.sql b/tests/ast_json_fixtures/shapes/1bf6de7052a87993.sql new file mode 100644 index 000000000000..8efd222f21bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1bf6de7052a87993.sql @@ -0,0 +1,7 @@ +SELECT * FROM lc_00931 +WHERE (key < 100 OR key > 50000) + AND NOT has(value, toString(key)) + AND length(value) == 1 +LIMIT 10 +SETTINGS max_block_size = 8192, + max_threads = 1 diff --git a/tests/ast_json_fixtures/shapes/1c2461e4c97e8dcc.json b/tests/ast_json_fixtures/shapes/1c2461e4c97e8dcc.json new file mode 100644 index 000000000000..0d873ab36256 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c2461e4c97e8dcc.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "03221_rmv" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "rand64", + "arguments": [] + } + ] + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } + ] + }, + "refresh": { + "type": "RefreshStrategy", + "schedule_kind": "AFTER", + "period": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Second", + "value": "10" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1c2461e4c97e8dcc.sql b/tests/ast_json_fixtures/shapes/1c2461e4c97e8dcc.sql new file mode 100644 index 000000000000..ad7d360d9252 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c2461e4c97e8dcc.sql @@ -0,0 +1,10 @@ +CREATE MATERIALIZED VIEW 03221_rmv +REFRESH AFTER 10 SECOND +( +x UInt64 +) +ENGINE = Memory +AS SELECT number AS x +FROM numbers(3) +UNION ALL +SELECT rand64() AS x diff --git a/tests/ast_json_fixtures/shapes/1c3ba3a760dce1de.json b/tests/ast_json_fixtures/shapes/1c3ba3a760dce1de.json new file mode 100644 index 000000000000..5935972e2443 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c3ba3a760dce1de.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_all": true, + "order_by_all": true, + "select": [ + { + "type": "Function", + "alias": "isEven", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "Bool", + "value": true + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "localhos{t,t,t}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1c3ba3a760dce1de.sql b/tests/ast_json_fixtures/shapes/1c3ba3a760dce1de.sql new file mode 100644 index 000000000000..0ed9f785b56b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c3ba3a760dce1de.sql @@ -0,0 +1 @@ +SELECT ((number % 2) = 0) = true AS isEven FROM remote('localhos{t,t,t}', numbers(10)) GROUP BY all ORDER BY all diff --git a/tests/ast_json_fixtures/shapes/1c4ffdfc59751938.json b/tests/ast_json_fixtures/shapes/1c4ffdfc59751938.json new file mode 100644 index 000000000000..6c3dc35e4e37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c4ffdfc59751938.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "l", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l.id", + "name_parts": ["l", "id"] + }, + { + "type": "Identifier", + "name": "r.id", + "name_parts": ["r", "id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "r", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "r.x", + "name_parts": ["r", "x"] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1c4ffdfc59751938.sql b/tests/ast_json_fixtures/shapes/1c4ffdfc59751938.sql new file mode 100644 index 000000000000..2379c4157972 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c4ffdfc59751938.sql @@ -0,0 +1 @@ +select 2 from t as l join t as r on l.id = r.id where r.x diff --git a/tests/ast_json_fixtures/shapes/1c6be20d62950c20.json b/tests/ast_json_fixtures/shapes/1c6be20d62950c20.json new file mode 100644 index 000000000000..b4029ee32ad7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c6be20d62950c20.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "name", + "name": "concat", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "name_" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + } + ], + "format": "JSONObjectEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/1c6be20d62950c20.sql b/tests/ast_json_fixtures/shapes/1c6be20d62950c20.sql new file mode 100644 index 000000000000..8e4adeeae57c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c6be20d62950c20.sql @@ -0,0 +1 @@ +select concat('name_', toString(number)) as name, number from numbers(3) format JSONObjectEachRow diff --git a/tests/ast_json_fixtures/shapes/1c83ad394a04ed8a.json b/tests/ast_json_fixtures/shapes/1c83ad394a04ed8a.json new file mode 100644 index 000000000000..864ba081e977 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c83ad394a04ed8a.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "alias": "q", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "URLHierarchy", + "arguments": [ + { + "type": "Identifier", + "name": "URL" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "alias": "w", + "value_type": "String", + "value": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "14917930" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "URL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1c83ad394a04ed8a.sql b/tests/ast_json_fixtures/shapes/1c83ad394a04ed8a.sql new file mode 100644 index 000000000000..6b18425237fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c83ad394a04ed8a.sql @@ -0,0 +1 @@ +SELECT DISTINCT (URLHierarchy(URL)[1]) AS q, 'x' AS w FROM test.hits WHERE CounterID = 14917930 ORDER BY URL diff --git a/tests/ast_json_fixtures/shapes/1c8d57e1249d0945.json b/tests/ast_json_fixtures/shapes/1c8d57e1249d0945.json new file mode 100644 index 000000000000..2a1dd4ae1263 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c8d57e1249d0945.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateTableQuery", + "table": { + "type": "Identifier", + "name": "x" + }, + "format": "TSVRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/1c8d57e1249d0945.sql b/tests/ast_json_fixtures/shapes/1c8d57e1249d0945.sql new file mode 100644 index 000000000000..e6bbfd1d534a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1c8d57e1249d0945.sql @@ -0,0 +1 @@ +SHOW CREATE TABLE x FORMAT TSVRaw diff --git a/tests/ast_json_fixtures/shapes/1cbd7fc9a1e06f16.json b/tests/ast_json_fixtures/shapes/1cbd7fc9a1e06f16.json new file mode 100644 index 000000000000..f6fa605edce0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1cbd7fc9a1e06f16.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH ASYNC INSERT QUEUE", + "tables": [ + { + "table": "03717_table" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1cbd7fc9a1e06f16.sql b/tests/ast_json_fixtures/shapes/1cbd7fc9a1e06f16.sql new file mode 100644 index 000000000000..0cd994135799 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1cbd7fc9a1e06f16.sql @@ -0,0 +1 @@ +SYSTEM FLUSH ASYNC INSERT QUEUE 03717_table diff --git a/tests/ast_json_fixtures/shapes/1ce035af716f8b6a.json b/tests/ast_json_fixtures/shapes/1ce035af716f8b6a.json new file mode 100644 index 000000000000..740d13d31132 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1ce035af716f8b6a.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "value", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "String", + "value": "Value" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple (id UInt64, value String)" + } + ] + }, + { + "type": "QualifiedColumnsListMatcher", + "qualifier": { + "type": "Identifier", + "name": "value" + }, + "columns": [ + { + "type": "Identifier", + "name": "id" + } + ], + "transformers": { + "type": "ColumnsTransformerList", + "children": [ + { + "type": "ColumnsApplyTransformer", + "func_name": "toString" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1ce035af716f8b6a.sql b/tests/ast_json_fixtures/shapes/1ce035af716f8b6a.sql new file mode 100644 index 000000000000..112307d8fe38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1ce035af716f8b6a.sql @@ -0,0 +1 @@ +SELECT cast((1, 'Value'), 'Tuple (id UInt64, value String)') AS value, value.COLUMNS(id) APPLY toString diff --git a/tests/ast_json_fixtures/shapes/1cf1e43ef35ff1a6.json b/tests/ast_json_fixtures/shapes/1cf1e43ef35ff1a6.json new file mode 100644 index 000000000000..5c7338d9908d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1cf1e43ef35ff1a6.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1cf1e43ef35ff1a6.sql b/tests/ast_json_fixtures/shapes/1cf1e43ef35ff1a6.sql new file mode 100644 index 000000000000..1f9f544f963d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1cf1e43ef35ff1a6.sql @@ -0,0 +1 @@ +SELECT 1 UNION DISTINCT SELECT 1 UNION ALL SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/1d087653cf3f6f17.json b/tests/ast_json_fixtures/shapes/1d087653cf3f6f17.json new file mode 100644 index 000000000000..3ca936befa29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1d087653cf3f6f17.json @@ -0,0 +1,110 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "is_dictionary": true, + "database": { + "type": "Identifier", + "name": "dictdb_01376" + }, + "table": { + "type": "Identifier", + "name": "dict_exists" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "key_column", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "Float64" + }, + "default_value": { + "type": "Literal", + "value_type": "Float64", + "value": 77.77 + }, + "injective": true + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "key_column" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "user", + "value": { + "type": "Literal", + "value_type": "String", + "value": "default" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "table_for_dict" + } + }, + { + "type": "pair", + "key": "db", + "value": { + "type": "Literal", + "value_type": "String", + "value": "dictdb_01376" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 1 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1d087653cf3f6f17.sql b/tests/ast_json_fixtures/shapes/1d087653cf3f6f17.sql new file mode 100644 index 000000000000..ff3e660e89ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1d087653cf3f6f17.sql @@ -0,0 +1,9 @@ +CREATE DICTIONARY IF NOT EXISTS dictdb_01376.dict_exists +( + key_column UInt64, + value Float64 DEFAULT 77.77 INJECTIVE +) +PRIMARY KEY key_column +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' DB 'dictdb_01376')) +LIFETIME(1) +LAYOUT(FLAT()) diff --git a/tests/ast_json_fixtures/shapes/1d1b5197c3e509d7.json b/tests/ast_json_fixtures/shapes/1d1b5197c3e509d7.json new file mode 100644 index 000000000000..4319845986f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1d1b5197c3e509d7.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u13_01292" + } + ] + }, + "hosts": { + "subnets": ["192.168.0.0\/16"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1d1b5197c3e509d7.sql b/tests/ast_json_fixtures/shapes/1d1b5197c3e509d7.sql new file mode 100644 index 000000000000..988b6d3dab2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1d1b5197c3e509d7.sql @@ -0,0 +1 @@ +CREATE USER u13_01292 HOST IP '192.168.0.0/16' diff --git a/tests/ast_json_fixtures/shapes/1d5e7d39a0024c9b.json b/tests/ast_json_fixtures/shapes/1d5e7d39a0024c9b.json new file mode 100644 index 000000000000..ed5b4c5aeaf1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1d5e7d39a0024c9b.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "STOP MERGES", + "table": { + "type": "Identifier", + "name": "t" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1d5e7d39a0024c9b.sql b/tests/ast_json_fixtures/shapes/1d5e7d39a0024c9b.sql new file mode 100644 index 000000000000..2af980aaedec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1d5e7d39a0024c9b.sql @@ -0,0 +1 @@ +SYSTEM STOP MERGES t diff --git a/tests/ast_json_fixtures/shapes/1d758cd8c873553d.json b/tests/ast_json_fixtures/shapes/1d758cd8c873553d.json new file mode 100644 index 000000000000..c9312a27dbfe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1d758cd8c873553d.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d.UInt64", + "name_parts": ["d", "UInt64"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1d758cd8c873553d.sql b/tests/ast_json_fixtures/shapes/1d758cd8c873553d.sql new file mode 100644 index 000000000000..cca936127990 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1d758cd8c873553d.sql @@ -0,0 +1 @@ +select d.UInt64 from test settings enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/1d94eb9a3ec575de.json b/tests/ast_json_fixtures/shapes/1d94eb9a3ec575de.json new file mode 100644 index 000000000000..21c7adfdb531 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1d94eb9a3ec575de.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "'" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1d94eb9a3ec575de.sql b/tests/ast_json_fixtures/shapes/1d94eb9a3ec575de.sql new file mode 100644 index 000000000000..f3e164684339 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1d94eb9a3ec575de.sql @@ -0,0 +1 @@ +CREATE DATABASE `'` diff --git a/tests/ast_json_fixtures/shapes/1da0f5878a71de54.json b/tests/ast_json_fixtures/shapes/1da0f5878a71de54.json new file mode 100644 index 000000000000..3d5b9b4fceb9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1da0f5878a71de54.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "primary_key_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "v1", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "v2", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ], + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1da0f5878a71de54.sql b/tests/ast_json_fixtures/shapes/1da0f5878a71de54.sql new file mode 100644 index 000000000000..2d46e3ddb213 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1da0f5878a71de54.sql @@ -0,0 +1 @@ +CREATE TABLE primary_key_test(v1 Int32, v2 Int32, PRIMARY KEY(v1, v2)) ENGINE=ReplacingMergeTree ORDER BY (v1, v2) diff --git a/tests/ast_json_fixtures/shapes/1da585ed8bf46bb3.json b/tests/ast_json_fixtures/shapes/1da585ed8bf46bb3.json new file mode 100644 index 000000000000..71207ac49d20 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1da585ed8bf46bb3.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "restore_01640" + }, + "settings": { + "type": "Settings", + "changes": { + "insert_keeper_fault_injection_probability": "0" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "FETCH_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2021-01-01" + } + ] + } + ] + } + ] + } + }, + "from": "\/clickhouse\/{database}\/{shard}\/tables\/test_01640" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1da585ed8bf46bb3.sql b/tests/ast_json_fixtures/shapes/1da585ed8bf46bb3.sql new file mode 100644 index 000000000000..507ff3d60d32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1da585ed8bf46bb3.sql @@ -0,0 +1,2 @@ +ALTER TABLE restore_01640 FETCH PARTITION tuple(toYYYYMM(toDate('2021-01-01'))) + FROM '/clickhouse/{database}/{shard}/tables/test_01640' SETTINGS insert_keeper_fault_injection_probability=0 diff --git a/tests/ast_json_fixtures/shapes/1db096752e665dff.json b/tests/ast_json_fixtures/shapes/1db096752e665dff.json new file mode 100644 index 000000000000..883145065d57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1db096752e665dff.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettySpaceNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/1db096752e665dff.sql b/tests/ast_json_fixtures/shapes/1db096752e665dff.sql new file mode 100644 index 000000000000..8c738f3a0712 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1db096752e665dff.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettySpaceNoEscapes diff --git a/tests/ast_json_fixtures/shapes/1e131399f93a9068.json b/tests/ast_json_fixtures/shapes/1e131399f93a9068.json new file mode 100644 index 000000000000..4c64a07d7a3e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e131399f93a9068.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "date_time", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2020-06-16 03:00:00" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "date_time" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "date_time" + }, + "direction": "ASC", + "with_fill": true, + "fill_from": { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2020-06-16 00:00:00" + } + ] + }, + "fill_to": { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2020-06-16 10:00:00" + } + ] + }, + "fill_step": { + "type": "Literal", + "value_type": "UInt64", + "value": "1800" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1e131399f93a9068.sql b/tests/ast_json_fixtures/shapes/1e131399f93a9068.sql new file mode 100644 index 000000000000..66a8893b97d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e131399f93a9068.sql @@ -0,0 +1,6 @@ +WITH toDateTime('2020-06-16 03:00:00') AS date_time +SELECT date_time ORDER BY date_time ASC +WITH FILL + FROM toDateTime('2020-06-16 00:00:00') + TO toDateTime('2020-06-16 10:00:00') + STEP 1800 diff --git a/tests/ast_json_fixtures/shapes/1e1525e3e3f8f887.json b/tests/ast_json_fixtures/shapes/1e1525e3e3f8f887.json new file mode 100644 index 000000000000..82f8529063ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e1525e3e3f8f887.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r2_01293_renamed"] + } +} diff --git a/tests/ast_json_fixtures/shapes/1e1525e3e3f8f887.sql b/tests/ast_json_fixtures/shapes/1e1525e3e3f8f887.sql new file mode 100644 index 000000000000..07784c37adc1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e1525e3e3f8f887.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r2_01293_renamed diff --git a/tests/ast_json_fixtures/shapes/1e289adaea3eb8c9.json b/tests/ast_json_fixtures/shapes/1e289adaea3eb8c9.json new file mode 100644 index 000000000000..ae6d63bc29f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e289adaea3eb8c9.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "avg", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ], + "window_definition": { + "type": "WindowDefinition" + } + }, + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_window_functions": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1e289adaea3eb8c9.sql b/tests/ast_json_fixtures/shapes/1e289adaea3eb8c9.sql new file mode 100644 index 000000000000..1f862082ccd8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e289adaea3eb8c9.sql @@ -0,0 +1 @@ +SELECT avg(a) OVER () AS a, id FROM test SETTINGS allow_experimental_window_functions = 1 diff --git a/tests/ast_json_fixtures/shapes/1e2f77dddc1bd9d1.json b/tests/ast_json_fixtures/shapes/1e2f77dddc1bd9d1.json new file mode 100644 index 000000000000..c66ea1c42360 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e2f77dddc1bd9d1.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "topKResampleState", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048576" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "257" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65536" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + } + ], + "format": "Parquet" + } +} diff --git a/tests/ast_json_fixtures/shapes/1e2f77dddc1bd9d1.sql b/tests/ast_json_fixtures/shapes/1e2f77dddc1bd9d1.sql new file mode 100644 index 000000000000..4ecc5c78ebae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e2f77dddc1bd9d1.sql @@ -0,0 +1,4 @@ +SELECT + topKResampleState(1048576, 257, 65536, 10)(toString(number), number) +FROM numbers(3) +FORMAT Parquet diff --git a/tests/ast_json_fixtures/shapes/1e380fe229bd9934.json b/tests/ast_json_fixtures/shapes/1e380fe229bd9934.json new file mode 100644 index 000000000000..c5541342cbaf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e380fe229bd9934.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "timezone", + "value_type": "String", + "value": "UTC" + } + ], + "select": [ + { + "type": "Identifier", + "name": "timezone" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "timeZoneOf", + "arguments": [ + { + "type": "Function", + "name": "now64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Identifier", + "name": "timezone" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "timezone" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1e380fe229bd9934.sql b/tests/ast_json_fixtures/shapes/1e380fe229bd9934.sql new file mode 100644 index 000000000000..21d0b8cbbe68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e380fe229bd9934.sql @@ -0,0 +1 @@ +WITH 'UTC' as timezone SELECT timezone, timeZoneOf(now64(3, timezone)) == timezone diff --git a/tests/ast_json_fixtures/shapes/1e466fa8604a478a.json b/tests/ast_json_fixtures/shapes/1e466fa8604a478a.json new file mode 100644 index 000000000000..f343484ef4e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e466fa8604a478a.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u5_01292", + "host_pattern": "65:ff0c::\/96" + } + ] + }, + "hosts": { + "like_patterns": ["65:ff0c::\/96"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1e466fa8604a478a.sql b/tests/ast_json_fixtures/shapes/1e466fa8604a478a.sql new file mode 100644 index 000000000000..8ae5a717e7fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e466fa8604a478a.sql @@ -0,0 +1 @@ +CREATE USER u5_01292@'65:ff0c::/96' diff --git a/tests/ast_json_fixtures/shapes/1e654c7f9c1a5bc5.json b/tests/ast_json_fixtures/shapes/1e654c7f9c1a5bc5.json new file mode 100644 index 000000000000..5620ead8f746 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e654c7f9c1a5bc5.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "tuple", + "is_operator": true, + "arguments": [] + }, + { + "type": "Function", + "alias": "b", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1e654c7f9c1a5bc5.sql b/tests/ast_json_fixtures/shapes/1e654c7f9c1a5bc5.sql new file mode 100644 index 000000000000..8e727948b30e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e654c7f9c1a5bc5.sql @@ -0,0 +1 @@ +create table x engine MergeTree order by () as select () as a, () as b diff --git a/tests/ast_json_fixtures/shapes/1e6998b57a36f87a.json b/tests/ast_json_fixtures/shapes/1e6998b57a36f87a.json new file mode 100644 index 000000000000..5254593570e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e6998b57a36f87a.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u15_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/1e6998b57a36f87a.sql b/tests/ast_json_fixtures/shapes/1e6998b57a36f87a.sql new file mode 100644 index 000000000000..b0e62a032737 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e6998b57a36f87a.sql @@ -0,0 +1 @@ +SHOW CREATE USER u15_01292 diff --git a/tests/ast_json_fixtures/shapes/1e6f58da0868209a.json b/tests/ast_json_fixtures/shapes/1e6f58da0868209a.json new file mode 100644 index 000000000000..84a4b498b391 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e6f58da0868209a.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "03783_autopr_dataflow_cache_reuse_query_0" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/1e6f58da0868209a.sql b/tests/ast_json_fixtures/shapes/1e6f58da0868209a.sql new file mode 100644 index 000000000000..9fb18b952c3c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e6f58da0868209a.sql @@ -0,0 +1 @@ +SELECT SUM(value) FROM t FORMAT Null SETTINGS log_comment='03783_autopr_dataflow_cache_reuse_query_0' diff --git a/tests/ast_json_fixtures/shapes/1e7073e029c27a6b.json b/tests/ast_json_fixtures/shapes/1e7073e029c27a6b.json new file mode 100644 index 000000000000..8a9385699c22 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e7073e029c27a6b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "slowdown_parallel_replicas_local_plan_read" + } +} diff --git a/tests/ast_json_fixtures/shapes/1e7073e029c27a6b.sql b/tests/ast_json_fixtures/shapes/1e7073e029c27a6b.sql new file mode 100644 index 000000000000..2a7c47c18422 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1e7073e029c27a6b.sql @@ -0,0 +1 @@ +SYSTEM ENABLE FAILPOINT slowdown_parallel_replicas_local_plan_read diff --git a/tests/ast_json_fixtures/shapes/1ea6e1d583e4fc04.json b/tests/ast_json_fixtures/shapes/1ea6e1d583e4fc04.json new file mode 100644 index 000000000000..f33943bb66cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1ea6e1d583e4fc04.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "hierarchy_flat_dictionary_index" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "parent_id", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "bidirectional": true + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "test_hierarchy_source_table" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 0 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1ea6e1d583e4fc04.sql b/tests/ast_json_fixtures/shapes/1ea6e1d583e4fc04.sql new file mode 100644 index 000000000000..e681c9e5613d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1ea6e1d583e4fc04.sql @@ -0,0 +1,9 @@ +CREATE DICTIONARY hierarchy_flat_dictionary_index +( + id UInt64, + parent_id UInt64 BIDIRECTIONAL +) +PRIMARY KEY id +SOURCE(CLICKHOUSE(TABLE 'test_hierarchy_source_table')) +LAYOUT(FLAT()) +LIFETIME(0) diff --git a/tests/ast_json_fixtures/shapes/1eb9e66604dc0a11.json b/tests/ast_json_fixtures/shapes/1eb9e66604dc0a11.json new file mode 100644 index 000000000000..7ef07b674e85 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1eb9e66604dc0a11.json @@ -0,0 +1,110 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "loanx_id" + }, + { + "type": "Identifier", + "name": "rating_sp" + }, + { + "type": "Identifier", + "name": "cdu_date" + }, + { + "type": "Function", + "alias": "row_number", + "name": "row_number", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "cdu_date" + } + ] + } + }, + { + "type": "Function", + "alias": "last_cdu_date", + "name": "last_value", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "cdu_date" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "loanx_id" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "cdu_date" + }, + "direction": "ASC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "atable" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "cdu_date" + }, + { + "type": "Identifier", + "name": "loanx_id" + }, + { + "type": "Identifier", + "name": "rating_sp" + } + ], + "settings": { + "type": "Settings", + "changes": { + "query_plan_remove_redundant_distinct": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1eb9e66604dc0a11.sql b/tests/ast_json_fixtures/shapes/1eb9e66604dc0a11.sql new file mode 100644 index 000000000000..ebbaeb18e9db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1eb9e66604dc0a11.sql @@ -0,0 +1,12 @@ +SELECT DISTINCT + loanx_id, + rating_sp, + cdu_date, + row_number() OVER (PARTITION BY cdu_date) AS row_number, + last_value(cdu_date) OVER (PARTITION BY loanx_id ORDER BY cdu_date ASC) AS last_cdu_date +FROM atable +GROUP BY + cdu_date, + loanx_id, + rating_sp +SETTINGS query_plan_remove_redundant_distinct = 1 diff --git a/tests/ast_json_fixtures/shapes/1ebc7dabb7703e7f.json b/tests/ast_json_fixtures/shapes/1ebc7dabb7703e7f.json new file mode 100644 index 000000000000..d268ff0ab1c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1ebc7dabb7703e7f.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s6_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "writability": "CONST" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1ebc7dabb7703e7f.sql b/tests/ast_json_fixtures/shapes/1ebc7dabb7703e7f.sql new file mode 100644 index 000000000000..e9cd19c2192e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1ebc7dabb7703e7f.sql @@ -0,0 +1 @@ +CREATE PROFILE s6_01294 SETTINGS max_memory_usage CONST diff --git a/tests/ast_json_fixtures/shapes/1edba54019b3a8c4.json b/tests/ast_json_fixtures/shapes/1edba54019b3a8c4.json new file mode 100644 index 000000000000..d3b64ad2acbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1edba54019b3a8c4.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1edba54019b3a8c4.sql b/tests/ast_json_fixtures/shapes/1edba54019b3a8c4.sql new file mode 100644 index 000000000000..a2c1a4951eb8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1edba54019b3a8c4.sql @@ -0,0 +1 @@ +SELECT DISTINCT ON (a, b) a, b, c FROM t1 diff --git a/tests/ast_json_fixtures/shapes/1edeb4cbe13a5124.json b/tests/ast_json_fixtures/shapes/1edeb4cbe13a5124.json new file mode 100644 index 000000000000..a9d405bb15c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1edeb4cbe13a5124.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "pk_test18" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "String" + }, + "primary_key_specifier": true + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "c", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "primary_key_from_columns": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + }, + "storage": { + "type": "Storage", + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1edeb4cbe13a5124.sql b/tests/ast_json_fixtures/shapes/1edeb4cbe13a5124.sql new file mode 100644 index 000000000000..b7adbbcecc3d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1edeb4cbe13a5124.sql @@ -0,0 +1 @@ +CREATE TABLE pk_test18 (a String PRIMARY KEY, b String, c String) ORDER BY (a,b,c) diff --git a/tests/ast_json_fixtures/shapes/1efe29cad4620a95.json b/tests/ast_json_fixtures/shapes/1efe29cad4620a95.json new file mode 100644 index 000000000000..71cba0006167 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1efe29cad4620a95.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_ordinary", + "from_table": "dst", + "to_database": "test_01155_atomic", + "to_table": "dst" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1efe29cad4620a95.sql b/tests/ast_json_fixtures/shapes/1efe29cad4620a95.sql new file mode 100644 index 000000000000..ea86e0009cb8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1efe29cad4620a95.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_ordinary.dst TO test_01155_atomic.dst diff --git a/tests/ast_json_fixtures/shapes/1f0584816f9a3581.json b/tests/ast_json_fixtures/shapes/1f0584816f9a3581.json new file mode 100644 index 000000000000..be5b00bb9b24 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f0584816f9a3581.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Function", + "name": "toInt8", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "alias": "cast", + "name": "CAST", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Enum8('Hello' = -100, '\\\\' = 0, '\\t\\\\t' = 111)" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "enum" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "y" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/1f0584816f9a3581.sql b/tests/ast_json_fixtures/shapes/1f0584816f9a3581.sql new file mode 100644 index 000000000000..4f57bf114542 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f0584816f9a3581.sql @@ -0,0 +1 @@ +SELECT x, y, toInt8(x), toString(x) AS s, CAST(s AS Enum8('Hello' = -100, '\\' = 0, '\t\\t' = 111)) AS cast FROM enum ORDER BY x, y FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/1f21d056aa6ed3b9.json b/tests/ast_json_fixtures/shapes/1f21d056aa6ed3b9.json new file mode 100644 index 000000000000..1ce9a6ab558d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f21d056aa6ed3b9.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "offset", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + { + "type": "Literal", + "alias": "length", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "Hello" + }, + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Function", + "name": "bin", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "length" + } + ] + }, + { + "type": "Function", + "name": "bin", + "arguments": [ + { + "type": "Function", + "name": "bitSlice", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "length" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1f21d056aa6ed3b9.sql b/tests/ast_json_fixtures/shapes/1f21d056aa6ed3b9.sql new file mode 100644 index 000000000000..dca50e588ecf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f21d056aa6ed3b9.sql @@ -0,0 +1 @@ +select number-8 as offset, 8 as length, 'Hello' as s, subString(bin(s), offset , length), bin(bitSlice(s, offset, length)) from numbers(9) diff --git a/tests/ast_json_fixtures/shapes/1f221b3d82e93a56.json b/tests/ast_json_fixtures/shapes/1f221b3d82e93a56.json new file mode 100644 index 000000000000..4281a78e2d33 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f221b3d82e93a56.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "ids", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "bbb" + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "aaa" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "has", + "arguments": [ + { + "type": "Identifier", + "name": "ids" + }, + { + "type": "Identifier", + "name": "id" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1f221b3d82e93a56.sql b/tests/ast_json_fixtures/shapes/1f221b3d82e93a56.sql new file mode 100644 index 000000000000..8c02568a391a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f221b3d82e93a56.sql @@ -0,0 +1,5 @@ +with (select groupArray(id) from bbb) as ids +select * + from aaa + where has(ids, id) +order by id diff --git a/tests/ast_json_fixtures/shapes/1f24be8b44cf8524.json b/tests/ast_json_fixtures/shapes/1f24be8b44cf8524.json new file mode 100644 index 000000000000..4315910978df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f24be8b44cf8524.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-02-29" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Date" + } + ] + } + ] + } + ], + "format": "PrettyNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/1f24be8b44cf8524.sql b/tests/ast_json_fixtures/shapes/1f24be8b44cf8524.sql new file mode 100644 index 000000000000..22c0ba37c7e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f24be8b44cf8524.sql @@ -0,0 +1 @@ +SELECT '2024-02-29'::Date FORMAT PrettyNoEscapes diff --git a/tests/ast_json_fixtures/shapes/1f7094ded3821284.json b/tests/ast_json_fixtures/shapes/1f7094ded3821284.json new file mode 100644 index 000000000000..1169dfd562ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f7094ded3821284.json @@ -0,0 +1,329 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "num", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Literal", + "alias": "arr", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "42" + }, + { + "value_type": "UInt64", + "value": "42" + } + ] + }, + { + "type": "Literal", + "alias": "nested_arr", + "value_type": "Array", + "value": [ + { + "value_type": "Array", + "value": [ + { + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "42" + }, + { + "value_type": "UInt64", + "value": "42" + } + ] + }, + { + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "42" + }, + { + "value_type": "UInt64", + "value": "42" + } + ] + } + ] + }, + { + "value_type": "Array", + "value": [ + { + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "42" + }, + { + "value_type": "UInt64", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple(a UInt32, b UInt32)" + } + ] + }, + { + "type": "Function", + "alias": "nested_tuple", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple(a Tuple(b Tuple(c UInt32, d UInt32), e UInt32), f UInt32)" + } + ] + }, + { + "type": "Function", + "alias": "map", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "24" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "24" + } + ] + }, + { + "type": "Function", + "alias": "nested_map", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Function", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Function", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "nested_types", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "42" + }, + { + "value_type": "UInt64", + "value": "42" + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "42" + }, + { + "value_type": "UInt64", + "value": "42" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Array(Tuple(Map(UInt32, UInt32), Array(UInt32)))" + } + ] + } + ] + } + ], + "format": "PrettyNDJSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/1f7094ded3821284.sql b/tests/ast_json_fixtures/shapes/1f7094ded3821284.sql new file mode 100644 index 000000000000..8a42c73f3d67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f7094ded3821284.sql @@ -0,0 +1 @@ +select 42 as num, [42, 42] as arr, [[[42, 42], [42, 42]], [[42, 42]]] as nested_arr, tuple(42, 42)::Tuple(a UInt32, b UInt32) as tuple, tuple(tuple(tuple(42, 42), 42), 42)::Tuple(a Tuple(b Tuple(c UInt32, d UInt32), e UInt32), f UInt32) as nested_tuple, map(42, 42, 24, 24) as map, map(42, map(42, map(42, 42))) as nested_map, [tuple(map(42, 42), [42, 42]), tuple(map(42, 42), [42, 42])]::Array(Tuple(Map(UInt32, UInt32), Array(UInt32))) as nested_types format PrettyNDJSON diff --git a/tests/ast_json_fixtures/shapes/1f7169007c1d2425.json b/tests/ast_json_fixtures/shapes/1f7169007c1d2425.json new file mode 100644 index 000000000000..2b275cfc3aec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f7169007c1d2425.json @@ -0,0 +1,137 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "stamp", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "DateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "stamp" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_nullable_key": "1" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2020-01-01" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1000 + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/1f7169007c1d2425.sql b/tests/ast_json_fixtures/shapes/1f7169007c1d2425.sql new file mode 100644 index 000000000000..9303c0a2c146 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f7169007c1d2425.sql @@ -0,0 +1 @@ +CREATE TABLE test (stamp Nullable(DateTime('UTC'))) ENGINE = MergeTree PARTITION BY toDate(stamp) ORDER BY tuple() SETTINGS allow_nullable_key = 1 as select toDateTime('2020-01-01', 'UTC')+number*60 from numbers(1e3) diff --git a/tests/ast_json_fixtures/shapes/1f79583d52ef414e.json b/tests/ast_json_fixtures/shapes/1f79583d52ef414e.json new file mode 100644 index 000000000000..0e6f4d2439c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f79583d52ef414e.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateTableQuery", + "database": { + "type": "Identifier", + "name": "sqllt" + }, + "table": { + "type": "Identifier", + "name": "table" + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/1f79583d52ef414e.sql b/tests/ast_json_fixtures/shapes/1f79583d52ef414e.sql new file mode 100644 index 000000000000..641c86c60fa2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1f79583d52ef414e.sql @@ -0,0 +1 @@ +SHOW CREATE TABLE sqllt.table FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/1faab61724629a33.json b/tests/ast_json_fixtures/shapes/1faab61724629a33.json new file mode 100644 index 000000000000..8418486241ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1faab61724629a33.json @@ -0,0 +1,126 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "a", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "30" + }, + { + "type": "Function", + "alias": "s", + "name": "sum", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "window_definition": { + "type": "WindowDefinition", + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1faab61724629a33.sql b/tests/ast_json_fixtures/shapes/1faab61724629a33.sql new file mode 100644 index 000000000000..c2516b6fbd3b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1faab61724629a33.sql @@ -0,0 +1,6 @@ +SELECT + *, + if((number % 2) = 0, 0.5, 1) AS a, + 30 AS b, + sum(a * b) OVER (ORDER BY number ASC) AS s +FROM numbers(10) diff --git a/tests/ast_json_fixtures/shapes/1fd6c83dcb66d5ca.json b/tests/ast_json_fixtures/shapes/1fd6c83dcb66d5ca.json new file mode 100644 index 000000000000..806975334bcb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1fd6c83dcb66d5ca.json @@ -0,0 +1,134 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "projection_test" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "domain_alias" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 1 + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "domain" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775808" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "first_time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-2147483649" + } + ] + } + ] + }, + "direction": "DESC", + "nulls_first": false + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1048576" + }, + "direction": "DESC", + "nulls_first": false + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/1fd6c83dcb66d5ca.sql b/tests/ast_json_fixtures/shapes/1fd6c83dcb66d5ca.sql new file mode 100644 index 000000000000..291b95333ab4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1fd6c83dcb66d5ca.sql @@ -0,0 +1 @@ +SELECT 2, -1 FROM projection_test PREWHERE domain_alias = 1. WHERE domain = NULL GROUP BY -9223372036854775808 ORDER BY countIf(first_time = 0) / count(-2147483649) DESC NULLS LAST, 1048576 DESC NULLS LAST diff --git a/tests/ast_json_fixtures/shapes/1fdee291fceec9b2.json b/tests/ast_json_fixtures/shapes/1fdee291fceec9b2.json new file mode 100644 index 000000000000..05129f3a5e28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1fdee291fceec9b2.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "if_exists": true, + "names": ["r1_01293", "r2_01293@%.myhost.com"] + } +} diff --git a/tests/ast_json_fixtures/shapes/1fdee291fceec9b2.sql b/tests/ast_json_fixtures/shapes/1fdee291fceec9b2.sql new file mode 100644 index 000000000000..c71e9693b663 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/1fdee291fceec9b2.sql @@ -0,0 +1 @@ +DROP ROLE IF EXISTS r1_01293@'%', 'r2_01293@%.myhost.com' diff --git a/tests/ast_json_fixtures/shapes/200be41212fdaa4a.json b/tests/ast_json_fixtures/shapes/200be41212fdaa4a.json new file mode 100644 index 000000000000..45edef446d5a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/200be41212fdaa4a.json @@ -0,0 +1,271 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "row_n", + "name": "ROW_NUMBER", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "c2" + }, + { + "type": "Identifier", + "name": "c4" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c5" + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c3" + }, + "direction": "DESC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "account_id", + "name": "t1.c1", + "name_parts": ["t1", "c1"] + }, + { + "type": "Identifier", + "alias": "c2", + "name": "t1.c2", + "name_parts": ["t1", "c2"] + }, + { + "type": "Identifier", + "alias": "c3", + "name": "t1.c3", + "name_parts": ["t1", "c3"] + }, + { + "type": "Identifier", + "alias": "c4", + "name": "t1.c4", + "name_parts": ["t1", "c4"] + }, + { + "type": "Identifier", + "alias": "c5", + "name": "t1.c5", + "name_parts": ["t1", "c5"] + }, + { + "type": "Function", + "alias": "rn", + "name": "ROW_NUMBER", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "t1.c2", + "name_parts": ["t1", "c2"] + }, + { + "type": "Identifier", + "name": "t1.c3", + "name_parts": ["t1", "c3"] + }, + { + "type": "Identifier", + "name": "t1.c4", + "name_parts": ["t1", "c4"] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.c5", + "name_parts": ["t1", "c5"] + }, + "direction": "DESC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "table_test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t1.c1", + "name_parts": ["t1", "c1"] + }, + { + "type": "Identifier", + "name": "t1.c2", + "name_parts": ["t1", "c2"] + }, + { + "type": "Identifier", + "name": "t1.c3", + "name_parts": ["t1", "c3"] + }, + { + "type": "Identifier", + "name": "t1.c4", + "name_parts": ["t1", "c4"] + }, + { + "type": "Identifier", + "name": "t1.c5", + "name_parts": ["t1", "c5"] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.c2", + "name_parts": ["t1", "c2"] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.c4", + "name_parts": ["t1", "c4"] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.c5", + "name_parts": ["t1", "c5"] + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "rn" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c2" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c4" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c5" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c3" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/200be41212fdaa4a.sql b/tests/ast_json_fixtures/shapes/200be41212fdaa4a.sql new file mode 100644 index 000000000000..ca2cd5a33f97 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/200be41212fdaa4a.sql @@ -0,0 +1,41 @@ +SELECT + *, + ROW_NUMBER() OVER (PARTITION BY c2, + c4 +ORDER BY + c5 DESC, + c3 DESC) AS row_n +FROM + ( + SELECT + t1.c1 as account_id, + t1.c2 as c2, + t1.c3 as c3, + t1.c4 as c4, + t1.c5 as c5, + ROW_NUMBER () OVER (PARTITION BY t1.c2, + t1.c3, + t1.c4 + ORDER BY + t1.c5 DESC) AS rn + FROM + table_test AS t1 + GROUP BY + t1.c1, + t1.c2, + t1.c3, + t1.c4, + t1.c5 + ORDER BY + t1.c2, + t1.c4, + t1.c5 +) +WHERE + rn = 1 +ORDER BY + c2, + c4, + c5, + c3 +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/202d64021aed299a.json b/tests/ast_json_fixtures/shapes/202d64021aed299a.json new file mode 100644 index 000000000000..015e63892188 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/202d64021aed299a.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1", + "enable_positional_arguments": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/202d64021aed299a.sql b/tests/ast_json_fixtures/shapes/202d64021aed299a.sql new file mode 100644 index 000000000000..401125c19dec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/202d64021aed299a.sql @@ -0,0 +1 @@ +SELECT tuple(2) = tuple(materialize(1)) GROUP BY 1 WITH ROLLUP WITH TOTALS SETTINGS group_by_use_nulls = 1, enable_positional_arguments = 1 diff --git a/tests/ast_json_fixtures/shapes/202dd4c843e2546d.json b/tests/ast_json_fixtures/shapes/202dd4c843e2546d.json new file mode 100644 index 000000000000..f8e082679611 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/202dd4c843e2546d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR FILESYSTEM CACHE", + "filesystem_cache_name": "s3_cache" + } +} diff --git a/tests/ast_json_fixtures/shapes/202dd4c843e2546d.sql b/tests/ast_json_fixtures/shapes/202dd4c843e2546d.sql new file mode 100644 index 000000000000..3d175bb002f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/202dd4c843e2546d.sql @@ -0,0 +1 @@ +SYSTEM DROP FILESYSTEM CACHE 's3_cache' diff --git a/tests/ast_json_fixtures/shapes/20699c132449963d.json b/tests/ast_json_fixtures/shapes/20699c132449963d.json new file mode 100644 index 000000000000..43c16b46d5c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/20699c132449963d.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Function", + "name": "arraySplit", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "toUInt8", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/20699c132449963d.sql b/tests/ast_json_fixtures/shapes/20699c132449963d.sql new file mode 100644 index 000000000000..e526459b5e02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/20699c132449963d.sql @@ -0,0 +1 @@ +SELECT count(arraySplit(x -> toUInt8(number), [])) FROM numbers(10) GROUP BY number, [number] WITH ROLLUP settings group_by_use_nulls=1 diff --git a/tests/ast_json_fixtures/shapes/2074f539fe0fbdee.json b/tests/ast_json_fixtures/shapes/2074f539fe0fbdee.json new file mode 100644 index 000000000000..0c55f5268d15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2074f539fe0fbdee.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "mv_primary_key" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "key" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "key" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2074f539fe0fbdee.sql b/tests/ast_json_fixtures/shapes/2074f539fe0fbdee.sql new file mode 100644 index 000000000000..b4478188951f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2074f539fe0fbdee.sql @@ -0,0 +1,7 @@ +CREATE MATERIALIZED VIEW mv_primary_key +( + key String, + PRIMARY KEY key +) +ENGINE = MergeTree +AS SELECT * FROM data diff --git a/tests/ast_json_fixtures/shapes/207694275dbf4f8c.json b/tests/ast_json_fixtures/shapes/207694275dbf4f8c.json new file mode 100644 index 000000000000..e2eb8f25a0d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/207694275dbf4f8c.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s2_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "parent_profile": "default" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/207694275dbf4f8c.sql b/tests/ast_json_fixtures/shapes/207694275dbf4f8c.sql new file mode 100644 index 000000000000..8ee7b5a43d59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/207694275dbf4f8c.sql @@ -0,0 +1 @@ +CREATE PROFILE s2_01294 SETTINGS INHERIT 'default' diff --git a/tests/ast_json_fixtures/shapes/2080a79d145fe21d.json b/tests/ast_json_fixtures/shapes/2080a79d145fe21d.json new file mode 100644 index 000000000000..2c092d838167 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2080a79d145fe21d.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "SLEEP #1 TEST" + }, + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.001 + } + ] + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/2080a79d145fe21d.sql b/tests/ast_json_fixtures/shapes/2080a79d145fe21d.sql new file mode 100644 index 000000000000..5d695606e264 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2080a79d145fe21d.sql @@ -0,0 +1 @@ +SELECT 'SLEEP #1 TEST', sleep(0.001) FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/20bdf5c2270ebeec.json b/tests/ast_json_fixtures/shapes/20bdf5c2270ebeec.json new file mode 100644 index 000000000000..6153abb3c4df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/20bdf5c2270ebeec.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_rollup": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "rollup_having" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "having": { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/20bdf5c2270ebeec.sql b/tests/ast_json_fixtures/shapes/20bdf5c2270ebeec.sql new file mode 100644 index 000000000000..9853e1ec5f38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/20bdf5c2270ebeec.sql @@ -0,0 +1 @@ +SELECT a, b, count(*) FROM rollup_having GROUP BY a, b WITH ROLLUP WITH TOTALS HAVING a IS NOT NULL diff --git a/tests/ast_json_fixtures/shapes/20d8796d3c5dee2a.json b/tests/ast_json_fixtures/shapes/20d8796d3c5dee2a.json new file mode 100644 index 000000000000..1b8fea8ef7ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/20d8796d3c5dee2a.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t0" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REWRITE_PARTS" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/20d8796d3c5dee2a.sql b/tests/ast_json_fixtures/shapes/20d8796d3c5dee2a.sql new file mode 100644 index 000000000000..a2c7e2a8cfeb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/20d8796d3c5dee2a.sql @@ -0,0 +1 @@ +ALTER TABLE t0 REWRITE PARTS SETTINGS mutations_sync=1 diff --git a/tests/ast_json_fixtures/shapes/20e4bb1e5bd1dc4f.json b/tests/ast_json_fixtures/shapes/20e4bb1e5bd1dc4f.json new file mode 100644 index 000000000000..b1bb17c0f957 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/20e4bb1e5bd1dc4f.json @@ -0,0 +1,93 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "21" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "22" + }, + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "23" + }, + { + "type": "Identifier", + "name": "s" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "bug" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/20e4bb1e5bd1dc4f.sql b/tests/ast_json_fixtures/shapes/20e4bb1e5bd1dc4f.sql new file mode 100644 index 000000000000..00c2b8dd6aee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/20e4bb1e5bd1dc4f.sql @@ -0,0 +1 @@ +select s, (s=21 or 22=s or 23=s) from bug SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/210cd533ba40568a.json b/tests/ast_json_fixtures/shapes/210cd533ba40568a.json new file mode 100644 index 000000000000..15d8e33a4f9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/210cd533ba40568a.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_detach_attach_patches_dst" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + }, + "replace": true, + "from_table": "t_detach_attach_patches" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/210cd533ba40568a.sql b/tests/ast_json_fixtures/shapes/210cd533ba40568a.sql new file mode 100644 index 000000000000..31bd8dd6a089 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/210cd533ba40568a.sql @@ -0,0 +1 @@ +ALTER TABLE t_detach_attach_patches_dst REPLACE PARTITION 3 FROM t_detach_attach_patches diff --git a/tests/ast_json_fixtures/shapes/214ee9f60c1ad3f6.json b/tests/ast_json_fixtures/shapes/214ee9f60c1ad3f6.json new file mode 100644 index 000000000000..acff548ec17d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/214ee9f60c1ad3f6.json @@ -0,0 +1,113 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "lambda_1", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Identifier", + "alias": "lambda_2", + "name": "lambda_1" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Identifier", + "name": "lambda_2" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "1" + }, + { + "value_type": "String", + "value": "2" + }, + { + "value_type": "String", + "value": "3" + } + ] + } + ] + } + ], + "where": { + "type": "Identifier", + "name": "lambda_2" + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/214ee9f60c1ad3f6.sql b/tests/ast_json_fixtures/shapes/214ee9f60c1ad3f6.sql new file mode 100644 index 000000000000..85c67744346f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/214ee9f60c1ad3f6.sql @@ -0,0 +1 @@ +WITH x -> toString(x) AS lambda_1 SELECT arrayMap(lambda_1 AS lambda_2, [1, 2, 3]), arrayMap(lambda_2, ['1', '2', '3']) WHERE lambda_2 SETTINGS enable_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/218918912e2ffac4.json b/tests/ast_json_fixtures/shapes/218918912e2ffac4.json new file mode 100644 index 000000000000..e5049ea982c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/218918912e2ffac4.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "PLAINTEXT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwe123" + } + ] + } + ], + "replace_authentication_methods": true, + "hosts": { + "local_host": true + }, + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/218918912e2ffac4.sql b/tests/ast_json_fixtures/shapes/218918912e2ffac4.sql new file mode 100644 index 000000000000..8a55f592c2d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/218918912e2ffac4.sql @@ -0,0 +1 @@ +CREATE USER u1_01292 IDENTIFIED WITH plaintext_password BY 'qwe123' HOST LOCAL SETTINGS readonly=1 diff --git a/tests/ast_json_fixtures/shapes/219456e97bf65e6e.json b/tests/ast_json_fixtures/shapes/219456e97bf65e6e.json new file mode 100644 index 000000000000..061c0b217d67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/219456e97bf65e6e.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR QUERY CACHE", + "query_result_cache_tag": "" + } +} diff --git a/tests/ast_json_fixtures/shapes/219456e97bf65e6e.sql b/tests/ast_json_fixtures/shapes/219456e97bf65e6e.sql new file mode 100644 index 000000000000..adbd0442ef51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/219456e97bf65e6e.sql @@ -0,0 +1 @@ +SYSTEM CLEAR QUERY CACHE TAG '' diff --git a/tests/ast_json_fixtures/shapes/219a5be6307afb9c.json b/tests/ast_json_fixtures/shapes/219a5be6307afb9c.json new file mode 100644 index 000000000000..56479a23311e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/219a5be6307afb9c.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "t1.x", + "name_parts": ["t1", "x"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.x", + "name_parts": ["t1", "x"] + }, + { + "type": "Identifier", + "name": "t2.x", + "name_parts": ["t2", "x"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/219a5be6307afb9c.sql b/tests/ast_json_fixtures/shapes/219a5be6307afb9c.sql new file mode 100644 index 000000000000..c8f312ca917b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/219a5be6307afb9c.sql @@ -0,0 +1 @@ +SELECT t1.x FROM t1 JOIN t1 as t2 ON t1.x = t2.x GROUP BY x ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/219acba45de54d39.json b/tests/ast_json_fixtures/shapes/219acba45de54d39.json new file mode 100644 index 000000000000..a90cdccd4e1c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/219acba45de54d39.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "rename_table_multiple" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "value1", + "data_type": { + "type": "DataType", + "name": "String" + } + } + }, + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "column": { + "type": "Identifier", + "name": "value1" + }, + "rename_to": { + "type": "Identifier", + "name": "value1_string" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/219acba45de54d39.sql b/tests/ast_json_fixtures/shapes/219acba45de54d39.sql new file mode 100644 index 000000000000..6ed5dd3b26af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/219acba45de54d39.sql @@ -0,0 +1 @@ +ALTER TABLE rename_table_multiple MODIFY COLUMN value1 String, RENAME COLUMN value1 to value1_string diff --git a/tests/ast_json_fixtures/shapes/219d5ecaaba42704.json b/tests/ast_json_fixtures/shapes/219d5ecaaba42704.json new file mode 100644 index 000000000000..43c1734e61c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/219d5ecaaba42704.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "field" + }, + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "num_field" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 6 + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "num_field" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 6 + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "field" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/219d5ecaaba42704.sql b/tests/ast_json_fixtures/shapes/219d5ecaaba42704.sql new file mode 100644 index 000000000000..00f7851e715f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/219d5ecaaba42704.sql @@ -0,0 +1 @@ +SELECT field, countIf(num_field > 6.0) FROM data PREWHERE (num_field>6.0) GROUP BY field diff --git a/tests/ast_json_fixtures/shapes/21a2095ec03517ad.json b/tests/ast_json_fixtures/shapes/21a2095ec03517ad.json new file mode 100644 index 000000000000..4a7f3a847080 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/21a2095ec03517ad.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "true" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Bool" + } + ] + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/21a2095ec03517ad.sql b/tests/ast_json_fixtures/shapes/21a2095ec03517ad.sql new file mode 100644 index 000000000000..d8c0192c9d3d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/21a2095ec03517ad.sql @@ -0,0 +1 @@ +SELECT CAST('true', 'Bool') format Vertical diff --git a/tests/ast_json_fixtures/shapes/21bc211b6a24febc.json b/tests/ast_json_fixtures/shapes/21bc211b6a24febc.json new file mode 100644 index 000000000000..1227f415fa1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/21bc211b6a24febc.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "DISABLE FAILPOINT", + "fail_point_name": "parallel_replicas_reading_response_timeout" + } +} diff --git a/tests/ast_json_fixtures/shapes/21bc211b6a24febc.sql b/tests/ast_json_fixtures/shapes/21bc211b6a24febc.sql new file mode 100644 index 000000000000..03bc901d5a1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/21bc211b6a24febc.sql @@ -0,0 +1 @@ +SYSTEM DISABLE FAILPOINT parallel_replicas_reading_response_timeout diff --git a/tests/ast_json_fixtures/shapes/21ef5bd2295e8d3d.json b/tests/ast_json_fixtures/shapes/21ef5bd2295e8d3d.json new file mode 100644 index 000000000000..2125de36cf7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/21ef5bd2295e8d3d.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x3" + }, + { + "type": "Identifier", + "name": "x2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x3" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/21ef5bd2295e8d3d.sql b/tests/ast_json_fixtures/shapes/21ef5bd2295e8d3d.sql new file mode 100644 index 000000000000..d9d6462d977d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/21ef5bd2295e8d3d.sql @@ -0,0 +1 @@ +select x3, x2 from test group by 1, 2 order by x3 diff --git a/tests/ast_json_fixtures/shapes/222d226c2d7d893f.json b/tests/ast_json_fixtures/shapes/222d226c2d7d893f.json new file mode 100644 index 000000000000..bf5e79370a8b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/222d226c2d7d893f.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "AdvEngineID" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits_s3", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "AdvEngineID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "AdvEngineID" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "AdvEngineID" + }, + "direction": "DESC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/222d226c2d7d893f.sql b/tests/ast_json_fixtures/shapes/222d226c2d7d893f.sql new file mode 100644 index 000000000000..bbac2bbf8e55 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/222d226c2d7d893f.sql @@ -0,0 +1 @@ +SELECT AdvEngineID, count() FROM test.hits_s3 WHERE AdvEngineID != 0 GROUP BY AdvEngineID ORDER BY AdvEngineID DESC diff --git a/tests/ast_json_fixtures/shapes/223784ec2a775927.json b/tests/ast_json_fixtures/shapes/223784ec2a775927.json new file mode 100644 index 000000000000..b063b83f398f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/223784ec2a775927.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "str", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx", + "expression": { + "type": "Identifier", + "name": "str" + }, + "index_type": { + "type": "Function", + "name": "text", + "arguments": [] + }, + "granularity": 100000000 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/223784ec2a775927.sql b/tests/ast_json_fixtures/shapes/223784ec2a775927.sql new file mode 100644 index 000000000000..9aac3012e588 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/223784ec2a775927.sql @@ -0,0 +1,7 @@ +CREATE TABLE tab +( + str String, + INDEX idx str TYPE text() +) +ENGINE = MergeTree +ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/225bc8293bad7b62.json b/tests/ast_json_fixtures/shapes/225bc8293bad7b62.json new file mode 100644 index 000000000000..b28daf06d09e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/225bc8293bad7b62.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "data_02222" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "dummy" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/225bc8293bad7b62.sql b/tests/ast_json_fixtures/shapes/225bc8293bad7b62.sql new file mode 100644 index 000000000000..f1217fc257de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/225bc8293bad7b62.sql @@ -0,0 +1 @@ +CREATE TABLE data_02222 engine=MergeTree() ORDER BY dummy AS SELECT * FROM system.one diff --git a/tests/ast_json_fixtures/shapes/226f15db9667f21d.json b/tests/ast_json_fixtures/shapes/226f15db9667f21d.json new file mode 100644 index 000000000000..7a8700003a48 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/226f15db9667f21d.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "dictionaries": true, + "from": { + "type": "Identifier", + "name": "sqllt" + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/226f15db9667f21d.sql b/tests/ast_json_fixtures/shapes/226f15db9667f21d.sql new file mode 100644 index 000000000000..014bbadeb4c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/226f15db9667f21d.sql @@ -0,0 +1 @@ +SHOW DICTIONARIES FROM sqllt FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/22851a37d6568db2.json b/tests/ast_json_fixtures/shapes/22851a37d6568db2.json new file mode 100644 index 000000000000..0eac7e99323c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22851a37d6568db2.json @@ -0,0 +1,195 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayMin", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x1" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x1" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayMin", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayMin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_aggregation_array" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "arrayAvg", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/22851a37d6568db2.sql b/tests/ast_json_fixtures/shapes/22851a37d6568db2.sql new file mode 100644 index 000000000000..3c4b7a66ae9c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22851a37d6568db2.sql @@ -0,0 +1 @@ +SELECT [arrayMin(x1 -> (x1 * materialize(-1)), [toNullable(toUInt256(0)), materialize(4)])], arrayMin([arrayMin([0])]) FROM test_aggregation_array GROUP BY arrayAvg([1]), [0, toUInt256(8)] WITH CUBE SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/2298b5387eab6ba6.json b/tests/ast_json_fixtures/shapes/2298b5387eab6ba6.json new file mode 100644 index 000000000000..fb49ac4cc8bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2298b5387eab6ba6.json @@ -0,0 +1,130 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "tid", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "processed_at", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "created_at", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "amount", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toStartOfQuarter", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toStartOfDay", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + { + "type": "Function", + "name": "toStartOfDay", + "arguments": [ + { + "type": "Identifier", + "name": "processed_at" + } + ] + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toStartOfDay", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + { + "type": "Function", + "name": "toStartOfDay", + "arguments": [ + { + "type": "Identifier", + "name": "processed_at" + } + ] + }, + { + "type": "Identifier", + "name": "tid" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2298b5387eab6ba6.sql b/tests/ast_json_fixtures/shapes/2298b5387eab6ba6.sql new file mode 100644 index 000000000000..0887d7d479a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2298b5387eab6ba6.sql @@ -0,0 +1,12 @@ +CREATE TABLE t +( + tid UInt64, + processed_at DateTime, + created_at DateTime, + amount Int64 +) +ENGINE = ReplacingMergeTree +PARTITION BY toStartOfQuarter(created_at) +PRIMARY KEY (toStartOfDay(created_at), toStartOfDay(processed_at)) +ORDER BY (toStartOfDay(created_at), toStartOfDay(processed_at), tid) +SETTINGS index_granularity = 1 diff --git a/tests/ast_json_fixtures/shapes/22a81a0a06064e0c.json b/tests/ast_json_fixtures/shapes/22a81a0a06064e0c.json new file mode 100644 index 000000000000..da3c34ece5ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22a81a0a06064e0c.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "col1" + }, + { + "type": "Function", + "alias": "k", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "213" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Москва" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Мир" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "multi_if_check" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/22a81a0a06064e0c.sql b/tests/ast_json_fixtures/shapes/22a81a0a06064e0c.sql new file mode 100644 index 000000000000..bd7c3f2bc78d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22a81a0a06064e0c.sql @@ -0,0 +1 @@ +SELECT DISTINCT col1, multiIf(col1 != 213, 'Москва', 'Мир') AS k FROM multi_if_check LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/22ae1838958cc032.json b/tests/ast_json_fixtures/shapes/22ae1838958cc032.json new file mode 100644 index 000000000000..5352e67d3f76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22ae1838958cc032.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "foo" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "AggregateFunction", + "arguments": [ + { + "type": "Identifier", + "name": "max" + }, + { + "type": "DataType", + "name": "UInt64" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "key" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/22ae1838958cc032.sql b/tests/ast_json_fixtures/shapes/22ae1838958cc032.sql new file mode 100644 index 000000000000..30c171d8f5bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22ae1838958cc032.sql @@ -0,0 +1 @@ +CREATE TABLE foo (id UInt64, key AggregateFunction(max, UInt64)) ENGINE MergeTree PARTITION BY key diff --git a/tests/ast_json_fixtures/shapes/22cb1aa3832b30fc.json b/tests/ast_json_fixtures/shapes/22cb1aa3832b30fc.json new file mode 100644 index 000000000000..1bf2fa075c8d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22cb1aa3832b30fc.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "fat_granularity" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "fat" + }, + { + "type": "Literal", + "value_type": "String", + "value": "256\\_%" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/22cb1aa3832b30fc.sql b/tests/ast_json_fixtures/shapes/22cb1aa3832b30fc.sql new file mode 100644 index 000000000000..09a72d215513 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22cb1aa3832b30fc.sql @@ -0,0 +1 @@ +select x from fat_granularity prewhere fat like '256\_%' settings max_threads=2 diff --git a/tests/ast_json_fixtures/shapes/22cfda2dc24a6890.json b/tests/ast_json_fixtures/shapes/22cfda2dc24a6890.json new file mode 100644 index 000000000000..b619e0e10a55 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22cfda2dc24a6890.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_part_offset" + }, + { + "type": "Function", + "alias": "granule", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "_part_offset" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_filter" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "_part_offset" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/22cfda2dc24a6890.sql b/tests/ast_json_fixtures/shapes/22cfda2dc24a6890.sql new file mode 100644 index 000000000000..737b3c4278e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22cfda2dc24a6890.sql @@ -0,0 +1 @@ +SELECT _part_offset, intDiv(_part_offset, 3) as granule, * FROM test_filter ORDER BY _part_offset diff --git a/tests/ast_json_fixtures/shapes/22db717c4a029a93.json b/tests/ast_json_fixtures/shapes/22db717c4a029a93.json new file mode 100644 index 000000000000..f6fd9e108403 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22db717c4a029a93.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONCompactStringsEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/22db717c4a029a93.sql b/tests/ast_json_fixtures/shapes/22db717c4a029a93.sql new file mode 100644 index 000000000000..7d84afe72374 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22db717c4a029a93.sql @@ -0,0 +1 @@ +SELECT name, count() AS c FROM test_table GROUP BY name WITH TOTALS ORDER BY name FORMAT JSONCompactStringsEachRow diff --git a/tests/ast_json_fixtures/shapes/22e1784d652f27b4.json b/tests/ast_json_fixtures/shapes/22e1784d652f27b4.json new file mode 100644 index 000000000000..d53f1f79197f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22e1784d652f27b4.json @@ -0,0 +1,263 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "with_table", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "p.a_id", + "name_parts": ["p", "a_id"] + }, + { + "type": "Identifier", + "name": "p.b_id", + "name_parts": ["p", "b_id"] + }, + { + "type": "Identifier", + "name": "p.c_id", + "name_parts": ["p", "c_id"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "p", + "name": "parent" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "jt1.a_id", + "name_parts": ["jt1", "a_id"] + }, + { + "type": "Identifier", + "name": "p.a_id", + "name_parts": ["p", "a_id"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "jt1.b_id", + "name_parts": ["jt1", "b_id"] + }, + { + "type": "Identifier", + "name": "p.b_id", + "name_parts": ["p", "b_id"] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "jt1", + "name": "join_table_1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "jt2.c_id", + "name_parts": ["jt2", "c_id"] + }, + { + "type": "Identifier", + "name": "p.c_id", + "name_parts": ["p", "c_id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "jt2", + "name": "join_table_2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "p.a_id", + "name_parts": ["p", "a_id"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "jt2.c_id", + "name_parts": ["jt2", "c_id"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "p.created_at", + "name_parts": ["p", "created_at"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "p.a_id", + "name_parts": ["p", "a_id"] + }, + { + "type": "Identifier", + "name": "p.b_id", + "name_parts": ["p", "b_id"] + }, + { + "type": "Function", + "alias": "f_count", + "name": "COUNT", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "with_table" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "p.a_id", + "name_parts": ["p", "a_id"] + }, + { + "type": "Identifier", + "name": "p.b_id", + "name_parts": ["p", "b_id"] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/22e1784d652f27b4.sql b/tests/ast_json_fixtures/shapes/22e1784d652f27b4.sql new file mode 100644 index 000000000000..96204af97273 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22e1784d652f27b4.sql @@ -0,0 +1,9 @@ +WITH with_table as ( + SELECT p.a_id, p.b_id, p.c_id FROM parent p + LEFT JOIN join_table_1 jt1 ON jt1.a_id = p.a_id AND jt1.b_id = p.b_id + LEFT JOIN join_table_2 jt2 ON jt2.c_id = p.c_id + WHERE + p.a_id = 0 AND (jt2.c_id = 0 OR p.created_at = 0) +) +SELECT p.a_id, p.b_id, COUNT(*) as f_count FROM with_table +GROUP BY p.a_id, p.b_id diff --git a/tests/ast_json_fixtures/shapes/22e3119f49c40bd4.json b/tests/ast_json_fixtures/shapes/22e3119f49c40bd4.json new file mode 100644 index 000000000000..df39323d55c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22e3119f49c40bd4.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t03324" + }, + "final": true + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c0" + }, + "direction": "DESC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "extremes": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/22e3119f49c40bd4.sql b/tests/ast_json_fixtures/shapes/22e3119f49c40bd4.sql new file mode 100644 index 000000000000..25302ead7bf3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22e3119f49c40bd4.sql @@ -0,0 +1 @@ +SELECT c0 FROM t03324 FINAL ORDER BY c0 DESC SETTINGS extremes = 1 diff --git a/tests/ast_json_fixtures/shapes/22e59d4117b4fc20.json b/tests/ast_json_fixtures/shapes/22e59d4117b4fc20.json new file mode 100644 index 000000000000..6a85bae2893a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22e59d4117b4fc20.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s1_01418"] + } +} diff --git a/tests/ast_json_fixtures/shapes/22e59d4117b4fc20.sql b/tests/ast_json_fixtures/shapes/22e59d4117b4fc20.sql new file mode 100644 index 000000000000..97375d179619 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22e59d4117b4fc20.sql @@ -0,0 +1 @@ +DROP SETTINGS PROFILE s1_01418 diff --git a/tests/ast_json_fixtures/shapes/22f63da8a9ec6e7a.json b/tests/ast_json_fixtures/shapes/22f63da8a9ec6e7a.json new file mode 100644 index 000000000000..fc540500dfb3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22f63da8a9ec6e7a.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t1" + } + }, + { + "type": "Identifier", + "name": "t2.x", + "name_parts": ["t2", "x"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ANY", + "using": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/22f63da8a9ec6e7a.sql b/tests/ast_json_fixtures/shapes/22f63da8a9ec6e7a.sql new file mode 100644 index 000000000000..bfa4f8e6bbbd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22f63da8a9ec6e7a.sql @@ -0,0 +1 @@ +SELECT t1.*, t2.x FROM t1 ANY LEFT JOIN t2 USING (x) ORDER BY x diff --git a/tests/ast_json_fixtures/shapes/22ffc94ddf299afa.json b/tests/ast_json_fixtures/shapes/22ffc94ddf299afa.json new file mode 100644 index 000000000000..5438c29bd6b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22ffc94ddf299afa.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "offset", + "value_type": "Int64", + "value": "-44" + }, + { + "type": "Function", + "alias": "length", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "40" + } + ] + }, + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "Hello" + }, + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Function", + "name": "bin", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "length" + } + ] + }, + { + "type": "Function", + "name": "bin", + "arguments": [ + { + "type": "Function", + "name": "bitSlice", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "length" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/22ffc94ddf299afa.sql b/tests/ast_json_fixtures/shapes/22ffc94ddf299afa.sql new file mode 100644 index 000000000000..fab9ae3c6037 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/22ffc94ddf299afa.sql @@ -0,0 +1 @@ +select -44 as offset, number + 40 as length, 'Hello' as s, subString(bin(s), offset , length), bin(bitSlice(s, offset, length)) from numbers(9) diff --git a/tests/ast_json_fixtures/shapes/2320f930917d876a.json b/tests/ast_json_fixtures/shapes/2320f930917d876a.json new file mode 100644 index 000000000000..54d67aacd4a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2320f930917d876a.json @@ -0,0 +1,335 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "actual", + "name": "geohashDecode", + "arguments": [ + { + "type": "Identifier", + "name": "encoded" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "expected:" + }, + { + "type": "Identifier", + "name": "encoded" + }, + { + "type": "Literal", + "value_type": "String", + "value": "=>" + }, + { + "type": "Identifier", + "name": "latitude" + }, + { + "type": "Identifier", + "name": "longitude" + }, + { + "type": "Literal", + "value_type": "String", + "value": "length:" + }, + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "encoded" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "max lat error:" + }, + { + "type": "Function", + "alias": "latitude_max_error", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "180" + }, + { + "type": "Function", + "name": "power", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 2.5 + }, + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "encoded" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "max lon error:" + }, + { + "type": "Function", + "alias": "longitude_max_error", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "360" + }, + { + "type": "Function", + "name": "power", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 2.5 + }, + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "encoded" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "err:" + }, + { + "type": "Function", + "alias": "lat_error", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "actual" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "latitude" + } + ] + }, + { + "type": "Function", + "alias": "lon_error", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "actual" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "longitude" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "derr:" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "abs", + "arguments": [ + { + "type": "Identifier", + "name": "lat_error" + } + ] + }, + { + "type": "Identifier", + "name": "latitude_max_error" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "abs", + "arguments": [ + { + "type": "Identifier", + "name": "lon_error" + } + ] + }, + { + "type": "Identifier", + "name": "longitude_max_error" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "geohash_test_data" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "abs", + "arguments": [ + { + "type": "Identifier", + "name": "lat_error" + } + ] + }, + { + "type": "Identifier", + "name": "latitude_max_error" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "abs", + "arguments": [ + { + "type": "Identifier", + "name": "lon_error" + } + ] + }, + { + "type": "Identifier", + "name": "longitude_max_error" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2320f930917d876a.sql b/tests/ast_json_fixtures/shapes/2320f930917d876a.sql new file mode 100644 index 000000000000..5140542ae67c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2320f930917d876a.sql @@ -0,0 +1,13 @@ +select + geohashDecode(encoded) as actual, + 'expected:', encoded, '=>', latitude, longitude, + 'length:', length(encoded), + 'max lat error:', 180 / power(2, 2.5 * length(encoded)) as latitude_max_error, + 'max lon error:', 360 / power(2, 2.5 * length(encoded)) as longitude_max_error, + 'err:', (actual.2 - latitude) as lat_error, (actual.1 - longitude) as lon_error, + 'derr:', abs(lat_error) - latitude_max_error, abs(lon_error) - longitude_max_error +from geohash_test_data +where + abs(lat_error) > latitude_max_error + or + abs(lon_error) > longitude_max_error diff --git a/tests/ast_json_fixtures/shapes/233ece42eaaca272.json b/tests/ast_json_fixtures/shapes/233ece42eaaca272.json new file mode 100644 index 000000000000..3d536a9f5c0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/233ece42eaaca272.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "coalesce", + "arguments": [ + { + "type": "Identifier", + "name": "qualified_match_join_left.x", + "name_parts": ["qualified_match_join_left", "x"] + }, + { + "type": "Identifier", + "name": "qualified_match_join_right.x", + "name_parts": ["qualified_match_join_right", "x"] + } + ] + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t" + } + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "qualified_match_join_left" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "using": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "qualified_match_join_right" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/233ece42eaaca272.sql b/tests/ast_json_fixtures/shapes/233ece42eaaca272.sql new file mode 100644 index 000000000000..ec95b24c8ce2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/233ece42eaaca272.sql @@ -0,0 +1,7 @@ +SELECT + coalesce(qualified_match_join_left.x, qualified_match_join_right.x) AS x, + t.*, + toTypeName(t) +FROM qualified_match_join_left +FULL JOIN qualified_match_join_right USING (t) +ORDER BY x diff --git a/tests/ast_json_fixtures/shapes/23538643931236ec.json b/tests/ast_json_fixtures/shapes/23538643931236ec.json new file mode 100644 index 000000000000..596ce0ebc176 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23538643931236ec.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "START TTL MERGES", + "table": { + "type": "Identifier", + "name": "ttl" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/23538643931236ec.sql b/tests/ast_json_fixtures/shapes/23538643931236ec.sql new file mode 100644 index 000000000000..6f9a4e137b06 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23538643931236ec.sql @@ -0,0 +1 @@ +system start ttl merges ttl diff --git a/tests/ast_json_fixtures/shapes/2365b2ba8053d36f.json b/tests/ast_json_fixtures/shapes/2365b2ba8053d36f.json new file mode 100644 index 000000000000..8670b314372f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2365b2ba8053d36f.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["ALTER UPDATE"], + "default_database": true, + "table": "normal" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_03727"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2365b2ba8053d36f.sql b/tests/ast_json_fixtures/shapes/2365b2ba8053d36f.sql new file mode 100644 index 000000000000..1aa02f43eacf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2365b2ba8053d36f.sql @@ -0,0 +1 @@ +GRANT ALTER UPDATE ON normal TO test_03727 diff --git a/tests/ast_json_fixtures/shapes/237279575ea79e57.json b/tests/ast_json_fixtures/shapes/237279575ea79e57.json new file mode 100644 index 000000000000..dc2368312bca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/237279575ea79e57.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q7_01297"], + "roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r1_01297", "u1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/237279575ea79e57.sql b/tests/ast_json_fixtures/shapes/237279575ea79e57.sql new file mode 100644 index 000000000000..75778241779c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/237279575ea79e57.sql @@ -0,0 +1 @@ +CREATE QUOTA q7_01297 TO ALL EXCEPT r1_01297, u1_01297 diff --git a/tests/ast_json_fixtures/shapes/23750b6845bbd6ea.json b/tests/ast_json_fixtures/shapes/23750b6845bbd6ea.json new file mode 100644 index 000000000000..b404b8166147 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23750b6845bbd6ea.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "j", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "k", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "j" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "i" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/23750b6845bbd6ea.sql b/tests/ast_json_fixtures/shapes/23750b6845bbd6ea.sql new file mode 100644 index 000000000000..b98f6771f63e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23750b6845bbd6ea.sql @@ -0,0 +1 @@ +create table t (i int, j int, k int, projection p (select * order by j)) engine MergeTree order by i settings index_granularity = 1 diff --git a/tests/ast_json_fixtures/shapes/237f515d7184a705.json b/tests/ast_json_fixtures/shapes/237f515d7184a705.json new file mode 100644 index 000000000000..c484463a1683 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/237f515d7184a705.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "t_shared" + }, + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "all" + } + }, + "final": true + } +} diff --git a/tests/ast_json_fixtures/shapes/237f515d7184a705.sql b/tests/ast_json_fixtures/shapes/237f515d7184a705.sql new file mode 100644 index 000000000000..13edc22384fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/237f515d7184a705.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE t_shared PARTITION ID 'all' FINAL diff --git a/tests/ast_json_fixtures/shapes/23874cf28abf9bce.json b/tests/ast_json_fixtures/shapes/23874cf28abf9bce.json new file mode 100644 index 000000000000..10db36e8c43f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23874cf28abf9bce.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/23874cf28abf9bce.sql b/tests/ast_json_fixtures/shapes/23874cf28abf9bce.sql new file mode 100644 index 000000000000..d4b3b80393bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23874cf28abf9bce.sql @@ -0,0 +1 @@ +select * from test group by tuple(d) order by all diff --git a/tests/ast_json_fixtures/shapes/2399ed5ab7d36748.json b/tests/ast_json_fixtures/shapes/2399ed5ab7d36748.json new file mode 100644 index 000000000000..6450403ac7b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2399ed5ab7d36748.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["test_user_03593"] + } +} diff --git a/tests/ast_json_fixtures/shapes/2399ed5ab7d36748.sql b/tests/ast_json_fixtures/shapes/2399ed5ab7d36748.sql new file mode 100644 index 000000000000..b33faf8116f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2399ed5ab7d36748.sql @@ -0,0 +1 @@ +DROP USER test_user_03593 diff --git a/tests/ast_json_fixtures/shapes/23c56e2ba35df1b1.json b/tests/ast_json_fixtures/shapes/23c56e2ba35df1b1.json new file mode 100644 index 000000000000..bf6f989fde91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23c56e2ba35df1b1.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "prop_table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "column_ttl" + }, + "remove_property": "TTL" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/23c56e2ba35df1b1.sql b/tests/ast_json_fixtures/shapes/23c56e2ba35df1b1.sql new file mode 100644 index 000000000000..5cb8ff0ec90d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23c56e2ba35df1b1.sql @@ -0,0 +1 @@ +ALTER TABLE prop_table MODIFY COLUMN column_ttl REMOVE TTL diff --git a/tests/ast_json_fixtures/shapes/23d698ba9bcab8f7.json b/tests/ast_json_fixtures/shapes/23d698ba9bcab8f7.json new file mode 100644 index 000000000000..6a59d8adc705 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23d698ba9bcab8f7.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "insert_select_dst" + }, + "columns": [ + { + "type": "ColumnsRegexpMatcher", + "pattern": ".*", + "transformers": [ + { + "type": "ColumnsExceptTransformer", + "columns": [ + { + "type": "Identifier", + "name": "middle_a" + }, + { + "type": "Identifier", + "name": "middle_b" + } + ] + } + ] + } + ], + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "insert_select_src" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/23d698ba9bcab8f7.sql b/tests/ast_json_fixtures/shapes/23d698ba9bcab8f7.sql new file mode 100644 index 000000000000..2f41b3879176 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23d698ba9bcab8f7.sql @@ -0,0 +1 @@ +INSERT INTO insert_select_dst(COLUMNS('.*') EXCEPT (middle_a, middle_b)) SELECT * FROM insert_select_src diff --git a/tests/ast_json_fixtures/shapes/23d9f03362b550e0.json b/tests/ast_json_fixtures/shapes/23d9f03362b550e0.json new file mode 100644 index 000000000000..de4b3d6fe6e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23d9f03362b550e0.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "dictionary": true, + "elements": [ + { + "from_database": "test_01155_ordinary", + "from_table": "dict", + "to_database": "test_01155_ordinary", + "to_table": "dict1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/23d9f03362b550e0.sql b/tests/ast_json_fixtures/shapes/23d9f03362b550e0.sql new file mode 100644 index 000000000000..29c7f53a459a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/23d9f03362b550e0.sql @@ -0,0 +1 @@ +RENAME DICTIONARY test_01155_ordinary.dict TO test_01155_ordinary.dict1 diff --git a/tests/ast_json_fixtures/shapes/2401aaeff2b68dac.json b/tests/ast_json_fixtures/shapes/2401aaeff2b68dac.json new file mode 100644 index 000000000000..872ed3f37d32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2401aaeff2b68dac.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s5_01294"], + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01294", "u1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2401aaeff2b68dac.sql b/tests/ast_json_fixtures/shapes/2401aaeff2b68dac.sql new file mode 100644 index 000000000000..9f9a20ccdff2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2401aaeff2b68dac.sql @@ -0,0 +1 @@ +CREATE PROFILE s5_01294 TO r1_01294, u1_01294 diff --git a/tests/ast_json_fixtures/shapes/241c1a1bc34757af.json b/tests/ast_json_fixtures/shapes/241c1a1bc34757af.json new file mode 100644 index 000000000000..9eab3a82d9ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/241c1a1bc34757af.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "temporary": true, + "table": { + "type": "Identifier", + "name": "tmp" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/241c1a1bc34757af.sql b/tests/ast_json_fixtures/shapes/241c1a1bc34757af.sql new file mode 100644 index 000000000000..86337dd72cb8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/241c1a1bc34757af.sql @@ -0,0 +1 @@ +ATTACH TEMPORARY TABLE tmp diff --git a/tests/ast_json_fixtures/shapes/241ef548903ce38a.json b/tests/ast_json_fixtures/shapes/241ef548903ce38a.json new file mode 100644 index 000000000000..c9d2eacc2740 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/241ef548903ce38a.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "01746_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "01746_local" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "01746_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/241ef548903ce38a.sql b/tests/ast_json_fixtures/shapes/241ef548903ce38a.sql new file mode 100644 index 000000000000..3c371c9c747e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/241ef548903ce38a.sql @@ -0,0 +1,2 @@ +CREATE TABLE `01746_dist` AS `01746_local` +ENGINE = Distributed('test_shard_localhost', currentDatabase(), `01746_local`, rand()) diff --git a/tests/ast_json_fixtures/shapes/241ffe592a1d48b0.json b/tests/ast_json_fixtures/shapes/241ffe592a1d48b0.json new file mode 100644 index 000000000000..0b15f6c9e02a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/241ffe592a1d48b0.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "Hello & world" + }, + { + "type": "Function", + "alias": "time", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2001-02-03 04:05:06" + } + ] + }, + { + "type": "Function", + "alias": "tpl", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Identifier", + "name": "time" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "extremes": "1", + "enable_named_columns_in_function_tuple": "0" + } + } + } + ], + "format": "XML" + } +} diff --git a/tests/ast_json_fixtures/shapes/241ffe592a1d48b0.sql b/tests/ast_json_fixtures/shapes/241ffe592a1d48b0.sql new file mode 100644 index 000000000000..39c6f7a665ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/241ffe592a1d48b0.sql @@ -0,0 +1 @@ +SELECT 'Hello & world' AS s, toDateTime('2001-02-03 04:05:06') AS time, (s, time) AS tpl SETTINGS extremes = 1, enable_named_columns_in_function_tuple = 0 FORMAT XML diff --git a/tests/ast_json_fixtures/shapes/242be4cfb2ec4281.json b/tests/ast_json_fixtures/shapes/242be4cfb2ec4281.json new file mode 100644 index 000000000000..639761942222 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/242be4cfb2ec4281.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_merge" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "test_local" + } + ] + } + }, + "as_table": "test_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/242be4cfb2ec4281.sql b/tests/ast_json_fixtures/shapes/242be4cfb2ec4281.sql new file mode 100644 index 000000000000..4a1747587c3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/242be4cfb2ec4281.sql @@ -0,0 +1,2 @@ +CREATE TABLE test_merge as test_local +ENGINE = Merge(currentDatabase(), 'test_local') diff --git a/tests/ast_json_fixtures/shapes/246e48297e2f8079.json b/tests/ast_json_fixtures/shapes/246e48297e2f8079.json new file mode 100644 index 000000000000..6c30e193809e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/246e48297e2f8079.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_clone_as": true, + "table": { + "type": "Identifier", + "name": "clone_as_foo_replacing_merge_tree" + }, + "as_table": "foo_replacing_merge_tree" + } +} diff --git a/tests/ast_json_fixtures/shapes/246e48297e2f8079.sql b/tests/ast_json_fixtures/shapes/246e48297e2f8079.sql new file mode 100644 index 000000000000..bd01fc298c15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/246e48297e2f8079.sql @@ -0,0 +1 @@ +CREATE TABLE clone_as_foo_replacing_merge_tree CLONE AS foo_replacing_merge_tree diff --git a/tests/ast_json_fixtures/shapes/247068ed5e9a4077.json b/tests/ast_json_fixtures/shapes/247068ed5e9a4077.json new file mode 100644 index 000000000000..380d5d99fb33 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/247068ed5e9a4077.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "merge_hits" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test" + }, + { + "type": "Literal", + "value_type": "String", + "value": "^hits$" + } + ] + } + }, + "as_database": "test", + "as_table": "hits" + } +} diff --git a/tests/ast_json_fixtures/shapes/247068ed5e9a4077.sql b/tests/ast_json_fixtures/shapes/247068ed5e9a4077.sql new file mode 100644 index 000000000000..6a8a8014076f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/247068ed5e9a4077.sql @@ -0,0 +1 @@ +CREATE TABLE IF NOT EXISTS merge_hits AS test.hits ENGINE = Merge(test, '^hits$') diff --git a/tests/ast_json_fixtures/shapes/24a214a5d39ff26b.json b/tests/ast_json_fixtures/shapes/24a214a5d39ff26b.json new file mode 100644 index 000000000000..3c2512797200 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24a214a5d39ff26b.json @@ -0,0 +1,234 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "id", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "query_id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "normalizeQuery", + "arguments": [ + { + "type": "Identifier", + "name": "query" + } + ] + }, + { + "type": "Function", + "name": "normalizeQuery", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "WITH 01091 AS id SELECT 1;" + } + ] + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + } + ], + "select": [ + { + "type": "Function", + "name": "uniqExact", + "arguments": [ + { + "type": "Identifier", + "name": "thread_id" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_thread_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Identifier", + "name": "id" + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "thread_id" + }, + { + "type": "Identifier", + "name": "master_thread_id" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/24a214a5d39ff26b.sql b/tests/ast_json_fixtures/shapes/24a214a5d39ff26b.sql new file mode 100644 index 000000000000..88ea60431259 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24a214a5d39ff26b.sql @@ -0,0 +1,11 @@ +WITH + ( + SELECT query_id + FROM system.query_log + WHERE current_database = currentDatabase() AND (normalizeQuery(query) like normalizeQuery('WITH 01091 AS id SELECT 1;')) AND (event_date >= (today() - 1)) + ORDER BY event_time DESC + LIMIT 1 + ) AS id +SELECT uniqExact(thread_id) +FROM system.query_thread_log +WHERE (event_date >= (today() - 1)) AND (query_id = id) AND (thread_id != master_thread_id) diff --git a/tests/ast_json_fixtures/shapes/24a8506bc962c825.json b/tests/ast_json_fixtures/shapes/24a8506bc962c825.json new file mode 100644 index 000000000000..89e5b33f064f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24a8506bc962c825.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "DropIndexQuery", + "table": { + "type": "Identifier", + "name": "t_index" + }, + "index_name": { + "type": "Identifier", + "name": "i_a" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/24a8506bc962c825.sql b/tests/ast_json_fixtures/shapes/24a8506bc962c825.sql new file mode 100644 index 000000000000..4ad32eb18efd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24a8506bc962c825.sql @@ -0,0 +1 @@ +drop index i_a on t_index diff --git a/tests/ast_json_fixtures/shapes/24a9d3883be5777a.json b/tests/ast_json_fixtures/shapes/24a9d3883be5777a.json new file mode 100644 index 000000000000..a8ec2813343e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24a9d3883be5777a.json @@ -0,0 +1,106 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "alias": "x", + "name": "sum", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "w" + }, + { + "type": "Function", + "alias": "y", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "w" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Identifier", + "name": "t_01568" + } + ] + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "p" + } + ] + } + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "y" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/24a9d3883be5777a.sql b/tests/ast_json_fixtures/shapes/24a9d3883be5777a.sql new file mode 100644 index 000000000000..968337b037aa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24a9d3883be5777a.sql @@ -0,0 +1 @@ +select distinct sum(number) over w as x, max(number) over w as y from remote('127.0.0.{1,2}', '', t_01568) window w as (partition by p) order by x, y diff --git a/tests/ast_json_fixtures/shapes/24b276ce998d0eca.json b/tests/ast_json_fixtures/shapes/24b276ce998d0eca.json new file mode 100644 index 000000000000..fe2a272f1bf5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24b276ce998d0eca.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q14_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "EXECUTION_TIME": "12884901888000000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/24b276ce998d0eca.sql b/tests/ast_json_fixtures/shapes/24b276ce998d0eca.sql new file mode 100644 index 000000000000..26cb4571a35a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24b276ce998d0eca.sql @@ -0,0 +1 @@ +CREATE QUOTA q14_01297 FOR INTERVAL 1 MINUTE MAX execution_time = '12Gi' diff --git a/tests/ast_json_fixtures/shapes/24ce434743cd570d.json b/tests/ast_json_fixtures/shapes/24ce434743cd570d.json new file mode 100644 index 000000000000..245b6b760d71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24ce434743cd570d.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "buffer1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Buffer", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "d5" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000000" + } + ] + } + }, + "as_table": "d5" + } +} diff --git a/tests/ast_json_fixtures/shapes/24ce434743cd570d.sql b/tests/ast_json_fixtures/shapes/24ce434743cd570d.sql new file mode 100644 index 000000000000..988241c4be10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24ce434743cd570d.sql @@ -0,0 +1 @@ +CREATE TABLE buffer1 AS d5 ENGINE = Buffer(currentDatabase(), d5, 1, 10000, 10000, 10000, 10000, 100000000, 100000000) diff --git a/tests/ast_json_fixtures/shapes/24e2cd3ccf5aadd2.json b/tests/ast_json_fixtures/shapes/24e2cd3ccf5aadd2.json new file mode 100644 index 000000000000..e372b3c37352 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24e2cd3ccf5aadd2.json @@ -0,0 +1,136 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "database": { + "type": "Identifier", + "name": "db_01268" + }, + "table": { + "type": "Identifier", + "name": "dict1" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "key_column", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "second_column", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "third_column", + "data_type": { + "type": "DataType", + "name": "String" + }, + "default_value": { + "type": "Literal", + "value_type": "String", + "value": "qqq" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "key_column" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "user", + "value": { + "type": "Literal", + "value_type": "String", + "value": "default" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "table_for_dict1" + } + }, + { + "type": "pair", + "key": "password", + "value": { + "type": "Literal", + "value_type": "String", + "value": "" + } + }, + { + "type": "pair", + "key": "db", + "value": { + "type": "Literal", + "value_type": "String", + "value": "database_for_dict_01268" + } + } + ] + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "direct", + "parameters": [] + }, + "settings": { + "type": "DictionarySettings", + "changes": { + "max_result_bytes": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/24e2cd3ccf5aadd2.sql b/tests/ast_json_fixtures/shapes/24e2cd3ccf5aadd2.sql new file mode 100644 index 000000000000..c34e80520fb5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24e2cd3ccf5aadd2.sql @@ -0,0 +1,9 @@ +CREATE DICTIONARY db_01268.dict1 +( + key_column UInt64 DEFAULT 0, + second_column UInt64 DEFAULT 1, + third_column String DEFAULT 'qqq' +) +PRIMARY KEY key_column +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict1' PASSWORD '' DB 'database_for_dict_01268')) +LAYOUT(DIRECT()) SETTINGS(max_result_bytes=1) diff --git a/tests/ast_json_fixtures/shapes/24e92de78e03c9db.json b/tests/ast_json_fixtures/shapes/24e92de78e03c9db.json new file mode 100644 index 000000000000..791df02d6eae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24e92de78e03c9db.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u1_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/24e92de78e03c9db.sql b/tests/ast_json_fixtures/shapes/24e92de78e03c9db.sql new file mode 100644 index 000000000000..d3035d5c825b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/24e92de78e03c9db.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS u1_01294 diff --git a/tests/ast_json_fixtures/shapes/252bab326fb281b9.json b/tests/ast_json_fixtures/shapes/252bab326fb281b9.json new file mode 100644 index 000000000000..6c30e5a758d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/252bab326fb281b9.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2,3}" + }, + { + "type": "Function", + "name": "values", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a UInt8, b UInt8" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/252bab326fb281b9.sql b/tests/ast_json_fixtures/shapes/252bab326fb281b9.sql new file mode 100644 index 000000000000..689a14a7fe32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/252bab326fb281b9.sql @@ -0,0 +1 @@ +SELECT DISTINCT a FROM remote('127.0.0.{1,2,3}', values('a UInt8, b UInt8', (1, 2), (1, 3))) GROUP BY a, b diff --git a/tests/ast_json_fixtures/shapes/25432aa7f4aa2e35.json b/tests/ast_json_fixtures/shapes/25432aa7f4aa2e35.json new file mode 100644 index 000000000000..bec51b812a1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/25432aa7f4aa2e35.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "alias": "a", + "name": "number" + }, + { + "type": "Function", + "alias": "b", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/25432aa7f4aa2e35.sql b/tests/ast_json_fixtures/shapes/25432aa7f4aa2e35.sql new file mode 100644 index 000000000000..9bf5db546c75 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/25432aa7f4aa2e35.sql @@ -0,0 +1,4 @@ +SELECT a, b +FROM numbers(3) +GROUP BY number as a, (number + number) as b WITH CUBE +ORDER BY a, b diff --git a/tests/ast_json_fixtures/shapes/255704b4f60ab5d0.json b/tests/ast_json_fixtures/shapes/255704b4f60ab5d0.json new file mode 100644 index 000000000000..510b0e590eae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/255704b4f60ab5d0.json @@ -0,0 +1,122 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "iterations", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "n", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "keccak256", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "consistent" + } + ] + } + ] + }, + { + "type": "Function", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "keccak256", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "iterations" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/255704b4f60ab5d0.sql b/tests/ast_json_fixtures/shapes/255704b4f60ab5d0.sql new file mode 100644 index 000000000000..b1015f2e60e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/255704b4f60ab5d0.sql @@ -0,0 +1,3 @@ +WITH iterations AS ( SELECT number AS n FROM system.numbers LIMIT 5 ) +SELECT hex(keccak256('consistent')), hex(keccak256(toString(n))) FROM iterations +ORDER BY n diff --git a/tests/ast_json_fixtures/shapes/256dbe7f5e375578.json b/tests/ast_json_fixtures/shapes/256dbe7f5e375578.json new file mode 100644 index 000000000000..3661f4ed29ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/256dbe7f5e375578.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "constrained2" + }, + "as_table": "constrained" + } +} diff --git a/tests/ast_json_fixtures/shapes/256dbe7f5e375578.sql b/tests/ast_json_fixtures/shapes/256dbe7f5e375578.sql new file mode 100644 index 000000000000..f0eeeb3bb93f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/256dbe7f5e375578.sql @@ -0,0 +1 @@ +CREATE TABLE constrained2 AS constrained diff --git a/tests/ast_json_fixtures/shapes/25859aabd77eb1f6.json b/tests/ast_json_fixtures/shapes/25859aabd77eb1f6.json new file mode 100644 index 000000000000..704ff2b393b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/25859aabd77eb1f6.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02483_plusthree" + } +} diff --git a/tests/ast_json_fixtures/shapes/25859aabd77eb1f6.sql b/tests/ast_json_fixtures/shapes/25859aabd77eb1f6.sql new file mode 100644 index 000000000000..8cb811d902f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/25859aabd77eb1f6.sql @@ -0,0 +1 @@ +DROP FUNCTION 02483_plusthree diff --git a/tests/ast_json_fixtures/shapes/25a53a9929552858.json b/tests/ast_json_fixtures/shapes/25a53a9929552858.json new file mode 100644 index 000000000000..7c7760d881a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/25a53a9929552858.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "table": { + "type": "Identifier", + "name": "primary_key_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "v1", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "v2", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ], + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/25a53a9929552858.sql b/tests/ast_json_fixtures/shapes/25a53a9929552858.sql new file mode 100644 index 000000000000..0f0b7035df4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/25a53a9929552858.sql @@ -0,0 +1 @@ +ATTACH TABLE primary_key_test(v1 Int32, v2 Int32, PRIMARY KEY(v1, v2)) ENGINE=ReplacingMergeTree ORDER BY (v1, v2) diff --git a/tests/ast_json_fixtures/shapes/25b60f75f09f96ef.json b/tests/ast_json_fixtures/shapes/25b60f75f09f96ef.json new file mode 100644 index 000000000000..872c2adcb390 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/25b60f75f09f96ef.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u2_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/25b60f75f09f96ef.sql b/tests/ast_json_fixtures/shapes/25b60f75f09f96ef.sql new file mode 100644 index 000000000000..6c5a5befbaac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/25b60f75f09f96ef.sql @@ -0,0 +1 @@ +DROP USER u1_01292, u2_01292 diff --git a/tests/ast_json_fixtures/shapes/25c3a58df52e0c88.json b/tests/ast_json_fixtures/shapes/25c3a58df52e0c88.json new file mode 100644 index 000000000000..26e5c56d809d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/25c3a58df52e0c88.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["Вася Пупкин"] + } +} diff --git a/tests/ast_json_fixtures/shapes/25c3a58df52e0c88.sql b/tests/ast_json_fixtures/shapes/25c3a58df52e0c88.sql new file mode 100644 index 000000000000..cd0c3c191776 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/25c3a58df52e0c88.sql @@ -0,0 +1 @@ +drop user "Вася Пупкин" diff --git a/tests/ast_json_fixtures/shapes/260fe2a495b5bb91.json b/tests/ast_json_fixtures/shapes/260fe2a495b5bb91.json new file mode 100644 index 000000000000..225f61abc287 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/260fe2a495b5bb91.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q1_01297", "q2_01297", "q3_01297", "q4_01297", "q5_01297", "q6_01297", "q7_01297", "q8_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/260fe2a495b5bb91.sql b/tests/ast_json_fixtures/shapes/260fe2a495b5bb91.sql new file mode 100644 index 000000000000..969c1313cb5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/260fe2a495b5bb91.sql @@ -0,0 +1 @@ +DROP QUOTA q1_01297, q2_01297, q3_01297, q4_01297, q5_01297, q6_01297, q7_01297, q8_01297 diff --git a/tests/ast_json_fixtures/shapes/262b82de8a280288.json b/tests/ast_json_fixtures/shapes/262b82de8a280288.json new file mode 100644 index 000000000000..046c1bbc48a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/262b82de8a280288.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SetRoleQuery", + "kind": "SET_DEFAULT_ROLE", + "roles": { + "type": "RolesOrUsersSet", + "names": ["r2_01292"] + }, + "to_users": { + "type": "RolesOrUsersSet", + "names": ["u3_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/262b82de8a280288.sql b/tests/ast_json_fixtures/shapes/262b82de8a280288.sql new file mode 100644 index 000000000000..948b27ab14c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/262b82de8a280288.sql @@ -0,0 +1 @@ +SET DEFAULT ROLE r2_01292 TO u3_01292 diff --git a/tests/ast_json_fixtures/shapes/2637781ab563074e.json b/tests/ast_json_fixtures/shapes/2637781ab563074e.json new file mode 100644 index 000000000000..9b7e1c341f46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2637781ab563074e.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/2637781ab563074e.sql b/tests/ast_json_fixtures/shapes/2637781ab563074e.sql new file mode 100644 index 000000000000..c1a0d38dea5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2637781ab563074e.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r1_01293 diff --git a/tests/ast_json_fixtures/shapes/26476e54b1d356c7.json b/tests/ast_json_fixtures/shapes/26476e54b1d356c7.json new file mode 100644 index 000000000000..b374608462bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/26476e54b1d356c7.json @@ -0,0 +1,125 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "period", + "name": "date" + }, + { + "type": "Literal", + "alias": "having_check", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "alias": "period_start", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + { + "type": "Function", + "alias": "period_end", + "name": "addDays", + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "total_duration", + "name": "dateDiff", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "second" + }, + { + "type": "Identifier", + "name": "period_start" + }, + { + "type": "Identifier", + "name": "period_end" + } + ] + }, + { + "type": "Function", + "alias": "metric_", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "metric" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "repro_hits" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "period" + } + ], + "having": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "having_check" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/26476e54b1d356c7.sql b/tests/ast_json_fixtures/shapes/26476e54b1d356c7.sql new file mode 100644 index 000000000000..40fcd5d449fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/26476e54b1d356c7.sql @@ -0,0 +1 @@ +SELECT date as period, 1 as having_check, min(date) as period_start, addDays(max(date), 1) as period_end, dateDiff('second', period_start, period_end) as total_duration, sum(metric) as metric_ FROM repro_hits GROUP BY period HAVING having_check != -1 diff --git a/tests/ast_json_fixtures/shapes/2664ebd33530996f.json b/tests/ast_json_fixtures/shapes/2664ebd33530996f.json new file mode 100644 index 000000000000..d51c0b48163f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2664ebd33530996f.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "uint64", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "int32", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "Int32" + } + ] + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "example comment" + } + }, + { + "type": "ColumnDeclaration", + "name": "str", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx", + "expression": { + "type": "Identifier", + "name": "str" + }, + "index_type": { + "type": "Function", + "name": "set", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "uint64" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "uint64" + }, + { + "type": "Identifier", + "name": "str" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2664ebd33530996f.sql b/tests/ast_json_fixtures/shapes/2664ebd33530996f.sql new file mode 100644 index 000000000000..8d95c98cda01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2664ebd33530996f.sql @@ -0,0 +1,10 @@ +CREATE TABLE tab +( + `uint64` UInt64, + `int32` Nullable(Int32) COMMENT 'example comment', + `str` String, + INDEX idx str TYPE set(1000) +) +ENGINE = MergeTree +PRIMARY KEY (uint64) +ORDER BY (uint64, str) diff --git a/tests/ast_json_fixtures/shapes/266a527db1f77cd0.json b/tests/ast_json_fixtures/shapes/266a527db1f77cd0.json new file mode 100644 index 000000000000..f21d35984190 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/266a527db1f77cd0.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "category" + }, + { + "type": "Function", + "alias": "combined", + "name": "concat", + "arguments": [ + { + "type": "Identifier", + "name": "category" + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + }, + { + "type": "Identifier", + "name": "name" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_all" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "category" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "by": [] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/266a527db1f77cd0.sql b/tests/ast_json_fixtures/shapes/266a527db1f77cd0.sql new file mode 100644 index 000000000000..c204947b3716 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/266a527db1f77cd0.sql @@ -0,0 +1,4 @@ +SELECT id, category, concat(category, '_', name) as combined +FROM test_limit_by_all +ORDER BY id, category, value +LIMIT 2 BY ALL diff --git a/tests/ast_json_fixtures/shapes/26a217c202ce4374.json b/tests/ast_json_fixtures/shapes/26a217c202ce4374.json new file mode 100644 index 000000000000..71b6066f02b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/26a217c202ce4374.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_part_offset" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_bytes_to_read": "98312" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/26a217c202ce4374.sql b/tests/ast_json_fixtures/shapes/26a217c202ce4374.sql new file mode 100644 index 000000000000..42fa4a945af4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/26a217c202ce4374.sql @@ -0,0 +1 @@ +select * from x prewhere _part_offset = 0 settings max_bytes_to_read = 98312 diff --git a/tests/ast_json_fixtures/shapes/26aa31065b2431d4.json b/tests/ast_json_fixtures/shapes/26aa31065b2431d4.json new file mode 100644 index 000000000000..f5b1ecc3b6a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/26aa31065b2431d4.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/26aa31065b2431d4.sql b/tests/ast_json_fixtures/shapes/26aa31065b2431d4.sql new file mode 100644 index 000000000000..25c1ef2044e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/26aa31065b2431d4.sql @@ -0,0 +1 @@ +SELECT min(id) FROM t FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/26ade9e9cfa18a7f.json b/tests/ast_json_fixtures/shapes/26ade9e9cfa18a7f.json new file mode 100644 index 000000000000..0ad2640b295d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/26ade9e9cfa18a7f.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "UndropQuery", + "table": { + "type": "Identifier", + "name": "02681_undrop_uuid_on_cluster" + }, + "format": "Null", + "cluster": "test_shard_localhost" + } +} diff --git a/tests/ast_json_fixtures/shapes/26ade9e9cfa18a7f.sql b/tests/ast_json_fixtures/shapes/26ade9e9cfa18a7f.sql new file mode 100644 index 000000000000..ad0090570a8d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/26ade9e9cfa18a7f.sql @@ -0,0 +1 @@ +undrop table 02681_undrop_uuid_on_cluster on cluster test_shard_localhost format Null diff --git a/tests/ast_json_fixtures/shapes/26cd62cd72e19b65.json b/tests/ast_json_fixtures/shapes/26cd62cd72e19b65.json new file mode 100644 index 000000000000..6ac65c803801 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/26cd62cd72e19b65.json @@ -0,0 +1,199 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "part_name" + }, + { + "type": "Function", + "alias": "mergers", + "name": "arraySort", + "arguments": [ + { + "type": "Function", + "name": "groupArrayIf", + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "MergeParts" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "fetchers", + "name": "arraySort", + "arguments": [ + { + "type": "Function", + "name": "groupArrayIf", + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DownloadPart" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "part_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_time" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "now", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "120" + } + ] + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "execute\\_on\\_single\\_replica\\_r%" + } + ] + }, + { + "type": "Function", + "name": "notLike", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "part_name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%\\_0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "part_name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "part_name" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/26cd62cd72e19b65.sql b/tests/ast_json_fixtures/shapes/26cd62cd72e19b65.sql new file mode 100644 index 000000000000..0c7610ba292c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/26cd62cd72e19b65.sql @@ -0,0 +1,12 @@ +SELECT + part_name, + arraySort(groupArrayIf(table, event_type = 'MergeParts')) AS mergers, + arraySort(groupArrayIf(table, event_type = 'DownloadPart')) AS fetchers +FROM system.part_log +WHERE (event_time > (now() - 120)) + AND (table LIKE 'execute\\_on\\_single\\_replica\\_r%') + AND (part_name NOT LIKE '%\\_0') + AND (database = currentDatabase()) +GROUP BY part_name +ORDER BY part_name +FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/2705df885c4ad2ff.json b/tests/ast_json_fixtures/shapes/2705df885c4ad2ff.json new file mode 100644 index 000000000000..a7ed6a1bb1ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2705df885c4ad2ff.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "rmt" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PARTITION", + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2705df885c4ad2ff.sql b/tests/ast_json_fixtures/shapes/2705df885c4ad2ff.sql new file mode 100644 index 000000000000..dcdf1c820499 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2705df885c4ad2ff.sql @@ -0,0 +1 @@ +alter table rmt drop partition id '0' diff --git a/tests/ast_json_fixtures/shapes/270a2e35575fe0e9.json b/tests/ast_json_fixtures/shapes/270a2e35575fe0e9.json new file mode 100644 index 000000000000..3146b1b0410a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/270a2e35575fe0e9.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "null_dict" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "val", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "default_val", + "data_type": { + "type": "DataType", + "name": "UInt8" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "123" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "nullable_val", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "UInt8" + } + ] + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "null", + "elements": [] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 0 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/270a2e35575fe0e9.sql b/tests/ast_json_fixtures/shapes/270a2e35575fe0e9.sql new file mode 100644 index 000000000000..34e02b5c59d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/270a2e35575fe0e9.sql @@ -0,0 +1,10 @@ +CREATE DICTIONARY null_dict ( + id UInt64, + val UInt8, + default_val UInt8 DEFAULT 123, + nullable_val Nullable(UInt8) +) +PRIMARY KEY id +SOURCE(NULL()) +LAYOUT(FLAT()) +LIFETIME(0) diff --git a/tests/ast_json_fixtures/shapes/2743d2322ac1160a.json b/tests/ast_json_fixtures/shapes/2743d2322ac1160a.json new file mode 100644 index 000000000000..d80587e3b3bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2743d2322ac1160a.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s3_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/2743d2322ac1160a.sql b/tests/ast_json_fixtures/shapes/2743d2322ac1160a.sql new file mode 100644 index 000000000000..3a13d05f2b77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2743d2322ac1160a.sql @@ -0,0 +1 @@ +CREATE PROFILE s3_01294 diff --git a/tests/ast_json_fixtures/shapes/2749396b496cbb39.json b/tests/ast_json_fixtures/shapes/2749396b496cbb39.json new file mode 100644 index 000000000000..80dcc7bbb15c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2749396b496cbb39.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "getSetting", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "max_block_size" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "1" + } + } + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/2749396b496cbb39.sql b/tests/ast_json_fixtures/shapes/2749396b496cbb39.sql new file mode 100644 index 000000000000..26c214e34a37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2749396b496cbb39.sql @@ -0,0 +1 @@ +SELECT getSetting('max_block_size') SETTINGS max_block_size = 1 FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/274a7b66d244ce6d.json b/tests/ast_json_fixtures/shapes/274a7b66d244ce6d.json new file mode 100644 index 000000000000..12f327bd2366 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/274a7b66d244ce6d.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/274a7b66d244ce6d.sql b/tests/ast_json_fixtures/shapes/274a7b66d244ce6d.sql new file mode 100644 index 000000000000..f7954a9d5db3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/274a7b66d244ce6d.sql @@ -0,0 +1 @@ +SELECT x, x + 1, 1 AS x diff --git a/tests/ast_json_fixtures/shapes/27569106ab0ca085.json b/tests/ast_json_fixtures/shapes/27569106ab0ca085.json new file mode 100644 index 000000000000..7c11dde3a300 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/27569106ab0ca085.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "check_query_comment_column" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "first_column", + "data_type": { + "type": "DataType", + "name": "UInt8" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "comment 1" + } + }, + { + "type": "ColumnDeclaration", + "name": "second_column", + "data_type": { + "type": "DataType", + "name": "UInt8" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "comment 2" + } + }, + { + "type": "ColumnDeclaration", + "name": "third_column", + "data_type": { + "type": "DataType", + "name": "UInt8" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "comment 3" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "second_column" + }, + "order_by": { + "type": "Identifier", + "name": "first_column" + }, + "sample_by": { + "type": "Identifier", + "name": "first_column" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/27569106ab0ca085.sql b/tests/ast_json_fixtures/shapes/27569106ab0ca085.sql new file mode 100644 index 000000000000..f25c0c4cd282 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/27569106ab0ca085.sql @@ -0,0 +1,9 @@ +CREATE TABLE check_query_comment_column + ( + first_column UInt8 COMMENT 'comment 1', + second_column UInt8 COMMENT 'comment 2', + third_column UInt8 COMMENT 'comment 3' + ) ENGINE = MergeTree() + ORDER BY first_column + PARTITION BY second_column + SAMPLE BY first_column diff --git a/tests/ast_json_fixtures/shapes/276fed42a494bc9a.json b/tests/ast_json_fixtures/shapes/276fed42a494bc9a.json new file mode 100644 index 000000000000..39949f033bd9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/276fed42a494bc9a.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "cluster": "test_shard_localhost", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "02911_rowpolicy", + "database": "default" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "names": ["02911_user"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/276fed42a494bc9a.sql b/tests/ast_json_fixtures/shapes/276fed42a494bc9a.sql new file mode 100644 index 000000000000..1917bcde9347 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/276fed42a494bc9a.sql @@ -0,0 +1 @@ +CREATE ROW POLICY 02911_rowpolicy ON CLUSTER test_shard_localhost ON default.* USING 1 TO 02911_user diff --git a/tests/ast_json_fixtures/shapes/278239a66c1428ae.json b/tests/ast_json_fixtures/shapes/278239a66c1428ae.json new file mode 100644 index 000000000000..edefa07f2a9f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/278239a66c1428ae.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t1_distr" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards_localhost" + }, + { + "type": "Identifier", + "name": "test_01103" + }, + { + "type": "Identifier", + "name": "t1_shard" + }, + { + "type": "Identifier", + "name": "id" + } + ] + } + }, + "as_table": "t1_shard" + } +} diff --git a/tests/ast_json_fixtures/shapes/278239a66c1428ae.sql b/tests/ast_json_fixtures/shapes/278239a66c1428ae.sql new file mode 100644 index 000000000000..20f47064615d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/278239a66c1428ae.sql @@ -0,0 +1 @@ +create table t1_distr as t1_shard engine Distributed(test_cluster_two_shards_localhost, test_01103, t1_shard, id) diff --git a/tests/ast_json_fixtures/shapes/278640c321846b68.json b/tests/ast_json_fixtures/shapes/278640c321846b68.json new file mode 100644 index 000000000000..a57017c96d6d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/278640c321846b68.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "02162_test_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "range_value", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "start", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "expression": { + "type": "Identifier", + "name": "range_value" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "end", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "expression": { + "type": "Identifier", + "name": "range_value" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "02162_test_table" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 0 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "range_hashed", + "parameters": [] + }, + "range": { + "type": "DictionaryRange", + "min_attr_name": "start", + "max_attr_name": "end" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/278640c321846b68.sql b/tests/ast_json_fixtures/shapes/278640c321846b68.sql new file mode 100644 index 000000000000..f1796258a4ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/278640c321846b68.sql @@ -0,0 +1,13 @@ +CREATE DICTIONARY 02162_test_dictionary +( + id UInt64, + value String, + range_value UInt64, + start UInt64 EXPRESSION range_value, + end UInt64 EXPRESSION range_value +) +PRIMARY KEY id +SOURCE(CLICKHOUSE(TABLE '02162_test_table')) +LAYOUT(RANGE_HASHED()) +RANGE(MIN start MAX end) +LIFETIME(0) diff --git a/tests/ast_json_fixtures/shapes/278ba44e6ae99e98.json b/tests/ast_json_fixtures/shapes/278ba44e6ae99e98.json new file mode 100644 index 000000000000..3ec9693594ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/278ba44e6ae99e98.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "_row_exists" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_apply_deleted_mask" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "apply_deleted_mask": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/278ba44e6ae99e98.sql b/tests/ast_json_fixtures/shapes/278ba44e6ae99e98.sql new file mode 100644 index 000000000000..dee294a50038 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/278ba44e6ae99e98.sql @@ -0,0 +1 @@ +SELECT *, _row_exists FROM test_apply_deleted_mask SETTINGS apply_deleted_mask = 0 diff --git a/tests/ast_json_fixtures/shapes/27c9e73540bfc27e.json b/tests/ast_json_fixtures/shapes/27c9e73540bfc27e.json new file mode 100644 index 000000000000..a1aff049bfa7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/27c9e73540bfc27e.json @@ -0,0 +1,98 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_window_view": true, + "table": { + "type": "Identifier", + "name": "v" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "Int8" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "nonexist" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "tumble", + "arguments": [ + { + "type": "Function", + "name": "now", + "arguments": [] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_window_view": "1", + "allow_experimental_analyzer": "0" + } + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "table": "nonexist" + }, + { + "kind": "inner", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "AggregatingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "x" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/27c9e73540bfc27e.sql b/tests/ast_json_fixtures/shapes/27c9e73540bfc27e.sql new file mode 100644 index 000000000000..176705f76dac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/27c9e73540bfc27e.sql @@ -0,0 +1 @@ +create window view v to nonexist (x Int8) inner engine AggregatingMergeTree order by x as select x from nonexist group by tumble(now()) settings allow_experimental_window_view = 1, allow_experimental_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/27cb0f135e2a5e05.json b/tests/ast_json_fixtures/shapes/27cb0f135e2a5e05.json new file mode 100644 index 000000000000..7ce5d03579b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/27cb0f135e2a5e05.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "dictGet", + "arguments": [] + } + ] + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/27cb0f135e2a5e05.sql b/tests/ast_json_fixtures/shapes/27cb0f135e2a5e05.sql new file mode 100644 index 000000000000..637f6774abef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/27cb0f135e2a5e05.sql @@ -0,0 +1 @@ +SELECT ( SELECT dictGet() ) settings enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/27d8464f64b35a5b.json b/tests/ast_json_fixtures/shapes/27d8464f64b35a5b.json new file mode 100644 index 000000000000..b7f97e3f8b5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/27d8464f64b35a5b.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mt2" + }, + "as_table": "mt" + } +} diff --git a/tests/ast_json_fixtures/shapes/27d8464f64b35a5b.sql b/tests/ast_json_fixtures/shapes/27d8464f64b35a5b.sql new file mode 100644 index 000000000000..1ba2228f1450 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/27d8464f64b35a5b.sql @@ -0,0 +1 @@ +CREATE TABLE mt2 AS mt diff --git a/tests/ast_json_fixtures/shapes/280a062d6fd0f792.json b/tests/ast_json_fixtures/shapes/280a062d6fd0f792.json new file mode 100644 index 000000000000..612f85cb7b4e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/280a062d6fd0f792.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "replace_table": true, + "create_or_replace": true, + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "INT" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "x" + }, + "settings": { + "type": "Settings", + "changes": { + "disk": "s3_disk" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/280a062d6fd0f792.sql b/tests/ast_json_fixtures/shapes/280a062d6fd0f792.sql new file mode 100644 index 000000000000..3596fa14ef41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/280a062d6fd0f792.sql @@ -0,0 +1 @@ +CREATE OR REPLACE TABLE t (x INT) ENGINE=MergeTree ORDER BY x SETTINGS disk='s3_disk' diff --git a/tests/ast_json_fixtures/shapes/2833d4038587286e.json b/tests/ast_json_fixtures/shapes/2833d4038587286e.json new file mode 100644 index 000000000000..fceac97ca1a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2833d4038587286e.json @@ -0,0 +1,104 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_agg_proj_02302" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "0", + "optimize_read_in_order": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2833d4038587286e.sql b/tests/ast_json_fixtures/shapes/2833d4038587286e.sql new file mode 100644 index 000000000000..3af0a7ac51da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2833d4038587286e.sql @@ -0,0 +1 @@ +select x + y, sum(x - y) as s from test_agg_proj_02302 group by x + y order by s desc limit 5 settings optimize_aggregation_in_order=0, optimize_read_in_order=0 diff --git a/tests/ast_json_fixtures/shapes/283a5a41e5739c49.json b/tests/ast_json_fixtures/shapes/283a5a41e5739c49.json new file mode 100644 index 000000000000..82e03b6fb1e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/283a5a41e5739c49.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "� �" + } + ] + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/283a5a41e5739c49.sql b/tests/ast_json_fixtures/shapes/283a5a41e5739c49.sql new file mode 100644 index 000000000000..13420a585a08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/283a5a41e5739c49.sql @@ -0,0 +1 @@ +SELECT '\xED\x20\xA8' AS s FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/285477900af72733.json b/tests/ast_json_fixtures/shapes/285477900af72733.json new file mode 100644 index 000000000000..269a442a98a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/285477900af72733.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "if_exists": true, + "names": ["s1_01294", "s2_01294", "s3_01294", "s4_01294", "s5_01294", "s6_01294", "s7_01294", "s8_01294", "s9_01294", "s10_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/285477900af72733.sql b/tests/ast_json_fixtures/shapes/285477900af72733.sql new file mode 100644 index 000000000000..66f01093c799 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/285477900af72733.sql @@ -0,0 +1 @@ +DROP SETTINGS PROFILE IF EXISTS s1_01294, s2_01294, s3_01294, s4_01294, s5_01294, s6_01294, s7_01294, s8_01294, s9_01294, s10_01294 diff --git a/tests/ast_json_fixtures/shapes/2860614c9609c4a5.json b/tests/ast_json_fixtures/shapes/2860614c9609c4a5.json new file mode 100644 index 000000000000..f454788f636b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2860614c9609c4a5.json @@ -0,0 +1,4010 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "sample_frequency", + "value_type": "UInt64", + "value": "44100" + }, + { + "type": "Identifier", + "alias": "tick", + "name": "number" + }, + { + "type": "Function", + "alias": "time", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tick" + }, + { + "type": "Identifier", + "name": "sample_frequency" + } + ] + }, + { + "type": "Literal", + "alias": "master_volume", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "alias": "clamp", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "level" + } + ] + }, + { + "type": "Function", + "name": "least", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1 + }, + { + "type": "Function", + "name": "greatest", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": -1 + }, + { + "type": "Identifier", + "name": "level" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "output", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "level" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "clamp", + "arguments": [ + { + "type": "Identifier", + "name": "level" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "32767" + } + ] + }, + { + "type": "Identifier", + "name": "master_volume" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Int16" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "mono", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "sine_wave", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "sin", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "pi", + "arguments": [] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "square_wave", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt64" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "sawtooth_wave", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "floor", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "triangle_wave", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "abs", + "arguments": [ + { + "type": "Function", + "name": "sawtooth_wave", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "lfo", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "from" + }, + { + "type": "Identifier", + "name": "to" + }, + { + "type": "Identifier", + "name": "wave" + }, + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "from" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "wave", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "to" + }, + { + "type": "Identifier", + "name": "from" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "step_lfo", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "from" + }, + { + "type": "Identifier", + "name": "to" + }, + { + "type": "Identifier", + "name": "steps" + }, + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "from" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "floor", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "floor", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "steps" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "steps" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "to" + }, + { + "type": "Identifier", + "name": "from" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "exp_step_lfo", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "from" + }, + { + "type": "Identifier", + "name": "to" + }, + { + "type": "Identifier", + "name": "steps" + }, + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "exp", + "arguments": [ + { + "type": "Function", + "name": "step_lfo", + "arguments": [ + { + "type": "Function", + "name": "log", + "arguments": [ + { + "type": "Identifier", + "name": "from" + } + ] + }, + { + "type": "Function", + "name": "log", + "arguments": [ + { + "type": "Identifier", + "name": "to" + } + ] + }, + { + "type": "Identifier", + "name": "steps" + }, + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "uniform_noise", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "18446744073709551615" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "white_noise", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "erf", + "arguments": [ + { + "type": "Function", + "name": "uniform_noise", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "bernoulli_noise", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "clipping", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "amount" + } + ] + }, + { + "type": "Function", + "name": "clamp", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "amount" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "power_distortion", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "amount" + } + ] + }, + { + "type": "Function", + "name": "clamp", + "arguments": [ + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "amount" + } + ] + }, + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Identifier", + "name": "amount" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "bitcrush", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "amount" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "exp2", + "arguments": [ + { + "type": "Identifier", + "name": "amount" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "exp2", + "arguments": [ + { + "type": "Identifier", + "name": "amount" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "desample", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Identifier", + "name": "sample_frequency" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Identifier", + "name": "sample_frequency" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "sample_frequency" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "thin", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Identifier", + "name": "wave" + }, + { + "type": "Identifier", + "name": "amount" + } + ] + }, + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "floor", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "amount" + } + ] + } + ] + }, + { + "type": "Function", + "name": "wave", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "amount" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "skew", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Identifier", + "name": "wave" + }, + { + "type": "Identifier", + "name": "amount" + } + ] + }, + { + "type": "Function", + "name": "wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "floor", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "floor", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "amount" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "combine", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "weight" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "weight" + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "weight" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "envelope", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "attack" + }, + { + "type": "Identifier", + "name": "hold" + }, + { + "type": "Identifier", + "name": "release" + } + ] + }, + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Identifier", + "name": "offset" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "attack" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Identifier", + "name": "offset" + } + ] + }, + { + "type": "Identifier", + "name": "attack" + } + ] + }, + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "attack" + } + ] + }, + { + "type": "Identifier", + "name": "hold" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "attack" + } + ] + }, + { + "type": "Identifier", + "name": "hold" + } + ] + }, + { + "type": "Identifier", + "name": "release" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "attack" + } + ] + }, + { + "type": "Identifier", + "name": "hold" + } + ] + }, + { + "type": "Identifier", + "name": "release" + } + ] + }, + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Identifier", + "name": "release" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "running_envelope", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bpm" + }, + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "attack" + }, + { + "type": "Identifier", + "name": "hold" + }, + { + "type": "Identifier", + "name": "release" + } + ] + }, + { + "type": "Function", + "name": "envelope", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bpm" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + } + ] + }, + { + "type": "Function", + "name": "floor", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bpm" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "attack" + }, + { + "type": "Identifier", + "name": "hold" + }, + { + "type": "Identifier", + "name": "release" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "sequencer", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "sequence" + }, + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "sequence" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt64" + } + ] + }, + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "sequence" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "delay", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Identifier", + "name": "wave" + }, + { + "type": "Identifier", + "name": "delay" + }, + { + "type": "Identifier", + "name": "decay" + }, + { + "type": "Identifier", + "name": "count" + } + ] + }, + { + "type": "Function", + "name": "arraySum", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "wave", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "delay" + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Identifier", + "name": "decay" + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "count" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "kick", + "name": "delay", + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "power_distortion", + "arguments": [ + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "80" + } + ] + }, + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "sine_wave" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "running_envelope", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + }, + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "output", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "kick" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "delay", + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "power_distortion", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "running_envelope", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + }, + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.75 + }, + { + "type": "Identifier", + "name": "triangle_wave" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "triangle_wave" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "delay", + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "power_distortion", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "sequencer", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "50" + }, + { + "value_type": "UInt64", + "value": "100" + }, + { + "value_type": "UInt64", + "value": "200" + }, + { + "value_type": "UInt64", + "value": "400" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "sequencer", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "50" + }, + { + "value_type": "UInt64", + "value": "100" + }, + { + "value_type": "UInt64", + "value": "200" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "running_envelope", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + }, + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.75 + }, + { + "type": "Identifier", + "name": "triangle_wave" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "triangle_wave" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "delay", + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "white_noise", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "running_envelope", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + }, + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.75 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "triangle_wave" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "24" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "13" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "running_envelope", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "120" + }, + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "output", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "kick" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "delay", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + } + ] + }, + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "power_distortion", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "running_envelope", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + }, + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.75 + }, + { + "type": "Identifier", + "name": "triangle_wave" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "triangle_wave" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "delay", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + } + ] + }, + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "power_distortion", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "sequencer", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "50" + }, + { + "value_type": "UInt64", + "value": "100" + }, + { + "value_type": "UInt64", + "value": "200" + }, + { + "value_type": "UInt64", + "value": "400" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "sine_wave", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "sequencer", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "50" + }, + { + "value_type": "UInt64", + "value": "100" + }, + { + "value_type": "UInt64", + "value": "200" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "running_envelope", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + }, + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.75 + }, + { + "type": "Identifier", + "name": "triangle_wave" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "triangle_wave" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "delay", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.005 + } + ] + }, + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "white_noise", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Function", + "name": "running_envelope", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + }, + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.75 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "lfo", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "triangle_wave" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "24" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "13" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2860614c9609c4a5.sql b/tests/ast_json_fixtures/shapes/2860614c9609c4a5.sql new file mode 100644 index 000000000000..1f187ca9d749 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2860614c9609c4a5.sql @@ -0,0 +1,121 @@ +WITH + + 44100 AS sample_frequency + , number AS tick + , tick / sample_frequency AS time + + + , 1 AS master_volume + , level -> least(1.0, greatest(-1.0, level)) AS clamp + , level -> (clamp(level) * 0x7FFF * master_volume)::Int16 AS output + , x -> (x, x) AS mono + + + , time -> sin(time * 2 * pi()) AS sine_wave + , time -> time::UInt64 % 2 * 2 - 1 AS square_wave + , time -> (time - floor(time)) * 2 - 1 AS sawtooth_wave + , time -> abs(sawtooth_wave(time)) * 2 - 1 AS triangle_wave + + + , (from, to, wave, time) -> from + ((wave(time) + 1) / 2) * (to - from) AS lfo + , (from, to, steps, time) -> from + floor((time - floor(time)) * steps) / steps * (to - from) AS step_lfo + , (from, to, steps, time) -> exp(step_lfo(log(from), log(to), steps, time)) AS exp_step_lfo + + + , time -> cityHash64(time) / 0xFFFFFFFFFFFFFFFF AS uniform_noise + , time -> erf(uniform_noise(time)) AS white_noise + , time -> cityHash64(time) % 2 ? 1 : -1 AS bernoulli_noise + + + , (x, amount) -> clamp(x * amount) AS clipping + , (x, amount) -> clamp(x > 0 ? pow(x, amount) : -pow(-x, amount)) AS power_distortion + , (x, amount) -> round(x * exp2(amount)) / exp2(amount) AS bitcrush + , (time, sample_frequency) -> round(time * sample_frequency) / sample_frequency AS desample + , (time, wave, amount) -> (time - floor(time) < (1 - amount)) ? wave(time * (1 - amount)) : 0 AS thin + , (time, wave, amount) -> wave(floor(time) + pow(time - floor(time), amount)) AS skew + + + , (a, b, weight) -> a * (1 - weight) + b * weight AS combine + + + , (time, offset, attack, hold, release) -> + time < offset ? 0 + : (time < offset + attack ? ((time - offset) / attack) + : (time < offset + attack + hold ? 1 + : (time < offset + attack + hold + release ? (offset + attack + hold + release - time) / release + : 0))) AS envelope + + , (bpm, time, offset, attack, hold, release) -> + envelope( + time * (bpm / 60) - floor(time * (bpm / 60)), + offset, + attack, + hold, + release) AS running_envelope + + + , (sequence, time) -> sequence[1 + time::UInt64 % length(sequence)] AS sequencer + + + , (time, wave, delay, decay, count) -> arraySum(n -> wave(time - delay * n) * pow(decay, n), range(count)) AS delay + + + , delay(time, (time -> power_distortion(sine_wave(time * 80 + sine_wave(time * 2)), lfo(0.5, 1, sine_wave, time / 16)) + * running_envelope(60, time, 0, 0.0, 0.01, 0.1)), + 0.2, 0.5, 5) AS kick + +SELECT + + (output( + kick + + delay(time, (time -> + power_distortion( + sine_wave(time * 50 + 1 * sine_wave(time * 100 + 1/4)) + * running_envelope(60, time, 0, 0.01, 0.01, 0.1), + lfo(1, 0.75, triangle_wave, time / 8))), + 0.2, 0.5, 10) + * lfo(0.5, 1, triangle_wave, time / 7) + + + delay(time, (time -> + power_distortion( + sine_wave(time * sequencer([50, 100, 200, 400], time / 2) + 1 * sine_wave(time * sequencer([50, 100, 200], time / 4) + 1/4)) + * running_envelope(60, time, 0.5, 0.01, 0.01, 0.1), + lfo(1, 0.75, triangle_wave, time / 8))), + 0.2, 0.5, 10) + * lfo(0.5, 1, triangle_wave, 16 + time / 11) + + + delay(time, (time -> + white_noise(time) * running_envelope(60, time, 0.75, 0.01, 0.01, 0.1)), + 0.2, 0.5, 10) + * lfo(0.5, 1, triangle_wave, 24 + time / 13) + + + sine_wave(time * 100 + 1 * sine_wave(time * 10 + 1/4)) + * running_envelope(120, time, 0, 0.01, 0.01, 0.1) + ), + + output( + kick + + delay(time + 0.01, (time -> + power_distortion( + sine_wave(time * 50 + 1 * sine_wave(time * 100 + 1/4)) + * running_envelope(60, time, 0, 0.01, 0.01, 0.1), + lfo(1, 0.75, triangle_wave, time / 8))), + 0.2, 0.5, 10) + * lfo(0.5, 1, triangle_wave, time / 7) + + + delay(time - 0.01, (time -> + power_distortion( + sine_wave(time * sequencer([50, 100, 200, 400], time / 2) + 1 * sine_wave(time * sequencer([50, 100, 200], time / 4) + 1/4)) + * running_envelope(60, time, 0.5, 0.01, 0.01, 0.1), + lfo(1, 0.75, triangle_wave, time / 8))), + 0.2, 0.5, 10) + * lfo(0.5, 1, triangle_wave, 16 + time / 11) + + + delay(time + 0.005, (time -> + white_noise(time) * running_envelope(60, time, 0.75, 0.01, 0.01, 0.1)), + 0.2, 0.5, 10) + * lfo(0.5, 1, triangle_wave, 24 + time / 13) + )) + +FROM system.numbers +LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/2867786a8abf7936.json b/tests/ast_json_fixtures/shapes/2867786a8abf7936.json new file mode 100644 index 000000000000..0735c0ca0947 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2867786a8abf7936.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "prefer_localhost_replica": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2867786a8abf7936.sql b/tests/ast_json_fixtures/shapes/2867786a8abf7936.sql new file mode 100644 index 000000000000..194df8358385 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2867786a8abf7936.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number order by number limit 1 settings prefer_localhost_replica=1 diff --git a/tests/ast_json_fixtures/shapes/287bdf512cde132e.json b/tests/ast_json_fixtures/shapes/287bdf512cde132e.json new file mode 100644 index 000000000000..cb61edb1df5c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/287bdf512cde132e.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r2_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/287bdf512cde132e.sql b/tests/ast_json_fixtures/shapes/287bdf512cde132e.sql new file mode 100644 index 000000000000..afa425c7748d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/287bdf512cde132e.sql @@ -0,0 +1 @@ +CREATE ROLE r2_01293 SETTINGS NONE diff --git a/tests/ast_json_fixtures/shapes/287ff7c6e52c1f8c.json b/tests/ast_json_fixtures/shapes/287ff7c6e52c1f8c.json new file mode 100644 index 000000000000..1557038bf491 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/287ff7c6e52c1f8c.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t_03363_hive_only_partition_columns" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "country", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "year", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "S3", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "s3_conn" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "partition_strategy" + }, + { + "type": "Literal", + "value_type": "String", + "value": "hive" + } + ] + } + ] + }, + "partition_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "year" + }, + { + "type": "Identifier", + "name": "country" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/287ff7c6e52c1f8c.sql b/tests/ast_json_fixtures/shapes/287ff7c6e52c1f8c.sql new file mode 100644 index 000000000000..7321968b9934 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/287ff7c6e52c1f8c.sql @@ -0,0 +1 @@ +CREATE TABLE t_03363_hive_only_partition_columns (country String, year UInt16) ENGINE = S3(s3_conn, partition_strategy='hive') PARTITION BY (year, country) diff --git a/tests/ast_json_fixtures/shapes/2893004f91f33663.json b/tests/ast_json_fixtures/shapes/2893004f91f33663.json new file mode 100644 index 000000000000..b55aa7671790 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2893004f91f33663.json @@ -0,0 +1,236 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "l_orderkey" + }, + { + "type": "Function", + "alias": "revenue", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l_extendedprice" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "l_discount" + } + ] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "o_orderdate" + }, + { + "type": "Identifier", + "name": "o_shippriority" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "customer" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "orders" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lineitem" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c_mktsegment" + }, + { + "type": "Literal", + "value_type": "String", + "value": "BUILDING" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c_custkey" + }, + { + "type": "Identifier", + "name": "o_custkey" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l_orderkey" + }, + { + "type": "Identifier", + "name": "o_orderkey" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "o_orderdate" + }, + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1995-03-15" + } + ] + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l_shipdate" + }, + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1995-03-15" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "l_orderkey" + }, + { + "type": "Identifier", + "name": "o_orderdate" + }, + { + "type": "Identifier", + "name": "o_shippriority" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "revenue" + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "o_orderdate" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2893004f91f33663.sql b/tests/ast_json_fixtures/shapes/2893004f91f33663.sql new file mode 100644 index 000000000000..5125c94611ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2893004f91f33663.sql @@ -0,0 +1,23 @@ +select + l_orderkey, + sum(l_extendedprice * (1 - l_discount)) as revenue, + o_orderdate, + o_shippriority +from + customer, + orders, + lineitem +where + c_mktsegment = 'BUILDING' + and c_custkey = o_custkey + and l_orderkey = o_orderkey + and o_orderdate < date '1995-03-15' + and l_shipdate > date '1995-03-15' +group by + l_orderkey, + o_orderdate, + o_shippriority +order by + revenue desc, + o_orderdate +limit 10 diff --git a/tests/ast_json_fixtures/shapes/28979cab2e4d4a77.json b/tests/ast_json_fixtures/shapes/28979cab2e4d4a77.json new file mode 100644 index 000000000000..7db2ad05715e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/28979cab2e4d4a77.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q2_01297"], + "limits": [ + { + "duration_sec": "1800" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/28979cab2e4d4a77.sql b/tests/ast_json_fixtures/shapes/28979cab2e4d4a77.sql new file mode 100644 index 000000000000..8606ab854f85 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/28979cab2e4d4a77.sql @@ -0,0 +1 @@ +ALTER QUOTA q2_01297 FOR INTERVAL 30 MINUTE TRACKING ONLY diff --git a/tests/ast_json_fixtures/shapes/289c14a632a55294.json b/tests/ast_json_fixtures/shapes/289c14a632a55294.json new file mode 100644 index 000000000000..b20d864004c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/289c14a632a55294.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "val2" + }, + "as_table": "val" + } +} diff --git a/tests/ast_json_fixtures/shapes/289c14a632a55294.sql b/tests/ast_json_fixtures/shapes/289c14a632a55294.sql new file mode 100644 index 000000000000..4efa44d69dcd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/289c14a632a55294.sql @@ -0,0 +1 @@ +CREATE TABLE val2 AS val diff --git a/tests/ast_json_fixtures/shapes/28a7ad6d370b100e.json b/tests/ast_json_fixtures/shapes/28a7ad6d370b100e.json new file mode 100644 index 000000000000..a72db1f3c9eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/28a7ad6d370b100e.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "trunc" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "n" + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/test\/1166\/{database}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "primary_key": { + "type": "Identifier", + "name": "n" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/28a7ad6d370b100e.sql b/tests/ast_json_fixtures/shapes/28a7ad6d370b100e.sql new file mode 100644 index 000000000000..bf1f481f895e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/28a7ad6d370b100e.sql @@ -0,0 +1 @@ +create table trunc (n int, primary key n) engine=ReplicatedMergeTree('/test/1166/{database}', '1') partition by n % 10 diff --git a/tests/ast_json_fixtures/shapes/28ad21c234cafcab.json b/tests/ast_json_fixtures/shapes/28ad21c234cafcab.json new file mode 100644 index 000000000000..b6d76abad0a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/28ad21c234cafcab.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "40" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "String", + "value": "a" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_skip_unused_shards": "1", + "force_optimize_skip_unused_shards": "0" + } + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/28ad21c234cafcab.sql b/tests/ast_json_fixtures/shapes/28ad21c234cafcab.sql new file mode 100644 index 000000000000..5b3cf3c03be8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/28ad21c234cafcab.sql @@ -0,0 +1 @@ +SELECT * FROM remote('127.0.0.{1,2}', numbers(40), number) ORDER BY 'a' LIMIT 1 BY number SETTINGS optimize_skip_unused_shards = 1, force_optimize_skip_unused_shards=0 format Null diff --git a/tests/ast_json_fixtures/shapes/28c02360c56ce069.json b/tests/ast_json_fixtures/shapes/28c02360c56ce069.json new file mode 100644 index 000000000000..d02425d5bf1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/28c02360c56ce069.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropNamedCollectionQuery", + "collection_name": "02918_json_fuzzer", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/28c02360c56ce069.sql b/tests/ast_json_fixtures/shapes/28c02360c56ce069.sql new file mode 100644 index 000000000000..2a731f16155f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/28c02360c56ce069.sql @@ -0,0 +1 @@ +DROP NAMED COLLECTION IF EXISTS 02918_json_fuzzer diff --git a/tests/ast_json_fixtures/shapes/28f10d4e37843c88.json b/tests/ast_json_fixtures/shapes/28f10d4e37843c88.json new file mode 100644 index 000000000000..6c8b6d912e83 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/28f10d4e37843c88.json @@ -0,0 +1,195 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "arr_tests_visits" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "CounterID", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "StartDate", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "Sign", + "data_type": { + "type": "DataType", + "name": "Int8" + } + }, + { + "type": "ColumnDeclaration", + "name": "VisitID", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "UserID", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "VisitVersion", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "Test.BannerID", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt64" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "Test.Load", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt8" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "Test.PuidKey", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt8" + } + ] + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "Test.PuidVal", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt32" + } + ] + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toMonday", + "arguments": [ + { + "type": "Identifier", + "name": "StartDate" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Identifier", + "name": "StartDate" + }, + { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + }, + { + "type": "Identifier", + "name": "VisitID" + } + ] + }, + "sample_by": { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/28f10d4e37843c88.sql b/tests/ast_json_fixtures/shapes/28f10d4e37843c88.sql new file mode 100644 index 000000000000..f56f9656e806 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/28f10d4e37843c88.sql @@ -0,0 +1,13 @@ +CREATE TABLE arr_tests_visits +( + CounterID UInt32, + StartDate Date, + Sign Int8, + VisitID UInt64, + UserID UInt64, + VisitVersion UInt16, + `Test.BannerID` Array(UInt64), + `Test.Load` Array(UInt8), + `Test.PuidKey` Array(Array(UInt8)), + `Test.PuidVal` Array(Array(UInt32)) +) ENGINE = MergeTree() PARTITION BY toMonday(StartDate) ORDER BY (CounterID, StartDate, intHash32(UserID), VisitID) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192 diff --git a/tests/ast_json_fixtures/shapes/290372217d0af42e.json b/tests/ast_json_fixtures/shapes/290372217d0af42e.json new file mode 100644 index 000000000000..2719066ee3fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/290372217d0af42e.json @@ -0,0 +1,161 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "246" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "arrayStringConcat", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reinterpretAsString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "XML" + } +} diff --git a/tests/ast_json_fixtures/shapes/290372217d0af42e.sql b/tests/ast_json_fixtures/shapes/290372217d0af42e.sql new file mode 100644 index 000000000000..22ce38713cb5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/290372217d0af42e.sql @@ -0,0 +1 @@ +SELECT number * 246 + 10 AS n, toDate('2000-01-01') + n AS d, range(n) AS arr, arrayStringConcat(arrayMap(x -> reinterpretAsString(x), arr)) AS s, (n, d) AS tuple FROM system.numbers LIMIT 2 FORMAT XML diff --git a/tests/ast_json_fixtures/shapes/290ec8948f9ec4e3.json b/tests/ast_json_fixtures/shapes/290ec8948f9ec4e3.json new file mode 100644 index 000000000000..537cdf768f1d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/290ec8948f9ec4e3.json @@ -0,0 +1,98 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "String", + "value": "str" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/290ec8948f9ec4e3.sql b/tests/ast_json_fixtures/shapes/290ec8948f9ec4e3.sql new file mode 100644 index 000000000000..b9de3d2e5433 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/290ec8948f9ec4e3.sql @@ -0,0 +1 @@ +SELECT 3 + 3 from numbers(10) GROUP BY GROUPING SETS (('str'), (3 + 3)) order by all diff --git a/tests/ast_json_fixtures/shapes/291bdb18a5855825.json b/tests/ast_json_fixtures/shapes/291bdb18a5855825.json new file mode 100644 index 000000000000..00726e68256a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/291bdb18a5855825.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "LINEITEM" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "LINEITEM_shard" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "LINEITEM_shard" + } +} diff --git a/tests/ast_json_fixtures/shapes/291bdb18a5855825.sql b/tests/ast_json_fixtures/shapes/291bdb18a5855825.sql new file mode 100644 index 000000000000..f90b7dfd8457 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/291bdb18a5855825.sql @@ -0,0 +1,2 @@ +CREATE TABLE LINEITEM AS LINEITEM_shard +ENGINE = Distributed('test_shard_localhost', currentDatabase(), LINEITEM_shard, rand()) diff --git a/tests/ast_json_fixtures/shapes/2936217c01f4d650.json b/tests/ast_json_fixtures/shapes/2936217c01f4d650.json new file mode 100644 index 000000000000..c5bdea28547b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2936217c01f4d650.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "T1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "A", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "B", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "A" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "A", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "B", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2936217c01f4d650.sql b/tests/ast_json_fixtures/shapes/2936217c01f4d650.sql new file mode 100644 index 000000000000..4ec4f346ec37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2936217c01f4d650.sql @@ -0,0 +1,6 @@ +CREATE TEMPORARY TABLE T1 +( + A Int32 , B Int32 +) +ENGINE = MergeTree ORDER BY A +AS SELECT 1 AS A, 2 AS B diff --git a/tests/ast_json_fixtures/shapes/293b1cf65890cd59.json b/tests/ast_json_fixtures/shapes/293b1cf65890cd59.json new file mode 100644 index 000000000000..0859e9fc0355 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/293b1cf65890cd59.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "test_join" + }, + "settings": { + "type": "Settings", + "changes": { + "ignore_drop_queries_probability": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/293b1cf65890cd59.sql b/tests/ast_json_fixtures/shapes/293b1cf65890cd59.sql new file mode 100644 index 000000000000..fa56912d23c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/293b1cf65890cd59.sql @@ -0,0 +1 @@ +drop table test_join settings ignore_drop_queries_probability=1 diff --git a/tests/ast_json_fixtures/shapes/294d415dc9b05421.json b/tests/ast_json_fixtures/shapes/294d415dc9b05421.json new file mode 100644 index 000000000000..eb9ea9230ed3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/294d415dc9b05421.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateDictionaryQuery", + "table": { + "type": "Identifier", + "name": "uk_mortgage_rates_dict" + }, + "settings": { + "type": "Settings", + "changes": { + "show_create_query_identifier_quoting_rule": "always", + "show_create_query_identifier_quoting_style": "Backticks" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/294d415dc9b05421.sql b/tests/ast_json_fixtures/shapes/294d415dc9b05421.sql new file mode 100644 index 000000000000..0e1bb128b8e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/294d415dc9b05421.sql @@ -0,0 +1,4 @@ +SHOW CREATE DICTIONARY uk_mortgage_rates_dict +SETTINGS + show_create_query_identifier_quoting_rule='always', + show_create_query_identifier_quoting_style='Backticks' diff --git a/tests/ast_json_fixtures/shapes/2957203c0c707f81.json b/tests/ast_json_fixtures/shapes/2957203c0c707f81.json new file mode 100644 index 000000000000..6958800d0699 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2957203c0c707f81.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s10_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/2957203c0c707f81.sql b/tests/ast_json_fixtures/shapes/2957203c0c707f81.sql new file mode 100644 index 000000000000..72bd7c169c1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2957203c0c707f81.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s10_01294 diff --git a/tests/ast_json_fixtures/shapes/2960cd478e7f3cf3.json b/tests/ast_json_fixtures/shapes/2960cd478e7f3cf3.json new file mode 100644 index 000000000000..f2e6cb9e37f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2960cd478e7f3cf3.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "name": "throwIf", + "arguments": [ + { + "type": "Function", + "name": "empty", + "arguments": [ + { + "type": "Identifier", + "name": "partition" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "part_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2960cd478e7f3cf3.sql b/tests/ast_json_fixtures/shapes/2960cd478e7f3cf3.sql new file mode 100644 index 000000000000..4c56c9b57aba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2960cd478e7f3cf3.sql @@ -0,0 +1 @@ +SELECT DISTINCT throwIf(empty(partition)) FROM system.part_log WHERE database = currentDatabase() diff --git a/tests/ast_json_fixtures/shapes/2967ebdda603abbe.json b/tests/ast_json_fixtures/shapes/2967ebdda603abbe.json new file mode 100644 index 000000000000..9ca8e8a700c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2967ebdda603abbe.json @@ -0,0 +1,115 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "alias": "b", + "name": "b" + }, + { + "type": "Function", + "alias": "c", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_lazy_mat_prewhere_parallel" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2967ebdda603abbe.sql b/tests/ast_json_fixtures/shapes/2967ebdda603abbe.sql new file mode 100644 index 000000000000..b73dde2feff3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2967ebdda603abbe.sql @@ -0,0 +1 @@ +SELECT a + 1 AS a, b AS b, c + 1 AS c, d + 1 AS d FROM t_lazy_mat_prewhere_parallel WHERE d > 1 ORDER BY c LIMIT 3 diff --git a/tests/ast_json_fixtures/shapes/297415fd3d0d599c.json b/tests/ast_json_fixtures/shapes/297415fd3d0d599c.json new file mode 100644 index 000000000000..98e4372744f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/297415fd3d0d599c.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "x", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + ], + "select": [ + { + "type": "Function", + "name": "reverse", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/297415fd3d0d599c.sql b/tests/ast_json_fixtures/shapes/297415fd3d0d599c.sql new file mode 100644 index 000000000000..eec547022e66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/297415fd3d0d599c.sql @@ -0,0 +1 @@ +WITH () AS x SELECT reverse(x) diff --git a/tests/ast_json_fixtures/shapes/299da80f869db54d.json b/tests/ast_json_fixtures/shapes/299da80f869db54d.json new file mode 100644 index 000000000000..23a9c0eaba30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/299da80f869db54d.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "i" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_part_offset" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/299da80f869db54d.sql b/tests/ast_json_fixtures/shapes/299da80f869db54d.sql new file mode 100644 index 000000000000..e36e6a75d812 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/299da80f869db54d.sql @@ -0,0 +1 @@ +select i from a where _part_offset = 0 order by i settings max_rows_to_read = 2 diff --git a/tests/ast_json_fixtures/shapes/29b94b72565232f2.json b/tests/ast_json_fixtures/shapes/29b94b72565232f2.json new file mode 100644 index 000000000000..dc51e01ea367 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29b94b72565232f2.json @@ -0,0 +1,118 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "a", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "alias": "col_a", + "name": "replaceAll", + "arguments": [ + { + "type": "Identifier", + "name": "data" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "value_type": "String", + "value": "e" + } + ] + }, + { + "type": "Identifier", + "name": "type" + } + ] + }, + { + "type": "Function", + "alias": "b", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "alias": "col_b", + "name": "replaceAll", + "arguments": [ + { + "type": "Identifier", + "name": "data" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "value_type": "String", + "value": "e" + } + ] + }, + { + "type": "Identifier", + "name": "type" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "cluster", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "src" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "prefer_localhost_replica": "0" + } + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/29b94b72565232f2.sql b/tests/ast_json_fixtures/shapes/29b94b72565232f2.sql new file mode 100644 index 000000000000..4a44b8ab9b68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29b94b72565232f2.sql @@ -0,0 +1 @@ +SELECT id, tuple(replaceAll(data, 'a', 'e') AS col_a, type) AS a, tuple(replaceAll(data, 'a', 'e') AS col_b, type) AS b FROM cluster(test_cluster_two_shards, currentDatabase(), src) SETTINGS prefer_localhost_replica=0 FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/29c8e9f509cb538d.json b/tests/ast_json_fixtures/shapes/29c8e9f509cb538d.json new file mode 100644 index 000000000000..7fc24081dca9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29c8e9f509cb538d.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "First row" + }, + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lwd_test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/29c8e9f509cb538d.sql b/tests/ast_json_fixtures/shapes/29c8e9f509cb538d.sql new file mode 100644 index 000000000000..1f74fd5b1dd8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29c8e9f509cb538d.sql @@ -0,0 +1 @@ +SELECT 'First row', id, length(value) FROM lwd_test ORDER BY id LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/29d61b3fbc0820c4.json b/tests/ast_json_fixtures/shapes/29d61b3fbc0820c4.json new file mode 100644 index 000000000000..f80925d71306 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29d61b3fbc0820c4.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "dict" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "x" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "tab" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 1000 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/29d61b3fbc0820c4.sql b/tests/ast_json_fixtures/shapes/29d61b3fbc0820c4.sql new file mode 100644 index 000000000000..d6728132298f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29d61b3fbc0820c4.sql @@ -0,0 +1 @@ +CREATE DICTIONARY IF NOT EXISTS dict (x UInt32, y UInt32) primary key x source(clickhouse(table 'tab')) LAYOUT(FLAT()) LIFETIME(MIN 0 MAX 1000) diff --git a/tests/ast_json_fixtures/shapes/29decd5856af7f20.json b/tests/ast_json_fixtures/shapes/29decd5856af7f20.json new file mode 100644 index 000000000000..737a3e8705d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29decd5856af7f20.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ], + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } + } + ] + } + } + ], + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/29decd5856af7f20.sql b/tests/ast_json_fixtures/shapes/29decd5856af7f20.sql new file mode 100644 index 000000000000..b83d597159da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29decd5856af7f20.sql @@ -0,0 +1,2 @@ +SELECT count() FROM (SELECT * FROM system.numbers LIMIT 1000) WHERE 1 IN (SELECT 0 WHERE 0) +FORMAT JSON diff --git a/tests/ast_json_fixtures/shapes/29ecd498c70b561a.json b/tests/ast_json_fixtures/shapes/29ecd498c70b561a.json new file mode 100644 index 000000000000..b33ca1d90173 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29ecd498c70b561a.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q12_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/29ecd498c70b561a.sql b/tests/ast_json_fixtures/shapes/29ecd498c70b561a.sql new file mode 100644 index 000000000000..ed13851ccc35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29ecd498c70b561a.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q12_01297 diff --git a/tests/ast_json_fixtures/shapes/29ef68de794eeeac.json b/tests/ast_json_fixtures/shapes/29ef68de794eeeac.json new file mode 100644 index 000000000000..7b4517ad9f0a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29ef68de794eeeac.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettyNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/29ef68de794eeeac.sql b/tests/ast_json_fixtures/shapes/29ef68de794eeeac.sql new file mode 100644 index 000000000000..6558f8da57ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29ef68de794eeeac.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettyNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/29f28bf8b759271b.json b/tests/ast_json_fixtures/shapes/29f28bf8b759271b.json new file mode 100644 index 000000000000..12a01f6ad1e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29f28bf8b759271b.json @@ -0,0 +1,113 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "toFloat32", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "source", + "value_type": "String", + "value": "original" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC", + "with_fill": true, + "fill_step": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/29f28bf8b759271b.sql b/tests/ast_json_fixtures/shapes/29f28bf8b759271b.sql new file mode 100644 index 000000000000..a9da49f2d55e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29f28bf8b759271b.sql @@ -0,0 +1,7 @@ +SELECT + toFloat32(number % 10) AS n, + 'original' AS source +FROM numbers(10) +WHERE (number % 3) = 1 +ORDER BY n ASC WITH FILL STEP 1 +LIMIT 2 diff --git a/tests/ast_json_fixtures/shapes/29fd87ce3990778a.json b/tests/ast_json_fixtures/shapes/29fd87ce3990778a.json new file mode 100644 index 000000000000..537c6f03dc46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29fd87ce3990778a.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "decimal" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TabSeparated" + } +} diff --git a/tests/ast_json_fixtures/shapes/29fd87ce3990778a.sql b/tests/ast_json_fixtures/shapes/29fd87ce3990778a.sql new file mode 100644 index 000000000000..e604f71ba450 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/29fd87ce3990778a.sql @@ -0,0 +1 @@ +SELECT * FROM decimal ORDER BY c FORMAT TabSeparated diff --git a/tests/ast_json_fixtures/shapes/2a00503d5ccb67d1.json b/tests/ast_json_fixtures/shapes/2a00503d5ccb67d1.json new file mode 100644 index 000000000000..4a762a499722 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a00503d5ccb67d1.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "show_settings": true, + "like": "%CONNECT_timeout%", + "case_insensitive_like": true + } +} diff --git a/tests/ast_json_fixtures/shapes/2a00503d5ccb67d1.sql b/tests/ast_json_fixtures/shapes/2a00503d5ccb67d1.sql new file mode 100644 index 000000000000..c62d40f4140e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a00503d5ccb67d1.sql @@ -0,0 +1 @@ +SHOW SETTINGS ILIKE '%CONNECT_timeout%' diff --git a/tests/ast_json_fixtures/shapes/2a13bf6c7342b4b8.json b/tests/ast_json_fixtures/shapes/2a13bf6c7342b4b8.json new file mode 100644 index 000000000000..6ac522e05819 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a13bf6c7342b4b8.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_v" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "extremes": "1" + } + }, + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/2a13bf6c7342b4b8.sql b/tests/ast_json_fixtures/shapes/2a13bf6c7342b4b8.sql new file mode 100644 index 000000000000..cde2c7707683 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a13bf6c7342b4b8.sql @@ -0,0 +1 @@ +SELECT * FROM t_v FORMAT JSON SETTINGS extremes = 1 diff --git a/tests/ast_json_fixtures/shapes/2a1d9e34e835e4be.json b/tests/ast_json_fixtures/shapes/2a1d9e34e835e4be.json new file mode 100644 index 000000000000..af025d784fce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a1d9e34e835e4be.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "db_hang", + "from_table": "test", + "to_database": "db_hang_temp", + "to_table": "test" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2a1d9e34e835e4be.sql b/tests/ast_json_fixtures/shapes/2a1d9e34e835e4be.sql new file mode 100644 index 000000000000..5f240c650c52 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a1d9e34e835e4be.sql @@ -0,0 +1 @@ +rename table db_hang.test to db_hang_temp.test diff --git a/tests/ast_json_fixtures/shapes/2a2642a24a8cb86c.json b/tests/ast_json_fixtures/shapes/2a2642a24a8cb86c.json new file mode 100644 index 000000000000..8a9d3d355ac5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a2642a24a8cb86c.json @@ -0,0 +1,189 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "bitAnd", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "257" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048576" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "argMaxIf", + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "255" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + } + ] + }, + { + "type": "Function", + "name": "toInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "65535" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "u", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "toInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-2" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "k" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/2a2642a24a8cb86c.sql b/tests/ast_json_fixtures/shapes/2a2642a24a8cb86c.sql new file mode 100644 index 000000000000..5edd52e08412 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a2642a24a8cb86c.sql @@ -0,0 +1 @@ +SELECT bitAnd(number, toUInt64(pow(257, 20) - 1048576)) AS k, argMaxIf(k, if((number % 255) = 256, toInt256(65535), number), number > 42), uniq(number) AS u FROM numbers(2) GROUP BY toInt256(-2, NULL), k FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/2a3eea663f21704c.json b/tests/ast_json_fixtures/shapes/2a3eea663f21704c.json new file mode 100644 index 000000000000..fbb50e7748d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a3eea663f21704c.json @@ -0,0 +1,116 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "String", + "value": "Hello, world" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/2a3eea663f21704c.sql b/tests/ast_json_fixtures/shapes/2a3eea663f21704c.sql new file mode 100644 index 000000000000..cffbfad2b2d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a3eea663f21704c.sql @@ -0,0 +1 @@ +SELECT 'Hello, world' AS x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/2a4b38fd418d571c.json b/tests/ast_json_fixtures/shapes/2a4b38fd418d571c.json new file mode 100644 index 000000000000..d7d6e88b0b5e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a4b38fd418d571c.json @@ -0,0 +1,181 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key_a" + }, + { + "type": "Identifier", + "name": "key_b" + } + ] + }, + { + "type": "Function", + "alias": "f", + "name": "rank", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "key_a", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "key_b", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key_a" + }, + { + "type": "Identifier", + "name": "key_b" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Identifier", + "name": "key_a" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + "direction": "ASC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/2a4b38fd418d571c.sql b/tests/ast_json_fixtures/shapes/2a4b38fd418d571c.sql new file mode 100644 index 000000000000..425d2f46979d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a4b38fd418d571c.sql @@ -0,0 +1,17 @@ +SELECT + key_a + key_b AS d, + rank() OVER () AS f +FROM + ( + SELECT + rand() % 10 AS key_a, + rand(1) % 5 AS key_b, + number + FROM numbers(100) + ) +GROUP BY + key_a, + key_b +WITH ROLLUP +ORDER BY multiIf(d = 0, key_a, NULL) ASC +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/2a6c0255d892ea7b.json b/tests/ast_json_fixtures/shapes/2a6c0255d892ea7b.json new file mode 100644 index 000000000000..92c2890c6d9e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a6c0255d892ea7b.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2a6c0255d892ea7b.sql b/tests/ast_json_fixtures/shapes/2a6c0255d892ea7b.sql new file mode 100644 index 000000000000..b2a31ea0a0e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a6c0255d892ea7b.sql @@ -0,0 +1 @@ +SELECT 1 AS n WITH ROLLUP diff --git a/tests/ast_json_fixtures/shapes/2a6ca34eb2f5d0aa.json b/tests/ast_json_fixtures/shapes/2a6ca34eb2f5d0aa.json new file mode 100644 index 000000000000..e68f0dd04e68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a6ca34eb2f5d0aa.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t5" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "Int8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "EmbeddedRocksDB", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "n" + } + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "this is a EmbeddedRocksDB table" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2a6ca34eb2f5d0aa.sql b/tests/ast_json_fixtures/shapes/2a6ca34eb2f5d0aa.sql new file mode 100644 index 000000000000..3aa002a5f141 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a6ca34eb2f5d0aa.sql @@ -0,0 +1,7 @@ +CREATE TABLE t5 +( + `n` Int8 +) +ENGINE = EmbeddedRocksDB +PRIMARY KEY n +COMMENT 'this is a EmbeddedRocksDB table' diff --git a/tests/ast_json_fixtures/shapes/2a7f5499b6e5680f.json b/tests/ast_json_fixtures/shapes/2a7f5499b6e5680f.json new file mode 100644 index 000000000000..fc7d95196ec8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a7f5499b6e5680f.json @@ -0,0 +1,118 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "alias": "x", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "toUUID", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "x" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/2a7f5499b6e5680f.sql b/tests/ast_json_fixtures/shapes/2a7f5499b6e5680f.sql new file mode 100644 index 000000000000..f87633ac7354 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a7f5499b6e5680f.sql @@ -0,0 +1 @@ +SELECT tuple(tuple(number)) AS x FROM numbers(10) WHERE toString(toUUID(tuple(number), NULL), x) GROUP BY number, (toString(x), number) WITH CUBE SETTINGS group_by_use_nulls = 1 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/2a8e7a4fecb001b2.json b/tests/ast_json_fixtures/shapes/2a8e7a4fecb001b2.json new file mode 100644 index 000000000000..15485d065b28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a8e7a4fecb001b2.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "polygonsSymDifferenceCartesian", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "alias": "x", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 1 + }, + { + "value_type": "Float64", + "value": 1 + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2a8e7a4fecb001b2.sql b/tests/ast_json_fixtures/shapes/2a8e7a4fecb001b2.sql new file mode 100644 index 000000000000..f4543d7dce0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a8e7a4fecb001b2.sql @@ -0,0 +1 @@ +SELECT polygonsSymDifferenceCartesian([[[(1., 1.)]] AS x], [x]) GROUP BY x WITH ROLLUP diff --git a/tests/ast_json_fixtures/shapes/2a963ee72bea2bec.json b/tests/ast_json_fixtures/shapes/2a963ee72bea2bec.json new file mode 100644 index 000000000000..90095eb86b82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a963ee72bea2bec.json @@ -0,0 +1,113 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "t0.c2", + "name_parts": ["t0", "c2"] + }, + { + "type": "Identifier", + "name": "t0.c1", + "name_parts": ["t0", "c1"] + }, + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t0.c2", + "name_parts": ["t0", "c2"] + }, + { + "type": "Identifier", + "name": "t0.c1", + "name_parts": ["t0", "c1"] + } + ] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + }, + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ] + } + ] + } + ] + }, + "direction": "ASC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_move_to_prewhere": "0" + } + }, + "format": "TabSeparatedWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/2a963ee72bea2bec.sql b/tests/ast_json_fixtures/shapes/2a963ee72bea2bec.sql new file mode 100644 index 000000000000..8f44feb5229c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a963ee72bea2bec.sql @@ -0,0 +1 @@ +SELECT t0.c2, t0.c1, t0.c0 FROM t0 WHERE t0.c0 ORDER BY ((t0.c2)>=(t0.c1)), (((- (((t0.c0)>(t0.c0))))) IS NULL) FORMAT TabSeparatedWithNamesAndTypes settings optimize_move_to_prewhere=0 diff --git a/tests/ast_json_fixtures/shapes/2a99f26765a06d75.json b/tests/ast_json_fixtures/shapes/2a99f26765a06d75.json new file mode 100644 index 000000000000..938afbb53ff6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a99f26765a06d75.json @@ -0,0 +1,110 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "RIGHT", + "strictness": "ALL", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t.key1", + "name_parts": ["t", "key1"] + }, + { + "type": "Identifier", + "name": "tj.key1", + "name_parts": ["tj", "key1"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t.key2", + "name_parts": ["t", "key2"] + }, + { + "type": "Identifier", + "name": "tj.key2", + "name_parts": ["tj", "key2"] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tj" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "query_plan_use_new_logical_join_step": "0" + } + } + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/2a99f26765a06d75.sql b/tests/ast_json_fixtures/shapes/2a99f26765a06d75.sql new file mode 100644 index 000000000000..612d81fe36fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2a99f26765a06d75.sql @@ -0,0 +1 @@ +SELECT * FROM t ALL RIGHT JOIN tj ON t.key1 == tj.key1 AND t.key2 == tj.key2 AND 1 ORDER BY ALL SETTINGS query_plan_use_new_logical_join_step = 0 FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/2ab4a744bc3148d4.json b/tests/ast_json_fixtures/shapes/2ab4a744bc3148d4.json new file mode 100644 index 000000000000..8e42af9b55dc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ab4a744bc3148d4.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/2ab4a744bc3148d4.sql b/tests/ast_json_fixtures/shapes/2ab4a744bc3148d4.sql new file mode 100644 index 000000000000..f151b76f9ef1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ab4a744bc3148d4.sql @@ -0,0 +1 @@ +SELECT * FROM t ORDER BY a FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/2abb78ea2193292a.json b/tests/ast_json_fixtures/shapes/2abb78ea2193292a.json new file mode 100644 index 000000000000..62b9c97d00fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2abb78ea2193292a.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_02709__fuzz_23" + }, + "final": true + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "sign" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1023" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "Float64", + "value": null + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "0" + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + }, + "direction": "DESC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_parallel_replicas": "3", + "enable_parallel_replicas": "1", + "use_hedged_requests": "0", + "cluster_for_parallel_replicas": "test_cluster_one_shard_three_replicas_localhost" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/2abb78ea2193292a.sql b/tests/ast_json_fixtures/shapes/2abb78ea2193292a.sql new file mode 100644 index 000000000000..023e1f7449b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2abb78ea2193292a.sql @@ -0,0 +1,9 @@ +SELECT NULL FROM t_02709__fuzz_23 FINAL +GROUP BY sign, '1023' +ORDER BY nan DESC, [0, NULL, NULL, NULL, NULL] DESC +FORMAT Null +SETTINGS + max_parallel_replicas = 3, + enable_parallel_replicas = 1, + use_hedged_requests = 0, + cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost' diff --git a/tests/ast_json_fixtures/shapes/2ae0f539c47836d3.json b/tests/ast_json_fixtures/shapes/2ae0f539c47836d3.json new file mode 100644 index 000000000000..0a1a6ab62d9a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ae0f539c47836d3.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2020-01-04" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2020-01-04" + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2020-01-04" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "day1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "10" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2ae0f539c47836d3.sql b/tests/ast_json_fixtures/shapes/2ae0f539c47836d3.sql new file mode 100644 index 000000000000..d8456a546da0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ae0f539c47836d3.sql @@ -0,0 +1 @@ +SELECT day1 = '2020-01-04' FROM test_table PREWHERE day1 = '2020-01-04' WHERE day1 = '2020-01-04' GROUP BY day1 SETTINGS max_rows_to_read = 10 diff --git a/tests/ast_json_fixtures/shapes/2b1674e1473de8fb.json b/tests/ast_json_fixtures/shapes/2b1674e1473de8fb.json new file mode 100644 index 000000000000..8f6df8f9fd4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b1674e1473de8fb.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "table_local" + } + ] + } + }, + "as_table": "table_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/2b1674e1473de8fb.sql b/tests/ast_json_fixtures/shapes/2b1674e1473de8fb.sql new file mode 100644 index 000000000000..8887bc72c362 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b1674e1473de8fb.sql @@ -0,0 +1 @@ +create table table_dist engine = Distributed('test_cluster_two_shards', currentDatabase(),table_local) AS table_local diff --git a/tests/ast_json_fixtures/shapes/2b2ec658719f967e.json b/tests/ast_json_fixtures/shapes/2b2ec658719f967e.json new file mode 100644 index 000000000000..1bf880891f1f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b2ec658719f967e.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "v4test_array_joins" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "INNER", + "expressions": [ + { + "type": "ColumnsRegexpMatcher", + "pattern": "^arr" + } + ] + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "match", + "arguments": [ + { + "type": "Identifier", + "name": "arr_4" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_read_in_order": "0" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/2b2ec658719f967e.sql b/tests/ast_json_fixtures/shapes/2b2ec658719f967e.sql new file mode 100644 index 000000000000..8ad25bf487a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b2ec658719f967e.sql @@ -0,0 +1 @@ +select * from v4test_array_joins array join columns('^arr') where match(arr_4,'a') and id < 100 order by id format Null settings optimize_read_in_order = 0 diff --git a/tests/ast_json_fixtures/shapes/2b37a10ca3b5b081.json b/tests/ast_json_fixtures/shapes/2b37a10ca3b5b081.json new file mode 100644 index 000000000000..aa4cafdc2bea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b37a10ca3b5b081.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "test_view" + } +} diff --git a/tests/ast_json_fixtures/shapes/2b37a10ca3b5b081.sql b/tests/ast_json_fixtures/shapes/2b37a10ca3b5b081.sql new file mode 100644 index 000000000000..f4341f91f248 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b37a10ca3b5b081.sql @@ -0,0 +1 @@ +CREATE TABLE t2 ENGINE=Memory AS test_view diff --git a/tests/ast_json_fixtures/shapes/2b47d6a99b77b3f9.json b/tests/ast_json_fixtures/shapes/2b47d6a99b77b3f9.json new file mode 100644 index 000000000000..b4e5e6cc407e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b47d6a99b77b3f9.json @@ -0,0 +1,129 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "u1", + "name": "users" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "age" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + }, + { + "type": "Function", + "name": "exists", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "u2", + "name": "users2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "u1.age", + "name_parts": ["u1", "age"] + }, + { + "type": "Identifier", + "name": "u2.age", + "name_parts": ["u2", "age"] + } + ] + } + } + ] + } + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_correlated_subqueries": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2b47d6a99b77b3f9.sql b/tests/ast_json_fixtures/shapes/2b47d6a99b77b3f9.sql new file mode 100644 index 000000000000..7e78ce0521c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b47d6a99b77b3f9.sql @@ -0,0 +1,9 @@ +SELECT name +FROM users AS u1 +WHERE (age = 50) OR exists(( + SELECT * + FROM users2 AS u2 + WHERE u1.age = u2.age +)) +ORDER BY ALL +SETTINGS allow_experimental_correlated_subqueries = 1 diff --git a/tests/ast_json_fixtures/shapes/2b52e1c8c91ed20d.json b/tests/ast_json_fixtures/shapes/2b52e1c8c91ed20d.json new file mode 100644 index 000000000000..f29e65f31913 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b52e1c8c91ed20d.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "03710" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1", + "max_block_size": "1" + } + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/2b52e1c8c91ed20d.sql b/tests/ast_json_fixtures/shapes/2b52e1c8c91ed20d.sql new file mode 100644 index 000000000000..ec5e2ba6bdb2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b52e1c8c91ed20d.sql @@ -0,0 +1 @@ +SELECT '03710', c FROM tab SETTINGS use_query_cache = 1, max_block_size = 1 FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/2b7392ffbb604dba.json b/tests/ast_json_fixtures/shapes/2b7392ffbb604dba.json new file mode 100644 index 000000000000..2e9696787ee9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b7392ffbb604dba.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_validation" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "c1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2b7392ffbb604dba.sql b/tests/ast_json_fixtures/shapes/2b7392ffbb604dba.sql new file mode 100644 index 000000000000..626fd268dd17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b7392ffbb604dba.sql @@ -0,0 +1 @@ +SELECT c0 FROM test_limit_by_validation GROUP BY c0 LIMIT 1 BY c1 diff --git a/tests/ast_json_fixtures/shapes/2b9157cbfcb4b047.json b/tests/ast_json_fixtures/shapes/2b9157cbfcb4b047.json new file mode 100644 index 000000000000..2437420163d8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b9157cbfcb4b047.json @@ -0,0 +1,290 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "common.key", + "name_parts": ["common", "key"] + }, + { + "type": "Identifier", + "name": "common.value", + "name_parts": ["common", "value"] + }, + { + "type": "Identifier", + "name": "trees.name", + "name_parts": ["trees", "name"] + }, + { + "type": "Identifier", + "name": "trees.name2", + "name_parts": ["trees", "name2"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "common", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tableCommon" + } + } + } + ] + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "common.key", + "name_parts": ["common", "key"] + }, + { + "type": "Identifier", + "name": "trees.key", + "name_parts": ["trees", "key"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "trees", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tableTrees" + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "common.key", + "name_parts": ["common", "key"] + }, + { + "type": "Identifier", + "name": "common.value", + "name_parts": ["common", "value"] + }, + { + "type": "Identifier", + "name": "flowers.name", + "name_parts": ["flowers", "name"] + }, + { + "type": "Literal", + "alias": "name2", + "value_type": "Null", + "value": null + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "common", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tableCommon" + } + } + } + ] + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "common.key", + "name_parts": ["common", "key"] + }, + { + "type": "Identifier", + "name": "flowers.key", + "name_parts": ["flowers", "key"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "flowers", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tableFlowers" + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2b9157cbfcb4b047.sql b/tests/ast_json_fixtures/shapes/2b9157cbfcb4b047.sql new file mode 100644 index 000000000000..355e68460bf6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2b9157cbfcb4b047.sql @@ -0,0 +1,25 @@ +SELECT * FROM ( + SELECT common.key, common.value, trees.name, trees.name2 + FROM ( + SELECT * + FROM tableCommon + ) as common + INNER JOIN ( + SELECT * + FROM tableTrees + ) trees ON (common.key = trees.key) +) +UNION ALL +( + SELECT common.key, common.value, + flowers.name, null as name2 + + FROM ( + SELECT * + FROM tableCommon + ) as common + INNER JOIN ( + SELECT * + FROM tableFlowers + ) flowers ON (common.key = flowers.key) +) diff --git a/tests/ast_json_fixtures/shapes/2ba2e3547c9b35de.json b/tests/ast_json_fixtures/shapes/2ba2e3547c9b35de.json new file mode 100644 index 000000000000..0d72a3fc47f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ba2e3547c9b35de.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "unicode" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + } + } + ], + "format": "PrettyNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/2ba2e3547c9b35de.sql b/tests/ast_json_fixtures/shapes/2ba2e3547c9b35de.sql new file mode 100644 index 000000000000..3d140674f3f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ba2e3547c9b35de.sql @@ -0,0 +1 @@ +SELECT * FROM unicode SETTINGS max_threads = 1 FORMAT PrettyNoEscapes diff --git a/tests/ast_json_fixtures/shapes/2bb5986d7db30cbf.json b/tests/ast_json_fixtures/shapes/2bb5986d7db30cbf.json new file mode 100644 index 000000000000..841de9647fe8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2bb5986d7db30cbf.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "reference_vec", + "value_type": "Array", + "value": [ + { + "value_type": "Float64", + "value": 0 + }, + { + "value_type": "Float64", + "value": 2 + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "settings": { + "type": "Settings", + "changes": { + "vector_search_with_rescoring": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2bb5986d7db30cbf.sql b/tests/ast_json_fixtures/shapes/2bb5986d7db30cbf.sql new file mode 100644 index 000000000000..b7020cce31a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2bb5986d7db30cbf.sql @@ -0,0 +1,6 @@ +WITH [0.0, 2.0] AS reference_vec +SELECT id +FROM tab +ORDER BY L2Distance(vec, reference_vec) +LIMIT 3 +SETTINGS vector_search_with_rescoring = 0 diff --git a/tests/ast_json_fixtures/shapes/2bce21f25d372385.json b/tests/ast_json_fixtures/shapes/2bce21f25d372385.json new file mode 100644 index 000000000000..46bb2872bdc7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2bce21f25d372385.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_database": "test_01109_ordinary", + "from_table": "t4", + "to_database": "test_01109_other_atomic", + "to_table": "t3" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2bce21f25d372385.sql b/tests/ast_json_fixtures/shapes/2bce21f25d372385.sql new file mode 100644 index 000000000000..7f768c0264ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2bce21f25d372385.sql @@ -0,0 +1 @@ +EXCHANGE TABLES test_01109_ordinary.t4 AND test_01109_other_atomic.t3 diff --git a/tests/ast_json_fixtures/shapes/2bd812f825db53f0.json b/tests/ast_json_fixtures/shapes/2bd812f825db53f0.json new file mode 100644 index 000000000000..3936111d5bd0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2bd812f825db53f0.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "test1_00843", + "to_table": "test2_00843" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2bd812f825db53f0.sql b/tests/ast_json_fixtures/shapes/2bd812f825db53f0.sql new file mode 100644 index 000000000000..3db594d4c8ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2bd812f825db53f0.sql @@ -0,0 +1 @@ +RENAME TABLE test1_00843 TO test2_00843 diff --git a/tests/ast_json_fixtures/shapes/2be4087040a30600.json b/tests/ast_json_fixtures/shapes/2be4087040a30600.json new file mode 100644 index 000000000000..1d4bfb9fbc08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2be4087040a30600.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q7_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/2be4087040a30600.sql b/tests/ast_json_fixtures/shapes/2be4087040a30600.sql new file mode 100644 index 000000000000..282447d0a303 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2be4087040a30600.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q7_01297 diff --git a/tests/ast_json_fixtures/shapes/2bf2b3bfd1ff8500.json b/tests/ast_json_fixtures/shapes/2bf2b3bfd1ff8500.json new file mode 100644 index 000000000000..b3f42a885894 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2bf2b3bfd1ff8500.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "nums_in_mem_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "nums_in_mem" + } + ] + } + }, + "as_table": "nums_in_mem" + } +} diff --git a/tests/ast_json_fixtures/shapes/2bf2b3bfd1ff8500.sql b/tests/ast_json_fixtures/shapes/2bf2b3bfd1ff8500.sql new file mode 100644 index 000000000000..08998eae2550 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2bf2b3bfd1ff8500.sql @@ -0,0 +1 @@ +create table nums_in_mem_dist as nums_in_mem engine=Distributed('test_shard_localhost', currentDatabase(), nums_in_mem) diff --git a/tests/ast_json_fixtures/shapes/2bf3c6bac8d654ee.json b/tests/ast_json_fixtures/shapes/2bf3c6bac8d654ee.json new file mode 100644 index 000000000000..1f2faec592a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2bf3c6bac8d654ee.json @@ -0,0 +1,133 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "id", + "name": "any", + "arguments": [ + { + "type": "Identifier", + "name": "uuid" + } + ] + }, + { + "type": "Function", + "alias": "time_delta", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "end_ts" + } + ] + }, + { + "type": "Function", + "name": "any", + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "start_ts", + "name": "any", + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + } + ] + }, + { + "type": "Function", + "alias": "end_ts", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "end_ts" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "mytable" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "uuid" + } + ], + "having": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "end_ts" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1620141001" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "any", + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + } + ] + }, + "direction": "DESC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2bf3c6bac8d654ee.sql b/tests/ast_json_fixtures/shapes/2bf3c6bac8d654ee.sql new file mode 100644 index 000000000000..194c2faa56b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2bf3c6bac8d654ee.sql @@ -0,0 +1 @@ +SELECT any(uuid) AS id, max(end_ts) - any(start_ts) AS time_delta, any(start_ts) AS start_ts, max(end_ts) AS end_ts FROM mytable GROUP BY uuid HAVING max(end_ts) < 1620141001 ORDER BY any(start_ts) DESC diff --git a/tests/ast_json_fixtures/shapes/2c4495f9092079df.json b/tests/ast_json_fixtures/shapes/2c4495f9092079df.json new file mode 100644 index 000000000000..9e9babc83d95 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2c4495f9092079df.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_INDEX", + "index": { + "type": "Identifier", + "name": "idx" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2c4495f9092079df.sql b/tests/ast_json_fixtures/shapes/2c4495f9092079df.sql new file mode 100644 index 000000000000..c9d9383c14ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2c4495f9092079df.sql @@ -0,0 +1 @@ +ALTER TABLE tab DROP INDEX idx diff --git a/tests/ast_json_fixtures/shapes/2c4d772b7bf9a7a8.json b/tests/ast_json_fixtures/shapes/2c4d772b7bf9a7a8.json new file mode 100644 index 000000000000..70592b26489e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2c4d772b7bf9a7a8.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(JSON)" + } + ] + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2c4d772b7bf9a7a8.sql b/tests/ast_json_fixtures/shapes/2c4d772b7bf9a7a8.sql new file mode 100644 index 000000000000..c1baa580db17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2c4d772b7bf9a7a8.sql @@ -0,0 +1 @@ +select null::Nullable(JSON) group by 1 diff --git a/tests/ast_json_fixtures/shapes/2c7b09c59228d8a1.json b/tests/ast_json_fixtures/shapes/2c7b09c59228d8a1.json new file mode 100644 index 000000000000..e00b60892bba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2c7b09c59228d8a1.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "alias": "t", + "name": "queryID", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Function", + "name": "initialQueryID", + "arguments": [] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2c7b09c59228d8a1.sql b/tests/ast_json_fixtures/shapes/2c7b09c59228d8a1.sql new file mode 100644 index 000000000000..5244683d3aa9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2c7b09c59228d8a1.sql @@ -0,0 +1 @@ +select queryID() as t from numbers(10) with totals having t = initialQueryID() diff --git a/tests/ast_json_fixtures/shapes/2c7e5b56296697a0.json b/tests/ast_json_fixtures/shapes/2c7e5b56296697a0.json new file mode 100644 index 000000000000..2f4c85df0493 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2c7e5b56296697a0.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d1" + }, + { + "type": "Identifier", + "name": "f1" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d1" + }, + { + "type": "Identifier", + "name": "f1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "f1" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2c7e5b56296697a0.sql b/tests/ast_json_fixtures/shapes/2c7e5b56296697a0.sql new file mode 100644 index 000000000000..c0c7a5cc78e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2c7e5b56296697a0.sql @@ -0,0 +1 @@ +SELECT d1, f1, d1 * f1 FROM t ORDER BY f1 diff --git a/tests/ast_json_fixtures/shapes/2c94cb41037d917f.json b/tests/ast_json_fixtures/shapes/2c94cb41037d917f.json new file mode 100644 index 000000000000..d38cc2de3202 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2c94cb41037d917f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u2_01292@%.myhost.com", "u3_01292@192.168.%.%", "u4_01292@::1", "u5_01292@65:ff0c::\/96"] + } +} diff --git a/tests/ast_json_fixtures/shapes/2c94cb41037d917f.sql b/tests/ast_json_fixtures/shapes/2c94cb41037d917f.sql new file mode 100644 index 000000000000..88aa673c1203 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2c94cb41037d917f.sql @@ -0,0 +1 @@ +DROP USER u1_01292@'%', 'u2_01292@%.myhost.com', u3_01292@'192.168.%.%', 'u4_01292@::1', u5_01292@'65:ff0c::/96' diff --git a/tests/ast_json_fixtures/shapes/2ca5812c959c497b.json b/tests/ast_json_fixtures/shapes/2ca5812c959c497b.json new file mode 100644 index 000000000000..e554b2788b66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ca5812c959c497b.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test1601_detach_permanently_atomic", + "from_table": "test_name_rename_attempt", + "to_database": "test1601_detach_permanently_atomic", + "to_table": "test_name_reuse" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2ca5812c959c497b.sql b/tests/ast_json_fixtures/shapes/2ca5812c959c497b.sql new file mode 100644 index 000000000000..a98d6e26ae13 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ca5812c959c497b.sql @@ -0,0 +1 @@ +RENAME TABLE test1601_detach_permanently_atomic.test_name_rename_attempt TO test1601_detach_permanently_atomic.test_name_reuse diff --git a/tests/ast_json_fixtures/shapes/2ca8466851cb5cc0.json b/tests/ast_json_fixtures/shapes/2ca8466851cb5cc0.json new file mode 100644 index 000000000000..b1ca05d6b257 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ca8466851cb5cc0.json @@ -0,0 +1,164 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_part_offset" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "6" + } + ] + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_simple_projection" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "101" + }, + { + "type": "Identifier", + "name": "user_id" + } + ] + }, + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "255" + }, + { + "type": "Function", + "name": "isZeroOrNull", + "arguments": [ + { + "type": "Function", + "name": "assumeNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ] + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "106" + }, + { + "type": "Identifier", + "name": "user_id" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "region" + }, + { + "type": "Literal", + "value_type": "String", + "value": "us_west" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2ca8466851cb5cc0.sql b/tests/ast_json_fixtures/shapes/2ca8466851cb5cc0.sql new file mode 100644 index 000000000000..de79ce90aed7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ca8466851cb5cc0.sql @@ -0,0 +1 @@ +SELECT *, _part_offset = (isNullable(1) = toUInt128(6)), * FROM test_simple_projection PREWHERE (101 = user_id) = ignore(255, isZeroOrNull(assumeNotNull(0))) WHERE (106 = user_id) AND (region = 'us_west') diff --git a/tests/ast_json_fixtures/shapes/2ccbb993e0f8ed9d.json b/tests/ast_json_fixtures/shapes/2ccbb993e0f8ed9d.json new file mode 100644 index 000000000000..c7db1eb92efa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ccbb993e0f8ed9d.json @@ -0,0 +1,155 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "group_by_with_totals": true, + "group_by_with_rollup": true, + "order_by_all": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "(forward, head, A->B)" + }, + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "next_node", + "name": "sequenceNextNodeDistinct", + "nulls_action": "IGNORE NULLS", + "arguments": [ + { + "type": "Identifier", + "name": "dt" + }, + { + "type": "Identifier", + "name": "action" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "action" + }, + { + "type": "Literal", + "value_type": "String", + "value": "A" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "String", + "value": "forward" + }, + { + "type": "Literal", + "value_type": "String", + "value": "head" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "events_demo" + } + } + } + ] + }, + "group_by": [ + { + "type": "Asterisk" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC", + "nulls_first": false + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2ccbb993e0f8ed9d.sql b/tests/ast_json_fixtures/shapes/2ccbb993e0f8ed9d.sql new file mode 100644 index 000000000000..4d20b53212fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ccbb993e0f8ed9d.sql @@ -0,0 +1,16 @@ +SELECT + DISTINCT '(forward, head, A->B)', + id, + sequenceNextNodeDistinct('forward', 'head', 4) ( + dt, + action, + action = 'A', + toNullable(1 IS NOT NULL) + AND (NOT toNullable(isNullable(1))) + ) IGNORE NULLS AS next_node +FROM + events_demo +GROUP BY + * WITH ROLLUP WITH TOTALS +ORDER BY + ALL ASC NULLS LAST diff --git a/tests/ast_json_fixtures/shapes/2cdacb4c92aba67f.json b/tests/ast_json_fixtures/shapes/2cdacb4c92aba67f.json new file mode 100644 index 000000000000..90e317337032 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2cdacb4c92aba67f.json @@ -0,0 +1,174 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "key1", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "AA" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "String", + "value": "b" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "BB" + }, + { + "type": "Literal", + "value_type": "String", + "value": "other" + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "t1", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "t1" + } + ] + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "key1" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "a", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "key1", + "name": "key" + }, + { + "type": "Identifier", + "name": "attr" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a.attr", + "name_parts": ["a", "attr"] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1", + "analyzer_compatibility_join_using_top_level_identifier": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2cdacb4c92aba67f.sql b/tests/ast_json_fixtures/shapes/2cdacb4c92aba67f.sql new file mode 100644 index 000000000000..4b48f2aa7f76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2cdacb4c92aba67f.sql @@ -0,0 +1,17 @@ +SELECT + CASE + WHEN key = 'a' THEN 'AA' + WHEN key = 'b' THEN 'BB' + ELSE 'other' + END AS key1, + * +FROM remote('127.0.0.{2,3}', currentDatabase(), t1) t1 +INNER JOIN +( + SELECT + key AS key1, + attr + FROM t2 +) AS a USING (key1) +ORDER BY a.attr +SETTINGS enable_analyzer = 1, analyzer_compatibility_join_using_top_level_identifier=1 diff --git a/tests/ast_json_fixtures/shapes/2ce42e824f216375.json b/tests/ast_json_fixtures/shapes/2ce42e824f216375.json new file mode 100644 index 000000000000..0f18cb14726e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ce42e824f216375.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "ROLLBACK" + } +} diff --git a/tests/ast_json_fixtures/shapes/2ce42e824f216375.sql b/tests/ast_json_fixtures/shapes/2ce42e824f216375.sql new file mode 100644 index 000000000000..61d3424233be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ce42e824f216375.sql @@ -0,0 +1 @@ +ROLLBACK diff --git a/tests/ast_json_fixtures/shapes/2cf8be53dd4848a3.json b/tests/ast_json_fixtures/shapes/2cf8be53dd4848a3.json new file mode 100644 index 000000000000..dc0bd8f2c0a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2cf8be53dd4848a3.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "category" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_all" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "category" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2cf8be53dd4848a3.sql b/tests/ast_json_fixtures/shapes/2cf8be53dd4848a3.sql new file mode 100644 index 000000000000..f141ea34ae4e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2cf8be53dd4848a3.sql @@ -0,0 +1,5 @@ +SELECT DISTINCT id, category +FROM test_limit_by_all +ORDER BY id, category +LIMIT 1 BY ALL +LIMIT 2 diff --git a/tests/ast_json_fixtures/shapes/2d00990823adf833.json b/tests/ast_json_fixtures/shapes/2d00990823adf833.json new file mode 100644 index 000000000000..28b3f366d3f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d00990823adf833.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "extractAllGroupsHorizontal", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "hello world" + }, + { + "type": "Literal", + "value_type": "String", + "value": "(\\w+)" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "regexp_max_matches_per_row": "1000000" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/2d00990823adf833.sql b/tests/ast_json_fixtures/shapes/2d00990823adf833.sql new file mode 100644 index 000000000000..db4024e5fdff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d00990823adf833.sql @@ -0,0 +1 @@ +SELECT extractAllGroupsHorizontal('hello world', '(\\w+)') SETTINGS regexp_max_matches_per_row = 1000000 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/2d03d7974439576d.json b/tests/ast_json_fixtures/shapes/2d03d7974439576d.json new file mode 100644 index 000000000000..c2ad2c7731f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d03d7974439576d.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN ESTIMATE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "29103473" + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2d03d7974439576d.sql b/tests/ast_json_fixtures/shapes/2d03d7974439576d.sql new file mode 100644 index 000000000000..108f5ee643ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d03d7974439576d.sql @@ -0,0 +1 @@ +EXPLAIN ESTIMATE SELECT count() FROM test.hits WHERE CounterID < 29103473 diff --git a/tests/ast_json_fixtures/shapes/2d1585916fbb41be.json b/tests/ast_json_fixtures/shapes/2d1585916fbb41be.json new file mode 100644 index 000000000000..dc82b11a95a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d1585916fbb41be.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q1_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/2d1585916fbb41be.sql b/tests/ast_json_fixtures/shapes/2d1585916fbb41be.sql new file mode 100644 index 000000000000..c12946982fda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d1585916fbb41be.sql @@ -0,0 +1 @@ +CREATE QUOTA q1_01297 diff --git a/tests/ast_json_fixtures/shapes/2d244d905dcd5436.json b/tests/ast_json_fixtures/shapes/2d244d905dcd5436.json new file mode 100644 index 000000000000..a943e182d655 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d244d905dcd5436.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2d244d905dcd5436.sql b/tests/ast_json_fixtures/shapes/2d244d905dcd5436.sql new file mode 100644 index 000000000000..d5cc202f84e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d244d905dcd5436.sql @@ -0,0 +1 @@ +SELECT [] diff --git a/tests/ast_json_fixtures/shapes/2d2597fef8f36733.json b/tests/ast_json_fixtures/shapes/2d2597fef8f36733.json new file mode 100644 index 000000000000..93827971625f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d2597fef8f36733.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "varchar", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "255" + } + ] + }, + "null_modifier": false, + "collation": { + "type": "Collation", + "name": "binary" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2d2597fef8f36733.sql b/tests/ast_json_fixtures/shapes/2d2597fef8f36733.sql new file mode 100644 index 000000000000..d52d6970a7b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d2597fef8f36733.sql @@ -0,0 +1 @@ +EXPLAIN SYNTAX CREATE TABLE t (x varchar(255) COLLATE binary NOT NULL) ENGINE=Memory diff --git a/tests/ast_json_fixtures/shapes/2d68bca6e56a58b2.json b/tests/ast_json_fixtures/shapes/2d68bca6e56a58b2.json new file mode 100644 index 000000000000..944b47ce6bfd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d68bca6e56a58b2.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "test_filter_policy_2", + "table": "test_table" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "names": ["default"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2d68bca6e56a58b2.sql b/tests/ast_json_fixtures/shapes/2d68bca6e56a58b2.sql new file mode 100644 index 000000000000..bd695c603447 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d68bca6e56a58b2.sql @@ -0,0 +1 @@ +CREATE ROW POLICY test_filter_policy_2 ON test_table USING (n % 5) >= 3 TO default diff --git a/tests/ast_json_fixtures/shapes/2d8e5aca95ac6f89.json b/tests/ast_json_fixtures/shapes/2d8e5aca95ac6f89.json new file mode 100644 index 000000000000..d253e2b68fca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d8e5aca95ac6f89.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "lowCardinalityKeys", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "client_name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "client1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2d8e5aca95ac6f89.sql b/tests/ast_json_fixtures/shapes/2d8e5aca95ac6f89.sql new file mode 100644 index 000000000000..adcaf9dd7cb3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2d8e5aca95ac6f89.sql @@ -0,0 +1 @@ +SELECT DISTINCT lowCardinalityKeys(s) FROM test PREWHERE client_name = 'client1' ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/2da34202e9600f82.json b/tests/ast_json_fixtures/shapes/2da34202e9600f82.json new file mode 100644 index 000000000000..40c12bcf1af2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2da34202e9600f82.json @@ -0,0 +1,128 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "res", + "name": "minSampleSizeConversion", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.8 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.05 + } + ] + } + ], + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "conversion const 2" + }, + { + "type": "Function", + "name": "roundBankers", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "roundBankers", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "roundBankers", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2da34202e9600f82.sql b/tests/ast_json_fixtures/shapes/2da34202e9600f82.sql new file mode 100644 index 000000000000..2f856b004792 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2da34202e9600f82.sql @@ -0,0 +1 @@ +WITH minSampleSizeConversion(0.0, 0.01, 0.8, 0.05) AS res SELECT 'conversion const 2', roundBankers(res.1, 2), roundBankers(res.2, 2), roundBankers(res.3, 2) diff --git a/tests/ast_json_fixtures/shapes/2da4ef3ae280a986.json b/tests/ast_json_fixtures/shapes/2da4ef3ae280a986.json new file mode 100644 index 000000000000..bd1d33bea02a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2da4ef3ae280a986.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "predicate": { + "type": "Literal", + "value_type": "Bool", + "value": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2da4ef3ae280a986.sql b/tests/ast_json_fixtures/shapes/2da4ef3ae280a986.sql new file mode 100644 index 000000000000..08a67ca023ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2da4ef3ae280a986.sql @@ -0,0 +1 @@ +DELETE FROM t0 WHERE true diff --git a/tests/ast_json_fixtures/shapes/2da70063a1e21211.json b/tests/ast_json_fixtures/shapes/2da70063a1e21211.json new file mode 100644 index 000000000000..29fb495593f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2da70063a1e21211.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "X", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "Y", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + "direction": "ASC", + "nulls_first": false + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2da70063a1e21211.sql b/tests/ast_json_fixtures/shapes/2da70063a1e21211.sql new file mode 100644 index 000000000000..eaf9ca8fdd99 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2da70063a1e21211.sql @@ -0,0 +1,14 @@ +SELECT 4 +FROM +( + SELECT + 1 AS X, + 2 AS Y + UNION ALL + SELECT + 3, + 4 + GROUP BY 2 +) +WHERE materialize(4) +ORDER BY materialize(4) ASC NULLS LAST diff --git a/tests/ast_json_fixtures/shapes/2db7ae4ac2d31871.json b/tests/ast_json_fixtures/shapes/2db7ae4ac2d31871.json new file mode 100644 index 000000000000..2461a7cc20b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2db7ae4ac2d31871.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u_03174_multiple_auth_show_create"] + } +} diff --git a/tests/ast_json_fixtures/shapes/2db7ae4ac2d31871.sql b/tests/ast_json_fixtures/shapes/2db7ae4ac2d31871.sql new file mode 100644 index 000000000000..2b19e8f736e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2db7ae4ac2d31871.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS u_03174_multiple_auth_show_create diff --git a/tests/ast_json_fixtures/shapes/2dbb1166853f9e0c.json b/tests/ast_json_fixtures/shapes/2dbb1166853f9e0c.json new file mode 100644 index 000000000000..653d00f7b7d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2dbb1166853f9e0c.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN PIPELINE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + }, + "format": "PrettySpace", + "output_settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2dbb1166853f9e0c.sql b/tests/ast_json_fixtures/shapes/2dbb1166853f9e0c.sql new file mode 100644 index 000000000000..c6b815ed54c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2dbb1166853f9e0c.sql @@ -0,0 +1,6 @@ +EXPLAIN PIPELINE +SELECT a +FROM t +GROUP BY a +FORMAT PrettySpace +SETTINGS optimize_aggregation_in_order = 1 diff --git a/tests/ast_json_fixtures/shapes/2dbdbcd0ae419cac.json b/tests/ast_json_fixtures/shapes/2dbdbcd0ae419cac.json new file mode 100644 index 000000000000..f8223d5fbde2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2dbdbcd0ae419cac.json @@ -0,0 +1,94 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "pending to flush" + }, + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "entries.bytes", + "name_parts": ["entries", "bytes"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "asynchronous_inserts", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "t_async_insert_skip_settings" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "first_update" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2dbdbcd0ae419cac.sql b/tests/ast_json_fixtures/shapes/2dbdbcd0ae419cac.sql new file mode 100644 index 000000000000..7e0ac67fbfe3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2dbdbcd0ae419cac.sql @@ -0,0 +1,3 @@ +SELECT 'pending to flush', length(entries.bytes) FROM system.asynchronous_inserts +WHERE database = currentDatabase() AND table = 't_async_insert_skip_settings' +ORDER BY first_update diff --git a/tests/ast_json_fixtures/shapes/2dd24363e8f95c36.json b/tests/ast_json_fixtures/shapes/2dd24363e8f95c36.json new file mode 100644 index 000000000000..bdc768de110e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2dd24363e8f95c36.json @@ -0,0 +1,207 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "21" + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "21" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "22" + } + ] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "21" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "22" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "23" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "bug" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2dd24363e8f95c36.sql b/tests/ast_json_fixtures/shapes/2dd24363e8f95c36.sql new file mode 100644 index 000000000000..297b28e8f368 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2dd24363e8f95c36.sql @@ -0,0 +1 @@ +select k, (k=1 or k=2 or k=3), s, (s=21), (s=21 or s=22), (s=21 or s=22 or s=23) from bug SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/2dd3c9ae13625ab4.json b/tests/ast_json_fixtures/shapes/2dd3c9ae13625ab4.json new file mode 100644 index 000000000000..9332c0b2b0ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2dd3c9ae13625ab4.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "l", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab_00717" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "l" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2dd3c9ae13625ab4.sql b/tests/ast_json_fixtures/shapes/2dd3c9ae13625ab4.sql new file mode 100644 index 000000000000..f2c9219f6eff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2dd3c9ae13625ab4.sql @@ -0,0 +1 @@ +select length(b) as l from tab_00717 group by l, l + 1 diff --git a/tests/ast_json_fixtures/shapes/2dd47d57a56369b6.json b/tests/ast_json_fixtures/shapes/2dd47d57a56369b6.json new file mode 100644 index 000000000000..c4da2e40d386 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2dd47d57a56369b6.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "01231_log_queries_min_type\/EXCEPTION_WHILE_PROCESSING" + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "Float64", + "value": 1000000 + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2dd47d57a56369b6.sql b/tests/ast_json_fixtures/shapes/2dd47d57a56369b6.sql new file mode 100644 index 000000000000..2fb619468128 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2dd47d57a56369b6.sql @@ -0,0 +1 @@ +select '01231_log_queries_min_type/EXCEPTION_WHILE_PROCESSING', max(number) from system.numbers limit 1e6 diff --git a/tests/ast_json_fixtures/shapes/2de83f90e02d2bee.json b/tests/ast_json_fixtures/shapes/2de83f90e02d2bee.json new file mode 100644 index 000000000000..48edc159ec50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2de83f90e02d2bee.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t1" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "b" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2de83f90e02d2bee.sql b/tests/ast_json_fixtures/shapes/2de83f90e02d2bee.sql new file mode 100644 index 000000000000..274a58fb3116 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2de83f90e02d2bee.sql @@ -0,0 +1 @@ +SELECT t1.* FROM t1 JOIN t2 USING (b) ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/2e09fc5e34093227.json b/tests/ast_json_fixtures/shapes/2e09fc5e34093227.json new file mode 100644 index 000000000000..91012e9ce6f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e09fc5e34093227.json @@ -0,0 +1,137 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "with": [ + { + "type": "WithElement", + "name": "t0", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table0" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Literal", + "value_type": "String", + "value": "b%" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "table2" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "id2" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "table1" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2e09fc5e34093227.sql b/tests/ast_json_fixtures/shapes/2e09fc5e34093227.sql new file mode 100644 index 000000000000..d7b42be47b4e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e09fc5e34093227.sql @@ -0,0 +1,4 @@ +WITH t0 AS ( + SELECT * FROM table0 WHERE val LIKE 'b%' +) +SELECT * FROM t0 JOIN table2 AS t2 USING id JOIN table1 AS t1 USING id2 ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/2e0e818581231dbb.json b/tests/ast_json_fixtures/shapes/2e0e818581231dbb.json new file mode 100644 index 000000000000..94c20f5b0d7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e0e818581231dbb.json @@ -0,0 +1,173 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "name", + "name": "transform", + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "Henry" + }, + { + "value_type": "String", + "value": "Irene" + }, + { + "value_type": "String", + "value": "Dave" + }, + { + "value_type": "String", + "value": "Cindy" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "Henry or Irene" + }, + { + "value_type": "String", + "value": "Henry or Irene" + }, + { + "value_type": "String", + "value": "Dave or Cindy" + }, + { + "value_type": "String", + "value": "Dave or Cindy" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "department" + }, + { + "type": "Identifier", + "name": "salary" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "employees" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "department" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "salary" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "salary" + }, + "direction": "DESC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/2e0e818581231dbb.sql b/tests/ast_json_fixtures/shapes/2e0e818581231dbb.sql new file mode 100644 index 000000000000..e1f57b368f9f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e0e818581231dbb.sql @@ -0,0 +1,5 @@ +select transform(name, ['Henry', 'Irene', 'Dave', 'Cindy'], ['Henry or Irene', 'Henry or Irene', 'Dave or Cindy', 'Dave or Cindy']) AS name, department, salary from (SELECT * FROM employees ORDER BY id, name, department, salary) +order by salary desc +offset 3 rows +fetch next 5 rows only +format PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/2e57bfde14c29bb8.json b/tests/ast_json_fixtures/shapes/2e57bfde14c29bb8.json new file mode 100644 index 000000000000..a0b3010910cf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e57bfde14c29bb8.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "a" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2e57bfde14c29bb8.sql b/tests/ast_json_fixtures/shapes/2e57bfde14c29bb8.sql new file mode 100644 index 000000000000..7b5f40f55a7a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e57bfde14c29bb8.sql @@ -0,0 +1 @@ +CREATE TABLE IF NOT EXISTS test (a UInt64) ENGINE=MergeTree() ORDER BY a diff --git a/tests/ast_json_fixtures/shapes/2e6160cc64645035.json b/tests/ast_json_fixtures/shapes/2e6160cc64645035.json new file mode 100644 index 000000000000..e1f95f6c5e61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e6160cc64645035.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "value", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "sum", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ], + "window_definition": { + "type": "WindowDefinition" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2e6160cc64645035.sql b/tests/ast_json_fixtures/shapes/2e6160cc64645035.sql new file mode 100644 index 000000000000..e7c18ebd46e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e6160cc64645035.sql @@ -0,0 +1 @@ +SELECT (number = 1) AND (number = 2) AS value, sum(value) OVER () FROM numbers(1) WHERE 1 SETTINGS enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/2e6a1b6220bcc1a6.json b/tests/ast_json_fixtures/shapes/2e6a1b6220bcc1a6.json new file mode 100644 index 000000000000..0290b01269a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e6a1b6220bcc1a6.json @@ -0,0 +1,305 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0.0000000257" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "rval" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "s1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "alias": "val", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ANY", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "rval" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "255" + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "s2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "rval", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_rows_in_join": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2e6a1b6220bcc1a6.sql b/tests/ast_json_fixtures/shapes/2e6a1b6220bcc1a6.sql new file mode 100644 index 000000000000..1e8450bdf616 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e6a1b6220bcc1a6.sql @@ -0,0 +1 @@ +SELECT pow('0.0000000257', NULL), pow(pow(NULL, NULL), NULL) - NULL, (val + NULL) = (rval * 0), * FROM (SELECT (val + 256) = (NULL * NULL), toLowCardinality(toNullable(dummy)) AS val FROM system.one) AS s1 ANY LEFT JOIN (SELECT toLowCardinality(dummy) AS rval FROM system.one) AS s2 ON (val + 0) = (rval * 255) settings max_rows_in_join = 1 diff --git a/tests/ast_json_fixtures/shapes/2e79b1630d586ce8.json b/tests/ast_json_fixtures/shapes/2e79b1630d586ce8.json new file mode 100644 index 000000000000..4134a465fd66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e79b1630d586ce8.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "dictionary": true, + "elements": [ + { + "from_database": "01914_db", + "from_table": "dictionary_1", + "to_database": "01914_db", + "to_table": "dictionary_2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2e79b1630d586ce8.sql b/tests/ast_json_fixtures/shapes/2e79b1630d586ce8.sql new file mode 100644 index 000000000000..fd8e1aad633e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e79b1630d586ce8.sql @@ -0,0 +1 @@ +EXCHANGE DICTIONARIES 01914_db.dictionary_1 AND 01914_db.dictionary_2 diff --git a/tests/ast_json_fixtures/shapes/2e9503f5b3a3cd2a.json b/tests/ast_json_fixtures/shapes/2e9503f5b3a3cd2a.json new file mode 100644 index 000000000000..6eba68ab3ecd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e9503f5b3a3cd2a.json @@ -0,0 +1,104 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "shardNum", + "arguments": [] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dt" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tag_id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tag_name" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "String", + "value": "foo1" + }, + { + "value_type": "String", + "value": "foo2" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2e9503f5b3a3cd2a.sql b/tests/ast_json_fixtures/shapes/2e9503f5b3a3cd2a.sql new file mode 100644 index 000000000000..77af1fe101f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e9503f5b3a3cd2a.sql @@ -0,0 +1 @@ +SELECT shardNum(), count() FROM dt WHERE tag_id = 1 AND tag_name IN ('foo1', 'foo2') GROUP BY 1 ORDER BY 1 diff --git a/tests/ast_json_fixtures/shapes/2e9541990ec329c7.json b/tests/ast_json_fixtures/shapes/2e9541990ec329c7.json new file mode 100644 index 000000000000..4a23fb306670 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e9541990ec329c7.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "r2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2e9541990ec329c7.sql b/tests/ast_json_fixtures/shapes/2e9541990ec329c7.sql new file mode 100644 index 000000000000..74ffa802df1c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2e9541990ec329c7.sql @@ -0,0 +1 @@ +SELECT * FROM r2 WHERE key=4 diff --git a/tests/ast_json_fixtures/shapes/2ebdfda2836038fc.json b/tests/ast_json_fixtures/shapes/2ebdfda2836038fc.json new file mode 100644 index 000000000000..a9fb7df814a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ebdfda2836038fc.json @@ -0,0 +1,207 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "5" + }, + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/2ebdfda2836038fc.sql b/tests/ast_json_fixtures/shapes/2ebdfda2836038fc.sql new file mode 100644 index 000000000000..f4cc370d2cc1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ebdfda2836038fc.sql @@ -0,0 +1,8 @@ +WITH + t as (SELECT number + a as x FROM numbers(5)) +SELECT 0 as a, x FROM t +UNION ALL +SELECT 5 as a, x FROM t +ORDER BY a, x +FORMAT Null +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/2ec2db825417f509.json b/tests/ast_json_fixtures/shapes/2ec2db825417f509.json new file mode 100644 index 000000000000..8ef14e54aa42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ec2db825417f509.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "or_replace": true, + "function_name": { + "type": "Identifier", + "name": "02125_function_2" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2ec2db825417f509.sql b/tests/ast_json_fixtures/shapes/2ec2db825417f509.sql new file mode 100644 index 000000000000..265da96f2458 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ec2db825417f509.sql @@ -0,0 +1 @@ +CREATE OR REPLACE FUNCTION 02125_function_2 AS x -> x + 1 diff --git a/tests/ast_json_fixtures/shapes/2eef529df216e456.json b/tests/ast_json_fixtures/shapes/2eef529df216e456.json new file mode 100644 index 000000000000..50c9a12d0a16 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2eef529df216e456.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "null_ip_dict" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "network", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "val", + "data_type": { + "type": "DataType", + "name": "UInt8" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "77" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "network" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "null", + "elements": [] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 0 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "ip_trie", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2eef529df216e456.sql b/tests/ast_json_fixtures/shapes/2eef529df216e456.sql new file mode 100644 index 000000000000..855cba199b99 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2eef529df216e456.sql @@ -0,0 +1,8 @@ +CREATE DICTIONARY null_ip_dict ( + network String, + val UInt8 DEFAULT 77 +) +PRIMARY KEY network +SOURCE(NULL()) +LAYOUT(IP_TRIE()) +LIFETIME(0) diff --git a/tests/ast_json_fixtures/shapes/2efa117764518a07.json b/tests/ast_json_fixtures/shapes/2efa117764518a07.json new file mode 100644 index 000000000000..16e1efa5d93c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2efa117764518a07.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "1", + "value_type": "String", + "value": "str" + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2efa117764518a07.sql b/tests/ast_json_fixtures/shapes/2efa117764518a07.sql new file mode 100644 index 000000000000..7724fe9ca584 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2efa117764518a07.sql @@ -0,0 +1 @@ +select * from (select 'str' as `1`) where 1 diff --git a/tests/ast_json_fixtures/shapes/2f112ef5ec194560.json b/tests/ast_json_fixtures/shapes/2f112ef5ec194560.json new file mode 100644 index 000000000000..a51ae3cecc42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f112ef5ec194560.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "attach_from_path": "01188_attach\/file", + "table": { + "type": "Identifier", + "name": "mt" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "n" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2f112ef5ec194560.sql b/tests/ast_json_fixtures/shapes/2f112ef5ec194560.sql new file mode 100644 index 000000000000..5d493bdabb5a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f112ef5ec194560.sql @@ -0,0 +1 @@ +attach table mt from '01188_attach/file' (n UInt8, s String) engine=MergeTree order by n diff --git a/tests/ast_json_fixtures/shapes/2f175b98e4112a3d.json b/tests/ast_json_fixtures/shapes/2f175b98e4112a3d.json new file mode 100644 index 000000000000..3f1c6cb18e0b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f175b98e4112a3d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["spaces "] + } +} diff --git a/tests/ast_json_fixtures/shapes/2f175b98e4112a3d.sql b/tests/ast_json_fixtures/shapes/2f175b98e4112a3d.sql new file mode 100644 index 000000000000..8b6c865f23a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f175b98e4112a3d.sql @@ -0,0 +1 @@ +drop user 'spaces ' diff --git a/tests/ast_json_fixtures/shapes/2f1cb2caca16bdaf.json b/tests/ast_json_fixtures/shapes/2f1cb2caca16bdaf.json new file mode 100644 index 000000000000..8fd784638642 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f1cb2caca16bdaf.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "123456789" + } + ] + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/2f1cb2caca16bdaf.sql b/tests/ast_json_fixtures/shapes/2f1cb2caca16bdaf.sql new file mode 100644 index 000000000000..8bcb670907d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f1cb2caca16bdaf.sql @@ -0,0 +1 @@ +SELECT 123456789 AS x FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/2f6abcecf7153f9c.json b/tests/ast_json_fixtures/shapes/2f6abcecf7153f9c.json new file mode 100644 index 000000000000..70df600a5f25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f6abcecf7153f9c.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "aRray_Agg", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2f6abcecf7153f9c.sql b/tests/ast_json_fixtures/shapes/2f6abcecf7153f9c.sql new file mode 100644 index 000000000000..ea138f353a3b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f6abcecf7153f9c.sql @@ -0,0 +1 @@ +select aRray_Agg(s) from t group by n diff --git a/tests/ast_json_fixtures/shapes/2f8ea0f351aeb52f.json b/tests/ast_json_fixtures/shapes/2f8ea0f351aeb52f.json new file mode 100644 index 000000000000..a2cd98c4f5b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f8ea0f351aeb52f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292@192.168.%.%"] + } +} diff --git a/tests/ast_json_fixtures/shapes/2f8ea0f351aeb52f.sql b/tests/ast_json_fixtures/shapes/2f8ea0f351aeb52f.sql new file mode 100644 index 000000000000..b323e99da77d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f8ea0f351aeb52f.sql @@ -0,0 +1 @@ +SHOW CREATE USER u1_01292@'192.168.%.%' diff --git a/tests/ast_json_fixtures/shapes/2f9df9091a695c48.json b/tests/ast_json_fixtures/shapes/2f9df9091a695c48.json new file mode 100644 index 000000000000..979698246f15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f9df9091a695c48.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Q1" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "mt" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2106-02-07" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/2f9df9091a695c48.sql b/tests/ast_json_fixtures/shapes/2f9df9091a695c48.sql new file mode 100644 index 000000000000..32e6df15f9b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2f9df9091a695c48.sql @@ -0,0 +1 @@ +SELECT 'Q1', * FROM mt WHERE d = '2106-02-07' diff --git a/tests/ast_json_fixtures/shapes/2fa2c0f4a1b86c16.json b/tests/ast_json_fixtures/shapes/2fa2c0f4a1b86c16.json new file mode 100644 index 000000000000..b7437f13342a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2fa2c0f4a1b86c16.json @@ -0,0 +1,161 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "246" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "arrayStringConcat", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reinterpretAsString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "RowBinary" + } +} diff --git a/tests/ast_json_fixtures/shapes/2fa2c0f4a1b86c16.sql b/tests/ast_json_fixtures/shapes/2fa2c0f4a1b86c16.sql new file mode 100644 index 000000000000..fd62410a910a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2fa2c0f4a1b86c16.sql @@ -0,0 +1 @@ +SELECT number * 246 + 10 AS n, toDate('2000-01-01') + n AS d, range(n) AS arr, arrayStringConcat(arrayMap(x -> reinterpretAsString(x), arr)) AS s, (n, d) AS tuple FROM system.numbers LIMIT 2 FORMAT RowBinary diff --git a/tests/ast_json_fixtures/shapes/2fc49f46482f73ea.json b/tests/ast_json_fixtures/shapes/2fc49f46482f73ea.json new file mode 100644 index 000000000000..6ea4680a2f92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2fc49f46482f73ea.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u8_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "BCRYPT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwe123" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/2fc49f46482f73ea.sql b/tests/ast_json_fixtures/shapes/2fc49f46482f73ea.sql new file mode 100644 index 000000000000..7d0906e620c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2fc49f46482f73ea.sql @@ -0,0 +1 @@ +CREATE USER u8_01292 IDENTIFIED WITH bcrypt_password BY 'qwe123' diff --git a/tests/ast_json_fixtures/shapes/2fc6a87d6b897cc6.json b/tests/ast_json_fixtures/shapes/2fc6a87d6b897cc6.json new file mode 100644 index 000000000000..10a53a158f5a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2fc6a87d6b897cc6.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "foo", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "LowCardinality", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + ] + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx", + "expression": { + "type": "Identifier", + "name": "foo" + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2fc6a87d6b897cc6.sql b/tests/ast_json_fixtures/shapes/2fc6a87d6b897cc6.sql new file mode 100644 index 000000000000..28573f3d4f7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2fc6a87d6b897cc6.sql @@ -0,0 +1,7 @@ +CREATE TABLE tab +( + foo Array(LowCardinality(String)), + INDEX idx foo TYPE bloom_filter +) +ENGINE = MergeTree +PRIMARY KEY tuple() diff --git a/tests/ast_json_fixtures/shapes/2fd60bed748f6a0d.json b/tests/ast_json_fixtures/shapes/2fd60bed748f6a0d.json new file mode 100644 index 000000000000..297de92353a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2fd60bed748f6a0d.json @@ -0,0 +1,119 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "alias_1", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Identifier", + "name": "c2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "distributed_bug_table" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "c1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "alias_1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c2" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "c2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "alias_1" + } + } + } + ] + } + } + ] + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/2fd60bed748f6a0d.sql b/tests/ast_json_fixtures/shapes/2fd60bed748f6a0d.sql new file mode 100644 index 000000000000..53948daa6ccd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2fd60bed748f6a0d.sql @@ -0,0 +1,4 @@ +WITH alias_1 AS + (SELECT c1,c2 FROM distributed_bug_table) +SELECT c1 from alias_1 where c2 IN (SELECT DISTINCT c2 from alias_1) +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/2ff68b298e44d2e0.json b/tests/ast_json_fixtures/shapes/2ff68b298e44d2e0.json new file mode 100644 index 000000000000..2a10f6cb3dac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ff68b298e44d2e0.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "data" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "p", + "data_type": { + "type": "DataType", + "name": "Int" + } + }, + { + "type": "ColumnDeclaration", + "name": "t", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx", + "expression": { + "type": "Identifier", + "name": "t" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "p" + }, + "order_by": { + "type": "Identifier", + "name": "t" + }, + "settings": { + "type": "Settings", + "changes": { + "number_of_free_entries_in_pool_to_execute_mutation": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/2ff68b298e44d2e0.sql b/tests/ast_json_fixtures/shapes/2ff68b298e44d2e0.sql new file mode 100644 index 000000000000..4071aa908349 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/2ff68b298e44d2e0.sql @@ -0,0 +1,10 @@ +CREATE TABLE data +( + p Int, + t DateTime, + INDEX idx t TYPE minmax GRANULARITY 1 +) +ENGINE = MergeTree +PARTITION BY p +ORDER BY t +SETTINGS number_of_free_entries_in_pool_to_execute_mutation=0 diff --git a/tests/ast_json_fixtures/shapes/3013672b83ba5fae.json b/tests/ast_json_fixtures/shapes/3013672b83ba5fae.json new file mode 100644 index 000000000000..cb12b3cfe7f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3013672b83ba5fae.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "tab", + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "field" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%int%" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3013672b83ba5fae.sql b/tests/ast_json_fixtures/shapes/3013672b83ba5fae.sql new file mode 100644 index 000000000000..efc0a83be83a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3013672b83ba5fae.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM tab WHERE field LIKE '%int%' diff --git a/tests/ast_json_fixtures/shapes/30264ab815fab995.json b/tests/ast_json_fixtures/shapes/30264ab815fab995.json new file mode 100644 index 000000000000..8af11b084705 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/30264ab815fab995.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u4_01292", + "host_pattern": "::1" + } + ] + }, + "hosts": { + "local_host": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/30264ab815fab995.sql b/tests/ast_json_fixtures/shapes/30264ab815fab995.sql new file mode 100644 index 000000000000..67cd1aa8257f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/30264ab815fab995.sql @@ -0,0 +1 @@ +CREATE USER u4_01292@'::1' diff --git a/tests/ast_json_fixtures/shapes/303c9a09dcd9f6cf.json b/tests/ast_json_fixtures/shapes/303c9a09dcd9f6cf.json new file mode 100644 index 000000000000..edd1d4dbb7f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/303c9a09dcd9f6cf.json @@ -0,0 +1,273 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "q", + "name": "normalizeQuery", + "arguments": [ + { + "type": "Identifier", + "name": "query" + } + ] + }, + { + "type": "Function", + "alias": "not_blazingly_fast", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DistributedIndexAnalysisMicroseconds" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "alias": "missing_parts", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DistributedIndexAnalysisMissingParts" + } + ] + }, + { + "type": "Function", + "alias": "replicas", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DistributedIndexAnalysisScheduledReplicas" + } + ] + }, + { + "type": "Function", + "alias": "failed_replicas", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DistributedIndexAnalysisFailedReplicas" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "yesterday", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryStart" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_kind" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Select" + } + ] + }, + { + "type": "Identifier", + "name": "is_initial_query" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Settings" + }, + { + "type": "Literal", + "value_type": "String", + "value": "distributed_index_analysis" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "endsWith", + "arguments": [ + { + "type": "Identifier", + "name": "log_comment" + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time_microseconds" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/303c9a09dcd9f6cf.sql b/tests/ast_json_fixtures/shapes/303c9a09dcd9f6cf.sql new file mode 100644 index 000000000000..241586ccba1c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/303c9a09dcd9f6cf.sql @@ -0,0 +1,17 @@ +select + normalizeQuery(query) q, + ProfileEvents['DistributedIndexAnalysisMicroseconds'] > 0 not_blazingly_fast, + ProfileEvents['DistributedIndexAnalysisMissingParts'] missing_parts, + ProfileEvents['DistributedIndexAnalysisScheduledReplicas'] replicas, + ProfileEvents['DistributedIndexAnalysisFailedReplicas'] > 0 failed_replicas +from system.query_log +where + current_database = currentDatabase() + and event_date >= yesterday() + and type != 'QueryStart' + and query_kind = 'Select' + and is_initial_query + and Settings['distributed_index_analysis'] = '1' + and endsWith(log_comment, '-' || currentDatabase()) +order by event_time_microseconds +format Vertical diff --git a/tests/ast_json_fixtures/shapes/304423d7ee23ff33.json b/tests/ast_json_fixtures/shapes/304423d7ee23ff33.json new file mode 100644 index 000000000000..c0795076ccd2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/304423d7ee23ff33.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q2_01297"], + "key_type": "USER_NAME", + "limits": [ + { + "duration_sec": "60", + "max": { + "QUERY_INSERTS": "1" + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/304423d7ee23ff33.sql b/tests/ast_json_fixtures/shapes/304423d7ee23ff33.sql new file mode 100644 index 000000000000..ee976ad6e030 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/304423d7ee23ff33.sql @@ -0,0 +1 @@ +CREATE QUOTA q2_01297 KEYED BY user_name FOR INTERVAL 1 minute MAX query_inserts = 1 TO r1_01297 diff --git a/tests/ast_json_fixtures/shapes/3077ad31de3be4d2.json b/tests/ast_json_fixtures/shapes/3077ad31de3be4d2.json new file mode 100644 index 000000000000..d85b3075f0bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3077ad31de3be4d2.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "test_float" + }, + "format": "TabSeparated" + } +} diff --git a/tests/ast_json_fixtures/shapes/3077ad31de3be4d2.sql b/tests/ast_json_fixtures/shapes/3077ad31de3be4d2.sql new file mode 100644 index 000000000000..39383a84606d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3077ad31de3be4d2.sql @@ -0,0 +1,3 @@ +INSERT INTO test_float FORMAT TabSeparated 1.075e+06 + +SELECT * FROM test_float diff --git a/tests/ast_json_fixtures/shapes/308647f707f45304.json b/tests/ast_json_fixtures/shapes/308647f707f45304.json new file mode 100644 index 000000000000..be9ff9e3c91d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/308647f707f45304.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "mv" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "src" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "table": "dst" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/308647f707f45304.sql b/tests/ast_json_fixtures/shapes/308647f707f45304.sql new file mode 100644 index 000000000000..aa9338a5830f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/308647f707f45304.sql @@ -0,0 +1 @@ +CREATE MATERIALIZED VIEW mv TO dst (n String) AS SELECT * FROM src diff --git a/tests/ast_json_fixtures/shapes/309d0a480b974597.json b/tests/ast_json_fixtures/shapes/309d0a480b974597.json new file mode 100644 index 000000000000..e09a61438002 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/309d0a480b974597.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02484_plusthree" + } +} diff --git a/tests/ast_json_fixtures/shapes/309d0a480b974597.sql b/tests/ast_json_fixtures/shapes/309d0a480b974597.sql new file mode 100644 index 000000000000..4f63c69f7a76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/309d0a480b974597.sql @@ -0,0 +1 @@ +DROP FUNCTION 02484_plusthree diff --git a/tests/ast_json_fixtures/shapes/30a0c7661c4bc4bc.json b/tests/ast_json_fixtures/shapes/30a0c7661c4bc4bc.json new file mode 100644 index 000000000000..fb07cce11550 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/30a0c7661c4bc4bc.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": [" "] + } +} diff --git a/tests/ast_json_fixtures/shapes/30a0c7661c4bc4bc.sql b/tests/ast_json_fixtures/shapes/30a0c7661c4bc4bc.sql new file mode 100644 index 000000000000..04c24894afe0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/30a0c7661c4bc4bc.sql @@ -0,0 +1 @@ +drop user if exists " " diff --git a/tests/ast_json_fixtures/shapes/30e21ca670d32701.json b/tests/ast_json_fixtures/shapes/30e21ca670d32701.json new file mode 100644 index 000000000000..0505f0113225 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/30e21ca670d32701.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u16_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/30e21ca670d32701.sql b/tests/ast_json_fixtures/shapes/30e21ca670d32701.sql new file mode 100644 index 000000000000..aa1a8042709c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/30e21ca670d32701.sql @@ -0,0 +1 @@ +SHOW CREATE USER u16_01292 diff --git a/tests/ast_json_fixtures/shapes/30f22c5ca3857741.json b/tests/ast_json_fixtures/shapes/30f22c5ca3857741.json new file mode 100644 index 000000000000..81c1cc3902fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/30f22c5ca3857741.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ES" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/30f22c5ca3857741.sql b/tests/ast_json_fixtures/shapes/30f22c5ca3857741.sql new file mode 100644 index 000000000000..f2e95463fa31 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/30f22c5ca3857741.sql @@ -0,0 +1 @@ +SELECT * FROM ES LIMIT 1 format Null diff --git a/tests/ast_json_fixtures/shapes/30fe311aa7016960.json b/tests/ast_json_fixtures/shapes/30fe311aa7016960.json new file mode 100644 index 000000000000..d6e2dd84b564 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/30fe311aa7016960.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["02294_profile2"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_execution_time", + "value": 0.5 + } + ] + }, + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["default"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/30fe311aa7016960.sql b/tests/ast_json_fixtures/shapes/30fe311aa7016960.sql new file mode 100644 index 000000000000..7ede3da3e152 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/30fe311aa7016960.sql @@ -0,0 +1 @@ +CREATE SETTINGS PROFILE 02294_profile2 SETTINGS max_execution_time = 0.5 TO default diff --git a/tests/ast_json_fixtures/shapes/311ca35d52ca76a5.json b/tests/ast_json_fixtures/shapes/311ca35d52ca76a5.json new file mode 100644 index 000000000000..2b4e8e7fd332 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/311ca35d52ca76a5.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "pp", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "ParsedParams.Key2" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "ParsedParams.Key2", + "name_parts": ["ParsedParams", "Key2"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Identifier", + "name": "pp" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/311ca35d52ca76a5.sql b/tests/ast_json_fixtures/shapes/311ca35d52ca76a5.sql new file mode 100644 index 000000000000..349f5d8005bf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/311ca35d52ca76a5.sql @@ -0,0 +1 @@ +WITH arrayJoin(`ParsedParams.Key2`) AS pp SELECT ParsedParams.Key2 AS x FROM test.hits WHERE NOT ignore(pp) ORDER BY x ASC LIMIT 2 diff --git a/tests/ast_json_fixtures/shapes/311e233ceb724fa3.json b/tests/ast_json_fixtures/shapes/311e233ceb724fa3.json new file mode 100644 index 000000000000..a64b1e64a297 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/311e233ceb724fa3.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["user_03141"] + } +} diff --git a/tests/ast_json_fixtures/shapes/311e233ceb724fa3.sql b/tests/ast_json_fixtures/shapes/311e233ceb724fa3.sql new file mode 100644 index 000000000000..4e6392afb62b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/311e233ceb724fa3.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS user_03141 diff --git a/tests/ast_json_fixtures/shapes/31364a2be165d85d.json b/tests/ast_json_fixtures/shapes/31364a2be165d85d.json new file mode 100644 index 000000000000..48a2cf60c9ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31364a2be165d85d.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "CROSS" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/31364a2be165d85d.sql b/tests/ast_json_fixtures/shapes/31364a2be165d85d.sql new file mode 100644 index 000000000000..25d82ca955c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31364a2be165d85d.sql @@ -0,0 +1 @@ +SELECT 1 FROM t1 CROSS JOIN t0 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/314e83120be307b2.json b/tests/ast_json_fixtures/shapes/314e83120be307b2.json new file mode 100644 index 000000000000..3e656cb93b9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/314e83120be307b2.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "reference_vec", + "value_type": "Array", + "value": [ + { + "value_type": "Float64", + "value": 1 + }, + { + "value_type": "Float64", + "value": 2 + } + ] + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5000" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "cosineDistance", + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/314e83120be307b2.sql b/tests/ast_json_fixtures/shapes/314e83120be307b2.sql new file mode 100644 index 000000000000..ba6d5bbdef40 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/314e83120be307b2.sql @@ -0,0 +1,7 @@ +WITH [1., 2.] AS reference_vec +SELECT * +FROM tab +PREWHERE id < 5000 +ORDER BY cosineDistance(vec, reference_vec) ASC +LIMIT 10 +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/315c5d1695712393.json b/tests/ast_json_fixtures/shapes/315c5d1695712393.json new file mode 100644 index 000000000000..03c5e0561064 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/315c5d1695712393.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "n" + }, + "settings": { + "type": "Settings", + "changes": { + "add_minmax_index_for_numeric_columns": "0" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "8192" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "123" + } + ] + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/315c5d1695712393.sql b/tests/ast_json_fixtures/shapes/315c5d1695712393.sql new file mode 100644 index 000000000000..60ee80d8e813 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/315c5d1695712393.sql @@ -0,0 +1 @@ +CREATE TABLE tab2 ENGINE=ReplacingMergeTree ORDER BY n SETTINGS add_minmax_index_for_numeric_columns=0 AS SELECT intDiv(number,2) as n from numbers(8192 * 123) diff --git a/tests/ast_json_fixtures/shapes/316216d71bf29260.json b/tests/ast_json_fixtures/shapes/316216d71bf29260.json new file mode 100644 index 000000000000..5cefddf6e8ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/316216d71bf29260.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/316216d71bf29260.sql b/tests/ast_json_fixtures/shapes/316216d71bf29260.sql new file mode 100644 index 000000000000..06aec6917ae4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/316216d71bf29260.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/31989c75b224d226.json b/tests/ast_json_fixtures/shapes/31989c75b224d226.json new file mode 100644 index 000000000000..2c9f64b3bac7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31989c75b224d226.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ExistsTableQuery", + "table": { + "type": "Identifier", + "name": "t_01048" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/31989c75b224d226.sql b/tests/ast_json_fixtures/shapes/31989c75b224d226.sql new file mode 100644 index 000000000000..165b7d98de51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31989c75b224d226.sql @@ -0,0 +1 @@ +EXISTS t_01048 diff --git a/tests/ast_json_fixtures/shapes/3199d1c1d50da760.json b/tests/ast_json_fixtures/shapes/3199d1c1d50da760.json new file mode 100644 index 000000000000..6646eb48b483 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3199d1c1d50da760.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/3199d1c1d50da760.sql b/tests/ast_json_fixtures/shapes/3199d1c1d50da760.sql new file mode 100644 index 000000000000..602e3d99d710 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3199d1c1d50da760.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/31a3254e2e572f14.json b/tests/ast_json_fixtures/shapes/31a3254e2e572f14.json new file mode 100644 index 000000000000..09feb2c962fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31a3254e2e572f14.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value1" + }, + { + "type": "Identifier", + "name": "value2" + }, + { + "type": "Function", + "alias": "start_ts", + "name": "toUInt64", + "arguments": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "join_inner_table__fuzz_146" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value1" + }, + { + "type": "Identifier", + "name": "value2" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC", + "nulls_first": false + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value2" + }, + "direction": "DESC", + "nulls_first": false + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775806" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_parallel_replicas": "3", + "prefer_localhost_replica": "1", + "cluster_for_parallel_replicas": "test_cluster_one_shard_three_replicas_localhost", + "enable_parallel_replicas": "1", + "use_hedged_requests": "0" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/31a3254e2e572f14.sql b/tests/ast_json_fixtures/shapes/31a3254e2e572f14.sql new file mode 100644 index 000000000000..167fd425e1f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31a3254e2e572f14.sql @@ -0,0 +1,8 @@ +SELECT key, value1, value2, toUInt64(min(time)) AS start_ts FROM join_inner_table__fuzz_146 GROUP BY key, value1, value2 WITH CUBE ORDER BY key ASC NULLS LAST, value2 DESC NULLS LAST LIMIT 9223372036854775806 + FORMAT Null + SETTINGS + max_parallel_replicas = 3, + prefer_localhost_replica = 1, + cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', + enable_parallel_replicas = 1, + use_hedged_requests = 0 diff --git a/tests/ast_json_fixtures/shapes/31b52e6f31a25502.json b/tests/ast_json_fixtures/shapes/31b52e6f31a25502.json new file mode 100644 index 000000000000..3b21b1626da1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31b52e6f31a25502.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "DetachQuery", + "kind": "DETACH", + "table": { + "type": "Identifier", + "name": "b" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/31b52e6f31a25502.sql b/tests/ast_json_fixtures/shapes/31b52e6f31a25502.sql new file mode 100644 index 000000000000..bd76e4a26b10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31b52e6f31a25502.sql @@ -0,0 +1 @@ +detach table b diff --git a/tests/ast_json_fixtures/shapes/31d396dd25521173.json b/tests/ast_json_fixtures/shapes/31d396dd25521173.json new file mode 100644 index 000000000000..e974afeefbf4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31d396dd25521173.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "alter": true, + "names": ["s1_01294"], + "alter_settings": { + "type": "AlterSettingsProfileElements", + "add_settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "0" + } + ] + }, + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/31d396dd25521173.sql b/tests/ast_json_fixtures/shapes/31d396dd25521173.sql new file mode 100644 index 000000000000..47811586c0c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31d396dd25521173.sql @@ -0,0 +1 @@ +ALTER PROFILE s1_01294 SETTINGS readonly=0 diff --git a/tests/ast_json_fixtures/shapes/31f766db6b96584a.json b/tests/ast_json_fixtures/shapes/31f766db6b96584a.json new file mode 100644 index 000000000000..664da2cb4240 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31f766db6b96584a.json @@ -0,0 +1,146 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Function", + "name": "argMax", + "arguments": [ + { + "type": "Identifier", + "name": "part_type" + }, + { + "type": "Identifier", + "name": "event_time_microseconds" + } + ] + }, + { + "type": "Function", + "name": "argMax", + "arguments": [ + { + "type": "Identifier", + "name": "deduplication_block_ids" + }, + { + "type": "Identifier", + "name": "event_time_microseconds" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "part_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "03711_join_with" + }, + { + "value_type": "String", + "value": "03711_table" + }, + { + "value_type": "String", + "value": "03711_mv_table_1" + }, + { + "value_type": "String", + "value": "03711_mv_table_2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Literal", + "value_type": "String", + "value": "03710_database" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Identifier", + "name": "name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/31f766db6b96584a.sql b/tests/ast_json_fixtures/shapes/31f766db6b96584a.sql new file mode 100644 index 000000000000..4ce2d0e771e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/31f766db6b96584a.sql @@ -0,0 +1,6 @@ +SELECT table, name, argMax(part_type, event_time_microseconds), argMax(deduplication_block_ids, event_time_microseconds) FROM system.part_log +WHERE + table IN ['03711_join_with', '03711_table', '03711_mv_table_1', '03711_mv_table_2'] + AND database = '03710_database' +group BY database, table, name +ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/323afe2d512869bc.json b/tests/ast_json_fixtures/shapes/323afe2d512869bc.json new file mode 100644 index 000000000000..e0d927c082b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/323afe2d512869bc.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_result_rows": "1" + } + }, + "format": "CSVWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/323afe2d512869bc.sql b/tests/ast_json_fixtures/shapes/323afe2d512869bc.sql new file mode 100644 index 000000000000..f4a374d6c56b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/323afe2d512869bc.sql @@ -0,0 +1 @@ +select * from numbers(100) FORMAT CSVWithNamesAndTypes settings max_result_rows = 1 diff --git a/tests/ast_json_fixtures/shapes/3262390eea0c461c.json b/tests/ast_json_fixtures/shapes/3262390eea0c461c.json new file mode 100644 index 000000000000..35efe74bd858 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3262390eea0c461c.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01643" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01643" + }, + { + "type": "Identifier", + "name": "key" + } + ] + } + }, + "as_table": "data_01643" + } +} diff --git a/tests/ast_json_fixtures/shapes/3262390eea0c461c.sql b/tests/ast_json_fixtures/shapes/3262390eea0c461c.sql new file mode 100644 index 000000000000..9a997e754913 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3262390eea0c461c.sql @@ -0,0 +1 @@ +create table dist_01643 as data_01643 engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01643, key) diff --git a/tests/ast_json_fixtures/shapes/3280a1c67eaed5c3.json b/tests/ast_json_fixtures/shapes/3280a1c67eaed5c3.json new file mode 100644 index 000000000000..34d6e09de2f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3280a1c67eaed5c3.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "dummy" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "dummy" + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3280a1c67eaed5c3.sql b/tests/ast_json_fixtures/shapes/3280a1c67eaed5c3.sql new file mode 100644 index 000000000000..c50659b8140b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3280a1c67eaed5c3.sql @@ -0,0 +1 @@ +SELECT dummy, count() / 0.1 GROUP BY dummy WITH TOTALS HAVING count() > 0.1 diff --git a/tests/ast_json_fixtures/shapes/329ba8299c94ed8e.json b/tests/ast_json_fixtures/shapes/329ba8299c94ed8e.json new file mode 100644 index 000000000000..fb67216a2bd2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/329ba8299c94ed8e.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettySpaceNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/329ba8299c94ed8e.sql b/tests/ast_json_fixtures/shapes/329ba8299c94ed8e.sql new file mode 100644 index 000000000000..28671b232745 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/329ba8299c94ed8e.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettySpaceNoEscapes diff --git a/tests/ast_json_fixtures/shapes/329fc64650539194.json b/tests/ast_json_fixtures/shapes/329fc64650539194.json new file mode 100644 index 000000000000..26f66de1c73a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/329fc64650539194.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROW POLICY", + "cluster": "test_shard_localhost", + "row_policy_names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "02911_rowpolicy", + "database": "default" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/329fc64650539194.sql b/tests/ast_json_fixtures/shapes/329fc64650539194.sql new file mode 100644 index 000000000000..34185defdcbb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/329fc64650539194.sql @@ -0,0 +1 @@ +DROP ROW POLICY 02911_rowpolicy ON default.* ON CLUSTER test_shard_localhost diff --git a/tests/ast_json_fixtures/shapes/32b8bf5d4e0b834b.json b/tests/ast_json_fixtures/shapes/32b8bf5d4e0b834b.json new file mode 100644 index 000000000000..ebdf07bdd8a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32b8bf5d4e0b834b.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH DISTRIBUTED", + "table": { + "type": "Identifier", + "name": "dist" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/32b8bf5d4e0b834b.sql b/tests/ast_json_fixtures/shapes/32b8bf5d4e0b834b.sql new file mode 100644 index 000000000000..267ccf4ee7a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32b8bf5d4e0b834b.sql @@ -0,0 +1 @@ +system flush distributed dist diff --git a/tests/ast_json_fixtures/shapes/32c31c3ea7e0ed8f.json b/tests/ast_json_fixtures/shapes/32c31c3ea7e0ed8f.json new file mode 100644 index 000000000000..ba820b7f7469 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32c31c3ea7e0ed8f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["test_user_03532"] + } +} diff --git a/tests/ast_json_fixtures/shapes/32c31c3ea7e0ed8f.sql b/tests/ast_json_fixtures/shapes/32c31c3ea7e0ed8f.sql new file mode 100644 index 000000000000..093c51cbf0d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32c31c3ea7e0ed8f.sql @@ -0,0 +1 @@ +SHOW CREATE USER test_user_03532 diff --git a/tests/ast_json_fixtures/shapes/32c6ded81ee1028e.json b/tests/ast_json_fixtures/shapes/32c6ded81ee1028e.json new file mode 100644 index 000000000000..fb815361b485 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32c6ded81ee1028e.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettySpaceMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/32c6ded81ee1028e.sql b/tests/ast_json_fixtures/shapes/32c6ded81ee1028e.sql new file mode 100644 index 000000000000..68a33cdcb244 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32c6ded81ee1028e.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettySpaceMonoBlock diff --git a/tests/ast_json_fixtures/shapes/32c7e32554e2c185.json b/tests/ast_json_fixtures/shapes/32c7e32554e2c185.json new file mode 100644 index 000000000000..2cde438f7027 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32c7e32554e2c185.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "distinct" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/32c7e32554e2c185.sql b/tests/ast_json_fixtures/shapes/32c7e32554e2c185.sql new file mode 100644 index 000000000000..8a87c42a006b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32c7e32554e2c185.sql @@ -0,0 +1 @@ +SELECT DISTINCT 1 as a, 2 as b FROM distinct diff --git a/tests/ast_json_fixtures/shapes/32decc4bd1880336.json b/tests/ast_json_fixtures/shapes/32decc4bd1880336.json new file mode 100644 index 000000000000..28a13426365d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32decc4bd1880336.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "format", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "JSONEachRow" + }, + { + "type": "Literal", + "value_type": "String", + "value": "{\"x\" : 42}, {\"x\" : \"Hello\"}" + } + ] + } + } + } + ] + } + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/32decc4bd1880336.sql b/tests/ast_json_fixtures/shapes/32decc4bd1880336.sql new file mode 100644 index 000000000000..b659ec9c472e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32decc4bd1880336.sql @@ -0,0 +1 @@ +SELECT x, toTypeName(x) FROM format('JSONEachRow', '{"x" : 42}, {"x" : "Hello"}') FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/32e4ab9106b51bf3.json b/tests/ast_json_fixtures/shapes/32e4ab9106b51bf3.json new file mode 100644 index 000000000000..31e6369c1b67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32e4ab9106b51bf3.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "alias": "m", + "name": "n" + }, + { + "type": "Function", + "alias": "cnt", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "m" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "st" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "String", + "value": "x" + }, + { + "value_type": "String", + "value": "y" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "m" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/32e4ab9106b51bf3.sql b/tests/ast_json_fixtures/shapes/32e4ab9106b51bf3.sql new file mode 100644 index 000000000000..1043a28c277c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/32e4ab9106b51bf3.sql @@ -0,0 +1,7 @@ +SELECT + n as m, + count() OVER (PARTITION BY m) cnt +FROM t +WHERE st IN ('x', 'y') +ORDER BY ALL +LIMIT 1 BY m diff --git a/tests/ast_json_fixtures/shapes/33035c16efabc4bd.json b/tests/ast_json_fixtures/shapes/33035c16efabc4bd.json new file mode 100644 index 000000000000..ee149616f74c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33035c16efabc4bd.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u3_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/33035c16efabc4bd.sql b/tests/ast_json_fixtures/shapes/33035c16efabc4bd.sql new file mode 100644 index 000000000000..aa86499c1acf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33035c16efabc4bd.sql @@ -0,0 +1 @@ +SHOW CREATE USER u3_01292 diff --git a/tests/ast_json_fixtures/shapes/335bbffd3de4d9ad.json b/tests/ast_json_fixtures/shapes/335bbffd3de4d9ad.json new file mode 100644 index 000000000000..651546dc7e90 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/335bbffd3de4d9ad.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "Int64", + "value": "-999999" + }, + "limit": { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/335bbffd3de4d9ad.sql b/tests/ast_json_fixtures/shapes/335bbffd3de4d9ad.sql new file mode 100644 index 000000000000..58f8cbdcb7a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/335bbffd3de4d9ad.sql @@ -0,0 +1 @@ +SELECT DISTINCT number FROM numbers(1000000) ORDER BY number LIMIT -1 OFFSET -999999 diff --git a/tests/ast_json_fixtures/shapes/33961fc5ed5ff0b3.json b/tests/ast_json_fixtures/shapes/33961fc5ed5ff0b3.json new file mode 100644 index 000000000000..597e626435cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33961fc5ed5ff0b3.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "� �" + } + ] + } + ], + "format": "JSONColumnsWithMetadata" + } +} diff --git a/tests/ast_json_fixtures/shapes/33961fc5ed5ff0b3.sql b/tests/ast_json_fixtures/shapes/33961fc5ed5ff0b3.sql new file mode 100644 index 000000000000..899610845c20 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33961fc5ed5ff0b3.sql @@ -0,0 +1 @@ +SELECT '\xED\x20\xA8' AS s FORMAT JSONColumnsWithMetadata diff --git a/tests/ast_json_fixtures/shapes/3398f19c3e4c46d1.json b/tests/ast_json_fixtures/shapes/3398f19c3e4c46d1.json new file mode 100644 index 000000000000..e4b8837cbde9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3398f19c3e4c46d1.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_in" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "ephemeral" + }, + { + "type": "Identifier", + "name": "key" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "background_insert_batch": "1" + } + } + }, + "as_table": "ephemeral" + } +} diff --git a/tests/ast_json_fixtures/shapes/3398f19c3e4c46d1.sql b/tests/ast_json_fixtures/shapes/3398f19c3e4c46d1.sql new file mode 100644 index 000000000000..a6958d18d84c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3398f19c3e4c46d1.sql @@ -0,0 +1 @@ +create table dist_in as ephemeral engine=Distributed(test_shard_localhost, currentDatabase(), ephemeral, key) settings background_insert_batch=1 diff --git a/tests/ast_json_fixtures/shapes/33a08ca486b77ee9.json b/tests/ast_json_fixtures/shapes/33a08ca486b77ee9.json new file mode 100644 index 000000000000..e1946d565f87 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33a08ca486b77ee9.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "sqllt", + "from_table": "table", + "to_database": "sqllt", + "to_table": "table_new" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/33a08ca486b77ee9.sql b/tests/ast_json_fixtures/shapes/33a08ca486b77ee9.sql new file mode 100644 index 000000000000..d954d8ff452f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33a08ca486b77ee9.sql @@ -0,0 +1 @@ +RENAME TABLE sqllt.table TO sqllt.table_new diff --git a/tests/ast_json_fixtures/shapes/33ab378da584f686.json b/tests/ast_json_fixtures/shapes/33ab378da584f686.json new file mode 100644 index 000000000000..cd69f94ba3fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33ab378da584f686.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q1_01297", "q2_01297_renamed", "q3_01297", "q4_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/33ab378da584f686.sql b/tests/ast_json_fixtures/shapes/33ab378da584f686.sql new file mode 100644 index 000000000000..f22ca49d3082 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33ab378da584f686.sql @@ -0,0 +1 @@ +DROP QUOTA q1_01297, q2_01297_renamed, q3_01297, q4_01297 diff --git a/tests/ast_json_fixtures/shapes/33b345ce2a4b46d2.json b/tests/ast_json_fixtures/shapes/33b345ce2a4b46d2.json new file mode 100644 index 000000000000..6354a72f9639 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33b345ce2a4b46d2.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/33b345ce2a4b46d2.sql b/tests/ast_json_fixtures/shapes/33b345ce2a4b46d2.sql new file mode 100644 index 000000000000..a1a4a59ad6ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33b345ce2a4b46d2.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE t (a UInt8) diff --git a/tests/ast_json_fixtures/shapes/33bd5c44257a1f77.json b/tests/ast_json_fixtures/shapes/33bd5c44257a1f77.json new file mode 100644 index 000000000000..9a0a8c3deeff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33bd5c44257a1f77.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "alias": "k", + "name": "rand", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers_10k_log" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/33bd5c44257a1f77.sql b/tests/ast_json_fixtures/shapes/33bd5c44257a1f77.sql new file mode 100644 index 000000000000..e3d3412912c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33bd5c44257a1f77.sql @@ -0,0 +1 @@ +SELECT ignore(rand() AS k), ignore(max(toString(number))) FROM numbers_10k_log GROUP BY k LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/33bd735523e47af3.json b/tests/ast_json_fixtures/shapes/33bd735523e47af3.json new file mode 100644 index 000000000000..cbd47799b3e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33bd735523e47af3.json @@ -0,0 +1,194 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "subdepartment", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "level", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "department" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "A" + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "sd.level", + "name_parts": ["sd", "level"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "d" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "d", + "name": "department" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "sd", + "name": "subdepartment" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d.parent_department", + "name_parts": ["d", "parent_department"] + }, + { + "type": "Identifier", + "name": "sd.id", + "name_parts": ["sd", "id"] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "subdepartment" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "level" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/33bd735523e47af3.sql b/tests/ast_json_fixtures/shapes/33bd735523e47af3.sql new file mode 100644 index 000000000000..ed7a27829caa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33bd735523e47af3.sql @@ -0,0 +1,12 @@ +WITH RECURSIVE subdepartment AS +( + + SELECT 1 AS level, * FROM department WHERE name = 'A' + + UNION ALL + + + SELECT sd.level + 1, d.* FROM department AS d, subdepartment AS sd + WHERE d.parent_department = sd.id +) +SELECT * FROM subdepartment WHERE level >= 2 ORDER BY name diff --git a/tests/ast_json_fixtures/shapes/33d2ac5e761b0a31.json b/tests/ast_json_fixtures/shapes/33d2ac5e761b0a31.json new file mode 100644 index 000000000000..1d1003056e9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33d2ac5e761b0a31.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tbl" + } + } + } + ] + } + } + ], + "format": "TabSeparatedWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/33d2ac5e761b0a31.sql b/tests/ast_json_fixtures/shapes/33d2ac5e761b0a31.sql new file mode 100644 index 000000000000..5df29e19050d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33d2ac5e761b0a31.sql @@ -0,0 +1 @@ +SELECT * FROM tbl FORMAT TabSeparatedWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/33f4c6440021d634.json b/tests/ast_json_fixtures/shapes/33f4c6440021d634.json new file mode 100644 index 000000000000..cbdc97958d37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33f4c6440021d634.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR QUERY CONDITION CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/33f4c6440021d634.sql b/tests/ast_json_fixtures/shapes/33f4c6440021d634.sql new file mode 100644 index 000000000000..f5cfd9077a60 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/33f4c6440021d634.sql @@ -0,0 +1 @@ +system clear query condition cache diff --git a/tests/ast_json_fixtures/shapes/3404ac69ab32ef34.json b/tests/ast_json_fixtures/shapes/3404ac69ab32ef34.json new file mode 100644 index 000000000000..bc055403c47a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3404ac69ab32ef34.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "if_exists": true, + "names": ["r1_01295"] + } +} diff --git a/tests/ast_json_fixtures/shapes/3404ac69ab32ef34.sql b/tests/ast_json_fixtures/shapes/3404ac69ab32ef34.sql new file mode 100644 index 000000000000..82510afb6e35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3404ac69ab32ef34.sql @@ -0,0 +1 @@ +DROP ROLE IF EXISTS r1_01295 diff --git a/tests/ast_json_fixtures/shapes/34082f0670b19b1e.json b/tests/ast_json_fixtures/shapes/34082f0670b19b1e.json new file mode 100644 index 000000000000..6b520bdde562 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/34082f0670b19b1e.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_name": "dummy" + } + ], + "window": [ + { + "type": "WindowListElement", + "name": "dummy", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "dummy" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/34082f0670b19b1e.sql b/tests/ast_json_fixtures/shapes/34082f0670b19b1e.sql new file mode 100644 index 000000000000..bfbf05db20b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/34082f0670b19b1e.sql @@ -0,0 +1 @@ +SELECT count() OVER dummy WINDOW dummy AS (PARTITION BY dummy) diff --git a/tests/ast_json_fixtures/shapes/342c04b2fa515304.json b/tests/ast_json_fixtures/shapes/342c04b2fa515304.json new file mode 100644 index 000000000000..2d090740a35b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/342c04b2fa515304.json @@ -0,0 +1,279 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "arrayPartialReverseSort", + "arguments": [ + { + "type": "Function", + "name": "arraySort", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ] + }, + { + "type": "Identifier", + "name": "y" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "257" + }, + { + "value_type": "Int64", + "value": "-9223372036854775807" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "Int64", + "value": "-2147483648" + }, + { + "value_type": "UInt64", + "value": "2147483648" + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "UInt64", + "value": "65536" + }, + { + "value_type": "Int64", + "value": "-2147483648" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "65535" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "alias": "lim", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65536" + }, + { + "type": "Function", + "name": "arrayResize", + "arguments": [ + { + "type": "Function", + "name": "arrayPartialSort", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reverse", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "lim" + }, + { + "type": "Identifier", + "name": "arr" + } + ] + }, + { + "type": "Identifier", + "name": "lim" + } + ] + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "UInt64", + "value": "1023" + }, + { + "value_type": "Int64", + "value": "-2" + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "UInt64", + "value": "255" + }, + { + "value_type": "String", + "value": "0" + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "UInt64", + "value": "9223372036854775806" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/342c04b2fa515304.sql b/tests/ast_json_fixtures/shapes/342c04b2fa515304.sql new file mode 100644 index 000000000000..b92838312b2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/342c04b2fa515304.sql @@ -0,0 +1 @@ +SELECT arrayPartialReverseSort(arraySort((x, y) -> y, [NULL, NULL], [NULL, NULL]), arr), arrayMap(x -> toString(x), [257, -9223372036854775807, 2, -2147483648, 2147483648, NULL, 65536, -2147483648, 2, 65535]) AS arr, NULL, 100 AS lim, 65536, arrayResize(arrayPartialSort(x -> reverse(x), lim, arr), lim) GROUP BY [NULL, 1023, -2, NULL, 255, '0', NULL, 9223372036854775806] WITH ROLLUP diff --git a/tests/ast_json_fixtures/shapes/343967de9b9ebdb0.json b/tests/ast_json_fixtures/shapes/343967de9b9ebdb0.json new file mode 100644 index 000000000000..4a032a184307 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/343967de9b9ebdb0.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r6_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/343967de9b9ebdb0.sql b/tests/ast_json_fixtures/shapes/343967de9b9ebdb0.sql new file mode 100644 index 000000000000..13fae063421c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/343967de9b9ebdb0.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r6_01293 diff --git a/tests/ast_json_fixtures/shapes/344634e2fc7c48d0.json b/tests/ast_json_fixtures/shapes/344634e2fc7c48d0.json new file mode 100644 index 000000000000..4ee09fd459ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/344634e2fc7c48d0.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "like": "tES%", + "case_insensitive_like": true + } +} diff --git a/tests/ast_json_fixtures/shapes/344634e2fc7c48d0.sql b/tests/ast_json_fixtures/shapes/344634e2fc7c48d0.sql new file mode 100644 index 000000000000..1e201ccd6ecc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/344634e2fc7c48d0.sql @@ -0,0 +1 @@ +SHOW TABLES ILIKE 'tES%' diff --git a/tests/ast_json_fixtures/shapes/347aeecd322d32eb.json b/tests/ast_json_fixtures/shapes/347aeecd322d32eb.json new file mode 100644 index 000000000000..fbc891257bb6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/347aeecd322d32eb.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "alias": "a", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "b", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + } + ] + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/347aeecd322d32eb.sql b/tests/ast_json_fixtures/shapes/347aeecd322d32eb.sql new file mode 100644 index 000000000000..0c09304c9cc4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/347aeecd322d32eb.sql @@ -0,0 +1 @@ +SELECT (SELECT 1 WHERE 0) AS a, (SELECT 1 WHERE 1) AS b FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/3489bd5352bd8780.json b/tests/ast_json_fixtures/shapes/3489bd5352bd8780.json new file mode 100644 index 000000000000..91c17cfec544 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3489bd5352bd8780.json @@ -0,0 +1,305 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "alias": "total", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "cnt" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "cnt", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers_mt", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "100", + "max_execution_time": "120" + } + } + } + ], + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/3489bd5352bd8780.sql b/tests/ast_json_fixtures/shapes/3489bd5352bd8780.sql new file mode 100644 index 000000000000..54b8203fba3b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3489bd5352bd8780.sql @@ -0,0 +1,16 @@ +select + sum(cnt) > 0 as total, + k[1], k[2] + from + ( + select + arrayMap( x -> x % 3 ? toNullable(number%5 + x) : null, range(3)) as k, + number % 4 ? toNullable( rand() ) : Null as cnt + from system.numbers_mt + where number < 1000000 + limit 1000000 + ) +group by k with totals +order by k[2] +SETTINGS max_threads = 100, max_execution_time = 120 +format JSON diff --git a/tests/ast_json_fixtures/shapes/3489cd6973f7e658.json b/tests/ast_json_fixtures/shapes/3489cd6973f7e658.json new file mode 100644 index 000000000000..bbe2d0135ddd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3489cd6973f7e658.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateResourceQuery", + "resource_name": { + "type": "Identifier", + "name": "03232_write" + }, + "unit": "IOByte", + "operations": [ + { + "mode": "WRITE", + "disk": "03232_fake_disk" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3489cd6973f7e658.sql b/tests/ast_json_fixtures/shapes/3489cd6973f7e658.sql new file mode 100644 index 000000000000..21acca7ed12c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3489cd6973f7e658.sql @@ -0,0 +1 @@ +create resource 03232_write (write disk 03232_fake_disk) diff --git a/tests/ast_json_fixtures/shapes/349460603d5918c3.json b/tests/ast_json_fixtures/shapes/349460603d5918c3.json new file mode 100644 index 000000000000..78a2fdede6b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/349460603d5918c3.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "NULL" + } +} diff --git a/tests/ast_json_fixtures/shapes/349460603d5918c3.sql b/tests/ast_json_fixtures/shapes/349460603d5918c3.sql new file mode 100644 index 000000000000..8b2cd56add88 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/349460603d5918c3.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM NULL diff --git a/tests/ast_json_fixtures/shapes/3499251a9d5017a6.json b/tests/ast_json_fixtures/shapes/3499251a9d5017a6.json new file mode 100644 index 000000000000..54c549998f33 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3499251a9d5017a6.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "alter_settings": { + "type": "AlterSettingsProfileElements", + "add_settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "1" + } + ] + }, + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3499251a9d5017a6.sql b/tests/ast_json_fixtures/shapes/3499251a9d5017a6.sql new file mode 100644 index 000000000000..dccc244dfcca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3499251a9d5017a6.sql @@ -0,0 +1 @@ +ALTER USER u1_01292 SETTINGS readonly=1 diff --git a/tests/ast_json_fixtures/shapes/34db17bfd3b33eff.json b/tests/ast_json_fixtures/shapes/34db17bfd3b33eff.json new file mode 100644 index 000000000000..d125426820b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/34db17bfd3b33eff.json @@ -0,0 +1,154 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "ym:s:paramsLevel1", + "name": "PP.Key1", + "name_parts": ["PP", "Key1"] + }, + { + "type": "Function", + "alias": "ym:s:visits", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "arrayAll", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x_1" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x_1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "ParsedParams.Key2", + "name_parts": ["ParsedParams", "Key2"] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "INNER", + "expressions": [ + { + "type": "Identifier", + "alias": "PP", + "name": "ParsedParams" + } + ] + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1704509" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "ym:s:paramsLevel1" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "PP.Key1", + "name_parts": ["PP", "Key1"] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ym:s:visits" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/34db17bfd3b33eff.sql b/tests/ast_json_fixtures/shapes/34db17bfd3b33eff.sql new file mode 100644 index 000000000000..633c3bd33920 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/34db17bfd3b33eff.sql @@ -0,0 +1 @@ +SELECT PP.Key1 AS `ym:s:paramsLevel1`, sum(arrayAll(`x_1` -> `x_1`= '', ParsedParams.Key2)) AS `ym:s:visits` FROM test.hits ARRAY JOIN ParsedParams AS `PP` WHERE CounterID = 1704509 GROUP BY `ym:s:paramsLevel1` ORDER BY PP.Key1, `ym:s:visits` LIMIT 0, 100 diff --git a/tests/ast_json_fixtures/shapes/3503182b45efba89.json b/tests/ast_json_fixtures/shapes/3503182b45efba89.json new file mode 100644 index 000000000000..3a9e5713809c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3503182b45efba89.json @@ -0,0 +1,111 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "index_test" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_INDEX", + "index_declaration": { + "type": "Index", + "name": "i_x", + "expression": { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "mortonDecode", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Identifier", + "name": "z" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + }, + { + "type": "AlterCommand", + "command_type": "ADD_INDEX", + "index_declaration": { + "type": "Index", + "name": "i_y", + "expression": { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "mortonDecode", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Identifier", + "name": "z" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + }, + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_INDEX", + "index": { + "type": "Identifier", + "name": "i_x" + } + }, + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_INDEX", + "index": { + "type": "Identifier", + "name": "i_y" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3503182b45efba89.sql b/tests/ast_json_fixtures/shapes/3503182b45efba89.sql new file mode 100644 index 000000000000..2dcf8100b717 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3503182b45efba89.sql @@ -0,0 +1,5 @@ +ALTER TABLE index_test + ADD INDEX i_x mortonDecode(2, z).1 TYPE minmax GRANULARITY 1, + ADD INDEX i_y mortonDecode(2, z).2 TYPE minmax GRANULARITY 1, + MATERIALIZE INDEX i_x, + MATERIALIZE INDEX i_y diff --git a/tests/ast_json_fixtures/shapes/350da80c02727ce5.json b/tests/ast_json_fixtures/shapes/350da80c02727ce5.json new file mode 100644 index 000000000000..d7f37f3a4d9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/350da80c02727ce5.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "test_01148_atomic" + }, + "table": { + "type": "Identifier", + "name": "rmt3" + }, + "as_database": "test_01148_atomic", + "as_table": "rmt2" + } +} diff --git a/tests/ast_json_fixtures/shapes/350da80c02727ce5.sql b/tests/ast_json_fixtures/shapes/350da80c02727ce5.sql new file mode 100644 index 000000000000..d3eb3bc0a86b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/350da80c02727ce5.sql @@ -0,0 +1 @@ +CREATE TABLE test_01148_atomic.rmt3 AS test_01148_atomic.rmt2 diff --git a/tests/ast_json_fixtures/shapes/350f7d859c070c5b.json b/tests/ast_json_fixtures/shapes/350f7d859c070c5b.json new file mode 100644 index 000000000000..456dacaea444 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/350f7d859c070c5b.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_result_rows": "1" + } + }, + "format": "TSVWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/350f7d859c070c5b.sql b/tests/ast_json_fixtures/shapes/350f7d859c070c5b.sql new file mode 100644 index 000000000000..9e392ef5b703 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/350f7d859c070c5b.sql @@ -0,0 +1 @@ +select * from numbers(100) FORMAT TSVWithNamesAndTypes settings max_result_rows = 1 diff --git a/tests/ast_json_fixtures/shapes/3537160ffea0deda.json b/tests/ast_json_fixtures/shapes/3537160ffea0deda.json new file mode 100644 index 000000000000..2ef77f20d85d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3537160ffea0deda.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "intersect" + }, + { + "type": "Function", + "name": "countSubstrings", + "arguments": [ + { + "type": "Function", + "name": "repeat", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "00" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/3537160ffea0deda.sql b/tests/ast_json_fixtures/shapes/3537160ffea0deda.sql new file mode 100644 index 000000000000..6d70454908af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3537160ffea0deda.sql @@ -0,0 +1 @@ +select 'intersect', countSubstrings(repeat(toString(number), 8), '00') from numbers(1) format CSV diff --git a/tests/ast_json_fixtures/shapes/35425776217669ca.json b/tests/ast_json_fixtures/shapes/35425776217669ca.json new file mode 100644 index 000000000000..daf0b470a5de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35425776217669ca.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q12_01297"], + "key_type": "CLIENT_KEY_OR_IP_ADDRESS" + } +} diff --git a/tests/ast_json_fixtures/shapes/35425776217669ca.sql b/tests/ast_json_fixtures/shapes/35425776217669ca.sql new file mode 100644 index 000000000000..cb4d33bc4f6e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35425776217669ca.sql @@ -0,0 +1 @@ +CREATE QUOTA q12_01297 KEYED BY 'client key or ip address' diff --git a/tests/ast_json_fixtures/shapes/3545e0d46492564e.json b/tests/ast_json_fixtures/shapes/3545e0d46492564e.json new file mode 100644 index 000000000000..a1c5c8de5661 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3545e0d46492564e.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s6_01294"], + "to_roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3545e0d46492564e.sql b/tests/ast_json_fixtures/shapes/3545e0d46492564e.sql new file mode 100644 index 000000000000..8ca2ccde48fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3545e0d46492564e.sql @@ -0,0 +1 @@ +CREATE PROFILE s6_01294 TO ALL EXCEPT r1_01294 diff --git a/tests/ast_json_fixtures/shapes/3579d0c0e567494f.json b/tests/ast_json_fixtures/shapes/3579d0c0e567494f.json new file mode 100644 index 000000000000..17067f54e360 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3579d0c0e567494f.json @@ -0,0 +1,116 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "URL" + }, + { + "type": "Identifier", + "name": "URLDomain" + }, + { + "type": "Function", + "alias": "x", + "name": "position", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "http:\/\/yandex.ru\/" + }, + { + "type": "Function", + "name": "domain", + "arguments": [ + { + "type": "Identifier", + "name": "URL" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "position", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "http:\/\/yandex.ru\/" + }, + { + "type": "Function", + "name": "domain", + "arguments": [ + { + "type": "Identifier", + "name": "URL" + } + ] + } + ] + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "URL" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3579d0c0e567494f.sql b/tests/ast_json_fixtures/shapes/3579d0c0e567494f.sql new file mode 100644 index 000000000000..79fb2915b737 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3579d0c0e567494f.sql @@ -0,0 +1 @@ +SELECT DISTINCT URL, URLDomain, position('http://yandex.ru/', domain(URL)) AS x FROM test.hits WHERE x > 8 ORDER BY position('http://yandex.ru/', domain(URL)) DESC, URL LIMIT 3 diff --git a/tests/ast_json_fixtures/shapes/35a975e85e64f146.json b/tests/ast_json_fixtures/shapes/35a975e85e64f146.json new file mode 100644 index 000000000000..51ec8c38caa3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35a975e85e64f146.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "TSVRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/35a975e85e64f146.sql b/tests/ast_json_fixtures/shapes/35a975e85e64f146.sql new file mode 100644 index 000000000000..3b050a7dd9d9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35a975e85e64f146.sql @@ -0,0 +1 @@ +select toTypeName(a) from test limit 1 format TSVRaw diff --git a/tests/ast_json_fixtures/shapes/35b1c5de54da8c09.json b/tests/ast_json_fixtures/shapes/35b1c5de54da8c09.json new file mode 100644 index 000000000000..d3f010bf27ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35b1c5de54da8c09.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "tmp" + }, + "columns": [ + { + "type": "Asterisk" + } + ], + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/35b1c5de54da8c09.sql b/tests/ast_json_fixtures/shapes/35b1c5de54da8c09.sql new file mode 100644 index 000000000000..0d4a7388ce5d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35b1c5de54da8c09.sql @@ -0,0 +1 @@ +INSERT INTO tmp (*) VALUES ('a') diff --git a/tests/ast_json_fixtures/shapes/35b307576c4bcfcf.json b/tests/ast_json_fixtures/shapes/35b307576c4bcfcf.json new file mode 100644 index 000000000000..28ab19ed850c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35b307576c4bcfcf.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "ColumnsRegexpMatcher", + "pattern": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/35b307576c4bcfcf.sql b/tests/ast_json_fixtures/shapes/35b307576c4bcfcf.sql new file mode 100644 index 000000000000..3c90ca470de4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35b307576c4bcfcf.sql @@ -0,0 +1 @@ +SELECT COLUMNS('x') FROM numbers(10) WHERE number > 5 diff --git a/tests/ast_json_fixtures/shapes/35ebbd985e2e2872.json b/tests/ast_json_fixtures/shapes/35ebbd985e2e2872.json new file mode 100644 index 000000000000..ee0ef08235f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35ebbd985e2e2872.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/35ebbd985e2e2872.sql b/tests/ast_json_fixtures/shapes/35ebbd985e2e2872.sql new file mode 100644 index 000000000000..ec9b9f9d1042 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35ebbd985e2e2872.sql @@ -0,0 +1 @@ +SELECT count() FROM system.numbers LIMIT 1, 0 diff --git a/tests/ast_json_fixtures/shapes/35eece6bde089bb8.json b/tests/ast_json_fixtures/shapes/35eece6bde089bb8.json new file mode 100644 index 000000000000..6159ddef73c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35eece6bde089bb8.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Identifier", + "name": "system" + }, + { + "type": "Identifier", + "name": "columns" + } + ] + } + }, + "as_database": "system", + "as_table": "columns" + } +} diff --git a/tests/ast_json_fixtures/shapes/35eece6bde089bb8.sql b/tests/ast_json_fixtures/shapes/35eece6bde089bb8.sql new file mode 100644 index 000000000000..6b6a4cfc9a53 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35eece6bde089bb8.sql @@ -0,0 +1 @@ +CREATE TABLE table1 AS system.columns ENGINE = Distributed('test_shard_localhost', system, columns) diff --git a/tests/ast_json_fixtures/shapes/35f81e2028af731b.json b/tests/ast_json_fixtures/shapes/35f81e2028af731b.json new file mode 100644 index 000000000000..7de3f1145cf1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35f81e2028af731b.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "dummy", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "y", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_global_with_statement": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/35f81e2028af731b.sql b/tests/ast_json_fixtures/shapes/35f81e2028af731b.sql new file mode 100644 index 000000000000..d2601f52624a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35f81e2028af731b.sql @@ -0,0 +1,4 @@ +WITH dummy + 3 AS dummy +SELECT dummy + 1 AS y +FROM system.one +SETTINGS enable_global_with_statement = 1 diff --git a/tests/ast_json_fixtures/shapes/35ffdbab73cdf5b9.json b/tests/ast_json_fixtures/shapes/35ffdbab73cdf5b9.json new file mode 100644 index 000000000000..4f524bf0b41a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35ffdbab73cdf5b9.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "visits_order" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "user_id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "user_name", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "some_int", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "user_id" + }, + "primary_key": { + "type": "Identifier", + "name": "user_id" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/35ffdbab73cdf5b9.sql b/tests/ast_json_fixtures/shapes/35ffdbab73cdf5b9.sql new file mode 100644 index 000000000000..f78e629e0cd1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/35ffdbab73cdf5b9.sql @@ -0,0 +1,6 @@ +CREATE TABLE visits_order +( + user_id UInt64, + user_name String, + some_int UInt64 +) ENGINE = MergeTree() PRIMARY KEY user_id PARTITION BY user_id SETTINGS index_granularity = 1 diff --git a/tests/ast_json_fixtures/shapes/3608d8b45e736112.json b/tests/ast_json_fixtures/shapes/3608d8b45e736112.json new file mode 100644 index 000000000000..bbfe932b4b77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3608d8b45e736112.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3608d8b45e736112.sql b/tests/ast_json_fixtures/shapes/3608d8b45e736112.sql new file mode 100644 index 000000000000..c2101507a548 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3608d8b45e736112.sql @@ -0,0 +1 @@ +SELECT DISTINCT x / 2 FROM tab diff --git a/tests/ast_json_fixtures/shapes/361c8dcd1f005d91.json b/tests/ast_json_fixtures/shapes/361c8dcd1f005d91.json new file mode 100644 index 000000000000..7ea33a02ea59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/361c8dcd1f005d91.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["spaces "] + } +} diff --git a/tests/ast_json_fixtures/shapes/361c8dcd1f005d91.sql b/tests/ast_json_fixtures/shapes/361c8dcd1f005d91.sql new file mode 100644 index 000000000000..52520ff4063e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/361c8dcd1f005d91.sql @@ -0,0 +1 @@ +drop user if exists 'spaces ' diff --git a/tests/ast_json_fixtures/shapes/363468452a1292d2.json b/tests/ast_json_fixtures/shapes/363468452a1292d2.json new file mode 100644 index 000000000000..6542a5a84eaa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/363468452a1292d2.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Count" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lwd_test" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/363468452a1292d2.sql b/tests/ast_json_fixtures/shapes/363468452a1292d2.sql new file mode 100644 index 000000000000..455ac48cded5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/363468452a1292d2.sql @@ -0,0 +1 @@ +SELECT 'Count', count() FROM lwd_test diff --git a/tests/ast_json_fixtures/shapes/365bc0223939ea2d.json b/tests/ast_json_fixtures/shapes/365bc0223939ea2d.json new file mode 100644 index 000000000000..a5d2d196fc95 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/365bc0223939ea2d.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "test2_d" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shard_three_replicas_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test2" + }, + { + "type": "Identifier", + "name": "id" + } + ] + } + }, + "as_table": "test2" + } +} diff --git a/tests/ast_json_fixtures/shapes/365bc0223939ea2d.sql b/tests/ast_json_fixtures/shapes/365bc0223939ea2d.sql new file mode 100644 index 000000000000..35d63f1e55b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/365bc0223939ea2d.sql @@ -0,0 +1,2 @@ +CREATE TABLE IF NOT EXISTS test2_d as test2 +ENGINE = Distributed(test_cluster_two_shard_three_replicas_localhost, currentDatabase(), test2, id) diff --git a/tests/ast_json_fixtures/shapes/365e93aaf95e37c4.json b/tests/ast_json_fixtures/shapes/365e93aaf95e37c4.json new file mode 100644 index 000000000000..d2a9f4cd57eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/365e93aaf95e37c4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q6_01297"], + "key_type": "CLIENT_KEY_OR_IP_ADDRESS" + } +} diff --git a/tests/ast_json_fixtures/shapes/365e93aaf95e37c4.sql b/tests/ast_json_fixtures/shapes/365e93aaf95e37c4.sql new file mode 100644 index 000000000000..0746cb1ad2b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/365e93aaf95e37c4.sql @@ -0,0 +1 @@ +CREATE QUOTA q6_01297 KEY BY client_key, ip_address diff --git a/tests/ast_json_fixtures/shapes/367ed87f3fb2293c.json b/tests/ast_json_fixtures/shapes/367ed87f3fb2293c.json new file mode 100644 index 000000000000..4f402da07d47 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/367ed87f3fb2293c.json @@ -0,0 +1,116 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "a", + "name": "query_log", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.query_id", + "name_parts": ["a", "query_id"] + }, + { + "type": "Identifier", + "name": "b.query_id", + "name_parts": ["b", "query_id"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.query_id", + "name_parts": ["a", "query_id"] + }, + { + "type": "Identifier", + "name": "b.query_id", + "name_parts": ["b", "query_id"] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "b", + "name": "processes", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "query_plan_use_new_logical_join_step": true, + "query_plan_convert_join_to_in": true + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/367ed87f3fb2293c.sql b/tests/ast_json_fixtures/shapes/367ed87f3fb2293c.sql new file mode 100644 index 000000000000..da01028991b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/367ed87f3fb2293c.sql @@ -0,0 +1,7 @@ +SELECT 10 +FROM system.query_log AS a +INNER JOIN system.processes AS b +ON (a.query_id = b.query_id) AND (a.query_id = b.query_id) +WHERE current_database = currentDatabase() +FORMAT Null +SETTINGS query_plan_use_new_logical_join_step = true, query_plan_convert_join_to_in = true diff --git a/tests/ast_json_fixtures/shapes/36932261e8d56fd2.json b/tests/ast_json_fixtures/shapes/36932261e8d56fd2.json new file mode 100644 index 000000000000..e4c8459970b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/36932261e8d56fd2.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q3_01297"], + "key_type": "NONE" + } +} diff --git a/tests/ast_json_fixtures/shapes/36932261e8d56fd2.sql b/tests/ast_json_fixtures/shapes/36932261e8d56fd2.sql new file mode 100644 index 000000000000..72650a3620ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/36932261e8d56fd2.sql @@ -0,0 +1 @@ +ALTER QUOTA q3_01297 NOT KEYED diff --git a/tests/ast_json_fixtures/shapes/36ccb2bae56b266f.json b/tests/ast_json_fixtures/shapes/36ccb2bae56b266f.json new file mode 100644 index 000000000000..29bd7389eff4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/36ccb2bae56b266f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s1_01294", "s2_01294", "s3_01294", "s4_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/36ccb2bae56b266f.sql b/tests/ast_json_fixtures/shapes/36ccb2bae56b266f.sql new file mode 100644 index 000000000000..2c39b1842331 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/36ccb2bae56b266f.sql @@ -0,0 +1 @@ +DROP PROFILE s1_01294, s2_01294, s3_01294, s4_01294 diff --git a/tests/ast_json_fixtures/shapes/36ed171f26803bb9.json b/tests/ast_json_fixtures/shapes/36ed171f26803bb9.json new file mode 100644 index 000000000000..7fd9b2cb4fe5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/36ed171f26803bb9.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u1_01296"] + } +} diff --git a/tests/ast_json_fixtures/shapes/36ed171f26803bb9.sql b/tests/ast_json_fixtures/shapes/36ed171f26803bb9.sql new file mode 100644 index 000000000000..ca28e09d2647 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/36ed171f26803bb9.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS u1_01296 diff --git a/tests/ast_json_fixtures/shapes/371863a6f38548c2.json b/tests/ast_json_fixtures/shapes/371863a6f38548c2.json new file mode 100644 index 000000000000..ce354b17a918 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/371863a6f38548c2.json @@ -0,0 +1,279 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "13" + }, + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "or", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-32" + }, + { + "type": "Function", + "name": "dictGetInt32", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "dictionary_all" + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "14" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "i32" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Identifier", + "name": "id" + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNotDistinctFrom", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775806" + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "arguments": [ + { + "type": "Identifier", + "name": "payload" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775806" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "dictGetFloat64 - plan" + } + ] + }, + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab__fuzz_24" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775806" + }, + { + "type": "Identifier", + "name": "payload" + } + ] + }, + "where": { + "type": "Function", + "name": "isNotDistinctFrom", + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "isNotDistinctFrom", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775806" + }, + { + "type": "Function", + "name": "equals", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775806" + } + ] + } + ] + } + ] + } + ] + }, + "qualify": { + "type": "Function", + "name": "and", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "equals", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "isZeroOrNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "payload" + }, + "direction": "DESC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/371863a6f38548c2.sql b/tests/ast_json_fixtures/shapes/371863a6f38548c2.sql new file mode 100644 index 000000000000..3c1bed16862b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/371863a6f38548c2.sql @@ -0,0 +1,4 @@ +SELECT DISTINCT 13, *, or(-32 = dictGetInt32(toFixedString('dictionary_all', toLowCardinality(14)), toFixedString('i32', 3), id), isNotDistinctFrom(1, 9223372036854775806), toLowCardinality(19), not(equals(payload, 9223372036854775806))), isNotNull('dictGetFloat64 - plan'), id, isNotNull(1) +FROM tab__fuzz_24 PREWHERE equals(9223372036854775806, payload) +WHERE isNotDistinctFrom(id, isNotDistinctFrom(9223372036854775806, equals(1, isNotNull(9223372036854775806)))) QUALIFY and(NULL, equals(1, isZeroOrNull(1))) +ORDER BY payload DESC diff --git a/tests/ast_json_fixtures/shapes/372ceb6c15f9d907.json b/tests/ast_json_fixtures/shapes/372ceb6c15f9d907.json new file mode 100644 index 000000000000..fe3f27708e5a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/372ceb6c15f9d907.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/372ceb6c15f9d907.sql b/tests/ast_json_fixtures/shapes/372ceb6c15f9d907.sql new file mode 100644 index 000000000000..c18fc94d4be5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/372ceb6c15f9d907.sql @@ -0,0 +1 @@ +with 1 as x select * from (select x) diff --git a/tests/ast_json_fixtures/shapes/3758967ce851be9e.json b/tests/ast_json_fixtures/shapes/3758967ce851be9e.json new file mode 100644 index 000000000000..94695ab722c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3758967ce851be9e.json @@ -0,0 +1,132 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "implicit_True" + }, + { + "type": "Function", + "alias": "all", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "alias": "is_empty", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "transaction_id" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "0" + }, + { + "value_type": "UInt64", + "value": "0" + }, + { + "value_type": "String", + "value": "00000000-0000-0000-0000-000000000000" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "yesterday", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "-- Verify that the transaction_id column is populated correctly%" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "transaction_id" + } + ] + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/3758967ce851be9e.sql b/tests/ast_json_fixtures/shapes/3758967ce851be9e.sql new file mode 100644 index 000000000000..ac3041f1a279 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3758967ce851be9e.sql @@ -0,0 +1,11 @@ +SELECT + 'implicit_True', + count() as all, + transaction_id = (0,0,'00000000-0000-0000-0000-000000000000') as is_empty +FROM system.query_log +WHERE + current_database = currentDatabase() AND + event_date >= yesterday() AND + query LIKE '-- Verify that the transaction_id column is populated correctly%' +GROUP BY transaction_id +FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/375f8c09ceb785cb.json b/tests/ast_json_fixtures/shapes/375f8c09ceb785cb.json new file mode 100644 index 000000000000..5188ff21dd68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/375f8c09ceb785cb.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_02513" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + }, + "where": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "13" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/375f8c09ceb785cb.sql b/tests/ast_json_fixtures/shapes/375f8c09ceb785cb.sql new file mode 100644 index 000000000000..69d7980953bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/375f8c09ceb785cb.sql @@ -0,0 +1 @@ +SELECT * FROM table_02513 PREWHERE n%11 WHERE n%13 diff --git a/tests/ast_json_fixtures/shapes/377ef0980d024b46.json b/tests/ast_json_fixtures/shapes/377ef0980d024b46.json new file mode 100644 index 000000000000..9b75df436118 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/377ef0980d024b46.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "v1" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "use_top_k_dynamic_filtering": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/377ef0980d024b46.sql b/tests/ast_json_fixtures/shapes/377ef0980d024b46.sql new file mode 100644 index 000000000000..95af76c70954 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/377ef0980d024b46.sql @@ -0,0 +1 @@ +SELECT v1, v2 FROM tab1 WHERE v2 > 100000 ORDER BY v1 ASC LIMIT 10 SETTINGS use_top_k_dynamic_filtering=1 diff --git a/tests/ast_json_fixtures/shapes/377f21a21bf4e7ff.json b/tests/ast_json_fixtures/shapes/377f21a21bf4e7ff.json new file mode 100644 index 000000000000..8a79090569a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/377f21a21bf4e7ff.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": -0 + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": -0 + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/377f21a21bf4e7ff.sql b/tests/ast_json_fixtures/shapes/377f21a21bf4e7ff.sql new file mode 100644 index 000000000000..3abc775cecba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/377f21a21bf4e7ff.sql @@ -0,0 +1 @@ +SELECT -0, toTypeName(-0), -1, toTypeName(-1), -0., toTypeName(-0.) diff --git a/tests/ast_json_fixtures/shapes/3782d99f9907853a.json b/tests/ast_json_fixtures/shapes/3782d99f9907853a.json new file mode 100644 index 000000000000..d56da9132483 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3782d99f9907853a.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "mv_primary_key_from_column" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "String" + }, + "primary_key_specifier": true + } + ], + "primary_key_from_columns": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3782d99f9907853a.sql b/tests/ast_json_fixtures/shapes/3782d99f9907853a.sql new file mode 100644 index 000000000000..b398fd768f19 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3782d99f9907853a.sql @@ -0,0 +1,6 @@ +CREATE MATERIALIZED VIEW mv_primary_key_from_column +( + key String PRIMARY KEY +) +ENGINE = MergeTree +AS SELECT * FROM data diff --git a/tests/ast_json_fixtures/shapes/37960594e14c325c.json b/tests/ast_json_fixtures/shapes/37960594e14c325c.json new file mode 100644 index 000000000000..bb0f079adde8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/37960594e14c325c.json @@ -0,0 +1,187 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "LoadedMarksCount" + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "nonexistent", + "database": "system" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "match", + "arguments": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "SELECT * FROM t_prewarm_add_column%" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "current_database" + } + ] + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "notLike", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "SELECT * FROM t_prewarm_add_column%" + }, + { + "type": "Identifier", + "name": "query" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryFinish" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "DESC", + "nulls_first": true + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/37960594e14c325c.sql b/tests/ast_json_fixtures/shapes/37960594e14c325c.sql new file mode 100644 index 000000000000..937c650aee2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/37960594e14c325c.sql @@ -0,0 +1 @@ +SELECT ProfileEvents['LoadedMarksCount'], 1 OR toLowCardinality(1) FROM system.nonexistent PREWHERE tupleElement(*, 1) AND match(query, 'SELECT * FROM t_prewarm_add_column%') AND (currentDatabase() = current_database) WHERE ('SELECT * FROM t_prewarm_add_column%' NOT LIKE query) AND (type = 'QueryFinish') AND (current_database = currentDatabase()) ORDER BY ALL DESC NULLS FIRST diff --git a/tests/ast_json_fixtures/shapes/37a4407cb39f5dc8.json b/tests/ast_json_fixtures/shapes/37a4407cb39f5dc8.json new file mode 100644 index 000000000000..0f6037f76f68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/37a4407cb39f5dc8.json @@ -0,0 +1,110 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_alter_mixed" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "a" + } + }, + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "if_exists": true, + "column": { + "type": "Identifier", + "name": "a" + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "if_exists": true, + "column_declaration": { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + }, + { + "type": "AlterCommand", + "command_type": "COMMENT_COLUMN", + "if_exists": true, + "column": { + "type": "Identifier", + "name": "a" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "should be ignored" + } + }, + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "if_exists": true, + "column": { + "type": "Identifier", + "name": "a" + }, + "rename_to": { + "type": "Identifier", + "name": "a_renamed" + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "if_exists": true, + "column_declaration": { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "String" + }, + "default_specifier": "DEFAULT", + "default_expression": { + "type": "Literal", + "value_type": "String", + "value": "test" + } + } + }, + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "c" + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "if_exists": true, + "column_declaration": { + "type": "ColumnDeclaration", + "name": "c", + "data_type": { + "type": "DataType", + "name": "Float32" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/37a4407cb39f5dc8.sql b/tests/ast_json_fixtures/shapes/37a4407cb39f5dc8.sql new file mode 100644 index 000000000000..2b73ccd90687 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/37a4407cb39f5dc8.sql @@ -0,0 +1,9 @@ +ALTER TABLE test_alter_mixed + DROP COLUMN a, + DROP COLUMN IF EXISTS a, + MODIFY COLUMN IF EXISTS a Int64, + COMMENT COLUMN IF EXISTS a 'should be ignored', + RENAME COLUMN IF EXISTS a TO a_renamed, + MODIFY COLUMN IF EXISTS b String DEFAULT 'test', + DROP COLUMN c, + MODIFY COLUMN IF EXISTS c Float32 diff --git a/tests/ast_json_fixtures/shapes/37a7984ca47cbcd3.json b/tests/ast_json_fixtures/shapes/37a7984ca47cbcd3.json new file mode 100644 index 000000000000..2bf078c4435b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/37a7984ca47cbcd3.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s1_01294", "s2_01294", "s3_01294", "s4_01294", "s5_01294", "s6_01294", "s7_01294", "s8_01294", "s9_01294", "s10_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/37a7984ca47cbcd3.sql b/tests/ast_json_fixtures/shapes/37a7984ca47cbcd3.sql new file mode 100644 index 000000000000..c7be429941de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/37a7984ca47cbcd3.sql @@ -0,0 +1 @@ +DROP PROFILE s1_01294, s2_01294, s3_01294, s4_01294, s5_01294, s6_01294, s7_01294, s8_01294, s9_01294, s10_01294 diff --git a/tests/ast_json_fixtures/shapes/37c556bd95c32e5d.json b/tests/ast_json_fixtures/shapes/37c556bd95c32e5d.json new file mode 100644 index 000000000000..e39fd0724839 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/37c556bd95c32e5d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s3_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/37c556bd95c32e5d.sql b/tests/ast_json_fixtures/shapes/37c556bd95c32e5d.sql new file mode 100644 index 000000000000..2c8cbbf6402f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/37c556bd95c32e5d.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s3_01294 diff --git a/tests/ast_json_fixtures/shapes/37caa3e3f4725d18.json b/tests/ast_json_fixtures/shapes/37caa3e3f4725d18.json new file mode 100644 index 000000000000..fdf94db7279c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/37caa3e3f4725d18.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "null", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "auto" + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/37caa3e3f4725d18.sql b/tests/ast_json_fixtures/shapes/37caa3e3f4725d18.sql new file mode 100644 index 000000000000..112137b9c0c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/37caa3e3f4725d18.sql @@ -0,0 +1 @@ +INSERT INTO function null('auto') SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/380fa3ba8f9b67ae.json b/tests/ast_json_fixtures/shapes/380fa3ba8f9b67ae.json new file mode 100644 index 000000000000..75eb0d3cf262 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/380fa3ba8f9b67ae.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "_part" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "02581_trips" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "description" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "_part" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "_part" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "select_sequential_consistency": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/380fa3ba8f9b67ae.sql b/tests/ast_json_fixtures/shapes/380fa3ba8f9b67ae.sql new file mode 100644 index 000000000000..6fc014e91013 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/380fa3ba8f9b67ae.sql @@ -0,0 +1 @@ +SELECT count(), _part from 02581_trips WHERE description = '' GROUP BY _part ORDER BY _part SETTINGS select_sequential_consistency=1 diff --git a/tests/ast_json_fixtures/shapes/38498f4536e4148f.json b/tests/ast_json_fixtures/shapes/38498f4536e4148f.json new file mode 100644 index 000000000000..9b1e48963e52 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38498f4536e4148f.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q4_01297"], + "key_type": "NONE", + "limits": [ + { + "duration_sec": "3600", + "drop": true + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/38498f4536e4148f.sql b/tests/ast_json_fixtures/shapes/38498f4536e4148f.sql new file mode 100644 index 000000000000..5908be1ae5e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38498f4536e4148f.sql @@ -0,0 +1 @@ +CREATE QUOTA q4_01297 KEYED BY none FOR 1 hour NO LIMITS diff --git a/tests/ast_json_fixtures/shapes/386d2e42fb788dff.json b/tests/ast_json_fixtures/shapes/386d2e42fb788dff.json new file mode 100644 index 000000000000..56e07c663057 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/386d2e42fb788dff.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/386d2e42fb788dff.sql b/tests/ast_json_fixtures/shapes/386d2e42fb788dff.sql new file mode 100644 index 000000000000..20dfd57d3a1f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/386d2e42fb788dff.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) LIMIT 3 OFFSET 2 diff --git a/tests/ast_json_fixtures/shapes/38726bb855e5ace5.json b/tests/ast_json_fixtures/shapes/38726bb855e5ace5.json new file mode 100644 index 000000000000..c59991878c9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38726bb855e5ace5.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_shard_num" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/38726bb855e5ace5.sql b/tests/ast_json_fixtures/shapes/38726bb855e5ace5.sql new file mode 100644 index 000000000000..24d4e6d5952f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38726bb855e5ace5.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 where number = _shard_num-1 group by number order by number limit 1 offset 1 diff --git a/tests/ast_json_fixtures/shapes/3884271d650e4bd4.json b/tests/ast_json_fixtures/shapes/3884271d650e4bd4.json new file mode 100644 index 000000000000..b4591d5d4d22 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3884271d650e4bd4.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits_s3", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "URL" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%metrika%" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "EventTime" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/3884271d650e4bd4.sql b/tests/ast_json_fixtures/shapes/3884271d650e4bd4.sql new file mode 100644 index 000000000000..3ccf2a3a41ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3884271d650e4bd4.sql @@ -0,0 +1 @@ +SELECT * FROM test.hits_s3 WHERE URL LIKE '%metrika%' ORDER BY EventTime LIMIT 10 format Null diff --git a/tests/ast_json_fixtures/shapes/38871da53b49064c.json b/tests/ast_json_fixtures/shapes/38871da53b49064c.json new file mode 100644 index 000000000000..d238cba5291e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38871da53b49064c.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": [" spaces"] + } +} diff --git a/tests/ast_json_fixtures/shapes/38871da53b49064c.sql b/tests/ast_json_fixtures/shapes/38871da53b49064c.sql new file mode 100644 index 000000000000..ee16c45d66c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38871da53b49064c.sql @@ -0,0 +1 @@ +drop user if exists ' spaces' diff --git a/tests/ast_json_fixtures/shapes/388b04541ed4ed45.json b/tests/ast_json_fixtures/shapes/388b04541ed4ed45.json new file mode 100644 index 000000000000..ede1b4e5dedb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/388b04541ed4ed45.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "alter": true, + "names": ["s1_01294"], + "alter_settings": { + "type": "AlterSettingsProfileElements", + "add_settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "parent_profile": "default" + } + ] + }, + "drop_all_settings": true, + "drop_all_profiles": true + }, + "to_roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/388b04541ed4ed45.sql b/tests/ast_json_fixtures/shapes/388b04541ed4ed45.sql new file mode 100644 index 000000000000..eb6165c571c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/388b04541ed4ed45.sql @@ -0,0 +1 @@ +ALTER SETTINGS PROFILE s1_01294 SETTINGS INHERIT 'default' TO NONE diff --git a/tests/ast_json_fixtures/shapes/389c0c1210bc574c.json b/tests/ast_json_fixtures/shapes/389c0c1210bc574c.json new file mode 100644 index 000000000000..d558c270c4ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/389c0c1210bc574c.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "alter": true, + "names": ["r1_01293", "r2_01293"], + "alter_settings": { + "type": "AlterSettingsProfileElements", + "add_settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "1" + } + ] + }, + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/389c0c1210bc574c.sql b/tests/ast_json_fixtures/shapes/389c0c1210bc574c.sql new file mode 100644 index 000000000000..376bfbadf434 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/389c0c1210bc574c.sql @@ -0,0 +1 @@ +ALTER ROLE r1_01293, r2_01293 SETTINGS readonly=1 diff --git a/tests/ast_json_fixtures/shapes/38bc969f7103fd37.json b/tests/ast_json_fixtures/shapes/38bc969f7103fd37.json new file mode 100644 index 000000000000..e2e36b1b24e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38bc969f7103fd37.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "databases": true, + "like": "sqllt", + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/38bc969f7103fd37.sql b/tests/ast_json_fixtures/shapes/38bc969f7103fd37.sql new file mode 100644 index 000000000000..5550713f5585 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38bc969f7103fd37.sql @@ -0,0 +1 @@ +SHOW DATABASES LIKE 'sqllt' FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/38df62ef8e08408e.json b/tests/ast_json_fixtures/shapes/38df62ef8e08408e.json new file mode 100644 index 000000000000..463667bc6431 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38df62ef8e08408e.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": [" spaces"] + } +} diff --git a/tests/ast_json_fixtures/shapes/38df62ef8e08408e.sql b/tests/ast_json_fixtures/shapes/38df62ef8e08408e.sql new file mode 100644 index 000000000000..398e7fcc3f2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38df62ef8e08408e.sql @@ -0,0 +1 @@ +drop user ' spaces' diff --git a/tests/ast_json_fixtures/shapes/38efbd953143c4e5.json b/tests/ast_json_fixtures/shapes/38efbd953143c4e5.json new file mode 100644 index 000000000000..1a4a53b825a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38efbd953143c4e5.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_ordinary", + "from_table": "mv1", + "to_database": "test_01155_atomic", + "to_table": "mv1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/38efbd953143c4e5.sql b/tests/ast_json_fixtures/shapes/38efbd953143c4e5.sql new file mode 100644 index 000000000000..079053e3b545 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/38efbd953143c4e5.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_ordinary.mv1 TO test_01155_atomic.mv1 diff --git a/tests/ast_json_fixtures/shapes/3903d4baee0f2795.json b/tests/ast_json_fixtures/shapes/3903d4baee0f2795.json new file mode 100644 index 000000000000..5fa4f0ff1e02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3903d4baee0f2795.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "query_1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/3903d4baee0f2795.sql b/tests/ast_json_fixtures/shapes/3903d4baee0f2795.sql new file mode 100644 index 000000000000..cd0f3e8abe25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3903d4baee0f2795.sql @@ -0,0 +1 @@ +SELECT a FROM t FORMAT Null SETTINGS log_comment='query_1' diff --git a/tests/ast_json_fixtures/shapes/3909502192be23ed.json b/tests/ast_json_fixtures/shapes/3909502192be23ed.json new file mode 100644 index 000000000000..18f37ec7714a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3909502192be23ed.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "02681_undrop_uuid_on_cluster" + }, + "format": "Null", + "cluster": "test_shard_localhost" + } +} diff --git a/tests/ast_json_fixtures/shapes/3909502192be23ed.sql b/tests/ast_json_fixtures/shapes/3909502192be23ed.sql new file mode 100644 index 000000000000..ff15d6aff85b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3909502192be23ed.sql @@ -0,0 +1 @@ +drop table 02681_undrop_uuid_on_cluster on cluster test_shard_localhost format Null diff --git a/tests/ast_json_fixtures/shapes/391cb2bd9907789c.json b/tests/ast_json_fixtures/shapes/391cb2bd9907789c.json new file mode 100644 index 000000000000..ed89c1b59b7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/391cb2bd9907789c.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["INSERT"], + "database": "team", + "wildcard": true + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["user_03141"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/391cb2bd9907789c.sql b/tests/ast_json_fixtures/shapes/391cb2bd9907789c.sql new file mode 100644 index 000000000000..6d7d624b8d13 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/391cb2bd9907789c.sql @@ -0,0 +1 @@ +GRANT INSERT ON team*.* TO user_03141 diff --git a/tests/ast_json_fixtures/shapes/39202efce3979f24.json b/tests/ast_json_fixtures/shapes/39202efce3979f24.json new file mode 100644 index 000000000000..c4fc32bcc798 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39202efce3979f24.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "NO_PASSWORD", + "arguments": [] + } + ], + "replace_authentication_methods": true, + "hosts": { + "like_patterns": ["%.%.myhost.com"] + }, + "default_roles": { + "type": "RolesOrUsersSet" + }, + "alter_settings": { + "type": "AlterSettingsProfileElements", + "add_settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "parent_profile": "default" + } + ] + }, + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/39202efce3979f24.sql b/tests/ast_json_fixtures/shapes/39202efce3979f24.sql new file mode 100644 index 000000000000..97183ee2df36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39202efce3979f24.sql @@ -0,0 +1 @@ +ALTER USER u1_01292 NOT IDENTIFIED HOST LIKE '%.%.myhost.com' DEFAULT ROLE NONE SETTINGS PROFILE 'default' diff --git a/tests/ast_json_fixtures/shapes/3922e4d68e4b1835.json b/tests/ast_json_fixtures/shapes/3922e4d68e4b1835.json new file mode 100644 index 000000000000..f3f171d33cdb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3922e4d68e4b1835.json @@ -0,0 +1,217 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "min", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "wa" + }, + { + "type": "Function", + "name": "min", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "wo" + }, + { + "type": "Function", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "wa" + }, + { + "type": "Function", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "wo" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "p", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "alias": "o", + "name": "mod", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "31" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "wa", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "p" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "o" + }, + "direction": "ASC" + } + ], + "frame_type": "RANGE", + "frame_begin": { + "type": "Unbounded", + "preceding": true + }, + "frame_end": { + "type": "Unbounded" + } + } + }, + { + "type": "WindowListElement", + "name": "wo", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "p" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "o" + }, + "direction": "ASC" + } + ], + "frame_type": "ROWS", + "frame_begin": { + "type": "Unbounded", + "preceding": true + }, + "frame_end": { + "type": "Unbounded" + } + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3922e4d68e4b1835.sql b/tests/ast_json_fixtures/shapes/3922e4d68e4b1835.sql new file mode 100644 index 000000000000..70a81ddccac5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3922e4d68e4b1835.sql @@ -0,0 +1,12 @@ +select + min(number) over wa, min(number) over wo, + max(number) over wa, max(number) over wo +from + (select number, intDiv(number, 3) p, mod(number, 5) o + from numbers(31)) +window + wa as (partition by p order by o + range between unbounded preceding and unbounded following), + wo as (partition by p order by o + rows between unbounded preceding and unbounded following) +settings max_block_size = 2 diff --git a/tests/ast_json_fixtures/shapes/392369eeec30741d.json b/tests/ast_json_fixtures/shapes/392369eeec30741d.json new file mode 100644 index 000000000000..0c832dddf3ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/392369eeec30741d.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "t" + }, + "sync": true + } +} diff --git a/tests/ast_json_fixtures/shapes/392369eeec30741d.sql b/tests/ast_json_fixtures/shapes/392369eeec30741d.sql new file mode 100644 index 000000000000..9c519a0a7470 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/392369eeec30741d.sql @@ -0,0 +1 @@ +DROP TABLE t SYNC diff --git a/tests/ast_json_fixtures/shapes/393f882d823c43f1.json b/tests/ast_json_fixtures/shapes/393f882d823c43f1.json new file mode 100644 index 000000000000..43aafa5e88ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/393f882d823c43f1.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "y", + "value_type": "UInt64", + "value": "2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "distinct_in_order" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/393f882d823c43f1.sql b/tests/ast_json_fixtures/shapes/393f882d823c43f1.sql new file mode 100644 index 000000000000..28b28f028f1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/393f882d823c43f1.sql @@ -0,0 +1 @@ +select distinct a, 1 as x, 2 as y from distinct_in_order order by a diff --git a/tests/ast_json_fixtures/shapes/3963f507ed88241d.json b/tests/ast_json_fixtures/shapes/3963f507ed88241d.json new file mode 100644 index 000000000000..e403d61ce532 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3963f507ed88241d.json @@ -0,0 +1,132 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "alias": "val", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "val" + } + ] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3963f507ed88241d.sql b/tests/ast_json_fixtures/shapes/3963f507ed88241d.sql new file mode 100644 index 000000000000..e33412f4355b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3963f507ed88241d.sql @@ -0,0 +1,5 @@ +SELECT number, number % 2, sum(number) AS val +FROM numbers(10) +GROUP BY CUBE(number, number % 2) +ORDER BY (number, number % 2, val) +SETTINGS group_by_use_nulls=0 diff --git a/tests/ast_json_fixtures/shapes/397a73ba58d7ef0f.json b/tests/ast_json_fixtures/shapes/397a73ba58d7ef0f.json new file mode 100644 index 000000000000..6023786387a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/397a73ba58d7ef0f.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "replace_access": true, + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "all" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/397a73ba58d7ef0f.sql b/tests/ast_json_fixtures/shapes/397a73ba58d7ef0f.sql new file mode 100644 index 000000000000..644ccce89837 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/397a73ba58d7ef0f.sql @@ -0,0 +1 @@ +GRANT SELECT ON all.* TO test_user_01999 WITH REPLACE OPTION diff --git a/tests/ast_json_fixtures/shapes/398925716ea18a7a.json b/tests/ast_json_fixtures/shapes/398925716ea18a7a.json new file mode 100644 index 000000000000..67a3b3fa3f33 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/398925716ea18a7a.json @@ -0,0 +1,137 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + }, + { + "type": "Identifier", + "name": "d.values", + "name_parts": ["d", "values"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "d.values", + "name_parts": ["d", "values"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "a", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "value", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "SEMI", + "using": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "d", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "values", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/398925716ea18a7a.sql b/tests/ast_json_fixtures/shapes/398925716ea18a7a.sql new file mode 100644 index 000000000000..9f843e74298e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/398925716ea18a7a.sql @@ -0,0 +1 @@ +SELECT id, toTypeName(id), value, toTypeName(value), d.values, toTypeName(d.values) FROM ( SELECT 1 AS id, 2 AS value ) a SEMI LEFT JOIN ( SELECT 1 AS id, 3 AS values ) AS d USING id diff --git a/tests/ast_json_fixtures/shapes/39893e381698744d.json b/tests/ast_json_fixtures/shapes/39893e381698744d.json new file mode 100644 index 000000000000..bc6fa2148646 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39893e381698744d.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "replace_granted_roles": true, + "roles": { + "type": "RolesOrUsersSet" + }, + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/39893e381698744d.sql b/tests/ast_json_fixtures/shapes/39893e381698744d.sql new file mode 100644 index 000000000000..9d7b4133b348 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39893e381698744d.sql @@ -0,0 +1 @@ +GRANT NONE TO test_user_01999 WITH REPLACE OPTION diff --git a/tests/ast_json_fixtures/shapes/398a69b23d779ad3.json b/tests/ast_json_fixtures/shapes/398a69b23d779ad3.json new file mode 100644 index 000000000000..5f0ebdc71c29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/398a69b23d779ad3.json @@ -0,0 +1,120 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "alias": "k", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "queryID", + "arguments": [] + }, + { + "type": "Function", + "name": "initialQueryID", + "arguments": [] + } + ] + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "k" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_two_level_threshold": "9", + "max_bytes_before_external_group_by": "10000000000", + "max_bytes_ratio_before_external_group_by": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/398a69b23d779ad3.sql b/tests/ast_json_fixtures/shapes/398a69b23d779ad3.sql new file mode 100644 index 000000000000..bb20d571e70b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/398a69b23d779ad3.sql @@ -0,0 +1 @@ +SELECT count(), toString(number) AS k FROM remote('127.0.0.{1,2}', numbers(10)) where number > ( queryID() = initialQueryID()) GROUP BY GROUPING SETS ((k)) ORDER BY k SETTINGS group_by_two_level_threshold=9, max_bytes_before_external_group_by=10000000000, max_bytes_ratio_before_external_group_by=0 diff --git a/tests/ast_json_fixtures/shapes/39a1c60c84079279.json b/tests/ast_json_fixtures/shapes/39a1c60c84079279.json new file mode 100644 index 000000000000..851d5bbda253 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39a1c60c84079279.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_condition_cache": true + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/39a1c60c84079279.sql b/tests/ast_json_fixtures/shapes/39a1c60c84079279.sql new file mode 100644 index 000000000000..fa8592534ab0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39a1c60c84079279.sql @@ -0,0 +1 @@ +SELECT * FROM tab WHERE b = 10_000 FORMAT Null SETTINGS use_query_condition_cache = true diff --git a/tests/ast_json_fixtures/shapes/39a2b06d67bb420d.json b/tests/ast_json_fixtures/shapes/39a2b06d67bb420d.json new file mode 100644 index 000000000000..a27f25efd023 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39a2b06d67bb420d.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "a", + "name": "avg", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ], + "window_definition": { + "type": "WindowDefinition" + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_window_functions": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/39a2b06d67bb420d.sql b/tests/ast_json_fixtures/shapes/39a2b06d67bb420d.sql new file mode 100644 index 000000000000..eeaf11866e5d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39a2b06d67bb420d.sql @@ -0,0 +1 @@ +WITH avg(a) OVER () AS a SELECT a, id FROM test SETTINGS allow_experimental_window_functions = 1 diff --git a/tests/ast_json_fixtures/shapes/39a3e8b062da043b.json b/tests/ast_json_fixtures/shapes/39a3e8b062da043b.json new file mode 100644 index 000000000000..5d96d9279813 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39a3e8b062da043b.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "d0" + }, + "if_exists": true, + "is_dictionary": true + } +} diff --git a/tests/ast_json_fixtures/shapes/39a3e8b062da043b.sql b/tests/ast_json_fixtures/shapes/39a3e8b062da043b.sql new file mode 100644 index 000000000000..d8c6ce6342c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39a3e8b062da043b.sql @@ -0,0 +1 @@ +DROP DICTIONARY IF EXISTS d0 diff --git a/tests/ast_json_fixtures/shapes/39bb71e5e00f672d.json b/tests/ast_json_fixtures/shapes/39bb71e5e00f672d.json new file mode 100644 index 000000000000..0a3bea86cc2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39bb71e5e00f672d.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u5_01292" + } + ] + }, + "default_roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r2_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/39bb71e5e00f672d.sql b/tests/ast_json_fixtures/shapes/39bb71e5e00f672d.sql new file mode 100644 index 000000000000..4b07663a48ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39bb71e5e00f672d.sql @@ -0,0 +1 @@ +CREATE USER u5_01292 DEFAULT ROLE ALL EXCEPT r2_01292 diff --git a/tests/ast_json_fixtures/shapes/39d680819be30b30.json b/tests/ast_json_fixtures/shapes/39d680819be30b30.json new file mode 100644 index 000000000000..10e9a8d8c33d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39d680819be30b30.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "map_formats" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "m" + }, + { + "type": "Literal", + "value_type": "String", + "value": "k1" + } + ] + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSKV" + } +} diff --git a/tests/ast_json_fixtures/shapes/39d680819be30b30.sql b/tests/ast_json_fixtures/shapes/39d680819be30b30.sql new file mode 100644 index 000000000000..5a5b8eb8761f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39d680819be30b30.sql @@ -0,0 +1 @@ +SELECT * FROM map_formats ORDER BY m['k1'] FORMAT TSKV diff --git a/tests/ast_json_fixtures/shapes/39fb376de9d4de1d.json b/tests/ast_json_fixtures/shapes/39fb376de9d4de1d.json new file mode 100644 index 000000000000..63d367fcd515 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39fb376de9d4de1d.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ], + "format": "JSONCompactEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/39fb376de9d4de1d.sql b/tests/ast_json_fixtures/shapes/39fb376de9d4de1d.sql new file mode 100644 index 000000000000..1ac18b77251f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/39fb376de9d4de1d.sql @@ -0,0 +1 @@ +SELECT * FROM test_table FORMAT JSONCompactEachRow diff --git a/tests/ast_json_fixtures/shapes/3a0513d581a1c189.json b/tests/ast_json_fixtures/shapes/3a0513d581a1c189.json new file mode 100644 index 000000000000..ba8dd100ff9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a0513d581a1c189.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q10_01297"], + "key_type": "CLIENT_KEY" + } +} diff --git a/tests/ast_json_fixtures/shapes/3a0513d581a1c189.sql b/tests/ast_json_fixtures/shapes/3a0513d581a1c189.sql new file mode 100644 index 000000000000..cb09501bc09a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a0513d581a1c189.sql @@ -0,0 +1 @@ +CREATE QUOTA q10_01297 KEYED BY CLIENT_KEY diff --git a/tests/ast_json_fixtures/shapes/3a1614a4f38534aa.json b/tests/ast_json_fixtures/shapes/3a1614a4f38534aa.json new file mode 100644 index 000000000000..ae8d2088c7fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a1614a4f38534aa.json @@ -0,0 +1,273 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "a1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.0001 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "a2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.0001 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "a3", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.0001 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "a4", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.0001 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "a5", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.0001 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "02177_CTE_NEW_ANALYZER" + }, + { + "type": "Identifier", + "name": "a1" + }, + { + "type": "Identifier", + "name": "a2" + }, + { + "type": "Identifier", + "name": "a3" + }, + { + "type": "Identifier", + "name": "a4" + }, + { + "type": "Identifier", + "name": "a5" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/3a1614a4f38534aa.sql b/tests/ast_json_fixtures/shapes/3a1614a4f38534aa.sql new file mode 100644 index 000000000000..53c69531cb40 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a1614a4f38534aa.sql @@ -0,0 +1,9 @@ +WITH + ( SELECT sleep(0.0001) FROM system.one ) as a1, + ( SELECT sleep(0.0001) FROM system.one ) as a2, + ( SELECT sleep(0.0001) FROM system.one ) as a3, + ( SELECT sleep(0.0001) FROM system.one ) as a4, + ( SELECT sleep(0.0001) FROM system.one ) as a5 +SELECT '02177_CTE_NEW_ANALYZER', a1, a2, a3, a4, a5 FROM system.numbers LIMIT 100 + FORMAT Null +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/3a26653d4ada709d.json b/tests/ast_json_fixtures/shapes/3a26653d4ada709d.json new file mode 100644 index 000000000000..2ee68b2b4cfd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a26653d4ada709d.json @@ -0,0 +1,310 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "t", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "String", + "value": "11\u00001111111\u000011111" + }, + { + "value_type": "String", + "value": "1111" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048576" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-2147483648" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-2147483648" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "group_by": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "String", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1023" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483647" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775807" + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483647" + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65535" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + } + ] + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3a26653d4ada709d.sql b/tests/ast_json_fixtures/shapes/3a26653d4ada709d.sql new file mode 100644 index 000000000000..7c0829fa1533 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a26653d4ada709d.sql @@ -0,0 +1,9 @@ +SELECT + materialize([(NULL, '11\01111111\011111', '1111')]) AS t, + (t[1048576]).2, + materialize(-2147483648), + (t[-2147483648]).1 +GROUP BY + materialize([(NULL, '1')]), + '', + (materialize((t[1023]).2), (materialize(''), (t[2147483647]).1, materialize(9223372036854775807)), (materialize(''), materialize(NULL, 2147483647, t[65535], 256)), materialize(NULL)) diff --git a/tests/ast_json_fixtures/shapes/3a4716896a962b4e.json b/tests/ast_json_fixtures/shapes/3a4716896a962b4e.json new file mode 100644 index 000000000000..e17089138578 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a4716896a962b4e.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s2_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "0" + } + ] + }, + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3a4716896a962b4e.sql b/tests/ast_json_fixtures/shapes/3a4716896a962b4e.sql new file mode 100644 index 000000000000..02b33202ff00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a4716896a962b4e.sql @@ -0,0 +1 @@ +CREATE PROFILE s2_01294 SETTINGS readonly=0 TO r1_01294 diff --git a/tests/ast_json_fixtures/shapes/3a6913567ba42ddc.json b/tests/ast_json_fixtures/shapes/3a6913567ba42ddc.json new file mode 100644 index 000000000000..17c82c986c5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a6913567ba42ddc.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u5_01292" + } + ] + }, + "hosts": { + "local_host": true, + "names": ["myhost.com"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3a6913567ba42ddc.sql b/tests/ast_json_fixtures/shapes/3a6913567ba42ddc.sql new file mode 100644 index 000000000000..e28af12206a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a6913567ba42ddc.sql @@ -0,0 +1 @@ +CREATE USER u5_01292 HOST NAME 'myhost.com', LOCAL diff --git a/tests/ast_json_fixtures/shapes/3a72be0a297a5848.json b/tests/ast_json_fixtures/shapes/3a72be0a297a5848.json new file mode 100644 index 000000000000..b8d200ec01ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a72be0a297a5848.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "completions", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "startsWith", + "arguments": [ + { + "type": "Identifier", + "name": "word" + }, + { + "type": "Literal", + "value_type": "String", + "value": "0003566" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "word" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/3a72be0a297a5848.sql b/tests/ast_json_fixtures/shapes/3a72be0a297a5848.sql new file mode 100644 index 000000000000..459d2a0a17c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a72be0a297a5848.sql @@ -0,0 +1,6 @@ +SELECT * +FROM system.completions +WHERE startsWith(word, '0003566') +ORDER BY word +LIMIT 5 +FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/3a9a645e2c735954.json b/tests/ast_json_fixtures/shapes/3a9a645e2c735954.json new file mode 100644 index 000000000000..4602e8e564b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a9a645e2c735954.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "uk_price_paid" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toYear", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2023" + } + ] + }, + "qualify": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "price" + }, + { + "type": "Function", + "name": "quantile", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "price" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.9 + } + ], + "window_definition": { + "type": "WindowDefinition" + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3a9a645e2c735954.sql b/tests/ast_json_fixtures/shapes/3a9a645e2c735954.sql new file mode 100644 index 000000000000..5dd7a61e6ecb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3a9a645e2c735954.sql @@ -0,0 +1 @@ +SELECT count() FROM uk_price_paid WHERE toYear(date) = 2023 QUALIFY price > (quantile(0.9)(price) OVER ()) diff --git a/tests/ast_json_fixtures/shapes/3ab3e130f99aa5b8.json b/tests/ast_json_fixtures/shapes/3ab3e130f99aa5b8.json new file mode 100644 index 000000000000..bf91560a44f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ab3e130f99aa5b8.json @@ -0,0 +1,132 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/3ab3e130f99aa5b8.sql b/tests/ast_json_fixtures/shapes/3ab3e130f99aa5b8.sql new file mode 100644 index 000000000000..dff566328495 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ab3e130f99aa5b8.sql @@ -0,0 +1 @@ +SELECT ignore(x), count() FROM (SELECT number AS x FROM system.numbers LIMIT 1000 UNION ALL SELECT number AS x FROM system.numbers LIMIT 1000) GROUP BY x WITH TOTALS ORDER BY x LIMIT 10 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/3abdaa9422711412.json b/tests/ast_json_fixtures/shapes/3abdaa9422711412.json new file mode 100644 index 000000000000..2f6e257d1b0c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3abdaa9422711412.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "format": "Values", + "settings": { + "type": "Settings", + "changes": { + "bool_true_representation": "да" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3abdaa9422711412.sql b/tests/ast_json_fixtures/shapes/3abdaa9422711412.sql new file mode 100644 index 000000000000..285800e2eef9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3abdaa9422711412.sql @@ -0,0 +1 @@ +insert into t settings bool_true_representation='да' values ('да') diff --git a/tests/ast_json_fixtures/shapes/3ac5a3e5e7c742c5.json b/tests/ast_json_fixtures/shapes/3ac5a3e5e7c742c5.json new file mode 100644 index 000000000000..e274ff4fc3ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ac5a3e5e7c742c5.json @@ -0,0 +1,127 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_optimize_predicate_expression": "0", + "force_grouping_standard_compatibility": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3ac5a3e5e7c742c5.sql b/tests/ast_json_fixtures/shapes/3ac5a3e5e7c742c5.sql new file mode 100644 index 000000000000..b9238de395d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ac5a3e5e7c742c5.sql @@ -0,0 +1,11 @@ +SELECT + number +FROM numbers(10) +GROUP BY + GROUPING SETS ( + (number), + (number % 2) + ) +HAVING grouping(number, number % 2) = 1 +ORDER BY number +SETTINGS enable_optimize_predicate_expression = 0, force_grouping_standard_compatibility=0 diff --git a/tests/ast_json_fixtures/shapes/3ac794926079c175.json b/tests/ast_json_fixtures/shapes/3ac794926079c175.json new file mode 100644 index 000000000000..85282a75ed16 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ac794926079c175.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_clone_as": true, + "table": { + "type": "Identifier", + "name": "clone_as_foo_replicated_merge_tree" + }, + "as_table": "foo_replicated_merge_tree" + } +} diff --git a/tests/ast_json_fixtures/shapes/3ac794926079c175.sql b/tests/ast_json_fixtures/shapes/3ac794926079c175.sql new file mode 100644 index 000000000000..40a6e527e208 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ac794926079c175.sql @@ -0,0 +1 @@ +CREATE TABLE clone_as_foo_replicated_merge_tree CLONE AS foo_replicated_merge_tree diff --git a/tests/ast_json_fixtures/shapes/3acb9d0cabe2d96d.json b/tests/ast_json_fixtures/shapes/3acb9d0cabe2d96d.json new file mode 100644 index 000000000000..87ed392c5c97 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3acb9d0cabe2d96d.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "settings": { + "type": "Settings", + "changes": { + "validate_mutation_query": "0" + } + }, + "predicate": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "foo" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "bar" + } + } + } + ] + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3acb9d0cabe2d96d.sql b/tests/ast_json_fixtures/shapes/3acb9d0cabe2d96d.sql new file mode 100644 index 000000000000..196ef199cef4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3acb9d0cabe2d96d.sql @@ -0,0 +1 @@ +DELETE FROM t WHERE x IN (SELECT foo FROM bar) SETTINGS validate_mutation_query = 0 diff --git a/tests/ast_json_fixtures/shapes/3af3d44564fba30c.json b/tests/ast_json_fixtures/shapes/3af3d44564fba30c.json new file mode 100644 index 000000000000..740e29388d3a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3af3d44564fba30c.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "alias": "res", + "name": "toDateOrDefault", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "res" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3af3d44564fba30c.sql b/tests/ast_json_fixtures/shapes/3af3d44564fba30c.sql new file mode 100644 index 000000000000..95d1d7a98852 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3af3d44564fba30c.sql @@ -0,0 +1 @@ +select distinct toDateOrDefault(d) as res from t order by res diff --git a/tests/ast_json_fixtures/shapes/3af90e18ca3f0e81.json b/tests/ast_json_fixtures/shapes/3af90e18ca3f0e81.json new file mode 100644 index 000000000000..a8a315c21aad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3af90e18ca3f0e81.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "query_thread_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3af90e18ca3f0e81.sql b/tests/ast_json_fixtures/shapes/3af90e18ca3f0e81.sql new file mode 100644 index 000000000000..78d1003f876a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3af90e18ca3f0e81.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS query_thread_log diff --git a/tests/ast_json_fixtures/shapes/3afafde645d63337.json b/tests/ast_json_fixtures/shapes/3afafde645d63337.json new file mode 100644 index 000000000000..e66113275ab8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3afafde645d63337.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "alter": true, + "names": ["s2_01294", "s3_01294", "s4_01294"], + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3afafde645d63337.sql b/tests/ast_json_fixtures/shapes/3afafde645d63337.sql new file mode 100644 index 000000000000..0e2bb59919c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3afafde645d63337.sql @@ -0,0 +1 @@ +ALTER PROFILE s2_01294, s3_01294, s4_01294 TO r1_01294 diff --git a/tests/ast_json_fixtures/shapes/3b0402abd74d5785.json b/tests/ast_json_fixtures/shapes/3b0402abd74d5785.json new file mode 100644 index 000000000000..36d0d274f9e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b0402abd74d5785.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "zero" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "zeros", + "arguments": [] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3b0402abd74d5785.sql b/tests/ast_json_fixtures/shapes/3b0402abd74d5785.sql new file mode 100644 index 000000000000..bfdd8555a1ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b0402abd74d5785.sql @@ -0,0 +1 @@ +SELECT zero FROM zeros() LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/3b089f03879477a8.json b/tests/ast_json_fixtures/shapes/3b089f03879477a8.json new file mode 100644 index 000000000000..a1e667308aeb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b089f03879477a8.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC", + "nulls_first": false + } + ], + "frame_type": "ROWS", + "frame_begin": { + "type": "Unbounded", + "preceding": true + }, + "frame_end": { + "type": "Current" + } + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "2" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/3b089f03879477a8.sql b/tests/ast_json_fixtures/shapes/3b089f03879477a8.sql new file mode 100644 index 000000000000..929fd16c45bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b089f03879477a8.sql @@ -0,0 +1 @@ +SELECT number, max(number) OVER (PARTITION BY intDiv(number, 7) ORDER BY number ASC NULLS LAST ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM numbers(1024) SETTINGS max_block_size = 2 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/3b162e190abef908.json b/tests/ast_json_fixtures/shapes/3b162e190abef908.json new file mode 100644 index 000000000000..8907fd82d0b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b162e190abef908.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "hostname" + }, + { + "type": "Identifier", + "name": "ip_address" + }, + { + "type": "Identifier", + "name": "ip_family" + }, + { + "type": "Identifier", + "name": "cached_at" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dns_cache", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ], + "format": "TSVWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/3b162e190abef908.sql b/tests/ast_json_fixtures/shapes/3b162e190abef908.sql new file mode 100644 index 000000000000..8a31bd451be3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b162e190abef908.sql @@ -0,0 +1,3 @@ +SELECT hostname, ip_address, ip_family, cached_at FROM system.dns_cache +LIMIT 0 +FORMAT TSVWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/3b2218a2e57c66db.json b/tests/ast_json_fixtures/shapes/3b2218a2e57c66db.json new file mode 100644 index 000000000000..8e81507fc906 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b2218a2e57c66db.json @@ -0,0 +1,150 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "block_0", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "loans" + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "block_1", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "loan_number", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "loan_number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "block_0" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "security_id" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "loan_number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "block_1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "loan_number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "loan_number" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "prefer_column_name_to_alias": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3b2218a2e57c66db.sql b/tests/ast_json_fixtures/shapes/3b2218a2e57c66db.sql new file mode 100644 index 000000000000..66c52cefc9a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b2218a2e57c66db.sql @@ -0,0 +1,7 @@ +with block_0 as ( + select * from loans +), +block_1 as ( + select sum(loan_number) as loan_number from block_0 group by security_id +) +select loan_number from block_1 where loan_number > 3 order by loan_number settings prefer_column_name_to_alias = 1 diff --git a/tests/ast_json_fixtures/shapes/3b335eeba498e6c8.json b/tests/ast_json_fixtures/shapes/3b335eeba498e6c8.json new file mode 100644 index 000000000000..5557614b2412 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b335eeba498e6c8.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "map_formats" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "m" + }, + { + "type": "Literal", + "value_type": "String", + "value": "k1" + } + ] + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/3b335eeba498e6c8.sql b/tests/ast_json_fixtures/shapes/3b335eeba498e6c8.sql new file mode 100644 index 000000000000..f44e3ea36192 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b335eeba498e6c8.sql @@ -0,0 +1 @@ +SELECT * FROM map_formats ORDER BY m['k1'] FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/3b427c360526f054.json b/tests/ast_json_fixtures/shapes/3b427c360526f054.json new file mode 100644 index 000000000000..fdc0a66e66d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b427c360526f054.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + } + } + } + ] + } + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/3b427c360526f054.sql b/tests/ast_json_fixtures/shapes/3b427c360526f054.sql new file mode 100644 index 000000000000..16f708681498 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b427c360526f054.sql @@ -0,0 +1 @@ +SELECT sleep(0.01), number FROM numbers(11) FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/3b51e9a7e3ecfa89.json b/tests/ast_json_fixtures/shapes/3b51e9a7e3ecfa89.json new file mode 100644 index 000000000000..30eec14f4381 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b51e9a7e3ecfa89.json @@ -0,0 +1,121 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "test1", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "alias": "z", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test1" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3b51e9a7e3ecfa89.sql b/tests/ast_json_fixtures/shapes/3b51e9a7e3ecfa89.sql new file mode 100644 index 000000000000..aa94e186a4b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b51e9a7e3ecfa89.sql @@ -0,0 +1,2 @@ +WITH test1 AS (SELECT number-1 as n FROM numbers(42)) +SELECT max(n+1)+1 z FROM test1 diff --git a/tests/ast_json_fixtures/shapes/3b5c6fc09c6dafc5.json b/tests/ast_json_fixtures/shapes/3b5c6fc09c6dafc5.json new file mode 100644 index 000000000000..9eeb73f25793 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b5c6fc09c6dafc5.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropWorkloadQuery", + "workload_name": "production", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/3b5c6fc09c6dafc5.sql b/tests/ast_json_fixtures/shapes/3b5c6fc09c6dafc5.sql new file mode 100644 index 000000000000..13d07b4980e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b5c6fc09c6dafc5.sql @@ -0,0 +1 @@ +DROP WORKLOAD IF EXISTS production diff --git a/tests/ast_json_fixtures/shapes/3b5ca15ea1f95106.json b/tests/ast_json_fixtures/shapes/3b5ca15ea1f95106.json new file mode 100644 index 000000000000..2f9494e2804e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b5ca15ea1f95106.json @@ -0,0 +1,111 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + } + ] + } + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3b5ca15ea1f95106.sql b/tests/ast_json_fixtures/shapes/3b5ca15ea1f95106.sql new file mode 100644 index 000000000000..ba4c9185f83f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b5ca15ea1f95106.sql @@ -0,0 +1 @@ +SELECT number from numbers(10) order by number limit (select sum(number), count() from numbers(3)).1 diff --git a/tests/ast_json_fixtures/shapes/3b65832efccd3fa3.json b/tests/ast_json_fixtures/shapes/3b65832efccd3fa3.json new file mode 100644 index 000000000000..8c5c68924227 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b65832efccd3fa3.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN AST", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "optimize": "0" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3b65832efccd3fa3.sql b/tests/ast_json_fixtures/shapes/3b65832efccd3fa3.sql new file mode 100644 index 000000000000..1057858dfc89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b65832efccd3fa3.sql @@ -0,0 +1 @@ +EXPLAIN AST optimize=0 SELECT * FROM numbers(0) diff --git a/tests/ast_json_fixtures/shapes/3b79881ab3dbf0a7.json b/tests/ast_json_fixtures/shapes/3b79881ab3dbf0a7.json new file mode 100644 index 000000000000..be9f96c85da0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b79881ab3dbf0a7.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_DISTINCT", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "uuid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "uuid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3b79881ab3dbf0a7.sql b/tests/ast_json_fixtures/shapes/3b79881ab3dbf0a7.sql new file mode 100644 index 000000000000..06360d782d66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b79881ab3dbf0a7.sql @@ -0,0 +1 @@ +select uuid from test union distinct select uuid from test diff --git a/tests/ast_json_fixtures/shapes/3b826d4f57ede100.json b/tests/ast_json_fixtures/shapes/3b826d4f57ede100.json new file mode 100644 index 000000000000..00256dbf8714 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b826d4f57ede100.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "range_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "CountryID", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "CountryKey", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "StartDate", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "EndDate", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "Tax", + "data_type": { + "type": "DataType", + "name": "Float64" + }, + "default_value": { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "CountryID" + }, + { + "type": "Identifier", + "name": "CountryKey" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "date_table" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 1, + "max_sec": 1000 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "complex_key_range_hashed", + "parameters": [] + }, + "range": { + "type": "DictionaryRange", + "min_attr_name": "StartDate", + "max_attr_name": "EndDate" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3b826d4f57ede100.sql b/tests/ast_json_fixtures/shapes/3b826d4f57ede100.sql new file mode 100644 index 000000000000..cf9f08448d81 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b826d4f57ede100.sql @@ -0,0 +1,13 @@ +CREATE DICTIONARY range_dictionary +( + CountryID UInt64, + CountryKey String, + StartDate Date, + EndDate Date, + Tax Float64 DEFAULT 0.2 +) +PRIMARY KEY CountryID, CountryKey +SOURCE(CLICKHOUSE(TABLE 'date_table')) +LIFETIME(MIN 1 MAX 1000) +LAYOUT(COMPLEX_KEY_RANGE_HASHED()) +RANGE(MIN StartDate MAX EndDate) diff --git a/tests/ast_json_fixtures/shapes/3b9367165363fb36.json b/tests/ast_json_fixtures/shapes/3b9367165363fb36.json new file mode 100644 index 000000000000..fcc982297818 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b9367165363fb36.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "dynamicType", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Identifier", + "name": "d.Int64", + "name_parts": ["d", "Int64"] + }, + { + "type": "Identifier", + "name": "d.String", + "name_parts": ["d", "String"] + }, + { + "type": "Identifier", + "name": "d.Date", + "name_parts": ["d", "Date"] + }, + { + "type": "Identifier", + "name": "d.Float64", + "name_parts": ["d", "Float64"] + }, + { + "type": "Identifier", + "name": "d.DateTime", + "name_parts": ["d", "DateTime"] + }, + { + "type": "Identifier", + "name": "d.Array(Int64)", + "name_parts": ["d", "Array(Int64)"] + }, + { + "type": "Identifier", + "name": "d.Array(String)", + "name_parts": ["d", "Array(String)"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_rapid_schema" + } + } + } + ] + } + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/3b9367165363fb36.sql b/tests/ast_json_fixtures/shapes/3b9367165363fb36.sql new file mode 100644 index 000000000000..bada8510ed34 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3b9367165363fb36.sql @@ -0,0 +1,2 @@ +SELECT d, dynamicType(d), d.Int64, d.String, d.Date, d.Float64, d.DateTime, d.`Array(Int64)`, d.`Array(String)` +FROM test_rapid_schema FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/3ba05a4453b182a8.json b/tests/ast_json_fixtures/shapes/3ba05a4453b182a8.json new file mode 100644 index 000000000000..1da35f825569 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ba05a4453b182a8.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3ba05a4453b182a8.sql b/tests/ast_json_fixtures/shapes/3ba05a4453b182a8.sql new file mode 100644 index 000000000000..9d2a7ca8a795 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ba05a4453b182a8.sql @@ -0,0 +1 @@ +SELECT * diff --git a/tests/ast_json_fixtures/shapes/3bc59fb2c61054b3.json b/tests/ast_json_fixtures/shapes/3bc59fb2c61054b3.json new file mode 100644 index 000000000000..25a8bbb02f0c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3bc59fb2c61054b3.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "inf" + }, + { + "value_type": "String", + "value": "Inf" + }, + { + "value_type": "String", + "value": "INF" + }, + { + "value_type": "String", + "value": "infinity" + }, + { + "value_type": "String", + "value": "Infinity" + } + ] + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3bc59fb2c61054b3.sql b/tests/ast_json_fixtures/shapes/3bc59fb2c61054b3.sql new file mode 100644 index 000000000000..76264b31fcb0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3bc59fb2c61054b3.sql @@ -0,0 +1 @@ +SELECT DISTINCT toFloat64(arrayJoin(['inf', 'Inf', 'INF', 'infinity', 'Infinity'])) diff --git a/tests/ast_json_fixtures/shapes/3bd47ed927f3ae17.json b/tests/ast_json_fixtures/shapes/3bd47ed927f3ae17.json new file mode 100644 index 000000000000..0e125cab9453 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3bd47ed927f3ae17.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + }, + "direction": "ASC", + "with_fill": true + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3bd47ed927f3ae17.sql b/tests/ast_json_fixtures/shapes/3bd47ed927f3ae17.sql new file mode 100644 index 000000000000..dc7c40884def --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3bd47ed927f3ae17.sql @@ -0,0 +1 @@ +SELECT 1 FROM t0 ORDER BY t0.c0 WITH FILL diff --git a/tests/ast_json_fixtures/shapes/3be1e50f641f3c07.json b/tests/ast_json_fixtures/shapes/3be1e50f641f3c07.json new file mode 100644 index 000000000000..03b80ea9a79e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3be1e50f641f3c07.json @@ -0,0 +1,127 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "k" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "n", + "name": "number" + }, + { + "type": "Function", + "alias": "k", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": " " + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3be1e50f641f3c07.sql b/tests/ast_json_fixtures/shapes/3be1e50f641f3c07.sql new file mode 100644 index 000000000000..94e9ba442317 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3be1e50f641f3c07.sql @@ -0,0 +1 @@ +SELECT n, k FROM (SELECT number AS n, toFixedString(materialize(' '), 3) AS k FROM system.numbers LIMIT 100000) GROUP BY n, k ORDER BY n DESC, k LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/3c1fab73bbe54a59.json b/tests/ast_json_fixtures/shapes/3c1fab73bbe54a59.json new file mode 100644 index 000000000000..2c0f7ce911d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3c1fab73bbe54a59.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dst" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "as_table_function": { + "type": "Function", + "name": "url", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "http:\/\/127.0.0.1\/" + }, + { + "type": "Identifier", + "name": "JSONEachRow" + }, + { + "type": "Literal", + "value_type": "String", + "value": "x int" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3c1fab73bbe54a59.sql b/tests/ast_json_fixtures/shapes/3c1fab73bbe54a59.sql new file mode 100644 index 000000000000..231d2e34a248 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3c1fab73bbe54a59.sql @@ -0,0 +1 @@ +CREATE TABLE dst (x int) AS url('http://127.0.0.1/', JSONEachRow, 'x int') diff --git a/tests/ast_json_fixtures/shapes/3c2682cef37a063f.json b/tests/ast_json_fixtures/shapes/3c2682cef37a063f.json new file mode 100644 index 000000000000..5ce365f622f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3c2682cef37a063f.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_alter_attach_01901D" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "2020-01-01" + } + }, + "replace": false, + "from_table": "test_alter_attach_01901S" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3c2682cef37a063f.sql b/tests/ast_json_fixtures/shapes/3c2682cef37a063f.sql new file mode 100644 index 000000000000..f5dba14c6a00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3c2682cef37a063f.sql @@ -0,0 +1 @@ +ALTER TABLE test_alter_attach_01901D ATTACH PARTITION '2020-01-01' FROM test_alter_attach_01901S diff --git a/tests/ast_json_fixtures/shapes/3c5f53d23ad5c29a.json b/tests/ast_json_fixtures/shapes/3c5f53d23ad5c29a.json new file mode 100644 index 000000000000..10e039daf797 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3c5f53d23ad5c29a.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "alter": true, + "names": ["s2_01294"], + "new_name": "s2_01294_renamed" + } +} diff --git a/tests/ast_json_fixtures/shapes/3c5f53d23ad5c29a.sql b/tests/ast_json_fixtures/shapes/3c5f53d23ad5c29a.sql new file mode 100644 index 000000000000..31ea7f9394f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3c5f53d23ad5c29a.sql @@ -0,0 +1 @@ +ALTER SETTINGS PROFILE s2_01294 RENAME TO 's2_01294_renamed' diff --git a/tests/ast_json_fixtures/shapes/3c6e1175f987b17e.json b/tests/ast_json_fixtures/shapes/3c6e1175f987b17e.json new file mode 100644 index 000000000000..b0958ec71615 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3c6e1175f987b17e.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "eligible_test", + "to_table": "eligible_test2" + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": true + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3c6e1175f987b17e.sql b/tests/ast_json_fixtures/shapes/3c6e1175f987b17e.sql new file mode 100644 index 000000000000..8c264f7f1062 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3c6e1175f987b17e.sql @@ -0,0 +1 @@ +RENAME TABLE eligible_test TO eligible_test2 SETTINGS use_query_cache = true diff --git a/tests/ast_json_fixtures/shapes/3c82f335bba82ad6.json b/tests/ast_json_fixtures/shapes/3c82f335bba82ad6.json new file mode 100644 index 000000000000..347f856c082e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3c82f335bba82ad6.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SetRoleQuery", + "kind": "SET_DEFAULT_ROLE", + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01292", "r2_01292"] + }, + "to_users": { + "type": "RolesOrUsersSet", + "names": ["u2_01292", "u3_01292", "u4_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3c82f335bba82ad6.sql b/tests/ast_json_fixtures/shapes/3c82f335bba82ad6.sql new file mode 100644 index 000000000000..b5fb93ce213a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3c82f335bba82ad6.sql @@ -0,0 +1 @@ +SET DEFAULT ROLE r1_01292, r2_01292 TO u2_01292, u3_01292, u4_01292 diff --git a/tests/ast_json_fixtures/shapes/3cb3160e4f605051.json b/tests/ast_json_fixtures/shapes/3cb3160e4f605051.json new file mode 100644 index 000000000000..fe91e0532c0c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3cb3160e4f605051.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "alias": "res", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "t" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "res" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3cb3160e4f605051.sql b/tests/ast_json_fixtures/shapes/3cb3160e4f605051.sql new file mode 100644 index 000000000000..772402c40e9a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3cb3160e4f605051.sql @@ -0,0 +1 @@ +SELECT DISTINCT NULL, if(number > 0, 't', '') AS res FROM numbers(1) ORDER BY res diff --git a/tests/ast_json_fixtures/shapes/3cbfd6b699ff1a4f.json b/tests/ast_json_fixtures/shapes/3cbfd6b699ff1a4f.json new file mode 100644 index 000000000000..842a66549b49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3cbfd6b699ff1a4f.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Identifier", + "name": "f" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "bool_test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/3cbfd6b699ff1a4f.sql b/tests/ast_json_fixtures/shapes/3cbfd6b699ff1a4f.sql new file mode 100644 index 000000000000..039e72c22699 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3cbfd6b699ff1a4f.sql @@ -0,0 +1 @@ +SELECT value,f FROM bool_test order by value FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/3cc2d075fb57174c.json b/tests/ast_json_fixtures/shapes/3cc2d075fb57174c.json new file mode 100644 index 000000000000..1e7a067c92df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3cc2d075fb57174c.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "URL" + }, + { + "type": "Function", + "alias": "c", + "name": "COUNT", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "URL" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "query_34" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/3cc2d075fb57174c.sql b/tests/ast_json_fixtures/shapes/3cc2d075fb57174c.sql new file mode 100644 index 000000000000..2b9abcc3d2ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3cc2d075fb57174c.sql @@ -0,0 +1 @@ +SELECT 1, URL, COUNT(*) AS c FROM test.hits GROUP BY 1, URL ORDER BY c DESC LIMIT 10 FORMAT Null SETTINGS log_comment='query_34' diff --git a/tests/ast_json_fixtures/shapes/3ccfb0db4bf82069.json b/tests/ast_json_fixtures/shapes/3ccfb0db4bf82069.json new file mode 100644 index 000000000000..048133212d43 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ccfb0db4bf82069.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "UserID" + }, + { + "type": "Function", + "alias": "m", + "name": "toMinute", + "arguments": [ + { + "type": "Identifier", + "name": "EventTime" + } + ] + }, + { + "type": "Function", + "alias": "u", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "SearchPhrase" + } + ] + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits_s3", + "database": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "UserID" + }, + { + "type": "Identifier", + "name": "m" + }, + { + "type": "Identifier", + "name": "SearchPhrase" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "UserID" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/3ccfb0db4bf82069.sql b/tests/ast_json_fixtures/shapes/3ccfb0db4bf82069.sql new file mode 100644 index 000000000000..a6800fdde77a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ccfb0db4bf82069.sql @@ -0,0 +1 @@ +SELECT UserID, toMinute(EventTime) AS m, uniq(SearchPhrase) as u, count() as c FROM test.hits_s3 GROUP BY UserID, m, SearchPhrase ORDER BY UserID DESC LIMIT 10 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/3ceefe0cea2a5dad.json b/tests/ast_json_fixtures/shapes/3ceefe0cea2a5dad.json new file mode 100644 index 000000000000..aa1139808026 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ceefe0cea2a5dad.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH DISTRIBUTED", + "database": { + "type": "Identifier", + "name": "db_01294" + }, + "table": { + "type": "Identifier", + "name": "dist_01294" + }, + "cluster": "test_shard_localhost" + } +} diff --git a/tests/ast_json_fixtures/shapes/3ceefe0cea2a5dad.sql b/tests/ast_json_fixtures/shapes/3ceefe0cea2a5dad.sql new file mode 100644 index 000000000000..d48d2c668e5e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ceefe0cea2a5dad.sql @@ -0,0 +1 @@ +system flush distributed on cluster test_shard_localhost db_01294.dist_01294 diff --git a/tests/ast_json_fixtures/shapes/3cfa78f52eccee2e.json b/tests/ast_json_fixtures/shapes/3cfa78f52eccee2e.json new file mode 100644 index 000000000000..0dc718211a7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3cfa78f52eccee2e.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "table": { + "type": "Identifier", + "name": "primary_key_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "v1", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "v2", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3cfa78f52eccee2e.sql b/tests/ast_json_fixtures/shapes/3cfa78f52eccee2e.sql new file mode 100644 index 000000000000..b0a1d3f609fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3cfa78f52eccee2e.sql @@ -0,0 +1 @@ +ATTACH TABLE primary_key_test(v1 Int32, v2 Int32) ENGINE=ReplacingMergeTree ORDER BY (v1, v2) PRIMARY KEY(v1, v2) diff --git a/tests/ast_json_fixtures/shapes/3cfce5ed823337a0.json b/tests/ast_json_fixtures/shapes/3cfce5ed823337a0.json new file mode 100644 index 000000000000..76491656dd00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3cfce5ed823337a0.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "hello", + "name": "number" + }, + { + "type": "Function", + "alias": "world", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Identifier", + "name": "world" + } + ] + }, + { + "type": "Function", + "alias": "sometimes_nulls", + "name": "nullIf", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "5" + } + } + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/3cfce5ed823337a0.sql b/tests/ast_json_fixtures/shapes/3cfce5ed823337a0.sql new file mode 100644 index 000000000000..b086df80a961 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3cfce5ed823337a0.sql @@ -0,0 +1 @@ +SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 10 SETTINGS max_block_size = 5 FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/3d09608260ac263b.json b/tests/ast_json_fixtures/shapes/3d09608260ac263b.json new file mode 100644 index 000000000000..1179486b0e08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3d09608260ac263b.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "val" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03408_memory" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "val" + } + ], + "having": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "val" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "exact_rows_before_limit": "1" + } + }, + "format": "JsonCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/3d09608260ac263b.sql b/tests/ast_json_fixtures/shapes/3d09608260ac263b.sql new file mode 100644 index 000000000000..fa8277d8f93c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3d09608260ac263b.sql @@ -0,0 +1,2 @@ +SELECT id, val FROM 03408_memory GROUP BY id, val HAVING id < 7 ORDER BY id, val DESC LIMIT 1 BY id LIMIT 3 +FORMAT JsonCompact SETTINGS exact_rows_before_limit=1 diff --git a/tests/ast_json_fixtures/shapes/3d499095917583a9.json b/tests/ast_json_fixtures/shapes/3d499095917583a9.json new file mode 100644 index 000000000000..21168a47347e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3d499095917583a9.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "one", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.dummy", + "name_parts": ["t1", "dummy"] + }, + { + "type": "Identifier", + "name": "t2.dummy", + "name_parts": ["t2", "dummy"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "one", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.dummy", + "name_parts": ["t2", "dummy"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ], + "format": "TabSeparated" + } +} diff --git a/tests/ast_json_fixtures/shapes/3d499095917583a9.sql b/tests/ast_json_fixtures/shapes/3d499095917583a9.sql new file mode 100644 index 000000000000..d996c982a2ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3d499095917583a9.sql @@ -0,0 +1,5 @@ +select * from system.one t1 +join system.one t2 +on t1.dummy = t2.dummy +where t2.dummy > 0 +FORMAT TabSeparated diff --git a/tests/ast_json_fixtures/shapes/3d60874f2c1c1f5a.json b/tests/ast_json_fixtures/shapes/3d60874f2c1c1f5a.json new file mode 100644 index 000000000000..5fc3ca5d1905 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3d60874f2c1c1f5a.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "03604_test" + }, + "assignments": [ + { + "type": "Assignment", + "column": "c0", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ], + "predicate": { + "type": "Literal", + "value_type": "Bool", + "value": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3d60874f2c1c1f5a.sql b/tests/ast_json_fixtures/shapes/3d60874f2c1c1f5a.sql new file mode 100644 index 000000000000..f51a16f6b2d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3d60874f2c1c1f5a.sql @@ -0,0 +1 @@ +UPDATE `03604_test` SET c0 = 3 WHERE TRUE diff --git a/tests/ast_json_fixtures/shapes/3d8ef82a24e4d37c.json b/tests/ast_json_fixtures/shapes/3d8ef82a24e4d37c.json new file mode 100644 index 000000000000..ffc969ae3857 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3d8ef82a24e4d37c.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "tab2" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "EXCEPT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + } + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + } + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3d8ef82a24e4d37c.sql b/tests/ast_json_fixtures/shapes/3d8ef82a24e4d37c.sql new file mode 100644 index 000000000000..a167cfbcef95 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3d8ef82a24e4d37c.sql @@ -0,0 +1 @@ +INSERT INTO tab2 SELECT * FROM tab EXCEPT SELECT * FROM tab diff --git a/tests/ast_json_fixtures/shapes/3dabcb234fb83188.json b/tests/ast_json_fixtures/shapes/3dabcb234fb83188.json new file mode 100644 index 000000000000..65c711bae932 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3dabcb234fb83188.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "if_exists": true, + "names": ["r1_01292", "r2_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/3dabcb234fb83188.sql b/tests/ast_json_fixtures/shapes/3dabcb234fb83188.sql new file mode 100644 index 000000000000..301bf241ba8d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3dabcb234fb83188.sql @@ -0,0 +1 @@ +DROP ROLE IF EXISTS r1_01292, r2_01292 diff --git a/tests/ast_json_fixtures/shapes/3df4603fb0296ab0.json b/tests/ast_json_fixtures/shapes/3df4603fb0296ab0.json new file mode 100644 index 000000000000..a2238b54b7ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3df4603fb0296ab0.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Float64", + "value": null + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC", + "with_fill": true + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3df4603fb0296ab0.sql b/tests/ast_json_fixtures/shapes/3df4603fb0296ab0.sql new file mode 100644 index 000000000000..63c74f87ccb7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3df4603fb0296ab0.sql @@ -0,0 +1 @@ +SELECT nan ORDER BY 1 WITH FILL diff --git a/tests/ast_json_fixtures/shapes/3e117b483e1588ad.json b/tests/ast_json_fixtures/shapes/3e117b483e1588ad.json new file mode 100644 index 000000000000..ab0142fff760 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e117b483e1588ad.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Boolean" + } + ] + }, + { + "type": "Function", + "name": "now", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Boolean" + } + ] + }, + { + "type": "Function", + "name": "now", + "arguments": [] + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/3e117b483e1588ad.sql b/tests/ast_json_fixtures/shapes/3e117b483e1588ad.sql new file mode 100644 index 000000000000..ef6e4087d0f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e117b483e1588ad.sql @@ -0,0 +1 @@ +SELECT isNull(number)::Boolean, now() FROM numbers(2) GROUP BY isNull(number)::Boolean, now() FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/3e2ccc48d3f20e64.json b/tests/ast_json_fixtures/shapes/3e2ccc48d3f20e64.json new file mode 100644 index 000000000000..d8a0aac8aa39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e2ccc48d3f20e64.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "visits_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "visits" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "visits" + } +} diff --git a/tests/ast_json_fixtures/shapes/3e2ccc48d3f20e64.sql b/tests/ast_json_fixtures/shapes/3e2ccc48d3f20e64.sql new file mode 100644 index 000000000000..64375d5430a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e2ccc48d3f20e64.sql @@ -0,0 +1 @@ +CREATE TABLE visits_dist AS visits ENGINE Distributed(test_cluster_two_shards_localhost, currentDatabase(), 'visits', rand()) diff --git a/tests/ast_json_fixtures/shapes/3e35360ad46ba022.json b/tests/ast_json_fixtures/shapes/3e35360ad46ba022.json new file mode 100644 index 000000000000..16a5d705f71d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e35360ad46ba022.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropWorkloadQuery", + "workload_name": "development" + } +} diff --git a/tests/ast_json_fixtures/shapes/3e35360ad46ba022.sql b/tests/ast_json_fixtures/shapes/3e35360ad46ba022.sql new file mode 100644 index 000000000000..a577d41bc5b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e35360ad46ba022.sql @@ -0,0 +1 @@ +DROP WORKLOAD development diff --git a/tests/ast_json_fixtures/shapes/3e4b6efd091fa935.json b/tests/ast_json_fixtures/shapes/3e4b6efd091fa935.json new file mode 100644 index 000000000000..64cbe21f706e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e4b6efd091fa935.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "Null", + "value": null + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "x" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3e4b6efd091fa935.sql b/tests/ast_json_fixtures/shapes/3e4b6efd091fa935.sql new file mode 100644 index 000000000000..ba37dbd272fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e4b6efd091fa935.sql @@ -0,0 +1 @@ +SELECT x FROM (SELECT NULL AS x) WHERE x diff --git a/tests/ast_json_fixtures/shapes/3e51c9bdbe22fbc3.json b/tests/ast_json_fixtures/shapes/3e51c9bdbe22fbc3.json new file mode 100644 index 000000000000..96372e1563a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e51c9bdbe22fbc3.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t_detach_attach_patches_dst" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/zookeeper\/{database}\/t_lwu_on_fly_dst\/" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + "partition_by": { + "type": "Identifier", + "name": "id" + }, + "order_by": { + "type": "Identifier", + "name": "a" + }, + "settings": { + "type": "Settings", + "changes": { + "enable_block_number_column": "1", + "enable_block_offset_column": "1" + } + } + }, + "as_table": "t_detach_attach_patches" + } +} diff --git a/tests/ast_json_fixtures/shapes/3e51c9bdbe22fbc3.sql b/tests/ast_json_fixtures/shapes/3e51c9bdbe22fbc3.sql new file mode 100644 index 000000000000..7ada137da2a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e51c9bdbe22fbc3.sql @@ -0,0 +1,6 @@ +CREATE TABLE t_detach_attach_patches_dst AS t_detach_attach_patches +ENGINE = ReplicatedMergeTree('/zookeeper/{database}/t_lwu_on_fly_dst/', '1') +ORDER BY a PARTITION BY id +SETTINGS + enable_block_number_column = 1, + enable_block_offset_column = 1 diff --git a/tests/ast_json_fixtures/shapes/3e5f5be2b68d7e73.json b/tests/ast_json_fixtures/shapes/3e5f5be2b68d7e73.json new file mode 100644 index 000000000000..5bd1c3a07a96 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e5f5be2b68d7e73.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateResourceQuery", + "resource_name": { + "type": "Identifier", + "name": "03232_read" + }, + "unit": "IOByte", + "operations": [ + { + "mode": "READ", + "disk": "03232_fake_disk" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3e5f5be2b68d7e73.sql b/tests/ast_json_fixtures/shapes/3e5f5be2b68d7e73.sql new file mode 100644 index 000000000000..4d7b62665fc3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e5f5be2b68d7e73.sql @@ -0,0 +1 @@ +create resource 03232_read (read disk 03232_fake_disk) diff --git a/tests/ast_json_fixtures/shapes/3e67d92ad4d7c216.json b/tests/ast_json_fixtures/shapes/3e67d92ad4d7c216.json new file mode 100644 index 000000000000..74538b0eb529 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e67d92ad4d7c216.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "test_user_02867" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "SSH_KEY", + "arguments": [ + { + "type": "PublicSSHKey", + "key_type": "ssh-rsa", + "key_base64": "invalid_key" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/3e67d92ad4d7c216.sql b/tests/ast_json_fixtures/shapes/3e67d92ad4d7c216.sql new file mode 100644 index 000000000000..11389d2e0e4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e67d92ad4d7c216.sql @@ -0,0 +1 @@ +CREATE USER test_user_02867 IDENTIFIED WITH ssh_key BY KEY 'invalid_key' TYPE 'ssh-rsa' diff --git a/tests/ast_json_fixtures/shapes/3e75647cab575ee6.json b/tests/ast_json_fixtures/shapes/3e75647cab575ee6.json new file mode 100644 index 000000000000..02f497817b36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e75647cab575ee6.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ATTACH_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3e75647cab575ee6.sql b/tests/ast_json_fixtures/shapes/3e75647cab575ee6.sql new file mode 100644 index 000000000000..a74dff4f70bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e75647cab575ee6.sql @@ -0,0 +1 @@ +alter table t attach partition 1 diff --git a/tests/ast_json_fixtures/shapes/3e77cd04b3e289b3.json b/tests/ast_json_fixtures/shapes/3e77cd04b3e289b3.json new file mode 100644 index 000000000000..ba22f3914b4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e77cd04b3e289b3.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tb" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "using": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tabc" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3e77cd04b3e289b3.sql b/tests/ast_json_fixtures/shapes/3e77cd04b3e289b3.sql new file mode 100644 index 000000000000..b009253bc11a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e77cd04b3e289b3.sql @@ -0,0 +1 @@ +SELECT 3 AS a, a, * FROM tb FULL JOIN tabc USING (a) ORDER BY ALL SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/3e799a638f6de12d.json b/tests/ast_json_fixtures/shapes/3e799a638f6de12d.json new file mode 100644 index 000000000000..19eb729a1eee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e799a638f6de12d.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Function", + "alias": "cnt", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.{1,2}" + }, + { + "type": "Identifier", + "name": "system.settings", + "name_parts": ["system", "settings"] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "name" + } + ], + "having": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "9" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "changed" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/3e799a638f6de12d.sql b/tests/ast_json_fixtures/shapes/3e799a638f6de12d.sql new file mode 100644 index 000000000000..2a1cc1b63303 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3e799a638f6de12d.sql @@ -0,0 +1,5 @@ +SELECT name, count() AS cnt +FROM remote('127.{1,2}', system.settings) +GROUP BY name +HAVING (max(value) > '9') AND (min(changed) = 0) +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/3ea9b7dce266fbe6.json b/tests/ast_json_fixtures/shapes/3ea9b7dce266fbe6.json new file mode 100644 index 000000000000..466d0ad46c02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ea9b7dce266fbe6.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "query_log" + }, + { + "table": "part_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3ea9b7dce266fbe6.sql b/tests/ast_json_fixtures/shapes/3ea9b7dce266fbe6.sql new file mode 100644 index 000000000000..dfa2777cc03f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ea9b7dce266fbe6.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS query_log, part_log diff --git a/tests/ast_json_fixtures/shapes/3ea9e7fa5f632ea9.json b/tests/ast_json_fixtures/shapes/3ea9e7fa5f632ea9.json new file mode 100644 index 000000000000..01f2e54fc8fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ea9e7fa5f632ea9.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u_02001"] + } +} diff --git a/tests/ast_json_fixtures/shapes/3ea9e7fa5f632ea9.sql b/tests/ast_json_fixtures/shapes/3ea9e7fa5f632ea9.sql new file mode 100644 index 000000000000..140dce07949d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ea9e7fa5f632ea9.sql @@ -0,0 +1 @@ +drop user if exists u_02001 diff --git a/tests/ast_json_fixtures/shapes/3ecf69c7a644d36a.json b/tests/ast_json_fixtures/shapes/3ecf69c7a644d36a.json new file mode 100644 index 000000000000..775c3c414900 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ecf69c7a644d36a.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/3ecf69c7a644d36a.sql b/tests/ast_json_fixtures/shapes/3ecf69c7a644d36a.sql new file mode 100644 index 000000000000..ebb52ede867f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ecf69c7a644d36a.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/3ed50cf9a071368c.json b/tests/ast_json_fixtures/shapes/3ed50cf9a071368c.json new file mode 100644 index 000000000000..28cad3427821 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ed50cf9a071368c.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_bf_indexOf" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Function", + "name": "indexOf", + "arguments": [ + { + "type": "Identifier", + "name": "ary" + }, + { + "type": "Literal", + "value_type": "String", + "value": "value1" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/3ed50cf9a071368c.sql b/tests/ast_json_fixtures/shapes/3ed50cf9a071368c.sql new file mode 100644 index 000000000000..e5718127ddea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ed50cf9a071368c.sql @@ -0,0 +1 @@ +SELECT id FROM test_bf_indexOf WHERE 0 < indexOf(ary, 'value1') ORDER BY id FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/3ed73676048851a5.json b/tests/ast_json_fixtures/shapes/3ed73676048851a5.json new file mode 100644 index 000000000000..b45b7b9ddeee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ed73676048851a5.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "SET_SNAPSHOT", + "snapshot": "1000000000000000" + } +} diff --git a/tests/ast_json_fixtures/shapes/3ed73676048851a5.sql b/tests/ast_json_fixtures/shapes/3ed73676048851a5.sql new file mode 100644 index 000000000000..fe0d47af86e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ed73676048851a5.sql @@ -0,0 +1 @@ +set transaction snapshot 1000000000000000 diff --git a/tests/ast_json_fixtures/shapes/3edb2b152faa7dc2.json b/tests/ast_json_fixtures/shapes/3edb2b152faa7dc2.json new file mode 100644 index 000000000000..9652c84e32a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3edb2b152faa7dc2.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateIndexQuery", + "table": { + "type": "Identifier", + "name": "tab2" + }, + "index_name": { + "type": "Identifier", + "name": "idx_tab2_0" + }, + "index_declaration": { + "type": "Index", + "name": "idx_tab2_0", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col0" + }, + { + "type": "Identifier", + "name": "col1" + } + ] + }, + "granularity": 1 + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3edb2b152faa7dc2.sql b/tests/ast_json_fixtures/shapes/3edb2b152faa7dc2.sql new file mode 100644 index 000000000000..df9278652408 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3edb2b152faa7dc2.sql @@ -0,0 +1 @@ +CREATE INDEX idx_tab2_0 ON tab2 (col0,col1) diff --git a/tests/ast_json_fixtures/shapes/3ee9a015326fcc18.json b/tests/ast_json_fixtures/shapes/3ee9a015326fcc18.json new file mode 100644 index 000000000000..c033b1c75875 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ee9a015326fcc18.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "dst" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + "replace": false, + "from_table": "src" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3ee9a015326fcc18.sql b/tests/ast_json_fixtures/shapes/3ee9a015326fcc18.sql new file mode 100644 index 000000000000..c56f1c72df05 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ee9a015326fcc18.sql @@ -0,0 +1 @@ +ALTER TABLE dst ATTACH PARTITION 1 FROM src diff --git a/tests/ast_json_fixtures/shapes/3eef35253a18fb51.json b/tests/ast_json_fixtures/shapes/3eef35253a18fb51.json new file mode 100644 index 000000000000..b8d1dd259e83 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3eef35253a18fb51.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "is_ordinary_view": true, + "cluster": "test", + "table": { + "type": "Identifier", + "name": "tview_cluster" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3eef35253a18fb51.sql b/tests/ast_json_fixtures/shapes/3eef35253a18fb51.sql new file mode 100644 index 000000000000..75ea27579537 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3eef35253a18fb51.sql @@ -0,0 +1 @@ +CREATE TEMPORARY VIEW tview_cluster ON CLUSTER 'test' AS SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/3ef1b1f222640cad.json b/tests/ast_json_fixtures/shapes/3ef1b1f222640cad.json new file mode 100644 index 000000000000..b8cbc34c8521 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ef1b1f222640cad.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONCompactStringsEachRowWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/3ef1b1f222640cad.sql b/tests/ast_json_fixtures/shapes/3ef1b1f222640cad.sql new file mode 100644 index 000000000000..cd60dd6b573e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ef1b1f222640cad.sql @@ -0,0 +1 @@ +SELECT name, count() AS c FROM test_table GROUP BY name WITH TOTALS ORDER BY name FORMAT JSONCompactStringsEachRowWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/3ef7321adef92f06.json b/tests/ast_json_fixtures/shapes/3ef7321adef92f06.json new file mode 100644 index 000000000000..944c2633c41e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ef7321adef92f06.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "assignments": [ + { + "type": "Assignment", + "column": "b", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3ef7321adef92f06.sql b/tests/ast_json_fixtures/shapes/3ef7321adef92f06.sql new file mode 100644 index 000000000000..d91928ec737c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3ef7321adef92f06.sql @@ -0,0 +1 @@ +alter table test update b = 0 where 1 settings mutations_sync=2 diff --git a/tests/ast_json_fixtures/shapes/3f0e664e91a5559b.json b/tests/ast_json_fixtures/shapes/3f0e664e91a5559b.json new file mode 100644 index 000000000000..a86d0e92e1ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3f0e664e91a5559b.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "having": { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "parallel_replicas_local_plan": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3f0e664e91a5559b.sql b/tests/ast_json_fixtures/shapes/3f0e664e91a5559b.sql new file mode 100644 index 000000000000..9bb6e9f5ed9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3f0e664e91a5559b.sql @@ -0,0 +1,5 @@ +SELECT a +FROM t1 +GROUP BY a +HAVING materialize(0) +SETTINGS parallel_replicas_local_plan = 1 diff --git a/tests/ast_json_fixtures/shapes/3f1d3f03163509b6.json b/tests/ast_json_fixtures/shapes/3f1d3f03163509b6.json new file mode 100644 index 000000000000..3738dc203018 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3f1d3f03163509b6.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "a", + "name": "toStartOfHour", + "arguments": [ + { + "type": "Identifier", + "name": "ts" + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "v", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "agg" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ts" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2021-12-06 22:00:00" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "v" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3f1d3f03163509b6.sql b/tests/ast_json_fixtures/shapes/3f1d3f03163509b6.sql new file mode 100644 index 000000000000..f06d3e253c35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3f1d3f03163509b6.sql @@ -0,0 +1 @@ +WITH toStartOfHour(ts) AS a SELECT sum(value) v FROM agg WHERE ts > '2021-12-06 22:00:00' GROUP BY a ORDER BY v LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/3f74be85e696824e.json b/tests/ast_json_fixtures/shapes/3f74be85e696824e.json new file mode 100644 index 000000000000..98ff79e798b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3f74be85e696824e.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "is_create_empty": true, + "table": { + "type": "Identifier", + "name": "mv" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3f74be85e696824e.sql b/tests/ast_json_fixtures/shapes/3f74be85e696824e.sql new file mode 100644 index 000000000000..8d38661d669d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3f74be85e696824e.sql @@ -0,0 +1 @@ +create materialized view mv engine=Memory empty as select 1 diff --git a/tests/ast_json_fixtures/shapes/3f783353423bfdb9.json b/tests/ast_json_fixtures/shapes/3f783353423bfdb9.json new file mode 100644 index 000000000000..185d6565e4d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3f783353423bfdb9.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "json" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3f783353423bfdb9.sql b/tests/ast_json_fixtures/shapes/3f783353423bfdb9.sql new file mode 100644 index 000000000000..3271466feb37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3f783353423bfdb9.sql @@ -0,0 +1 @@ +select json, materialize('') from test order by all asc diff --git a/tests/ast_json_fixtures/shapes/3fab9f98a37a7fb7.json b/tests/ast_json_fixtures/shapes/3fab9f98a37a7fb7.json new file mode 100644 index 000000000000..6c3931728e90 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3fab9f98a37a7fb7.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "cnt", + "name": "count", + "arguments": [] + } + ], + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cnt" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3fab9f98a37a7fb7.sql b/tests/ast_json_fixtures/shapes/3fab9f98a37a7fb7.sql new file mode 100644 index 000000000000..972abac33afa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3fab9f98a37a7fb7.sql @@ -0,0 +1 @@ +SELECT count() AS cnt WHERE 0 HAVING cnt = 0 diff --git a/tests/ast_json_fixtures/shapes/3fb4b56d9960235d.json b/tests/ast_json_fixtures/shapes/3fb4b56d9960235d.json new file mode 100644 index 000000000000..98ce5061ab22 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3fb4b56d9960235d.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_part_offset" + }, + { + "type": "Identifier", + "name": "_part_starting_offset" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_part_offset" + }, + { + "type": "Identifier", + "name": "_part_starting_offset" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "parallel_replicas_local_plan": "0", + "max_rows_to_read": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/3fb4b56d9960235d.sql b/tests/ast_json_fixtures/shapes/3fb4b56d9960235d.sql new file mode 100644 index 000000000000..c8fbd98b7980 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3fb4b56d9960235d.sql @@ -0,0 +1 @@ +select *, _part_offset + _part_starting_offset from test where _part_offset + _part_starting_offset = 8 settings parallel_replicas_local_plan = 0, max_rows_to_read = 1 diff --git a/tests/ast_json_fixtures/shapes/3fc57ce1d7f8098f.json b/tests/ast_json_fixtures/shapes/3fc57ce1d7f8098f.json new file mode 100644 index 000000000000..8b989f350b23 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3fc57ce1d7f8098f.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "START MERGES", + "table": { + "type": "Identifier", + "name": "t" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/3fc57ce1d7f8098f.sql b/tests/ast_json_fixtures/shapes/3fc57ce1d7f8098f.sql new file mode 100644 index 000000000000..0f7412d32b4c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3fc57ce1d7f8098f.sql @@ -0,0 +1 @@ +SYSTEM START MERGES t diff --git a/tests/ast_json_fixtures/shapes/3fdbaadd610ab373.json b/tests/ast_json_fixtures/shapes/3fdbaadd610ab373.json new file mode 100644 index 000000000000..206c3945ca32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3fdbaadd610ab373.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "cluster": "test_shard_localhost", + "table": { + "type": "Identifier", + "name": "m02006" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "alias": "i", + "value_type": "UInt64", + "value": "0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t02006" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "i" + } + ] + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } + ] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/3fdbaadd610ab373.sql b/tests/ast_json_fixtures/shapes/3fdbaadd610ab373.sql new file mode 100644 index 000000000000..d62f284a3129 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/3fdbaadd610ab373.sql @@ -0,0 +1,3 @@ +CREATE MATERIALIZED VIEW m02006 on cluster test_shard_localhost +Engine = MergeTree ORDER BY tuple() AS SELECT d, 0 AS i FROM t02006 GROUP BY d, i +format Null diff --git a/tests/ast_json_fixtures/shapes/4015b57a143aec51.json b/tests/ast_json_fixtures/shapes/4015b57a143aec51.json new file mode 100644 index 000000000000..c405ee3a9e66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4015b57a143aec51.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "COMMIT" + } +} diff --git a/tests/ast_json_fixtures/shapes/4015b57a143aec51.sql b/tests/ast_json_fixtures/shapes/4015b57a143aec51.sql new file mode 100644 index 000000000000..01f9a2aac3e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4015b57a143aec51.sql @@ -0,0 +1 @@ +commit diff --git a/tests/ast_json_fixtures/shapes/40419ec0dd22dc5f.json b/tests/ast_json_fixtures/shapes/40419ec0dd22dc5f.json new file mode 100644 index 000000000000..40d6b79a4ce1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/40419ec0dd22dc5f.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ] + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/40419ec0dd22dc5f.sql b/tests/ast_json_fixtures/shapes/40419ec0dd22dc5f.sql new file mode 100644 index 000000000000..bac1a541579c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/40419ec0dd22dc5f.sql @@ -0,0 +1 @@ +SELECT cityHash64('') FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/4043585532d5cab5.json b/tests/ast_json_fixtures/shapes/4043585532d5cab5.json new file mode 100644 index 000000000000..b4c4b8ec5c6d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4043585532d5cab5.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "b" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4043585532d5cab5.sql b/tests/ast_json_fixtures/shapes/4043585532d5cab5.sql new file mode 100644 index 000000000000..1d6f5567b322 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4043585532d5cab5.sql @@ -0,0 +1 @@ +SELECT * FROM b diff --git a/tests/ast_json_fixtures/shapes/4045243aa09c0966.json b/tests/ast_json_fixtures/shapes/4045243aa09c0966.json new file mode 100644 index 000000000000..e8f186cbd389 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4045243aa09c0966.json @@ -0,0 +1,374 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "queries", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Function", + "alias": "ordinal", + "name": "row_number", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time_microseconds" + }, + "direction": "ASC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryFinish" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_kind" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Select" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Settings" + }, + { + "type": "Literal", + "value_type": "String", + "value": "min_bytes_to_use_direct_io" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "queries.ordinal", + "name_parts": ["queries", "ordinal"] + }, + { + "type": "Identifier", + "name": "thread_name" + }, + { + "type": "Function", + "alias": "disk_reading", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "OSReadBytes" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "qtl", + "name": "query_thread_log", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "queries.query_id", + "name_parts": ["queries", "query_id"] + }, + { + "type": "Identifier", + "name": "qtl.query_id", + "name_parts": ["qtl", "query_id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "queries" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "query_id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "queries" + } + } + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "OSReadBytes" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4045243aa09c0966.sql b/tests/ast_json_fixtures/shapes/4045243aa09c0966.sql new file mode 100644 index 000000000000..21c331837f13 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4045243aa09c0966.sql @@ -0,0 +1,17 @@ +with queries as ( + select query_id, row_number() over(order by event_time_microseconds) as ordinal + from system.query_log + where type = 'QueryFinish' + and current_database = currentDatabase() + and query_kind = 'Select' + and Settings['min_bytes_to_use_direct_io'] = '1' +) +select queries.ordinal, thread_name, sum(ProfileEvents['OSReadBytes']) > 0 as disk_reading +from system.query_thread_log qtl + join queries + on queries.query_id = qtl.query_id +where current_database = currentDatabase() + and query_id in (select query_id from queries) + and ProfileEvents['OSReadBytes'] > 0 +group by 1, 2 +order by 1, 2 diff --git a/tests/ast_json_fixtures/shapes/404ff7b2e816c698.json b/tests/ast_json_fixtures/shapes/404ff7b2e816c698.json new file mode 100644 index 000000000000..24bfa559dea0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/404ff7b2e816c698.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ], + "format": "JSONCompactStringsEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/404ff7b2e816c698.sql b/tests/ast_json_fixtures/shapes/404ff7b2e816c698.sql new file mode 100644 index 000000000000..a64b9e8e611b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/404ff7b2e816c698.sql @@ -0,0 +1 @@ +SELECT * FROM test_table FORMAT JSONCompactStringsEachRow diff --git a/tests/ast_json_fixtures/shapes/406db84690a6f826.json b/tests/ast_json_fixtures/shapes/406db84690a6f826.json new file mode 100644 index 000000000000..94fc65048455 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/406db84690a6f826.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["test_user_03593_1"] + } +} diff --git a/tests/ast_json_fixtures/shapes/406db84690a6f826.sql b/tests/ast_json_fixtures/shapes/406db84690a6f826.sql new file mode 100644 index 000000000000..7aaf02f890bf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/406db84690a6f826.sql @@ -0,0 +1 @@ +DROP USER test_user_03593_1 diff --git a/tests/ast_json_fixtures/shapes/406fffa8b4940312.json b/tests/ast_json_fixtures/shapes/406fffa8b4940312.json new file mode 100644 index 000000000000..24ceb0b9f4bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/406fffa8b4940312.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "tab", + "like": "%INT%", + "not_like": true, + "case_insensitive_like": true + } +} diff --git a/tests/ast_json_fixtures/shapes/406fffa8b4940312.sql b/tests/ast_json_fixtures/shapes/406fffa8b4940312.sql new file mode 100644 index 000000000000..7c590fde5a7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/406fffa8b4940312.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM tab NOT ILIKE '%INT%' diff --git a/tests/ast_json_fixtures/shapes/40701a8624b1ea56.json b/tests/ast_json_fixtures/shapes/40701a8624b1ea56.json new file mode 100644 index 000000000000..b1a39d602225 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/40701a8624b1ea56.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "if_exists": true, + "names": ["02294_profile1", "02294_profile2"] + } +} diff --git a/tests/ast_json_fixtures/shapes/40701a8624b1ea56.sql b/tests/ast_json_fixtures/shapes/40701a8624b1ea56.sql new file mode 100644 index 000000000000..bfa1d2755cd2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/40701a8624b1ea56.sql @@ -0,0 +1 @@ +DROP SETTINGS PROFILE IF EXISTS 02294_profile1, 02294_profile2 diff --git a/tests/ast_json_fixtures/shapes/4078f75a8f43dd69.json b/tests/ast_json_fixtures/shapes/4078f75a8f43dd69.json new file mode 100644 index 000000000000..f173d41f686f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4078f75a8f43dd69.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["02294_profile1"] + } +} diff --git a/tests/ast_json_fixtures/shapes/4078f75a8f43dd69.sql b/tests/ast_json_fixtures/shapes/4078f75a8f43dd69.sql new file mode 100644 index 000000000000..1bf5f857c9d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4078f75a8f43dd69.sql @@ -0,0 +1 @@ +SHOW CREATE SETTINGS PROFILE 02294_profile1 diff --git a/tests/ast_json_fixtures/shapes/407a518e7457d114.json b/tests/ast_json_fixtures/shapes/407a518e7457d114.json new file mode 100644 index 000000000000..2f8d6021c574 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/407a518e7457d114.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "Dynamic" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "d" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/407a518e7457d114.sql b/tests/ast_json_fixtures/shapes/407a518e7457d114.sql new file mode 100644 index 000000000000..e951ba7172aa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/407a518e7457d114.sql @@ -0,0 +1 @@ +create table test (d Dynamic) engine=MergeTree order by tuple() primary key d diff --git a/tests/ast_json_fixtures/shapes/407b12be06a76fdd.json b/tests/ast_json_fixtures/shapes/407b12be06a76fdd.json new file mode 100644 index 000000000000..dd0e1d1817dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/407b12be06a76fdd.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/407b12be06a76fdd.sql b/tests/ast_json_fixtures/shapes/407b12be06a76fdd.sql new file mode 100644 index 000000000000..3f58fce29bb3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/407b12be06a76fdd.sql @@ -0,0 +1 @@ +ALTER TABLE t MODIFY COLUMN i Int32 diff --git a/tests/ast_json_fixtures/shapes/40858fdd3c0472c8.json b/tests/ast_json_fixtures/shapes/40858fdd3c0472c8.json new file mode 100644 index 000000000000..d77d1b4f4880 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/40858fdd3c0472c8.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q4_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "QUERY_SELECTS": "12582912" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/40858fdd3c0472c8.sql b/tests/ast_json_fixtures/shapes/40858fdd3c0472c8.sql new file mode 100644 index 000000000000..b85a4468ac90 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/40858fdd3c0472c8.sql @@ -0,0 +1 @@ +CREATE QUOTA q4_01297 FOR INTERVAL 1 MINUTE MAX query_selects = '12Mi' diff --git a/tests/ast_json_fixtures/shapes/4088ac45fa3c9d42.json b/tests/ast_json_fixtures/shapes/4088ac45fa3c9d42.json new file mode 100644 index 000000000000..ea705528da25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4088ac45fa3c9d42.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_shared" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "APPLY_PATCHES" + }, + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "assignments": [ + { + "type": "Assignment", + "column": "c1", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "2000" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4088ac45fa3c9d42.sql b/tests/ast_json_fixtures/shapes/4088ac45fa3c9d42.sql new file mode 100644 index 000000000000..4c70edf093d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4088ac45fa3c9d42.sql @@ -0,0 +1 @@ +ALTER TABLE t_shared APPLY PATCHES, UPDATE c1 = 2000 WHERE id % 10 = 0 diff --git a/tests/ast_json_fixtures/shapes/4090f1dc0216f30d.json b/tests/ast_json_fixtures/shapes/4090f1dc0216f30d.json new file mode 100644 index 000000000000..b542230e2c3a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4090f1dc0216f30d.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "PREWARM PRIMARY INDEX CACHE", + "table": { + "type": "Identifier", + "name": "t_prewarm_cache_rmt_1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4090f1dc0216f30d.sql b/tests/ast_json_fixtures/shapes/4090f1dc0216f30d.sql new file mode 100644 index 000000000000..013654ec7566 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4090f1dc0216f30d.sql @@ -0,0 +1 @@ +SYSTEM PREWARM PRIMARY INDEX CACHE t_prewarm_cache_rmt_1 diff --git a/tests/ast_json_fixtures/shapes/409b7748cf6f1e21.json b/tests/ast_json_fixtures/shapes/409b7748cf6f1e21.json new file mode 100644 index 000000000000..e98caf83687c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/409b7748cf6f1e21.json @@ -0,0 +1,161 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1000.0001 + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "UInt64", + "value": "257" + }, + { + "value_type": "UInt64", + "value": "65536" + }, + { + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayExists", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "2.55" + } + ] + } + ] + } + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Int64", + "value": "-9223372036854775808" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/409b7748cf6f1e21.sql b/tests/ast_json_fixtures/shapes/409b7748cf6f1e21.sql new file mode 100644 index 000000000000..7a4b363fea87 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/409b7748cf6f1e21.sql @@ -0,0 +1 @@ +SELECT 1000.0001, toUInt64(arrayJoin([NULL, 257, 65536, NULL])), arrayExists(x -> (x IN (SELECT '2.55')), [-9223372036854775808]) FROM remote('127.0.0.{1,2}') GROUP BY NULL, NULL, NULL, NULL diff --git a/tests/ast_json_fixtures/shapes/411c08de20a782aa.json b/tests/ast_json_fixtures/shapes/411c08de20a782aa.json new file mode 100644 index 000000000000..c32d09b52e70 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/411c08de20a782aa.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "replace_table": true, + "create_or_replace": true, + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "storage_policy": "policy_03755" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/411c08de20a782aa.sql b/tests/ast_json_fixtures/shapes/411c08de20a782aa.sql new file mode 100644 index 000000000000..a56021f8a1f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/411c08de20a782aa.sql @@ -0,0 +1 @@ +CREATE OR REPLACE TABLE t0 (c0 Int) ENGINE = MergeTree() ORDER BY tuple() SETTINGS storage_policy = 'policy_03755' diff --git a/tests/ast_json_fixtures/shapes/412d5ca0dd873f81.json b/tests/ast_json_fixtures/shapes/412d5ca0dd873f81.json new file mode 100644 index 000000000000..7d982efd5e64 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/412d5ca0dd873f81.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t_bad_constraint" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "constraints": [ + { + "type": "Constraint", + "name": "c1", + "constraint_type": "ASSUME", + "expression": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "toUInt32", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/412d5ca0dd873f81.sql b/tests/ast_json_fixtures/shapes/412d5ca0dd873f81.sql new file mode 100644 index 000000000000..40bffd92e700 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/412d5ca0dd873f81.sql @@ -0,0 +1 @@ +CREATE TABLE t_bad_constraint(a UInt32, s String, CONSTRAINT c1 ASSUME a = toUInt32(s)) ENGINE = MergeTree ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/412dbc9b220cdbba.json b/tests/ast_json_fixtures/shapes/412dbc9b220cdbba.json new file mode 100644 index 000000000000..c6f7c00e01c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/412dbc9b220cdbba.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "old_style" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_ORDER_BY", + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/412dbc9b220cdbba.sql b/tests/ast_json_fixtures/shapes/412dbc9b220cdbba.sql new file mode 100644 index 000000000000..70119d2c8b2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/412dbc9b220cdbba.sql @@ -0,0 +1 @@ +ALTER TABLE old_style ADD COLUMN y UInt32, MODIFY ORDER BY (x, y) diff --git a/tests/ast_json_fixtures/shapes/415a897dbea95a25.json b/tests/ast_json_fixtures/shapes/415a897dbea95a25.json new file mode 100644 index 000000000000..896cd010287e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/415a897dbea95a25.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "is_populate": true, + "table": { + "type": "Identifier", + "name": "test_view_filtered" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "EventDate", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "CounterID", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Identifier", + "name": "EventDate" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "EventDate" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2013-01-01" + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/415a897dbea95a25.sql b/tests/ast_json_fixtures/shapes/415a897dbea95a25.sql new file mode 100644 index 000000000000..e061b6a0edb1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/415a897dbea95a25.sql @@ -0,0 +1 @@ +CREATE MATERIALIZED VIEW test_view_filtered (EventDate Date, CounterID UInt32) POPULATE AS SELECT CounterID, EventDate FROM test_table WHERE EventDate < '2013-01-01' diff --git a/tests/ast_json_fixtures/shapes/416300d3988b9f42.json b/tests/ast_json_fixtures/shapes/416300d3988b9f42.json new file mode 100644 index 000000000000..2ff9198c2198 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/416300d3988b9f42.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/416300d3988b9f42.sql b/tests/ast_json_fixtures/shapes/416300d3988b9f42.sql new file mode 100644 index 000000000000..f0404466d764 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/416300d3988b9f42.sql @@ -0,0 +1,11 @@ +SELECT + number +FROM + numbers(10) +GROUP BY + GROUPING SETS + ( + number, + number % 2 + ) + WITH CUBE diff --git a/tests/ast_json_fixtures/shapes/4169120c7da6b6af.json b/tests/ast_json_fixtures/shapes/4169120c7da6b6af.json new file mode 100644 index 000000000000..ec52d89bff26 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4169120c7da6b6af.json @@ -0,0 +1,174 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "d1", + "name": "toDate", + "arguments": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "86400" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Istanbul" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "d2", + "name": "toDate", + "arguments": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "86400" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Istanbul" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "source", + "value_type": "String", + "value": "original" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d1" + }, + "direction": "ASC", + "with_fill": true, + "fill_step": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d2" + }, + "direction": "ASC", + "with_fill": true + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4169120c7da6b6af.sql b/tests/ast_json_fixtures/shapes/4169120c7da6b6af.sql new file mode 100644 index 000000000000..a715cca55963 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4169120c7da6b6af.sql @@ -0,0 +1,9 @@ +SELECT + toDate(toDateTime((number * 10) * 86400, 'Asia/Istanbul')) AS d1, + toDate(toDateTime(number * 86400, 'Asia/Istanbul')) AS d2, + 'original' AS source +FROM numbers(10) +WHERE (number % 3) = 1 +ORDER BY + d1 WITH FILL STEP 5, + d2 WITH FILL diff --git a/tests/ast_json_fixtures/shapes/4171b0638420bcca.json b/tests/ast_json_fixtures/shapes/4171b0638420bcca.json new file mode 100644 index 000000000000..7541508f154a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4171b0638420bcca.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "shift_right_bit", + "name": "id" + }, + { + "type": "Literal", + "alias": "arg", + "value_type": "String", + "value": "Hel" + }, + { + "type": "Function", + "alias": "string_res", + "name": "bin", + "arguments": [ + { + "type": "Function", + "name": "bitShiftLeft", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Hel" + }, + { + "type": "Identifier", + "name": "id" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_bit_shift_left_string_integer" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4171b0638420bcca.sql b/tests/ast_json_fixtures/shapes/4171b0638420bcca.sql new file mode 100644 index 000000000000..d2d2befeac2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4171b0638420bcca.sql @@ -0,0 +1 @@ +SELECT id as shift_right_bit,'Hel' as arg,bin(bitShiftLeft('Hel', id)) as string_res FROM test_bit_shift_left_string_integer WHERE id <= 8 * 3 diff --git a/tests/ast_json_fixtures/shapes/4183f261f59278dd.json b/tests/ast_json_fixtures/shapes/4183f261f59278dd.json new file mode 100644 index 000000000000..c400a4456e56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4183f261f59278dd.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TabSeparatedRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/4183f261f59278dd.sql b/tests/ast_json_fixtures/shapes/4183f261f59278dd.sql new file mode 100644 index 000000000000..b3509ffccfdc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4183f261f59278dd.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TabSeparatedRaw diff --git a/tests/ast_json_fixtures/shapes/4196b20c6814b182.json b/tests/ast_json_fixtures/shapes/4196b20c6814b182.json new file mode 100644 index 000000000000..a26579dd2181 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4196b20c6814b182.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "tup.u", + "name_parts": ["tup", "u"] + }, + { + "type": "Function", + "alias": "cnt", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tuple_test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "tup.u", + "name_parts": ["tup", "u"] + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tup.u", + "name_parts": ["tup", "u"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "tup.u", + "name_parts": ["tup", "u"] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4196b20c6814b182.sql b/tests/ast_json_fixtures/shapes/4196b20c6814b182.sql new file mode 100644 index 000000000000..d0f7225275ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4196b20c6814b182.sql @@ -0,0 +1,5 @@ +SELECT tup.u, count() as cnt +FROM tuple_test +GROUP BY tup.u +HAVING tup.u > 10 +ORDER BY tup.u diff --git a/tests/ast_json_fixtures/shapes/419fe6bec4a4f8cf.json b/tests/ast_json_fixtures/shapes/419fe6bec4a4f8cf.json new file mode 100644 index 000000000000..be096760d546 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/419fe6bec4a4f8cf.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "a", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "a" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/419fe6bec4a4f8cf.sql b/tests/ast_json_fixtures/shapes/419fe6bec4a4f8cf.sql new file mode 100644 index 000000000000..e5c7aeb95942 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/419fe6bec4a4f8cf.sql @@ -0,0 +1 @@ +WITH a AS (SELECT 1) SELECT a.* FROM (SELECT 1 FROM a) diff --git a/tests/ast_json_fixtures/shapes/41cbbdfd58d56bcb.json b/tests/ast_json_fixtures/shapes/41cbbdfd58d56bcb.json new file mode 100644 index 000000000000..6cd35a277108 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/41cbbdfd58d56bcb.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u2_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/41cbbdfd58d56bcb.sql b/tests/ast_json_fixtures/shapes/41cbbdfd58d56bcb.sql new file mode 100644 index 000000000000..3e27eace0b83 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/41cbbdfd58d56bcb.sql @@ -0,0 +1 @@ +SHOW CREATE USER u2_01292 diff --git a/tests/ast_json_fixtures/shapes/41decbee2f50b0ea.json b/tests/ast_json_fixtures/shapes/41decbee2f50b0ea.json new file mode 100644 index 000000000000..e78f90df6969 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/41decbee2f50b0ea.json @@ -0,0 +1,705 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "projection_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "sum(block_count)", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "domain_alias", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_specifier": "ALIAS", + "default_expression": { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "domain" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "datetime", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "domain", + "data_type": { + "type": "DataType", + "name": "LowCardinality", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "x_id", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "y_id", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "block_count", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "retry_count", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "duration", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "kbytes", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "buffer_time", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "first_time", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "total_bytes", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "UInt64" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "valid_bytes", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "UInt64" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "completed_bytes", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "UInt64" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "fixed_bytes", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "UInt64" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "force_bytes", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "UInt64" + } + ] + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Function", + "alias": "dt_m", + "name": "toStartOfMinute", + "arguments": [ + { + "type": "Identifier", + "name": "datetime" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "first_time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "kbytes" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "block_count" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + }, + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "block_count" + }, + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "buffer_time" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + }, + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "buffer_time" + }, + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "valid_bytes" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "total_bytes" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "completed_bytes" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "total_bytes" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "fixed_bytes" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "total_bytes" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "force_bytes" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "total_bytes" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "valid_bytes" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "total_bytes" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "retry_count" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + }, + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "retry_count" + }, + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "block_count" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "first_time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "uniqHLL12", + "arguments": [ + { + "type": "Identifier", + "name": "x_id" + } + ] + }, + { + "type": "Function", + "name": "uniqHLL12", + "arguments": [ + { + "type": "Identifier", + "name": "y_id" + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "dt_m" + }, + { + "type": "Identifier", + "name": "domain" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "datetime" + } + ] + }, + "order_by": { + "type": "Function", + "name": "toStartOfTenMinutes", + "arguments": [ + { + "type": "Identifier", + "name": "datetime" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity_bytes": "10000000", + "add_minmax_index_for_numeric_columns": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/41decbee2f50b0ea.sql b/tests/ast_json_fixtures/shapes/41decbee2f50b0ea.sql new file mode 100644 index 000000000000..9854d609f945 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/41decbee2f50b0ea.sql @@ -0,0 +1 @@ +create table projection_test (`sum(block_count)` UInt64, domain_alias UInt64 alias length(domain), datetime DateTime, domain LowCardinality(String), x_id String, y_id String, block_count Int64, retry_count Int64, duration Int64, kbytes Int64, buffer_time Int64, first_time Int64, total_bytes Nullable(UInt64), valid_bytes Nullable(UInt64), completed_bytes Nullable(UInt64), fixed_bytes Nullable(UInt64), force_bytes Nullable(UInt64), projection p (select toStartOfMinute(datetime) dt_m, countIf(first_time = 0) / count(), avg((kbytes * 8) / duration), count(), sum(block_count) / sum(duration), avg(block_count / duration), sum(buffer_time) / sum(duration), avg(buffer_time / duration), sum(valid_bytes) / sum(total_bytes), sum(completed_bytes) / sum(total_bytes), sum(fixed_bytes) / sum(total_bytes), sum(force_bytes) / sum(total_bytes), sum(valid_bytes) / sum(total_bytes), sum(retry_count) / sum(duration), avg(retry_count / duration), countIf(block_count > 0) / count(), countIf(first_time = 0) / count(), uniqHLL12(x_id), uniqHLL12(y_id) group by dt_m, domain)) engine MergeTree partition by toDate(datetime) order by toStartOfTenMinutes(datetime) settings index_granularity_bytes = 10000000, add_minmax_index_for_numeric_columns=0 diff --git a/tests/ast_json_fixtures/shapes/41e35c7c4f15c395.json b/tests/ast_json_fixtures/shapes/41e35c7c4f15c395.json new file mode 100644 index 000000000000..ecac131c9f04 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/41e35c7c4f15c395.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/41e35c7c4f15c395.sql b/tests/ast_json_fixtures/shapes/41e35c7c4f15c395.sql new file mode 100644 index 000000000000..9345a514b13d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/41e35c7c4f15c395.sql @@ -0,0 +1 @@ +SELECT DISTINCT * FROM (SELECT 2 UNION ALL SELECT 2) diff --git a/tests/ast_json_fixtures/shapes/4202a0ca4411ff6a.json b/tests/ast_json_fixtures/shapes/4202a0ca4411ff6a.json new file mode 100644 index 000000000000..8069e1999740 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4202a0ca4411ff6a.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "alter_test" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "if_exists": true, + "column_declaration": { + "type": "ColumnDeclaration", + "name": "ToDrop", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4202a0ca4411ff6a.sql b/tests/ast_json_fixtures/shapes/4202a0ca4411ff6a.sql new file mode 100644 index 000000000000..c292a22aa1e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4202a0ca4411ff6a.sql @@ -0,0 +1 @@ +ALTER TABLE alter_test MODIFY COLUMN IF EXISTS ToDrop UInt64 diff --git a/tests/ast_json_fixtures/shapes/420ed92012e0ed94.json b/tests/ast_json_fixtures/shapes/420ed92012e0ed94.json new file mode 100644 index 000000000000..c78651dfbbeb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/420ed92012e0ed94.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "test_d" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_one_shard_three_replicas_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test" + } + ] + } + }, + "as_table": "test" + } +} diff --git a/tests/ast_json_fixtures/shapes/420ed92012e0ed94.sql b/tests/ast_json_fixtures/shapes/420ed92012e0ed94.sql new file mode 100644 index 000000000000..2fa346b9639a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/420ed92012e0ed94.sql @@ -0,0 +1,2 @@ +CREATE TABLE IF NOT EXISTS test_d as test +ENGINE = Distributed(test_cluster_one_shard_three_replicas_localhost, currentDatabase(), test) diff --git a/tests/ast_json_fixtures/shapes/42364a017b73ef51.json b/tests/ast_json_fixtures/shapes/42364a017b73ef51.json new file mode 100644 index 000000000000..1c8fecc5b236 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42364a017b73ef51.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/42364a017b73ef51.sql b/tests/ast_json_fixtures/shapes/42364a017b73ef51.sql new file mode 100644 index 000000000000..2e3761f7a2c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42364a017b73ef51.sql @@ -0,0 +1 @@ +SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/42405c79b4b78e42.json b/tests/ast_json_fixtures/shapes/42405c79b4b78e42.json new file mode 100644 index 000000000000..c123b4f009cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42405c79b4b78e42.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "03710" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1", + "max_block_size": "1" + } + }, + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/42405c79b4b78e42.sql b/tests/ast_json_fixtures/shapes/42405c79b4b78e42.sql new file mode 100644 index 000000000000..6c5fe10ae20c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42405c79b4b78e42.sql @@ -0,0 +1 @@ +SELECT '03710', c FROM tab FORMAT CSV SETTINGS use_query_cache = 1, max_block_size = 1 diff --git a/tests/ast_json_fixtures/shapes/4242935651dc0e3f.json b/tests/ast_json_fixtures/shapes/4242935651dc0e3f.json new file mode 100644 index 000000000000..4ed725d05eec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4242935651dc0e3f.json @@ -0,0 +1,139 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.2" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "globalIn", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toUInt8", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + } + ] + } + ] + } + ] + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/4242935651dc0e3f.sql b/tests/ast_json_fixtures/shapes/4242935651dc0e3f.sql new file mode 100644 index 000000000000..1e7cb784f34b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4242935651dc0e3f.sql @@ -0,0 +1 @@ +SELECT arrayJoin(range(100)) AS x FROM remote('127.0.0.2', system.one) WHERE x GLOBAL IN (SELECT toUInt8(arrayJoin(range(100)) + 50)) GROUP BY x ORDER BY x LIMIT 10 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/42476038a920a74b.json b/tests/ast_json_fixtures/shapes/42476038a920a74b.json new file mode 100644 index 000000000000..3b36614ae216 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42476038a920a74b.json @@ -0,0 +1,264 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "MAX", + "arguments": [ + { + "type": "Identifier", + "name": "left.c0", + "name_parts": ["left", "c0"] + } + ] + }, + { + "type": "Function", + "alias": "g", + "name": "min2", + "arguments": [ + { + "type": "Identifier", + "name": "left.c0", + "name_parts": ["left", "c0"] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "left.c0", + "name_parts": ["left", "c0"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "radians", + "arguments": [ + { + "type": "Identifier", + "name": "left.c0", + "name_parts": ["left", "c0"] + } + ] + }, + { + "type": "Function", + "name": "radians", + "arguments": [ + { + "type": "Identifier", + "name": "left.c0", + "name_parts": ["left", "c0"] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "h", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1925024212" + } + ] + } + ] + }, + { + "type": "Function", + "name": "radians", + "arguments": [ + { + "type": "Function", + "name": "tan", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1216286224" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "cos", + "arguments": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "lcm", + "arguments": [ + { + "type": "Function", + "name": "MAX", + "arguments": [ + { + "type": "Identifier", + "name": "left.c0", + "name_parts": ["left", "c0"] + } + ] + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1966575216" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "MAX", + "arguments": [ + { + "type": "Identifier", + "name": "left.c0", + "name_parts": ["left", "c0"] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1180517420" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "h" + } + ] + }, + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "h" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "left", + "name": "t2" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "g" + } + ], + "having": { + "type": "Identifier", + "name": "h" + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "g" + }, + "direction": "DESC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_optimize_predicate_expression": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/42476038a920a74b.sql b/tests/ast_json_fixtures/shapes/42476038a920a74b.sql new file mode 100644 index 000000000000..5ee04bea58f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42476038a920a74b.sql @@ -0,0 +1,3 @@ +SELECT MAX(left.c0), min2(left.c0, -(-left.c0) * (radians(left.c0) - radians(left.c0))) as g, (((-1925024212 IS NOT NULL) IS NOT NULL) != radians(tan(1216286224))) AND cos(lcm(MAX(left.c0), -1966575216) OR (MAX(left.c0) * 1180517420)) as h, not h, h is null + FROM t2 AS left + GROUP BY g HAVING h ORDER BY g DESC SETTINGS enable_optimize_predicate_expression = 0 diff --git a/tests/ast_json_fixtures/shapes/425307b28f735762.json b/tests/ast_json_fixtures/shapes/425307b28f735762.json new file mode 100644 index 000000000000..9ffd223f3677 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/425307b28f735762.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02101_test_function", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/425307b28f735762.sql b/tests/ast_json_fixtures/shapes/425307b28f735762.sql new file mode 100644 index 000000000000..5aa1b346f82c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/425307b28f735762.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02101_test_function diff --git a/tests/ast_json_fixtures/shapes/4266d865e96c53af.json b/tests/ast_json_fixtures/shapes/4266d865e96c53af.json new file mode 100644 index 000000000000..8b59423fb07f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4266d865e96c53af.json @@ -0,0 +1,157 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "c", + "name": "toDayOfWeek", + "arguments": [ + { + "type": "Identifier", + "name": "ShipmentDate" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_data" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "lowerUTF8", + "arguments": [ + { + "type": "Function", + "name": "formatDateTime", + "arguments": [ + { + "type": "Function", + "name": "plus", + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-01-01" + } + ] + }, + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toInt32", + "arguments": [ + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "%W" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "%m%" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "c" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "62" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4266d865e96c53af.sql b/tests/ast_json_fixtures/shapes/4266d865e96c53af.sql new file mode 100644 index 000000000000..8da58a7d3f49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4266d865e96c53af.sql @@ -0,0 +1,8 @@ +SELECT + toDayOfWeek(ShipmentDate) AS c +FROM test_data +WHERE c IS NOT NULL AND lowerUTF8(formatDateTime(date_add(DAY, toInt32(c) - 1, toDate('2024-01-01')), '%W')) LIKE '%m%' +GROUP BY c +ORDER BY c ASC +LIMIT 62 +OFFSET 0 diff --git a/tests/ast_json_fixtures/shapes/42ab86bf9642bd9b.json b/tests/ast_json_fixtures/shapes/42ab86bf9642bd9b.json new file mode 100644 index 000000000000..224c24e4fad5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42ab86bf9642bd9b.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_STATISTICS" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/42ab86bf9642bd9b.sql b/tests/ast_json_fixtures/shapes/42ab86bf9642bd9b.sql new file mode 100644 index 000000000000..9c36cd64757e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42ab86bf9642bd9b.sql @@ -0,0 +1 @@ +ALTER TABLE tab MATERIALIZE STATISTICS ALL diff --git a/tests/ast_json_fixtures/shapes/42b296f2a2882902.json b/tests/ast_json_fixtures/shapes/42b296f2a2882902.json new file mode 100644 index 000000000000..923557a57a3c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42b296f2a2882902.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "alter_01355" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "first": true, + "column_declaration": { + "type": "ColumnDeclaration", + "name": "Added1", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/42b296f2a2882902.sql b/tests/ast_json_fixtures/shapes/42b296f2a2882902.sql new file mode 100644 index 000000000000..ca0d35430c1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42b296f2a2882902.sql @@ -0,0 +1 @@ +ALTER TABLE alter_01355 ADD COLUMN Added1 UInt32 FIRST diff --git a/tests/ast_json_fixtures/shapes/42c6e754c178ddb7.json b/tests/ast_json_fixtures/shapes/42c6e754c178ddb7.json new file mode 100644 index 000000000000..f30d9dbac90f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42c6e754c178ddb7.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "if_exists": true, + "names": ["s2_01294_renamed"] + } +} diff --git a/tests/ast_json_fixtures/shapes/42c6e754c178ddb7.sql b/tests/ast_json_fixtures/shapes/42c6e754c178ddb7.sql new file mode 100644 index 000000000000..1b595b41ef6c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42c6e754c178ddb7.sql @@ -0,0 +1 @@ +DROP SETTINGS PROFILE IF EXISTS s2_01294_renamed diff --git a/tests/ast_json_fixtures/shapes/42df0097915869d8.json b/tests/ast_json_fixtures/shapes/42df0097915869d8.json new file mode 100644 index 000000000000..58d79cc82e09 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42df0097915869d8.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_block_number_column": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/42df0097915869d8.sql b/tests/ast_json_fixtures/shapes/42df0097915869d8.sql new file mode 100644 index 000000000000..7129f9a7d595 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/42df0097915869d8.sql @@ -0,0 +1 @@ +CREATE TABLE t (x UInt8, PROJECTION p (SELECT x GROUP BY x)) ENGINE = MergeTree ORDER BY () SETTINGS enable_block_number_column = 1 diff --git a/tests/ast_json_fixtures/shapes/4304f3abf2ea972f.json b/tests/ast_json_fixtures/shapes/4304f3abf2ea972f.json new file mode 100644 index 000000000000..f06ce602d4ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4304f3abf2ea972f.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "lambda", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "lambda1", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Identifier", + "alias": "lambda1", + "name": "lambda" + } + ], + "select": [ + { + "type": "Function", + "name": "lambda", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4304f3abf2ea972f.sql b/tests/ast_json_fixtures/shapes/4304f3abf2ea972f.sql new file mode 100644 index 000000000000..fc897733a027 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4304f3abf2ea972f.sql @@ -0,0 +1,4 @@ +WITH + x -> (lambda1(x) + 1) AS lambda, + lambda AS lambda1 +SELECT lambda(1) diff --git a/tests/ast_json_fixtures/shapes/430d64dc5b124674.json b/tests/ast_json_fixtures/shapes/430d64dc5b124674.json new file mode 100644 index 000000000000..e8f25d1f9af8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/430d64dc5b124674.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC", + "with_fill": true, + "fill_from": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "fill_to": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/430d64dc5b124674.sql b/tests/ast_json_fixtures/shapes/430d64dc5b124674.sql new file mode 100644 index 000000000000..384c0c804eb8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/430d64dc5b124674.sql @@ -0,0 +1,8 @@ +SELECT + 2 AS x, + arrayJoin([NULL, NULL, NULL]) +GROUP BY + GROUPING SETS ( + (0), + ([NULL, NULL, NULL])) +ORDER BY x ASC WITH FILL FROM 1 TO 10 diff --git a/tests/ast_json_fixtures/shapes/432b51d5d8b43ff0.json b/tests/ast_json_fixtures/shapes/432b51d5d8b43ff0.json new file mode 100644 index 000000000000..cd699acf5fb0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/432b51d5d8b43ff0.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,1}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "merge_test_table" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "distributed_aggregation_memory_efficient": "1", + "max_threads": "4", + "optimize_aggregation_in_order": "0", + "prefer_localhost_replica": "1", + "async_socket_for_remote": "1", + "enable_analyzer": "0", + "enable_producing_buckets_out_of_order_in_aggregation": "0", + "enable_memory_bound_merging_of_aggregation_results": "0", + "max_memory_usage": "500Mi", + "group_by_two_level_threshold": 1000000, + "group_by_two_level_threshold_bytes": "500Mi" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/432b51d5d8b43ff0.sql b/tests/ast_json_fixtures/shapes/432b51d5d8b43ff0.sql new file mode 100644 index 000000000000..038474b75aab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/432b51d5d8b43ff0.sql @@ -0,0 +1,7 @@ +SELECT + cityHash64(number), + sum(1) +FROM remote('127.0.0.{1,1}', currentDatabase(), merge_test_table) +GROUP BY 1 +FORMAT Null +SETTINGS distributed_aggregation_memory_efficient = 1, max_threads = 4, optimize_aggregation_in_order = 0, prefer_localhost_replica = 1, async_socket_for_remote = 1, enable_analyzer = 0, enable_producing_buckets_out_of_order_in_aggregation = 0, enable_memory_bound_merging_of_aggregation_results = 0, max_memory_usage='500Mi', group_by_two_level_threshold=1e6, group_by_two_level_threshold_bytes='500Mi' diff --git a/tests/ast_json_fixtures/shapes/433cbf38d1257213.json b/tests/ast_json_fixtures/shapes/433cbf38d1257213.json new file mode 100644 index 000000000000..8d421db380a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/433cbf38d1257213.json @@ -0,0 +1,383 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "alias": "ym:ah:URL", + "name": "URL" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "DontCountHits" + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Refresh" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "t", + "name": "quantilesTimingIf", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "DOMCompleteTiming" + }, + { + "type": "Identifier", + "name": "LoadEventEndTiming" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "DOMCompleteTiming" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "LoadEventEndTiming" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + } + ] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.9 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Identifier", + "name": "test" + }, + { + "type": "Identifier", + "name": "hits" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "800784" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "DontCountHits" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "IsNotBounce" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "URL" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "ym:ah:URL" + } + ], + "having": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "DontCountHits" + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Refresh" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "DontCountHits" + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Refresh" + } + ] + } + ] + } + ] + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "URL" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/433cbf38d1257213.sql b/tests/ast_json_fixtures/shapes/433cbf38d1257213.sql new file mode 100644 index 000000000000..5954ba5e3ee7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/433cbf38d1257213.sql @@ -0,0 +1 @@ +SELECT URL AS `ym:ah:URL`, sum((NOT DontCountHits AND NOT Refresh)), quantilesTimingIf(0.1, 0.5, 0.9)((DOMCompleteTiming + LoadEventEndTiming), DOMCompleteTiming != -1 AND LoadEventEndTiming != -1) as t FROM remote('127.0.0.{1,2}', test, hits) WHERE (CounterID = 800784) AND (((DontCountHits = 0) OR (IsNotBounce = 1)) AND (URL != '')) GROUP BY `ym:ah:URL` WITH TOTALS HAVING (sum((NOT DontCountHits AND NOT Refresh)) > 0) AND (count() > 0) ORDER BY sum((NOT DontCountHits AND NOT Refresh)) DESC, URL LIMIT 0, 1 diff --git a/tests/ast_json_fixtures/shapes/4340fe3a5602191b.json b/tests/ast_json_fixtures/shapes/4340fe3a5602191b.json new file mode 100644 index 000000000000..681f3044d875 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4340fe3a5602191b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "constF32", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/4340fe3a5602191b.sql b/tests/ast_json_fixtures/shapes/4340fe3a5602191b.sql new file mode 100644 index 000000000000..e2c8963c41ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4340fe3a5602191b.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS constF32 diff --git a/tests/ast_json_fixtures/shapes/4359c7eb8a01c0cc.json b/tests/ast_json_fixtures/shapes/4359c7eb8a01c0cc.json new file mode 100644 index 000000000000..30545687bb67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4359c7eb8a01c0cc.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "v", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "secondaryidx", + "expression": { + "type": "Identifier", + "name": "v" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "id" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "2" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4359c7eb8a01c0cc.sql b/tests/ast_json_fixtures/shapes/4359c7eb8a01c0cc.sql new file mode 100644 index 000000000000..71f0bfa211ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4359c7eb8a01c0cc.sql @@ -0,0 +1 @@ +CREATE TABLE tab1 (id Int32, v Int32, INDEX secondaryidx v TYPE minmax) ENGINE=ReplacingMergeTree ORDER BY id SETTINGS index_granularity=2 diff --git a/tests/ast_json_fixtures/shapes/4361ab3d8eb94dc0.json b/tests/ast_json_fixtures/shapes/4361ab3d8eb94dc0.json new file mode 100644 index 000000000000..192851d2966e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4361ab3d8eb94dc0.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Function", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "CounterID" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4361ab3d8eb94dc0.sql b/tests/ast_json_fixtures/shapes/4361ab3d8eb94dc0.sql new file mode 100644 index 000000000000..cbb4282d87f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4361ab3d8eb94dc0.sql @@ -0,0 +1 @@ +SELECT CounterID, uniq(UserID) FROM test.hits WHERE 0 != 0 GROUP BY CounterID diff --git a/tests/ast_json_fixtures/shapes/436b5d285b5ef427.json b/tests/ast_json_fixtures/shapes/436b5d285b5ef427.json new file mode 100644 index 000000000000..f0d050afb36f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/436b5d285b5ef427.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "wups" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/436b5d285b5ef427.sql b/tests/ast_json_fixtures/shapes/436b5d285b5ef427.sql new file mode 100644 index 000000000000..9ec3ccea0ee0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/436b5d285b5ef427.sql @@ -0,0 +1 @@ +select count(), a[1] from wups group by a[1] order by a[1] diff --git a/tests/ast_json_fixtures/shapes/4390af88d82e7c37.json b/tests/ast_json_fixtures/shapes/4390af88d82e7c37.json new file mode 100644 index 000000000000..1aff11a28c11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4390af88d82e7c37.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02101_test_function" + } +} diff --git a/tests/ast_json_fixtures/shapes/4390af88d82e7c37.sql b/tests/ast_json_fixtures/shapes/4390af88d82e7c37.sql new file mode 100644 index 000000000000..89b83f0a0c86 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4390af88d82e7c37.sql @@ -0,0 +1 @@ +DROP FUNCTION 02101_test_function diff --git a/tests/ast_json_fixtures/shapes/439a05a6077b2b11.json b/tests/ast_json_fixtures/shapes/439a05a6077b2b11.json new file mode 100644 index 000000000000..9ad11fe0a8ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/439a05a6077b2b11.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u6_01292" + } + ] + }, + "default_roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r1_01292", "r2_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/439a05a6077b2b11.sql b/tests/ast_json_fixtures/shapes/439a05a6077b2b11.sql new file mode 100644 index 000000000000..c81be08d3d9c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/439a05a6077b2b11.sql @@ -0,0 +1 @@ +CREATE USER u6_01292 DEFAULT ROLE ALL EXCEPT r1_01292, r2_01292 diff --git a/tests/ast_json_fixtures/shapes/43b8912b2da2cadb.json b/tests/ast_json_fixtures/shapes/43b8912b2da2cadb.json new file mode 100644 index 000000000000..7a509682e256 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/43b8912b2da2cadb.json @@ -0,0 +1,117 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/43b8912b2da2cadb.sql b/tests/ast_json_fixtures/shapes/43b8912b2da2cadb.sql new file mode 100644 index 000000000000..b7fb28729d54 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/43b8912b2da2cadb.sql @@ -0,0 +1 @@ +SELECT number, count() / 0.1 FROM (SELECT number FROM system.numbers LIMIT 10) GROUP BY number WITH TOTALS HAVING count() > 0.1 ORDER BY number diff --git a/tests/ast_json_fixtures/shapes/43c735febb894e81.json b/tests/ast_json_fixtures/shapes/43c735febb894e81.json new file mode 100644 index 000000000000..90cf80d7117f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/43c735febb894e81.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "lwu_on_fly" + }, + "assignments": [ + { + "type": "Assignment", + "column": "u", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ], + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/43c735febb894e81.sql b/tests/ast_json_fixtures/shapes/43c735febb894e81.sql new file mode 100644 index 000000000000..654d6335a5db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/43c735febb894e81.sql @@ -0,0 +1 @@ +UPDATE lwu_on_fly SET u = 0 WHERE id % 3 = 1 diff --git a/tests/ast_json_fixtures/shapes/43daf4b29dc10ba4.json b/tests/ast_json_fixtures/shapes/43daf4b29dc10ba4.json new file mode 100644 index 000000000000..1aa221a46433 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/43daf4b29dc10ba4.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "limit_with_ties": true, + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ties" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/43daf4b29dc10ba4.sql b/tests/ast_json_fixtures/shapes/43daf4b29dc10ba4.sql new file mode 100644 index 000000000000..ee01db2307b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/43daf4b29dc10ba4.sql @@ -0,0 +1 @@ +SELECT a FROM ties order by a limit 1 with ties diff --git a/tests/ast_json_fixtures/shapes/43f3685fd1bef970.json b/tests/ast_json_fixtures/shapes/43f3685fd1bef970.json new file mode 100644 index 000000000000..dc1397c67caa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/43f3685fd1bef970.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "result", + "name": "CAST", + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Bool" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_jit_bool" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/43f3685fd1bef970.sql b/tests/ast_json_fixtures/shapes/43f3685fd1bef970.sql new file mode 100644 index 000000000000..8d84d0a5ff79 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/43f3685fd1bef970.sql @@ -0,0 +1 @@ +SELECT CAST(a, 'Bool') AS result FROM test_jit_bool WHERE a < 3 ORDER BY a diff --git a/tests/ast_json_fixtures/shapes/440073cf89b147d1.json b/tests/ast_json_fixtures/shapes/440073cf89b147d1.json new file mode 100644 index 000000000000..ffe4e48226ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/440073cf89b147d1.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q2_01297"], + "key_type": "CLIENT_KEY_OR_USER_NAME" + } +} diff --git a/tests/ast_json_fixtures/shapes/440073cf89b147d1.sql b/tests/ast_json_fixtures/shapes/440073cf89b147d1.sql new file mode 100644 index 000000000000..f75bb8d5f41d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/440073cf89b147d1.sql @@ -0,0 +1 @@ +ALTER QUOTA q2_01297 KEY BY client_key, user_name diff --git a/tests/ast_json_fixtures/shapes/440ca712a1ca775a.json b/tests/ast_json_fixtures/shapes/440ca712a1ca775a.json new file mode 100644 index 000000000000..feed7d96bbfa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/440ca712a1ca775a.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "arrays_out_02735" + }, + "as_table": "arrays_02735" + } +} diff --git a/tests/ast_json_fixtures/shapes/440ca712a1ca775a.sql b/tests/ast_json_fixtures/shapes/440ca712a1ca775a.sql new file mode 100644 index 000000000000..dfc4243265e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/440ca712a1ca775a.sql @@ -0,0 +1 @@ +create temporary table arrays_out_02735 as arrays_02735 diff --git a/tests/ast_json_fixtures/shapes/443997daab65e3f6.json b/tests/ast_json_fixtures/shapes/443997daab65e3f6.json new file mode 100644 index 000000000000..42c9a8631860 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/443997daab65e3f6.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "Int64", + "value": "-214748" + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/443997daab65e3f6.sql b/tests/ast_json_fixtures/shapes/443997daab65e3f6.sql new file mode 100644 index 000000000000..9ec55b2193c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/443997daab65e3f6.sql @@ -0,0 +1,3 @@ +SELECT DISTINCT number +FROM (SELECT number FROM numbers_mt(1000000) LIMIT -214748) +WHERE 0 diff --git a/tests/ast_json_fixtures/shapes/4442ee756c1f5385.json b/tests/ast_json_fixtures/shapes/4442ee756c1f5385.json new file mode 100644 index 000000000000..43c7225126c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4442ee756c1f5385.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q4_01297"], + "limits": [ + { + "duration_sec": "604800" + } + ], + "roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["u1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4442ee756c1f5385.sql b/tests/ast_json_fixtures/shapes/4442ee756c1f5385.sql new file mode 100644 index 000000000000..48ac46bbcd93 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4442ee756c1f5385.sql @@ -0,0 +1 @@ +CREATE QUOTA q4_01297 FOR 1 WEEK TRACKING ONLY TO ALL EXCEPT u1_01297 diff --git a/tests/ast_json_fixtures/shapes/444a72e1051779ff.json b/tests/ast_json_fixtures/shapes/444a72e1051779ff.json new file mode 100644 index 000000000000..2ca1c81e5bbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/444a72e1051779ff.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "if_exists": true, + "names": ["sqllt_role"] + } +} diff --git a/tests/ast_json_fixtures/shapes/444a72e1051779ff.sql b/tests/ast_json_fixtures/shapes/444a72e1051779ff.sql new file mode 100644 index 000000000000..c8e3bd3abea9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/444a72e1051779ff.sql @@ -0,0 +1 @@ +DROP ROLE IF EXISTS sqllt_role diff --git a/tests/ast_json_fixtures/shapes/44953c514ea8d6a4.json b/tests/ast_json_fixtures/shapes/44953c514ea8d6a4.json new file mode 100644 index 000000000000..3fa62c869773 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/44953c514ea8d6a4.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "tab" + } +} diff --git a/tests/ast_json_fixtures/shapes/44953c514ea8d6a4.sql b/tests/ast_json_fixtures/shapes/44953c514ea8d6a4.sql new file mode 100644 index 000000000000..3977f13cd131 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/44953c514ea8d6a4.sql @@ -0,0 +1 @@ +SHOW FIELDS FROM tab diff --git a/tests/ast_json_fixtures/shapes/449f9ccdfaabebd4.json b/tests/ast_json_fixtures/shapes/449f9ccdfaabebd4.json new file mode 100644 index 000000000000..6f8d346fb83a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/449f9ccdfaabebd4.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "primary_key_size" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parts", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "dist_idx_pk_size" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/449f9ccdfaabebd4.sql b/tests/ast_json_fixtures/shapes/449f9ccdfaabebd4.sql new file mode 100644 index 000000000000..8a04897c7eae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/449f9ccdfaabebd4.sql @@ -0,0 +1 @@ +select table, sum(primary_key_size) from system.parts where database = currentDatabase() AND table = 'dist_idx_pk_size' group by 1 diff --git a/tests/ast_json_fixtures/shapes/44a47a0cf62c9b1c.json b/tests/ast_json_fixtures/shapes/44a47a0cf62c9b1c.json new file mode 100644 index 000000000000..53740a0c74b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/44a47a0cf62c9b1c.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_STATISTICS", + "if_exists": true, + "statistics_declaration": { + "type": "Stat", + "columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "s" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/44a47a0cf62c9b1c.sql b/tests/ast_json_fixtures/shapes/44a47a0cf62c9b1c.sql new file mode 100644 index 000000000000..ed075243ef03 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/44a47a0cf62c9b1c.sql @@ -0,0 +1 @@ +ALTER TABLE tab DROP STATISTICS IF EXISTS s diff --git a/tests/ast_json_fixtures/shapes/44dc13ae4bda48a4.json b/tests/ast_json_fixtures/shapes/44dc13ae4bda48a4.json new file mode 100644 index 000000000000..b4dedfe74129 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/44dc13ae4bda48a4.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "alias": "value", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "u" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_sparse_full" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "alias": "k", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/44dc13ae4bda48a4.sql b/tests/ast_json_fixtures/shapes/44dc13ae4bda48a4.sql new file mode 100644 index 000000000000..095bc5b0ef74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/44dc13ae4bda48a4.sql @@ -0,0 +1 @@ +SELECT sum(u) AS value FROM t_sparse_full GROUP BY id % 3 AS k WITH ROLLUP ORDER BY value diff --git a/tests/ast_json_fixtures/shapes/44eb310248252696.json b/tests/ast_json_fixtures/shapes/44eb310248252696.json new file mode 100644 index 000000000000..c6cdb4a4b919 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/44eb310248252696.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s1_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/44eb310248252696.sql b/tests/ast_json_fixtures/shapes/44eb310248252696.sql new file mode 100644 index 000000000000..aa7c7f237e01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/44eb310248252696.sql @@ -0,0 +1 @@ +DROP SETTINGS PROFILE s1_01294 diff --git a/tests/ast_json_fixtures/shapes/4506dc60117ee597.json b/tests/ast_json_fixtures/shapes/4506dc60117ee597.json new file mode 100644 index 000000000000..f6bf7db81df7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4506dc60117ee597.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH ASYNC INSERT QUEUE", + "tables": [ + { + "table": "table2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4506dc60117ee597.sql b/tests/ast_json_fixtures/shapes/4506dc60117ee597.sql new file mode 100644 index 000000000000..697f1d11ff76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4506dc60117ee597.sql @@ -0,0 +1 @@ +SYSTEM FLUSH ASYNC INSERT QUEUE table2 diff --git a/tests/ast_json_fixtures/shapes/450e35eb29b45540.json b/tests/ast_json_fixtures/shapes/450e35eb29b45540.json new file mode 100644 index 000000000000..301f41ce091d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/450e35eb29b45540.json @@ -0,0 +1,111 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "sum", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "w" + }, + { + "type": "Function", + "alias": "y", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "w" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Identifier", + "name": "t_01568" + } + ] + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "p" + } + ] + } + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "y" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/450e35eb29b45540.sql b/tests/ast_json_fixtures/shapes/450e35eb29b45540.sql new file mode 100644 index 000000000000..41f3c1fb645d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/450e35eb29b45540.sql @@ -0,0 +1 @@ +select sum(number) over w as x, max(number) over w as y from remote('127.0.0.{1,2}', '', t_01568) window w as (partition by p) order by x, y SETTINGS max_threads = 1 diff --git a/tests/ast_json_fixtures/shapes/4524d56aa0cf4922.json b/tests/ast_json_fixtures/shapes/4524d56aa0cf4922.json new file mode 100644 index 000000000000..1299b59e29fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4524d56aa0cf4922.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowSetting", + "setting_name": "output_format_pretty_color" + } +} diff --git a/tests/ast_json_fixtures/shapes/4524d56aa0cf4922.sql b/tests/ast_json_fixtures/shapes/4524d56aa0cf4922.sql new file mode 100644 index 000000000000..e54c7c39dc30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4524d56aa0cf4922.sql @@ -0,0 +1 @@ +SHOW SETTING output_format_pretty_color diff --git a/tests/ast_json_fixtures/shapes/453aeeaa8d520637.json b/tests/ast_json_fixtures/shapes/453aeeaa8d520637.json new file mode 100644 index 000000000000..0a0ef8beeecf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/453aeeaa8d520637.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "01504_test_memory" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "01504_test" + } +} diff --git a/tests/ast_json_fixtures/shapes/453aeeaa8d520637.sql b/tests/ast_json_fixtures/shapes/453aeeaa8d520637.sql new file mode 100644 index 000000000000..1cd05a950fc9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/453aeeaa8d520637.sql @@ -0,0 +1 @@ +CREATE TABLE 01504_test_memory AS 01504_test Engine = Memory diff --git a/tests/ast_json_fixtures/shapes/453ff8be3e595b15.json b/tests/ast_json_fixtures/shapes/453ff8be3e595b15.json new file mode 100644 index 000000000000..1000345921a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/453ff8be3e595b15.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "array", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "array", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/453ff8be3e595b15.sql b/tests/ast_json_fixtures/shapes/453ff8be3e595b15.sql new file mode 100644 index 000000000000..b38b5b42489c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/453ff8be3e595b15.sql @@ -0,0 +1 @@ +select array(d) from test group by array(d) order by all diff --git a/tests/ast_json_fixtures/shapes/454127db0138ea9e.json b/tests/ast_json_fixtures/shapes/454127db0138ea9e.json new file mode 100644 index 000000000000..0eae26fd6d0b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/454127db0138ea9e.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "t0_tmp", + "to_table": "t1", + "if_exists": true + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/454127db0138ea9e.sql b/tests/ast_json_fixtures/shapes/454127db0138ea9e.sql new file mode 100644 index 000000000000..8c641defc908 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/454127db0138ea9e.sql @@ -0,0 +1 @@ +RENAME TABLE if exists t0_tmp TO t1 diff --git a/tests/ast_json_fixtures/shapes/4562641aa804fbac.json b/tests/ast_json_fixtures/shapes/4562641aa804fbac.json new file mode 100644 index 000000000000..141ba66c5ce6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4562641aa804fbac.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "02681_undrop_uuid_on_cluster" + }, + "format": "Null", + "cluster": "test_shard_localhost", + "if_exists": true, + "sync": true + } +} diff --git a/tests/ast_json_fixtures/shapes/4562641aa804fbac.sql b/tests/ast_json_fixtures/shapes/4562641aa804fbac.sql new file mode 100644 index 000000000000..47bfe0ad67d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4562641aa804fbac.sql @@ -0,0 +1 @@ +drop table if exists 02681_undrop_uuid_on_cluster on cluster test_shard_localhost sync format Null diff --git a/tests/ast_json_fixtures/shapes/4575e83819117265.json b/tests/ast_json_fixtures/shapes/4575e83819117265.json new file mode 100644 index 000000000000..dd4a75b84112 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4575e83819117265.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "table1" + } + } + } + ] + } + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/4575e83819117265.sql b/tests/ast_json_fixtures/shapes/4575e83819117265.sql new file mode 100644 index 000000000000..51b4a05efcdc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4575e83819117265.sql @@ -0,0 +1 @@ +SELECT * FROM table1 t1 FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/45a26cc8c8dc1ed4.json b/tests/ast_json_fixtures/shapes/45a26cc8c8dc1ed4.json new file mode 100644 index 000000000000..141564e7eaf6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45a26cc8c8dc1ed4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02484_plusthreedays", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/45a26cc8c8dc1ed4.sql b/tests/ast_json_fixtures/shapes/45a26cc8c8dc1ed4.sql new file mode 100644 index 000000000000..9aa1753f2307 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45a26cc8c8dc1ed4.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02484_plusthreedays diff --git a/tests/ast_json_fixtures/shapes/45a77500a3f7ca20.json b/tests/ast_json_fixtures/shapes/45a77500a3f7ca20.json new file mode 100644 index 000000000000..59ecf8a7370e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45a77500a3f7ca20.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "DESC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/45a77500a3f7ca20.sql b/tests/ast_json_fixtures/shapes/45a77500a3f7ca20.sql new file mode 100644 index 000000000000..ebd9a50ac300 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45a77500a3f7ca20.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number order by number desc diff --git a/tests/ast_json_fixtures/shapes/45b80711a7297726.json b/tests/ast_json_fixtures/shapes/45b80711a7297726.json new file mode 100644 index 000000000000..0f25a8606bab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45b80711a7297726.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "limit" + }, + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "World" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "LowCardinality(String)" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "String", + "value": "limit" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/45b80711a7297726.sql b/tests/ast_json_fixtures/shapes/45b80711a7297726.sql new file mode 100644 index 000000000000..9a5a83eb6c3b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45b80711a7297726.sql @@ -0,0 +1 @@ +SELECT cityHash64('limit', _CAST(materialize('World'), 'LowCardinality(String)')) FROM system.one GROUP BY GROUPING SETS ('limit') diff --git a/tests/ast_json_fixtures/shapes/45bc8abfb600e266.json b/tests/ast_json_fixtures/shapes/45bc8abfb600e266.json new file mode 100644 index 000000000000..3bc0f83a6d71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45bc8abfb600e266.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "d" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/45bc8abfb600e266.sql b/tests/ast_json_fixtures/shapes/45bc8abfb600e266.sql new file mode 100644 index 000000000000..fe6c78a6f9a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45bc8abfb600e266.sql @@ -0,0 +1 @@ +select * from test group by d order by all diff --git a/tests/ast_json_fixtures/shapes/45cea96bb56e98a8.json b/tests/ast_json_fixtures/shapes/45cea96bb56e98a8.json new file mode 100644 index 000000000000..369ce8daf161 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45cea96bb56e98a8.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "test_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "test_table" + } + } + ] + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "direct", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/45cea96bb56e98a8.sql b/tests/ast_json_fixtures/shapes/45cea96bb56e98a8.sql new file mode 100644 index 000000000000..ece00c5c9865 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45cea96bb56e98a8.sql @@ -0,0 +1 @@ +CREATE DICTIONARY test_dictionary (id UInt64) PRIMARY KEY id LAYOUT(DIRECT()) SOURCE(CLICKHOUSE(TABLE 'test_table')) diff --git a/tests/ast_json_fixtures/shapes/45e539498985cc92.json b/tests/ast_json_fixtures/shapes/45e539498985cc92.json new file mode 100644 index 000000000000..68b55b33e0f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45e539498985cc92.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "alter_01355" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "first": true, + "column_declaration": { + "type": "ColumnDeclaration", + "name": "Added2", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/45e539498985cc92.sql b/tests/ast_json_fixtures/shapes/45e539498985cc92.sql new file mode 100644 index 000000000000..37a082e27ca9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45e539498985cc92.sql @@ -0,0 +1 @@ +ALTER TABLE alter_01355 MODIFY COLUMN Added2 UInt32 FIRST diff --git a/tests/ast_json_fixtures/shapes/45eb920ac9b66112.json b/tests/ast_json_fixtures/shapes/45eb920ac9b66112.json new file mode 100644 index 000000000000..eb52584170f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45eb920ac9b66112.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/45eb920ac9b66112.sql b/tests/ast_json_fixtures/shapes/45eb920ac9b66112.sql new file mode 100644 index 000000000000..a5f81f547517 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/45eb920ac9b66112.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/46038ed8ba1205b7.json b/tests/ast_json_fixtures/shapes/46038ed8ba1205b7.json new file mode 100644 index 000000000000..dd14aa710983 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46038ed8ba1205b7.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR TEXT INDEX CACHES" + } +} diff --git a/tests/ast_json_fixtures/shapes/46038ed8ba1205b7.sql b/tests/ast_json_fixtures/shapes/46038ed8ba1205b7.sql new file mode 100644 index 000000000000..fcc5febc1cb8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46038ed8ba1205b7.sql @@ -0,0 +1 @@ +SYSTEM CLEAR TEXT INDEX CACHES diff --git a/tests/ast_json_fixtures/shapes/4614c01fe80fd772.json b/tests/ast_json_fixtures/shapes/4614c01fe80fd772.json new file mode 100644 index 000000000000..89ae89f890b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4614c01fe80fd772.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01223" + } + } + } + ] + }, + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4614c01fe80fd772.sql b/tests/ast_json_fixtures/shapes/4614c01fe80fd772.sql new file mode 100644 index 000000000000..69768635a527 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4614c01fe80fd772.sql @@ -0,0 +1 @@ +select * from dist_01223 having key = 1 diff --git a/tests/ast_json_fixtures/shapes/46198b5f00c922dc.json b/tests/ast_json_fixtures/shapes/46198b5f00c922dc.json new file mode 100644 index 000000000000..54a30cc69930 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46198b5f00c922dc.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q12_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "EXECUTION_TIME": "12582912000000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/46198b5f00c922dc.sql b/tests/ast_json_fixtures/shapes/46198b5f00c922dc.sql new file mode 100644 index 000000000000..71e2f675a0a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46198b5f00c922dc.sql @@ -0,0 +1 @@ +CREATE QUOTA q12_01297 FOR INTERVAL 1 MINUTE MAX execution_time = '12Mi' diff --git a/tests/ast_json_fixtures/shapes/4625a810266b6989.json b/tests/ast_json_fixtures/shapes/4625a810266b6989.json new file mode 100644 index 000000000000..ab2d83c92fbb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4625a810266b6989.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_exact" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Identifier", + "name": "c0" + } + ], + "having": { + "type": "Identifier", + "name": "c0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4625a810266b6989.sql b/tests/ast_json_fixtures/shapes/4625a810266b6989.sql new file mode 100644 index 000000000000..d965a2836efa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4625a810266b6989.sql @@ -0,0 +1 @@ +SELECT c1 FROM t_exact GROUP BY c1, c0 HAVING c0 diff --git a/tests/ast_json_fixtures/shapes/4649b94eb1091d40.json b/tests/ast_json_fixtures/shapes/4649b94eb1091d40.json new file mode 100644 index 000000000000..27af764a8503 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4649b94eb1091d40.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_layer_01223" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01223" + } + ] + } + }, + "as_table": "data_01223" + } +} diff --git a/tests/ast_json_fixtures/shapes/4649b94eb1091d40.sql b/tests/ast_json_fixtures/shapes/4649b94eb1091d40.sql new file mode 100644 index 000000000000..1c3d228541ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4649b94eb1091d40.sql @@ -0,0 +1 @@ +create table dist_layer_01223 as data_01223 Engine=Distributed(test_shard_localhost, currentDatabase(), data_01223) diff --git a/tests/ast_json_fixtures/shapes/46643e7ec0e91aa2.json b/tests/ast_json_fixtures/shapes/46643e7ec0e91aa2.json new file mode 100644 index 000000000000..606c7f189a64 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46643e7ec0e91aa2.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateViewQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "tview_basic" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/46643e7ec0e91aa2.sql b/tests/ast_json_fixtures/shapes/46643e7ec0e91aa2.sql new file mode 100644 index 000000000000..4196ec2ab455 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46643e7ec0e91aa2.sql @@ -0,0 +1 @@ +SHOW TEMPORARY VIEW tview_basic diff --git a/tests/ast_json_fixtures/shapes/4668198d2a65121f.json b/tests/ast_json_fixtures/shapes/4668198d2a65121f.json new file mode 100644 index 000000000000..c3158c3fefda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4668198d2a65121f.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q5_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/4668198d2a65121f.sql b/tests/ast_json_fixtures/shapes/4668198d2a65121f.sql new file mode 100644 index 000000000000..c0eb1ae7ad6f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4668198d2a65121f.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q5_01297 diff --git a/tests/ast_json_fixtures/shapes/4675383d23824697.json b/tests/ast_json_fixtures/shapes/4675383d23824697.json new file mode 100644 index 000000000000..1031d457f6d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4675383d23824697.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "demo_loan_01568_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards_different_databases" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "value_type": "String", + "value": "demo_loan_01568" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + }, + "as_database": "shard_0", + "as_table": "demo_loan_01568" + } +} diff --git a/tests/ast_json_fixtures/shapes/4675383d23824697.sql b/tests/ast_json_fixtures/shapes/4675383d23824697.sql new file mode 100644 index 000000000000..5299b9bb15e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4675383d23824697.sql @@ -0,0 +1 @@ +CREATE TABLE demo_loan_01568_dist AS shard_0.demo_loan_01568 ENGINE=Distributed('test_cluster_two_shards_different_databases', '', 'demo_loan_01568', id % 2) diff --git a/tests/ast_json_fixtures/shapes/468d4fecb2433d3e.json b/tests/ast_json_fixtures/shapes/468d4fecb2433d3e.json new file mode 100644 index 000000000000..4b603c1a3ba2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/468d4fecb2433d3e.json @@ -0,0 +1,110 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "99" + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "having": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "argMax", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/468d4fecb2433d3e.sql b/tests/ast_json_fixtures/shapes/468d4fecb2433d3e.sql new file mode 100644 index 000000000000..ec43be9eab3d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/468d4fecb2433d3e.sql @@ -0,0 +1 @@ +SELECT 1 FROM remote('127.0.0.{1,2}', numbers(99)) GROUP BY materialize(1) HAVING count() > 0 AND argMax(1, tuple(0)) diff --git a/tests/ast_json_fixtures/shapes/46983d2d1f8e488a.json b/tests/ast_json_fixtures/shapes/46983d2d1f8e488a.json new file mode 100644 index 000000000000..a8f5981da75b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46983d2d1f8e488a.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "DISABLE FAILPOINT", + "fail_point_name": "mt_select_parts_to_mutate_no_free_threads" + } +} diff --git a/tests/ast_json_fixtures/shapes/46983d2d1f8e488a.sql b/tests/ast_json_fixtures/shapes/46983d2d1f8e488a.sql new file mode 100644 index 000000000000..9a555cabc982 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46983d2d1f8e488a.sql @@ -0,0 +1 @@ +SYSTEM DISABLE FAILPOINT mt_select_parts_to_mutate_no_free_threads diff --git a/tests/ast_json_fixtures/shapes/46b51d10092cd218.json b/tests/ast_json_fixtures/shapes/46b51d10092cd218.json new file mode 100644 index 000000000000..88c3a249e15c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46b51d10092cd218.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t_remove_sample_by" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "id" + }, + "sample_by": { + "type": "Identifier", + "name": "id" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/46b51d10092cd218.sql b/tests/ast_json_fixtures/shapes/46b51d10092cd218.sql new file mode 100644 index 000000000000..0c742a0bb2e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46b51d10092cd218.sql @@ -0,0 +1 @@ +CREATE TABLE t_remove_sample_by(id UInt64) ENGINE = MergeTree ORDER BY id SAMPLE BY id diff --git a/tests/ast_json_fixtures/shapes/46d5cd2d0d4060d5.json b/tests/ast_json_fixtures/shapes/46d5cd2d0d4060d5.json new file mode 100644 index 000000000000..cf9f312f1cc3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46d5cd2d0d4060d5.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tt7" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "value_type": "String", + "value": "tt6" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "tt6" + } +} diff --git a/tests/ast_json_fixtures/shapes/46d5cd2d0d4060d5.sql b/tests/ast_json_fixtures/shapes/46d5cd2d0d4060d5.sql new file mode 100644 index 000000000000..cecfa78becb2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46d5cd2d0d4060d5.sql @@ -0,0 +1 @@ +CREATE TABLE tt7 as tt6 ENGINE = Distributed('test_shard_localhost', '', 'tt6', rand()) diff --git a/tests/ast_json_fixtures/shapes/46da47de5d7df393.json b/tests/ast_json_fixtures/shapes/46da47de5d7df393.json new file mode 100644 index 000000000000..83b3822cbaac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46da47de5d7df393.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "if_exists": true, + "names": ["test_role_01999_1"] + } +} diff --git a/tests/ast_json_fixtures/shapes/46da47de5d7df393.sql b/tests/ast_json_fixtures/shapes/46da47de5d7df393.sql new file mode 100644 index 000000000000..a52526fe8169 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46da47de5d7df393.sql @@ -0,0 +1 @@ +DROP ROLE IF EXISTS test_role_01999_1 diff --git a/tests/ast_json_fixtures/shapes/46dbc77a5d071043.json b/tests/ast_json_fixtures/shapes/46dbc77a5d071043.json new file mode 100644 index 000000000000..8a34010be707 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46dbc77a5d071043.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Function", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "CounterID" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/46dbc77a5d071043.sql b/tests/ast_json_fixtures/shapes/46dbc77a5d071043.sql new file mode 100644 index 000000000000..186135c19ab9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46dbc77a5d071043.sql @@ -0,0 +1 @@ +SELECT CounterID, uniq(UserID) FROM test.hits WHERE 0 != 0 GROUP BY CounterID SETTINGS optimize_aggregation_in_order = 1 diff --git a/tests/ast_json_fixtures/shapes/46ef7eef1678e0a3.json b/tests/ast_json_fixtures/shapes/46ef7eef1678e0a3.json new file mode 100644 index 000000000000..1600d65ba197 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46ef7eef1678e0a3.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "view_table_00942", + "to_table": "new_view_table_00942" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/46ef7eef1678e0a3.sql b/tests/ast_json_fixtures/shapes/46ef7eef1678e0a3.sql new file mode 100644 index 000000000000..f6638cc284fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46ef7eef1678e0a3.sql @@ -0,0 +1 @@ +RENAME TABLE view_table_00942 TO new_view_table_00942 diff --git a/tests/ast_json_fixtures/shapes/46f2c19a73304b28.json b/tests/ast_json_fixtures/shapes/46f2c19a73304b28.json new file mode 100644 index 000000000000..a6d83812f5cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46f2c19a73304b28.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "w" + }, + { + "type": "Function", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "w" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_01568" + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "p" + } + ] + } + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "p" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/46f2c19a73304b28.sql b/tests/ast_json_fixtures/shapes/46f2c19a73304b28.sql new file mode 100644 index 000000000000..22e80d5a9e26 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46f2c19a73304b28.sql @@ -0,0 +1 @@ +select sum(number) over w, max(number) over w from t_01568 window w as (partition by p) order by p diff --git a/tests/ast_json_fixtures/shapes/46facddbb5e629dd.json b/tests/ast_json_fixtures/shapes/46facddbb5e629dd.json new file mode 100644 index 000000000000..90d4ab82d6d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46facddbb5e629dd.json @@ -0,0 +1,140 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "alias": "using_id", + "name": "id" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "using_id" + } + ] + }, + { + "type": "Identifier", + "alias": "t1_id", + "name": "t1.id", + "name_parts": ["t1", "id"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t1_id" + } + ] + }, + { + "type": "Identifier", + "alias": "t1_value", + "name": "t1.value", + "name_parts": ["t1", "value"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t1_value" + } + ] + }, + { + "type": "Identifier", + "alias": "t2_id", + "name": "t2.id", + "name_parts": ["t2", "id"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t2_id" + } + ] + }, + { + "type": "Identifier", + "alias": "t2_value", + "name": "t2.value", + "name_parts": ["t2", "value"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t2_value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "test_table_join_1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "using": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "test_table_join_2" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/46facddbb5e629dd.sql b/tests/ast_json_fixtures/shapes/46facddbb5e629dd.sql new file mode 100644 index 000000000000..7cabc4cb640b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/46facddbb5e629dd.sql @@ -0,0 +1,3 @@ +SELECT id AS using_id, toTypeName(using_id), t1.id AS t1_id, toTypeName(t1_id), t1.value AS t1_value, toTypeName(t1_value), +t2.id AS t2_id, toTypeName(t2_id), t2.value AS t2_value, toTypeName(t2_value) +FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 USING (id) ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/471a72763217a52e.json b/tests/ast_json_fixtures/shapes/471a72763217a52e.json new file mode 100644 index 000000000000..e837c0ffbf61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/471a72763217a52e.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_rows_wide_part" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "exact_rows_before_limit": "0", + "output_format_write_statistics": "0" + } + }, + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/471a72763217a52e.sql b/tests/ast_json_fixtures/shapes/471a72763217a52e.sql new file mode 100644 index 000000000000..189b62c769ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/471a72763217a52e.sql @@ -0,0 +1 @@ +select 0 from test_rows_wide_part limit 1 FORMAT JSONCompact settings exact_rows_before_limit = 0,output_format_write_statistics = 0 diff --git a/tests/ast_json_fixtures/shapes/471f479a1e567905.json b/tests/ast_json_fixtures/shapes/471f479a1e567905.json new file mode 100644 index 000000000000..a010600f5e80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/471f479a1e567905.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "database": { + "type": "Identifier", + "name": "'" + }, + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/471f479a1e567905.sql b/tests/ast_json_fixtures/shapes/471f479a1e567905.sql new file mode 100644 index 000000000000..c370da7bf466 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/471f479a1e567905.sql @@ -0,0 +1 @@ +DROP DATABASE IF EXISTS `'` diff --git a/tests/ast_json_fixtures/shapes/4724769f2c41cc64.json b/tests/ast_json_fixtures/shapes/4724769f2c41cc64.json new file mode 100644 index 000000000000..20990a6a1237 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4724769f2c41cc64.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN QUERY TREE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "alias": "a", + "name": "number" + }, + { + "type": "Function", + "alias": "b", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + } + ] + } + ] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/4724769f2c41cc64.sql b/tests/ast_json_fixtures/shapes/4724769f2c41cc64.sql new file mode 100644 index 000000000000..55d69fdcb802 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4724769f2c41cc64.sql @@ -0,0 +1,5 @@ +EXPLAIN QUERY TREE +SELECT a, b +FROM numbers(3) +GROUP BY number as a, (number + number) as b WITH CUBE +ORDER BY a, b format Null diff --git a/tests/ast_json_fixtures/shapes/472dbdb27d3743a8.json b/tests/ast_json_fixtures/shapes/472dbdb27d3743a8.json new file mode 100644 index 000000000000..ab6403f8b5ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/472dbdb27d3743a8.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/472dbdb27d3743a8.sql b/tests/ast_json_fixtures/shapes/472dbdb27d3743a8.sql new file mode 100644 index 000000000000..121264fa234e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/472dbdb27d3743a8.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) ORDER BY number FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/474bf07017e49a28.json b/tests/ast_json_fixtures/shapes/474bf07017e49a28.json new file mode 100644 index 000000000000..6e278840c9ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/474bf07017e49a28.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "neighbor", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/474bf07017e49a28.sql b/tests/ast_json_fixtures/shapes/474bf07017e49a28.sql new file mode 100644 index 000000000000..26d789175a30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/474bf07017e49a28.sql @@ -0,0 +1 @@ +SELECT number, neighbor(number, 2) FROM system.numbers LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/475442e420ca25b4.json b/tests/ast_json_fixtures/shapes/475442e420ca25b4.json new file mode 100644 index 000000000000..4b7767e25251 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/475442e420ca25b4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/475442e420ca25b4.sql b/tests/ast_json_fixtures/shapes/475442e420ca25b4.sql new file mode 100644 index 000000000000..d7165b4e4f5a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/475442e420ca25b4.sql @@ -0,0 +1 @@ +DROP ROLE r1_01294 diff --git a/tests/ast_json_fixtures/shapes/475c0a97d6841816.json b/tests/ast_json_fixtures/shapes/475c0a97d6841816.json new file mode 100644 index 000000000000..5659e952be01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/475c0a97d6841816.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "query_log" + }, + { + "table": "query_thread_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/475c0a97d6841816.sql b/tests/ast_json_fixtures/shapes/475c0a97d6841816.sql new file mode 100644 index 000000000000..cf4354c18c35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/475c0a97d6841816.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS query_log, query_thread_log diff --git a/tests/ast_json_fixtures/shapes/477d7804ae7db087.json b/tests/ast_json_fixtures/shapes/477d7804ae7db087.json new file mode 100644 index 000000000000..e498ec24c982 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/477d7804ae7db087.json @@ -0,0 +1,83 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "from", + "value_type": "UInt64", + "value": "1" + } + ], + "select": [ + { + "type": "Identifier", + "name": "from" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "from" + }, + { + "type": "Identifier", + "name": "from" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "from" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/477d7804ae7db087.sql b/tests/ast_json_fixtures/shapes/477d7804ae7db087.sql new file mode 100644 index 000000000000..c167bc3ded3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/477d7804ae7db087.sql @@ -0,0 +1 @@ +WITH 1 as from SELECT from, from + from, from in [0], FROM numbers(1) diff --git a/tests/ast_json_fixtures/shapes/479505f5f8519a1f.json b/tests/ast_json_fixtures/shapes/479505f5f8519a1f.json new file mode 100644 index 000000000000..9a27e1f9b849 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/479505f5f8519a1f.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "cte_test_table_for_in", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table_for_in" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "value" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "cte_test_table_for_in" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/479505f5f8519a1f.sql b/tests/ast_json_fixtures/shapes/479505f5f8519a1f.sql new file mode 100644 index 000000000000..46795d4ebf32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/479505f5f8519a1f.sql @@ -0,0 +1 @@ +WITH cte_test_table_for_in AS (SELECT id FROM test_table_for_in) SELECT id, value FROM test_table WHERE id IN cte_test_table_for_in diff --git a/tests/ast_json_fixtures/shapes/4797de17b5ae2f90.json b/tests/ast_json_fixtures/shapes/4797de17b5ae2f90.json new file mode 100644 index 000000000000..ef2350d808c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4797de17b5ae2f90.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettySpaceNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/4797de17b5ae2f90.sql b/tests/ast_json_fixtures/shapes/4797de17b5ae2f90.sql new file mode 100644 index 000000000000..5cdb33f71802 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4797de17b5ae2f90.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettySpaceNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/47a7c05696e5b979.json b/tests/ast_json_fixtures/shapes/47a7c05696e5b979.json new file mode 100644 index 000000000000..271caf70fcb3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47a7c05696e5b979.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TSVRawWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/47a7c05696e5b979.sql b/tests/ast_json_fixtures/shapes/47a7c05696e5b979.sql new file mode 100644 index 000000000000..b992cc364b25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47a7c05696e5b979.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TSVRawWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/47b23a7730e99725.json b/tests/ast_json_fixtures/shapes/47b23a7730e99725.json new file mode 100644 index 000000000000..fccf359b3dd3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47b23a7730e99725.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "column": { + "type": "Identifier", + "name": "j" + }, + "rename_to": { + "type": "Identifier", + "name": "k" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/47b23a7730e99725.sql b/tests/ast_json_fixtures/shapes/47b23a7730e99725.sql new file mode 100644 index 000000000000..bcdae75a00e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47b23a7730e99725.sql @@ -0,0 +1 @@ +alter table t rename column j to k diff --git a/tests/ast_json_fixtures/shapes/47c38c7f64275959.json b/tests/ast_json_fixtures/shapes/47c38c7f64275959.json new file mode 100644 index 000000000000..d1c1357ac2ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47c38c7f64275959.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "_file" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "s3", + "arguments": [ + { + "type": "Identifier", + "name": "s3_conn" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "filename" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test_02495_1" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "format" + }, + { + "type": "Identifier", + "name": "Parquet" + } + ] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_file" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test_02495_1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/47c38c7f64275959.sql b/tests/ast_json_fixtures/shapes/47c38c7f64275959.sql new file mode 100644 index 000000000000..09ef36fd10e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47c38c7f64275959.sql @@ -0,0 +1,3 @@ +SELECT *, _file +FROM s3(s3_conn, filename = 'test_02495_1', format = Parquet) +WHERE _file = 'test_02495_1' diff --git a/tests/ast_json_fixtures/shapes/47cae42d442d9795.json b/tests/ast_json_fixtures/shapes/47cae42d442d9795.json new file mode 100644 index 000000000000..6e46619a1612 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47cae42d442d9795.json @@ -0,0 +1,1283 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_bloom_filter_index" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "WatchID", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "JavaEnable", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "Title", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "GoodEvent", + "data_type": { + "type": "DataType", + "name": "Int16" + } + }, + { + "type": "ColumnDeclaration", + "name": "EventTime", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "EventDate", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "CounterID", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "ClientIP", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "ClientIP6", + "data_type": { + "type": "DataType", + "name": "FixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "RegionID", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "UserID", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "CounterClass", + "data_type": { + "type": "DataType", + "name": "Int8" + } + }, + { + "type": "ColumnDeclaration", + "name": "OS", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "UserAgent", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "URL", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "Referer", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "URLDomain", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "RefererDomain", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "Refresh", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "IsRobot", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "RefererCategories", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt16" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "URLCategories", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt16" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "URLRegions", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt32" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "RefererRegions", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt32" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "ResolutionWidth", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "ResolutionHeight", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "ResolutionDepth", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "FlashMajor", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "FlashMinor", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "FlashMinor2", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "NetMajor", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "NetMinor", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "UserAgentMajor", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "UserAgentMinor", + "data_type": { + "type": "DataType", + "name": "FixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "CookieEnable", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "JavascriptEnable", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "IsMobile", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "MobilePhone", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "MobilePhoneModel", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "Params", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "IPNetworkID", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "TraficSourceID", + "data_type": { + "type": "DataType", + "name": "Int8" + } + }, + { + "type": "ColumnDeclaration", + "name": "SearchEngineID", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "SearchPhrase", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "AdvEngineID", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "IsArtifical", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "WindowClientWidth", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "WindowClientHeight", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "ClientTimeZone", + "data_type": { + "type": "DataType", + "name": "Int16" + } + }, + { + "type": "ColumnDeclaration", + "name": "ClientEventTime", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "SilverlightVersion1", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "SilverlightVersion2", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "SilverlightVersion3", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "SilverlightVersion4", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "PageCharset", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "CodeVersion", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "IsLink", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "IsDownload", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "IsNotBounce", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "FUniqID", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "HID", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "IsOldCounter", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "IsEvent", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "IsParameter", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "DontCountHits", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "WithHash", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "HitColor", + "data_type": { + "type": "DataType", + "name": "FixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "UTCEventTime", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "Age", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "Sex", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "Income", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "Interests", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "Robotness", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "GeneralInterests", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt16" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "RemoteIP", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "RemoteIP6", + "data_type": { + "type": "DataType", + "name": "FixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "WindowName", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "OpenerName", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "HistoryLength", + "data_type": { + "type": "DataType", + "name": "Int16" + } + }, + { + "type": "ColumnDeclaration", + "name": "BrowserLanguage", + "data_type": { + "type": "DataType", + "name": "FixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "BrowserCountry", + "data_type": { + "type": "DataType", + "name": "FixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "SocialNetwork", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "SocialAction", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "HTTPError", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "SendTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "DNSTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "ConnectTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "ResponseStartTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "ResponseEndTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "FetchTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "RedirectTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "DOMInteractiveTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "DOMContentLoadedTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "DOMCompleteTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "LoadEventStartTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "LoadEventEndTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "NSToDOMContentLoadedTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "FirstPaintTiming", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "RedirectCount", + "data_type": { + "type": "DataType", + "name": "Int8" + } + }, + { + "type": "ColumnDeclaration", + "name": "SocialSourceNetworkID", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "SocialSourcePage", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "ParamPrice", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "ParamOrderID", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "ParamCurrency", + "data_type": { + "type": "DataType", + "name": "FixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "ParamCurrencyID", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "GoalsReached", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt32" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "OpenstatServiceName", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "OpenstatCampaignID", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "OpenstatAdID", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "OpenstatSourceID", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "UTMSource", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "UTMMedium", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "UTMCampaign", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "UTMContent", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "UTMTerm", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "FromTag", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "HasGCLID", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "RefererHash", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "URLHash", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "CLID", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "YCLID", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "ShareService", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "ShareURL", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "ShareTitle", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "ParsedParams.Key1", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "ParsedParams.Key2", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "ParsedParams.Key3", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "ParsedParams.Key4", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "ParsedParams.Key5", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "ParsedParams.ValueDouble", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "Float64" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "IslandID", + "data_type": { + "type": "DataType", + "name": "FixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "RequestNum", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "RequestTry", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "test1", + "expression": { + "type": "Identifier", + "name": "RegionID" + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [] + }, + "granularity": 8129 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "EventDate" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Identifier", + "name": "EventDate" + }, + { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + } + ] + }, + "sample_by": { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/47cae42d442d9795.sql b/tests/ast_json_fixtures/shapes/47cae42d442d9795.sql new file mode 100644 index 000000000000..87c7cc4bc5fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47cae42d442d9795.sql @@ -0,0 +1 @@ +CREATE TABLE test_bloom_filter_index(`WatchID` UInt64, `JavaEnable` UInt8, `Title` String, `GoodEvent` Int16, `EventTime` DateTime, `EventDate` Date, `CounterID` UInt32, `ClientIP` UInt32, `ClientIP6` FixedString(16), `RegionID` UInt32, `UserID` UInt64, `CounterClass` Int8, `OS` UInt8, `UserAgent` UInt8, `URL` String, `Referer` String, `URLDomain` String, `RefererDomain` String, `Refresh` UInt8, `IsRobot` UInt8, `RefererCategories` Array(UInt16), `URLCategories` Array(UInt16), `URLRegions` Array(UInt32), `RefererRegions` Array(UInt32), `ResolutionWidth` UInt16, `ResolutionHeight` UInt16, `ResolutionDepth` UInt8, `FlashMajor` UInt8, `FlashMinor` UInt8, `FlashMinor2` String, `NetMajor` UInt8, `NetMinor` UInt8, `UserAgentMajor` UInt16, `UserAgentMinor` FixedString(2), `CookieEnable` UInt8, `JavascriptEnable` UInt8, `IsMobile` UInt8, `MobilePhone` UInt8, `MobilePhoneModel` String, `Params` String, `IPNetworkID` UInt32, `TraficSourceID` Int8, `SearchEngineID` UInt16, `SearchPhrase` String, `AdvEngineID` UInt8, `IsArtifical` UInt8, `WindowClientWidth` UInt16, `WindowClientHeight` UInt16, `ClientTimeZone` Int16, `ClientEventTime` DateTime, `SilverlightVersion1` UInt8, `SilverlightVersion2` UInt8, `SilverlightVersion3` UInt32, `SilverlightVersion4` UInt16, `PageCharset` String, `CodeVersion` UInt32, `IsLink` UInt8, `IsDownload` UInt8, `IsNotBounce` UInt8, `FUniqID` UInt64, `HID` UInt32, `IsOldCounter` UInt8, `IsEvent` UInt8, `IsParameter` UInt8, `DontCountHits` UInt8, `WithHash` UInt8, `HitColor` FixedString(1), `UTCEventTime` DateTime, `Age` UInt8, `Sex` UInt8, `Income` UInt8, `Interests` UInt16, `Robotness` UInt8, `GeneralInterests` Array(UInt16), `RemoteIP` UInt32, `RemoteIP6` FixedString(16), `WindowName` Int32, `OpenerName` Int32, `HistoryLength` Int16, `BrowserLanguage` FixedString(2), `BrowserCountry` FixedString(2), `SocialNetwork` String, `SocialAction` String, `HTTPError` UInt16, `SendTiming` Int32, `DNSTiming` Int32, `ConnectTiming` Int32, `ResponseStartTiming` Int32, `ResponseEndTiming` Int32, `FetchTiming` Int32, `RedirectTiming` Int32, `DOMInteractiveTiming` Int32, `DOMContentLoadedTiming` Int32, `DOMCompleteTiming` Int32, `LoadEventStartTiming` Int32, `LoadEventEndTiming` Int32, `NSToDOMContentLoadedTiming` Int32, `FirstPaintTiming` Int32, `RedirectCount` Int8, `SocialSourceNetworkID` UInt8, `SocialSourcePage` String, `ParamPrice` Int64, `ParamOrderID` String, `ParamCurrency` FixedString(3), `ParamCurrencyID` UInt16, `GoalsReached` Array(UInt32), `OpenstatServiceName` String, `OpenstatCampaignID` String, `OpenstatAdID` String, `OpenstatSourceID` String, `UTMSource` String, `UTMMedium` String, `UTMCampaign` String, `UTMContent` String, `UTMTerm` String, `FromTag` String, `HasGCLID` UInt8, `RefererHash` UInt64, `URLHash` UInt64, `CLID` UInt32, `YCLID` UInt64, `ShareService` String, `ShareURL` String, `ShareTitle` String, `ParsedParams.Key1` Array(String), `ParsedParams.Key2` Array(String), `ParsedParams.Key3` Array(String), `ParsedParams.Key4` Array(String), `ParsedParams.Key5` Array(String), `ParsedParams.ValueDouble` Array(Float64), `IslandID` FixedString(16), `RequestNum` UInt32, `RequestTry` UInt8, INDEX test1 RegionID TYPE bloom_filter GRANULARITY 8129) ENGINE = MergeTree() PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS index_granularity = 8192 diff --git a/tests/ast_json_fixtures/shapes/47e33aa7068738a9.json b/tests/ast_json_fixtures/shapes/47e33aa7068738a9.json new file mode 100644 index 000000000000..ec7b366b8268 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47e33aa7068738a9.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_explicit_ops" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "c", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_specifier": "DEFAULT", + "default_expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + }, + { + "type": "AlterCommand", + "command_type": "ADD_INDEX", + "index_declaration": { + "type": "Index", + "name": "idx_explicit_a", + "expression": { + "type": "Identifier", + "name": "a" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/47e33aa7068738a9.sql b/tests/ast_json_fixtures/shapes/47e33aa7068738a9.sql new file mode 100644 index 000000000000..d6473c627ede --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47e33aa7068738a9.sql @@ -0,0 +1 @@ +ALTER TABLE t_explicit_ops ADD COLUMN c UInt64 DEFAULT 0, ADD INDEX idx_explicit_a a TYPE minmax GRANULARITY 1 diff --git a/tests/ast_json_fixtures/shapes/47fa4c45968a35c7.json b/tests/ast_json_fixtures/shapes/47fa4c45968a35c7.json new file mode 100644 index 000000000000..e55ae37c9c5e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47fa4c45968a35c7.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s9_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/47fa4c45968a35c7.sql b/tests/ast_json_fixtures/shapes/47fa4c45968a35c7.sql new file mode 100644 index 000000000000..551f3456196c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/47fa4c45968a35c7.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s9_01294 diff --git a/tests/ast_json_fixtures/shapes/481639eee456730a.json b/tests/ast_json_fixtures/shapes/481639eee456730a.json new file mode 100644 index 000000000000..8a162e6a5824 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/481639eee456730a.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_ordinary_view": true, + "replace_view": true, + "table": { + "type": "Identifier", + "name": "t" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "next_number", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/481639eee456730a.sql b/tests/ast_json_fixtures/shapes/481639eee456730a.sql new file mode 100644 index 000000000000..153a926ca5a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/481639eee456730a.sql @@ -0,0 +1 @@ +CREATE OR REPLACE VIEW t AS SELECT number+1 AS next_number FROM system.numbers diff --git a/tests/ast_json_fixtures/shapes/4823327bd984c916.json b/tests/ast_json_fixtures/shapes/4823327bd984c916.json new file mode 100644 index 000000000000..d59cf088548c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4823327bd984c916.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "t_shared" + }, + "assignments": [ + { + "type": "Assignment", + "column": "c1", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ], + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4823327bd984c916.sql b/tests/ast_json_fixtures/shapes/4823327bd984c916.sql new file mode 100644 index 000000000000..ce093ca02fdd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4823327bd984c916.sql @@ -0,0 +1 @@ +UPDATE t_shared SET c1 = 100 WHERE id = 1 diff --git a/tests/ast_json_fixtures/shapes/48262b897a8c3c53.json b/tests/ast_json_fixtures/shapes/48262b897a8c3c53.json new file mode 100644 index 000000000000..7d9fe5be77e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48262b897a8c3c53.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + }, + "direction": "DESC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/48262b897a8c3c53.sql b/tests/ast_json_fixtures/shapes/48262b897a8c3c53.sql new file mode 100644 index 000000000000..149708954646 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48262b897a8c3c53.sql @@ -0,0 +1 @@ +SELECT 1 FROM t0 ORDER BY t0.c0 DESC FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/4830eb1a9f4a91fd.json b/tests/ast_json_fixtures/shapes/4830eb1a9f4a91fd.json new file mode 100644 index 000000000000..9fe53bcd5eec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4830eb1a9f4a91fd.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "b", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "alias": "c", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4830eb1a9f4a91fd.sql b/tests/ast_json_fixtures/shapes/4830eb1a9f4a91fd.sql new file mode 100644 index 000000000000..67bf0968301c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4830eb1a9f4a91fd.sql @@ -0,0 +1 @@ +SELECT (c + 1) as d, (a + 1) as b, 1 AS a, (b + 1) as c, d diff --git a/tests/ast_json_fixtures/shapes/484b750e2f5b58ed.json b/tests/ast_json_fixtures/shapes/484b750e2f5b58ed.json new file mode 100644 index 000000000000..809ed78ca491 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/484b750e2f5b58ed.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "03222_timeseries_table1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "TimeSeries", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/484b750e2f5b58ed.sql b/tests/ast_json_fixtures/shapes/484b750e2f5b58ed.sql new file mode 100644 index 000000000000..80bbe1395695 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/484b750e2f5b58ed.sql @@ -0,0 +1 @@ +CREATE TABLE 03222_timeseries_table1 ENGINE = TimeSeries FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/484dbb13ad1b76f8.json b/tests/ast_json_fixtures/shapes/484dbb13ad1b76f8.json new file mode 100644 index 000000000000..1074b3ffa7f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/484dbb13ad1b76f8.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tp_1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "y" + }, + "settings": { + "type": "Settings", + "changes": { + "old_parts_lifetime": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/484dbb13ad1b76f8.sql b/tests/ast_json_fixtures/shapes/484dbb13ad1b76f8.sql new file mode 100644 index 000000000000..8fd04edd88ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/484dbb13ad1b76f8.sql @@ -0,0 +1 @@ +create table tp_1 (x Int32, y Int32, projection p (select x, y order by x)) engine = MergeTree order by y partition by intDiv(y, 100) settings old_parts_lifetime=1 diff --git a/tests/ast_json_fixtures/shapes/4858fef04f626a9b.json b/tests/ast_json_fixtures/shapes/4858fef04f626a9b.json new file mode 100644 index 000000000000..914cd3b821ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4858fef04f626a9b.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "u" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_sparse_full" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "alias": "k", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4858fef04f626a9b.sql b/tests/ast_json_fixtures/shapes/4858fef04f626a9b.sql new file mode 100644 index 000000000000..0dd86a044662 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4858fef04f626a9b.sql @@ -0,0 +1 @@ +SELECT sum(u) FROM t_sparse_full GROUP BY id % 3 AS k WITH TOTALS ORDER BY k diff --git a/tests/ast_json_fixtures/shapes/4867397d049535af.json b/tests/ast_json_fixtures/shapes/4867397d049535af.json new file mode 100644 index 000000000000..e9c35420db38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4867397d049535af.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "age" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "users" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "age" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_write_statistics": "0" + } + }, + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/4867397d049535af.sql b/tests/ast_json_fixtures/shapes/4867397d049535af.sql new file mode 100644 index 000000000000..e9f9f5b49742 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4867397d049535af.sql @@ -0,0 +1 @@ +SELECT age FROM remote('127.0.0.{2,3}', currentDatabase(), users) GROUP BY age LIMIT 20 FORMAT JSON SETTINGS output_format_write_statistics=0 diff --git a/tests/ast_json_fixtures/shapes/487e45234550b2f0.json b/tests/ast_json_fixtures/shapes/487e45234550b2f0.json new file mode 100644 index 000000000000..744f43fadb59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/487e45234550b2f0.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "group_by": [ + { + "type": "Asterisk" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/487e45234550b2f0.sql b/tests/ast_json_fixtures/shapes/487e45234550b2f0.sql new file mode 100644 index 000000000000..bb07b76582d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/487e45234550b2f0.sql @@ -0,0 +1 @@ +SELECT * GROUP BY * diff --git a/tests/ast_json_fixtures/shapes/48af9965c10d7300.json b/tests/ast_json_fixtures/shapes/48af9965c10d7300.json new file mode 100644 index 000000000000..acefeb6c4991 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48af9965c10d7300.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u_03174_multiple_auth_show_create"] + } +} diff --git a/tests/ast_json_fixtures/shapes/48af9965c10d7300.sql b/tests/ast_json_fixtures/shapes/48af9965c10d7300.sql new file mode 100644 index 000000000000..9e4e38809dc0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48af9965c10d7300.sql @@ -0,0 +1 @@ +SHOW CREATE USER u_03174_multiple_auth_show_create diff --git a/tests/ast_json_fixtures/shapes/48c13e8be3a4b266.json b/tests/ast_json_fixtures/shapes/48c13e8be3a4b266.json new file mode 100644 index 000000000000..7c9cb2c3e977 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48c13e8be3a4b266.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "s3", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "http:\/\/localhost:9001\/foo\/{_partition_id}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "admin" + }, + { + "type": "Literal", + "value_type": "String", + "value": "admin" + }, + { + "type": "Literal", + "value_type": "String", + "value": "CSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "id Int32, val String" + } + ] + }, + "format": "Values", + "partition_by": { + "type": "Identifier", + "name": "val" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/48c13e8be3a4b266.sql b/tests/ast_json_fixtures/shapes/48c13e8be3a4b266.sql new file mode 100644 index 000000000000..c6aa1766717c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48c13e8be3a4b266.sql @@ -0,0 +1 @@ +INSERT INTO TABLE FUNCTION s3('http://localhost:9001/foo/{_partition_id}', 'admin', 'admin', 'CSV', 'id Int32, val String') PARTITION BY val VALUES (1, '') diff --git a/tests/ast_json_fixtures/shapes/48ca5c6a520c1cf8.json b/tests/ast_json_fixtures/shapes/48ca5c6a520c1cf8.json new file mode 100644 index 000000000000..33e02f767d43 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48ca5c6a520c1cf8.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "t1" + }, + "assignments": [ + { + "type": "Assignment", + "column": "c0", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + } + ], + "predicate": { + "type": "Literal", + "value_type": "Bool", + "value": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/48ca5c6a520c1cf8.sql b/tests/ast_json_fixtures/shapes/48ca5c6a520c1cf8.sql new file mode 100644 index 000000000000..f0f9eaecf58c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48ca5c6a520c1cf8.sql @@ -0,0 +1 @@ +UPDATE t1 SET c0 = () WHERE TRUE diff --git a/tests/ast_json_fixtures/shapes/48cfaaa218cd2d12.json b/tests/ast_json_fixtures/shapes/48cfaaa218cd2d12.json new file mode 100644 index 000000000000..535403ae646e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48cfaaa218cd2d12.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "replace_table": true, + "table": { + "type": "Identifier", + "name": "buf" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Null", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/48cfaaa218cd2d12.sql b/tests/ast_json_fixtures/shapes/48cfaaa218cd2d12.sql new file mode 100644 index 000000000000..d3eb91c9299a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48cfaaa218cd2d12.sql @@ -0,0 +1 @@ +replace table buf (n int) engine=Null diff --git a/tests/ast_json_fixtures/shapes/48d1298f20b0fc1e.json b/tests/ast_json_fixtures/shapes/48d1298f20b0fc1e.json new file mode 100644 index 000000000000..c6ebe41577bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48d1298f20b0fc1e.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["user_param_auth_03773"] + } +} diff --git a/tests/ast_json_fixtures/shapes/48d1298f20b0fc1e.sql b/tests/ast_json_fixtures/shapes/48d1298f20b0fc1e.sql new file mode 100644 index 000000000000..2a54fc1c3b89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48d1298f20b0fc1e.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS user_param_auth_03773 diff --git a/tests/ast_json_fixtures/shapes/48f941a787c9cdaf.json b/tests/ast_json_fixtures/shapes/48f941a787c9cdaf.json new file mode 100644 index 000000000000..31d0d8cd44f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48f941a787c9cdaf.json @@ -0,0 +1,147 @@ +{ + "version": 2, + "ast": { + "type": "ParallelWithQuery", + "children": [ + { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "table1" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + } + ] + } + }, + { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "table1" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + } + } + ] + } + }, + { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "table2" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/48f941a787c9cdaf.sql b/tests/ast_json_fixtures/shapes/48f941a787c9cdaf.sql new file mode 100644 index 000000000000..032dc7448a41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48f941a787c9cdaf.sql @@ -0,0 +1,5 @@ +INSERT INTO table1 SELECT number FROM numbers(3) +PARALLEL WITH +INSERT INTO table1 SELECT number FROM numbers(10, 2) +PARALLEL WITH +INSERT INTO table2 SELECT number FROM numbers(20, 1) diff --git a/tests/ast_json_fixtures/shapes/48fe9dc36ccbb219.json b/tests/ast_json_fixtures/shapes/48fe9dc36ccbb219.json new file mode 100644 index 000000000000..fad3f6ce9a0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48fe9dc36ccbb219.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "view_name" + }, + { + "type": "Identifier", + "name": "read_rows" + }, + { + "type": "Identifier", + "name": "read_bytes" + }, + { + "type": "Identifier", + "name": "written_rows" + }, + { + "type": "Identifier", + "name": "written_bytes" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_views_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "startsWith", + "arguments": [ + { + "type": "Identifier", + "name": "view_name" + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".mv" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "view_name" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/48fe9dc36ccbb219.sql b/tests/ast_json_fixtures/shapes/48fe9dc36ccbb219.sql new file mode 100644 index 000000000000..176a8483b856 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/48fe9dc36ccbb219.sql @@ -0,0 +1 @@ +select view_name, read_rows, read_bytes, written_rows, written_bytes from system.query_views_log where startsWith(view_name, currentDatabase() || '.mv') order by view_name format Vertical diff --git a/tests/ast_json_fixtures/shapes/49042449610f584c.json b/tests/ast_json_fixtures/shapes/49042449610f584c.json new file mode 100644 index 000000000000..6a88fb7a2bd7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49042449610f584c.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_clone_as": true, + "table": { + "type": "Identifier", + "name": "clone_as_foo_merge_tree_p_x" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "x" + } + }, + "as_table": "foo_merge_tree" + } +} diff --git a/tests/ast_json_fixtures/shapes/49042449610f584c.sql b/tests/ast_json_fixtures/shapes/49042449610f584c.sql new file mode 100644 index 000000000000..a184cc49e7c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49042449610f584c.sql @@ -0,0 +1 @@ +CREATE TABLE clone_as_foo_merge_tree_p_x CLONE AS foo_merge_tree ENGINE=MergeTree PRIMARY KEY x diff --git a/tests/ast_json_fixtures/shapes/4910b13628e2efd2.json b/tests/ast_json_fixtures/shapes/4910b13628e2efd2.json new file mode 100644 index 000000000000..ad1f9c30e0f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4910b13628e2efd2.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "type", + "value_type": "String", + "value": "processed" + }, + { + "type": "Function", + "alias": "max_date", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "min_date", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "type" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4910b13628e2efd2.sql b/tests/ast_json_fixtures/shapes/4910b13628e2efd2.sql new file mode 100644 index 000000000000..ffb78e395216 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4910b13628e2efd2.sql @@ -0,0 +1,6 @@ +SELECT + 'processed' AS type, + max(number) AS max_date, + min(number) AS min_date +FROM numbers(100) +GROUP BY type diff --git a/tests/ast_json_fixtures/shapes/493c5c3e82698781.json b/tests/ast_json_fixtures/shapes/493c5c3e82698781.json new file mode 100644 index 000000000000..80151c2f67bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/493c5c3e82698781.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Identifier", + "name": "x" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/493c5c3e82698781.sql b/tests/ast_json_fixtures/shapes/493c5c3e82698781.sql new file mode 100644 index 000000000000..c1c682eca487 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/493c5c3e82698781.sql @@ -0,0 +1 @@ +CREATE TABLE test (x UInt8) ORDER BY x diff --git a/tests/ast_json_fixtures/shapes/495663f2de082b06.json b/tests/ast_json_fixtures/shapes/495663f2de082b06.json new file mode 100644 index 000000000000..1d3b6d727b35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/495663f2de082b06.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "if_exists": true, + "names": ["sqllt_settings_profile"] + } +} diff --git a/tests/ast_json_fixtures/shapes/495663f2de082b06.sql b/tests/ast_json_fixtures/shapes/495663f2de082b06.sql new file mode 100644 index 000000000000..bbf9b5fd77a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/495663f2de082b06.sql @@ -0,0 +1 @@ +DROP SETTINGS PROFILE IF EXISTS sqllt_settings_profile diff --git a/tests/ast_json_fixtures/shapes/4959e1c33480228d.json b/tests/ast_json_fixtures/shapes/4959e1c33480228d.json new file mode 100644 index 000000000000..3d4fce80b543 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4959e1c33480228d.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t_dict_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "t_dict_dist_local" + } + ] + } + }, + "as_table": "t_dict_dist_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/4959e1c33480228d.sql b/tests/ast_json_fixtures/shapes/4959e1c33480228d.sql new file mode 100644 index 000000000000..8dc4d56fcdc9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4959e1c33480228d.sql @@ -0,0 +1,2 @@ +CREATE TABLE t_dict_dist AS t_dict_dist_local +ENGINE = Distributed(test_shard_localhost, currentDatabase(), t_dict_dist_local) diff --git a/tests/ast_json_fixtures/shapes/495bfebdc3cdd357.json b/tests/ast_json_fixtures/shapes/495bfebdc3cdd357.json new file mode 100644 index 000000000000..75ca8377fefc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/495bfebdc3cdd357.json @@ -0,0 +1,154 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "alias": "i0", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "alias": "u0", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "alias": "ip", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775807" + } + ] + }, + { + "type": "Function", + "alias": "in", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775808" + } + ] + }, + { + "type": "Function", + "alias": "up", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "18446744073709551615" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "i0" + }, + { + "type": "Identifier", + "name": "u0" + }, + { + "type": "Identifier", + "name": "ip" + }, + { + "type": "Identifier", + "name": "in" + }, + { + "type": "Identifier", + "name": "up" + }, + { + "type": "Identifier", + "name": "arr" + }, + { + "type": "Identifier", + "name": "tuple" + } + ] + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/495bfebdc3cdd357.sql b/tests/ast_json_fixtures/shapes/495bfebdc3cdd357.sql new file mode 100644 index 000000000000..e2b8a8877436 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/495bfebdc3cdd357.sql @@ -0,0 +1 @@ +SELECT toInt64(0) as i0, toUInt64(0) as u0, toInt64(9223372036854775807) as ip, toInt64(-9223372036854775808) as in, toUInt64(18446744073709551615) as up, [toInt64(0)] as arr, (toUInt64(0), toUInt64(0)) as tuple GROUP BY i0, u0, ip, in, up, arr, tuple WITH TOTALS FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/495d68171451117c.json b/tests/ast_json_fixtures/shapes/495d68171451117c.json new file mode 100644 index 000000000000..ea715525bf1d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/495d68171451117c.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN ESTIMATE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "partition_by_ignore" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ts" + }, + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2022-08-07 00:00:00" + } + ] + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ts" + }, + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2022-08-10 00:00:00" + } + ] + } + ] + } + ] + } + } + ] + }, + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/495d68171451117c.sql b/tests/ast_json_fixtures/shapes/495d68171451117c.sql new file mode 100644 index 000000000000..bd220ab5f856 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/495d68171451117c.sql @@ -0,0 +1 @@ +EXPLAIN ESTIMATE SELECT count() FROM partition_by_ignore WHERE ts BETWEEN toDateTime('2022-08-07 00:00:00') AND toDateTime('2022-08-10 00:00:00') FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/49699e145a8c0970.json b/tests/ast_json_fixtures/shapes/49699e145a8c0970.json new file mode 100644 index 000000000000..f4527f002a7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49699e145a8c0970.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distributed_table1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "source_table1" + } + ] + } + }, + "as_table": "source_table1" + } +} diff --git a/tests/ast_json_fixtures/shapes/49699e145a8c0970.sql b/tests/ast_json_fixtures/shapes/49699e145a8c0970.sql new file mode 100644 index 000000000000..aacd7bbfd922 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49699e145a8c0970.sql @@ -0,0 +1,2 @@ +CREATE TABLE distributed_table1 AS source_table1 +ENGINE = Distributed('test_shard_localhost', currentDatabase(), source_table1) diff --git a/tests/ast_json_fixtures/shapes/4991676be144c6f6.json b/tests/ast_json_fixtures/shapes/4991676be144c6f6.json new file mode 100644 index 000000000000..971d049ee909 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4991676be144c6f6.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "String", + "value": "Hello, \"World\"" + }, + { + "type": "Literal", + "alias": "y", + "value_type": "UInt64", + "value": "123" + }, + { + "type": "Literal", + "alias": "z", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "alias": "a", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "456" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "abc" + }, + { + "value_type": "String", + "value": "def" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "b", + "value_type": "String", + "value": "Newline\nhere" + } + ] + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/4991676be144c6f6.sql b/tests/ast_json_fixtures/shapes/4991676be144c6f6.sql new file mode 100644 index 000000000000..031c70ce3c42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4991676be144c6f6.sql @@ -0,0 +1 @@ +SELECT 'Hello, "World"' AS x, 123 AS y, [1, 2, 3] AS z, (456, ['abc', 'def']) AS a, 'Newline\nhere' AS b FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/4996a081ba3468cb.json b/tests/ast_json_fixtures/shapes/4996a081ba3468cb.json new file mode 100644 index 000000000000..37b685393ab0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4996a081ba3468cb.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "m" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^(mt1|b)$" + } + ] + } + }, + "as_table": "mt1" + } +} diff --git a/tests/ast_json_fixtures/shapes/4996a081ba3468cb.sql b/tests/ast_json_fixtures/shapes/4996a081ba3468cb.sql new file mode 100644 index 000000000000..33907fa26958 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4996a081ba3468cb.sql @@ -0,0 +1 @@ +create table m as mt1 engine = Merge(currentDatabase(), '^(mt1|b)$') diff --git a/tests/ast_json_fixtures/shapes/49979ff52a7ed996.json b/tests/ast_json_fixtures/shapes/49979ff52a7ed996.json new file mode 100644 index 000000000000..3a96f389db8f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49979ff52a7ed996.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TabSeparatedRawWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/49979ff52a7ed996.sql b/tests/ast_json_fixtures/shapes/49979ff52a7ed996.sql new file mode 100644 index 000000000000..e7738aa660d8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49979ff52a7ed996.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TabSeparatedRawWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/49a393fa8cef4593.json b/tests/ast_json_fixtures/shapes/49a393fa8cef4593.json new file mode 100644 index 000000000000..6c82cc62c6c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49a393fa8cef4593.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "dt", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Identifier", + "name": "dt" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "dt" + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt" + }, + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "15" + } + ] + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/49a393fa8cef4593.sql b/tests/ast_json_fixtures/shapes/49a393fa8cef4593.sql new file mode 100644 index 000000000000..34294e86e58d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49a393fa8cef4593.sql @@ -0,0 +1 @@ +create table x (dt DateTime, i Int32) engine MergeTree partition by indexHint(dt) order by dt TTL dt + toIntervalDay(15) settings index_granularity = 8192 diff --git a/tests/ast_json_fixtures/shapes/49b47e9e10f52e75.json b/tests/ast_json_fixtures/shapes/49b47e9e10f52e75.json new file mode 100644 index 000000000000..e3e87e7ab2d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49b47e9e10f52e75.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_create_empty": true, + "table": { + "type": "Identifier", + "name": "t" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/49b47e9e10f52e75.sql b/tests/ast_json_fixtures/shapes/49b47e9e10f52e75.sql new file mode 100644 index 000000000000..55af78e30747 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49b47e9e10f52e75.sql @@ -0,0 +1 @@ +create table t engine=Memory empty as select 1 diff --git a/tests/ast_json_fixtures/shapes/49d3d7916f84f795.json b/tests/ast_json_fixtures/shapes/49d3d7916f84f795.json new file mode 100644 index 000000000000..c95176652046 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49d3d7916f84f795.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u2_01292", "u3_01292", "u4_01292", "u5_01292", "u6_01292", "u7_01292", "u8_01292", "u9_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/49d3d7916f84f795.sql b/tests/ast_json_fixtures/shapes/49d3d7916f84f795.sql new file mode 100644 index 000000000000..56e1e12a1558 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49d3d7916f84f795.sql @@ -0,0 +1 @@ +DROP USER u1_01292, u2_01292, u3_01292, u4_01292, u5_01292, u6_01292, u7_01292, u8_01292, u9_01292 diff --git a/tests/ast_json_fixtures/shapes/49fa0504882d3909.json b/tests/ast_json_fixtures/shapes/49fa0504882d3909.json new file mode 100644 index 000000000000..3c6356c8c1fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49fa0504882d3909.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TabSeparatedWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/49fa0504882d3909.sql b/tests/ast_json_fixtures/shapes/49fa0504882d3909.sql new file mode 100644 index 000000000000..f1ab0dbf65c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/49fa0504882d3909.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TabSeparatedWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/4a0c24666122c89c.json b/tests/ast_json_fixtures/shapes/4a0c24666122c89c.json new file mode 100644 index 000000000000..041238c9be56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a0c24666122c89c.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.1" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "simple" + } + ] + }, + "format": "Values", + "settings": { + "type": "Settings", + "changes": { + "prefer_localhost_replica": "0", + "deduplicate_insert": "enable" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4a0c24666122c89c.sql b/tests/ast_json_fixtures/shapes/4a0c24666122c89c.sql new file mode 100644 index 000000000000..44de7b20d6f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a0c24666122c89c.sql @@ -0,0 +1 @@ +INSERT INTO TABLE FUNCTION remote('127.0.0.1', currentDatabase(), 'simple') SETTINGS prefer_localhost_replica=0, deduplicate_insert='enable' VALUES (1) diff --git a/tests/ast_json_fixtures/shapes/4a16356af762c450.json b/tests/ast_json_fixtures/shapes/4a16356af762c450.json new file mode 100644 index 000000000000..f833d01d68f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a16356af762c450.json @@ -0,0 +1,94 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "x", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_recursive_cte_evaluation_depth": "5" + } + }, + "format": "NULL" + } +} diff --git a/tests/ast_json_fixtures/shapes/4a16356af762c450.sql b/tests/ast_json_fixtures/shapes/4a16356af762c450.sql new file mode 100644 index 000000000000..77c9de24390d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a16356af762c450.sql @@ -0,0 +1,2 @@ +WITH RECURSIVE x AS (SELECT 1 AS n UNION ALL SELECT sum(n) FROM x) + SELECT * FROM x FORMAT NULL SETTINGS max_recursive_cte_evaluation_depth = 5 diff --git a/tests/ast_json_fixtures/shapes/4a1d70b537b1cef6.json b/tests/ast_json_fixtures/shapes/4a1d70b537b1cef6.json new file mode 100644 index 000000000000..981041c87f15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a1d70b537b1cef6.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4a1d70b537b1cef6.sql b/tests/ast_json_fixtures/shapes/4a1d70b537b1cef6.sql new file mode 100644 index 000000000000..ef307440a6c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a1d70b537b1cef6.sql @@ -0,0 +1 @@ +select 1 from t group by 1 diff --git a/tests/ast_json_fixtures/shapes/4a577c0088d4f506.json b/tests/ast_json_fixtures/shapes/4a577c0088d4f506.json new file mode 100644 index 000000000000..af5040c41c0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a577c0088d4f506.json @@ -0,0 +1,121 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t1" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.key", + "name_parts": ["t1", "key"] + }, + { + "type": "Identifier", + "name": "t2.key", + "name_parts": ["t2", "key"] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.a", + "name_parts": ["t1", "a"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.a", + "name_parts": ["t2", "a"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/4a577c0088d4f506.sql b/tests/ast_json_fixtures/shapes/4a577c0088d4f506.sql new file mode 100644 index 000000000000..5bf54527e343 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a577c0088d4f506.sql @@ -0,0 +1 @@ +SELECT t1.* FROM t1 FULL OUTER JOIN t2 ON t1.key = t2.key AND (t1.a = 2 OR indexHint(t2.a = 2)) FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/4a6a27b5cff574b5.json b/tests/ast_json_fixtures/shapes/4a6a27b5cff574b5.json new file mode 100644 index 000000000000..f3520f524760 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a6a27b5cff574b5.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "1", + "value_type": "UInt64", + "value": "3" + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4a6a27b5cff574b5.sql b/tests/ast_json_fixtures/shapes/4a6a27b5cff574b5.sql new file mode 100644 index 000000000000..56c13a51dee8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a6a27b5cff574b5.sql @@ -0,0 +1 @@ +with 3 as "1" select 1, "1" diff --git a/tests/ast_json_fixtures/shapes/4a85723dd3253dcf.json b/tests/ast_json_fixtures/shapes/4a85723dd3253dcf.json new file mode 100644 index 000000000000..fdeeb7c53693 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a85723dd3253dcf.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "predicate": { + "type": "Identifier", + "name": "c0" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4a85723dd3253dcf.sql b/tests/ast_json_fixtures/shapes/4a85723dd3253dcf.sql new file mode 100644 index 000000000000..65cf354c8e4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a85723dd3253dcf.sql @@ -0,0 +1 @@ +DELETE FROM t0 WHERE c0 diff --git a/tests/ast_json_fixtures/shapes/4a8cd9ac10789c8e.json b/tests/ast_json_fixtures/shapes/4a8cd9ac10789c8e.json new file mode 100644 index 000000000000..51fa00807b4f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a8cd9ac10789c8e.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "INTERSECT DISTINCT", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "fooooo" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "fooooo" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4a8cd9ac10789c8e.sql b/tests/ast_json_fixtures/shapes/4a8cd9ac10789c8e.sql new file mode 100644 index 000000000000..284f37b2e8d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a8cd9ac10789c8e.sql @@ -0,0 +1 @@ +SELECT 'fooooo' INTERSECT DISTINCT SELECT 'fooooo' diff --git a/tests/ast_json_fixtures/shapes/4a8d3b13016c7e04.json b/tests/ast_json_fixtures/shapes/4a8d3b13016c7e04.json new file mode 100644 index 000000000000..b19ec965c3ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a8d3b13016c7e04.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int" + } + }, + { + "type": "ColumnDeclaration", + "name": "c1", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "Int" + } + ] + }, + "default_specifier": "MATERIALIZED", + "default_expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "SummingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "abs", + "arguments": [ + { + "type": "Identifier", + "name": "c1" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_nullable_key": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4a8d3b13016c7e04.sql b/tests/ast_json_fixtures/shapes/4a8d3b13016c7e04.sql new file mode 100644 index 000000000000..9d4996342d50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4a8d3b13016c7e04.sql @@ -0,0 +1 @@ +CREATE TABLE t0 (c0 Int, c1 Nullable(Int) MATERIALIZED 1) ENGINE = SummingMergeTree() PRIMARY KEY (abs(c1)) SETTINGS allow_nullable_key = 1 diff --git a/tests/ast_json_fixtures/shapes/4aae2911d6157bc3.json b/tests/ast_json_fixtures/shapes/4aae2911d6157bc3.json new file mode 100644 index 000000000000..61e1ed963e80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4aae2911d6157bc3.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "124437995" + }, + { + "type": "Function", + "name": "throwIf", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4aae2911d6157bc3.sql b/tests/ast_json_fixtures/shapes/4aae2911d6157bc3.sql new file mode 100644 index 000000000000..58b5ce344c52 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4aae2911d6157bc3.sql @@ -0,0 +1 @@ +SELECT 124437995, throwIf(1) SETTINGS use_query_cache = 1 diff --git a/tests/ast_json_fixtures/shapes/4ab47ac880ecd575.json b/tests/ast_json_fixtures/shapes/4ab47ac880ecd575.json new file mode 100644 index 000000000000..3962f1ec2ae6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ab47ac880ecd575.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q3_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/4ab47ac880ecd575.sql b/tests/ast_json_fixtures/shapes/4ab47ac880ecd575.sql new file mode 100644 index 000000000000..582cdd2e2f9f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ab47ac880ecd575.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q3_01297 diff --git a/tests/ast_json_fixtures/shapes/4ad73d560aabf700.json b/tests/ast_json_fixtures/shapes/4ad73d560aabf700.json new file mode 100644 index 000000000000..347f9bb7142e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ad73d560aabf700.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4ad73d560aabf700.sql b/tests/ast_json_fixtures/shapes/4ad73d560aabf700.sql new file mode 100644 index 000000000000..1307d4efa3c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ad73d560aabf700.sql @@ -0,0 +1 @@ +SELECT count() WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/4aeabc3697e96e7b.json b/tests/ast_json_fixtures/shapes/4aeabc3697e96e7b.json new file mode 100644 index 000000000000..2a7fdf196393 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4aeabc3697e96e7b.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "SearchPhrase" + } + ] + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits_s3", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "SearchPhrase" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "SearchPhrase" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4aeabc3697e96e7b.sql b/tests/ast_json_fixtures/shapes/4aeabc3697e96e7b.sql new file mode 100644 index 000000000000..e40471449192 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4aeabc3697e96e7b.sql @@ -0,0 +1 @@ +SELECT uniq(SearchPhrase), count() AS c FROM test.hits_s3 WHERE SearchPhrase != '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/4b12d0ee1e5a99a2.json b/tests/ast_json_fixtures/shapes/4b12d0ee1e5a99a2.json new file mode 100644 index 000000000000..04a1724c972e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b12d0ee1e5a99a2.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_table" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test_table_sharded" + }, + { + "type": "Identifier", + "name": "hash" + } + ] + } + }, + "as_table": "test_table_sharded" + } +} diff --git a/tests/ast_json_fixtures/shapes/4b12d0ee1e5a99a2.sql b/tests/ast_json_fixtures/shapes/4b12d0ee1e5a99a2.sql new file mode 100644 index 000000000000..3cd35f757b5a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b12d0ee1e5a99a2.sql @@ -0,0 +1,2 @@ +create table test_table as test_table_sharded +engine=Distributed(test_cluster_two_shards, currentDatabase(), test_table_sharded, hash) diff --git a/tests/ast_json_fixtures/shapes/4b2a5f18af54d612.json b/tests/ast_json_fixtures/shapes/4b2a5f18af54d612.json new file mode 100644 index 000000000000..9e2b830f40ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b2a5f18af54d612.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "function_name": { + "type": "Identifier", + "name": "02181_invalid_lambda" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4b2a5f18af54d612.sql b/tests/ast_json_fixtures/shapes/4b2a5f18af54d612.sql new file mode 100644 index 000000000000..7e14e0413df8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b2a5f18af54d612.sql @@ -0,0 +1 @@ +CREATE FUNCTION 02181_invalid_lambda AS lambda(x) diff --git a/tests/ast_json_fixtures/shapes/4b360c576b54a7da.json b/tests/ast_json_fixtures/shapes/4b360c576b54a7da.json new file mode 100644 index 000000000000..4b14034ad421 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b360c576b54a7da.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + ], + "format": "PrettyNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/4b360c576b54a7da.sql b/tests/ast_json_fixtures/shapes/4b360c576b54a7da.sql new file mode 100644 index 000000000000..b159f6dd8aa0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b360c576b54a7da.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a FORMAT PrettyNoEscapes diff --git a/tests/ast_json_fixtures/shapes/4b42ef72b039c4de.json b/tests/ast_json_fixtures/shapes/4b42ef72b039c4de.json new file mode 100644 index 000000000000..5c29c53f02cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b42ef72b039c4de.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_part" + }, + { + "type": "Identifier", + "name": "_part_data_version" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_data_version" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_part_data_version" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4b42ef72b039c4de.sql b/tests/ast_json_fixtures/shapes/4b42ef72b039c4de.sql new file mode 100644 index 000000000000..7a80e7c1fe46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b42ef72b039c4de.sql @@ -0,0 +1 @@ +SELECT _part, _part_data_version, * FROM t_data_version WHERE _part_data_version = 4 ORDER BY a SETTINGS max_rows_to_read = 1 diff --git a/tests/ast_json_fixtures/shapes/4b4710d72c20a5ac.json b/tests/ast_json_fixtures/shapes/4b4710d72c20a5ac.json new file mode 100644 index 000000000000..84ae85347de9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b4710d72c20a5ac.json @@ -0,0 +1,196 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tbl" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "c", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "e", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "mm1_idx", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + }, + { + "type": "Index", + "name": "mm2_idx", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "e" + } + ] + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + }, + { + "type": "Index", + "name": "set_idx", + "expression": { + "type": "Identifier", + "name": "e" + }, + "index_type": { + "type": "Function", + "name": "set", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + "granularity": 1 + }, + { + "type": "Index", + "name": "blf_idx", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.8 + } + ] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "a" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "add_minmax_index_for_numeric_columns": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4b4710d72c20a5ac.sql b/tests/ast_json_fixtures/shapes/4b4710d72c20a5ac.sql new file mode 100644 index 000000000000..23fe23533981 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b4710d72c20a5ac.sql @@ -0,0 +1,15 @@ +CREATE TABLE tbl +( + a UInt64, + b UInt64, + c UInt64, + d UInt64, + e UInt64, + INDEX mm1_idx (a, c, d) TYPE minmax, + INDEX mm2_idx (c, d, e) TYPE minmax, + INDEX set_idx (e) TYPE set(100), + INDEX blf_idx (d, b) TYPE bloom_filter(0.8) +) +ENGINE = MergeTree +PRIMARY KEY (c, a) +SETTINGS add_minmax_index_for_numeric_columns=0 diff --git a/tests/ast_json_fixtures/shapes/4b562636132e2ccb.json b/tests/ast_json_fixtures/shapes/4b562636132e2ccb.json new file mode 100644 index 000000000000..440c0da2dee2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b562636132e2ccb.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "START REPLICATED SENDS", + "table": { + "type": "Identifier", + "name": "r1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4b562636132e2ccb.sql b/tests/ast_json_fixtures/shapes/4b562636132e2ccb.sql new file mode 100644 index 000000000000..313b5c75da30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b562636132e2ccb.sql @@ -0,0 +1 @@ +SYSTEM START REPLICATED SENDS r1 diff --git a/tests/ast_json_fixtures/shapes/4b56534401b88072.json b/tests/ast_json_fixtures/shapes/4b56534401b88072.json new file mode 100644 index 000000000000..ef46bde14895 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b56534401b88072.json @@ -0,0 +1,288 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "site", + "name": "s.site", + "name_parts": ["s", "site"] + }, + { + "type": "Function", + "alias": "page_level", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.order", + "name_parts": ["a", "order"] + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.order", + "name_parts": ["a", "order"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.order", + "name_parts": ["a", "order"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "accurateCastOrNull", + "arguments": [ + { + "type": "Identifier", + "name": "a.order", + "name_parts": ["a", "order"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Int32" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "count", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "a", + "name": "AddedToCart" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ANY", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.sessionId", + "name_parts": ["a", "sessionId"] + }, + { + "type": "Identifier", + "name": "s.id", + "name_parts": ["s", "id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "s", + "name": "Session" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.top", + "name_parts": ["a", "top"] + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.screenHeight", + "name_parts": ["a", "screenHeight"] + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.screenHeight", + "name_parts": ["a", "screenHeight"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.isPromotion", + "name_parts": ["a", "isPromotion"] + }, + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt8" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.device", + "name_parts": ["s", "device"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "DESKTOP" + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Identifier", + "name": "s.site", + "name_parts": ["s", "site"] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "site" + }, + { + "type": "Identifier", + "name": "page_level" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "site" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "page_level" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/4b56534401b88072.sql b/tests/ast_json_fixtures/shapes/4b56534401b88072.sql new file mode 100644 index 000000000000..8344faa62b2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b56534401b88072.sql @@ -0,0 +1,15 @@ +SELECT + s.site AS site, + if((a.order IS NULL) OR (a.order <= 0) OR (a.order > 30), NULL, accurateCastOrNull(a.order, 'Int32')) AS page_level, + count() AS count +FROM AddedToCart AS a +ANY LEFT JOIN Session AS s ON a.sessionId = s.id +WHERE (a.top IS NOT NULL) + AND (a.screenHeight IS NOT NULL) + AND (a.screenHeight > 0) + AND (a.isPromotion = _CAST(1, 'UInt8')) + AND (s.device = 'DESKTOP') + AND isNotNull(s.site) +GROUP BY site, page_level +ORDER BY site ASC, page_level ASC +FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/4b64675085ed3e38.json b/tests/ast_json_fixtures/shapes/4b64675085ed3e38.json new file mode 100644 index 000000000000..ed581145419f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b64675085ed3e38.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_ordinary_view": true, + "table": { + "type": "Identifier", + "name": "v" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4b64675085ed3e38.sql b/tests/ast_json_fixtures/shapes/4b64675085ed3e38.sql new file mode 100644 index 000000000000..3ea5ef0c9f17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b64675085ed3e38.sql @@ -0,0 +1 @@ +CREATE VIEW v AS SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/4b725922bf56e844.json b/tests/ast_json_fixtures/shapes/4b725922bf56e844.json new file mode 100644 index 000000000000..06d91c062050 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b725922bf56e844.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2015-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers_10" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "extremes": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4b725922bf56e844.sql b/tests/ast_json_fixtures/shapes/4b725922bf56e844.sql new file mode 100644 index 000000000000..7b0cd32c9916 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4b725922bf56e844.sql @@ -0,0 +1 @@ +SELECT number, (number, toDate('2015-01-01') + number) FROM numbers_10 LIMIT 10 SETTINGS extremes = 1 diff --git a/tests/ast_json_fixtures/shapes/4bdf938a7fef7fbf.json b/tests/ast_json_fixtures/shapes/4bdf938a7fef7fbf.json new file mode 100644 index 000000000000..1e2d339b0c10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4bdf938a7fef7fbf.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/4bdf938a7fef7fbf.sql b/tests/ast_json_fixtures/shapes/4bdf938a7fef7fbf.sql new file mode 100644 index 000000000000..c004affbbb9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4bdf938a7fef7fbf.sql @@ -0,0 +1 @@ +DROP USER u1_01297 diff --git a/tests/ast_json_fixtures/shapes/4beca3574e9fb2c7.json b/tests/ast_json_fixtures/shapes/4beca3574e9fb2c7.json new file mode 100644 index 000000000000..20f04043b7f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4beca3574e9fb2c7.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "tp" + }, + "final": true, + "deduplicate": true, + "deduplicate_by_columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "type" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4beca3574e9fb2c7.sql b/tests/ast_json_fixtures/shapes/4beca3574e9fb2c7.sql new file mode 100644 index 000000000000..d741e881f025 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4beca3574e9fb2c7.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE tp FINAL DEDUPLICATE BY type diff --git a/tests/ast_json_fixtures/shapes/4bf81d51f84c9c45.json b/tests/ast_json_fixtures/shapes/4bf81d51f84c9c45.json new file mode 100644 index 000000000000..a4d5d9d068b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4bf81d51f84c9c45.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "CounterID" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4bf81d51f84c9c45.sql b/tests/ast_json_fixtures/shapes/4bf81d51f84c9c45.sql new file mode 100644 index 000000000000..3eeb038ce91b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4bf81d51f84c9c45.sql @@ -0,0 +1 @@ +SELECT CounterID, count() AS c FROM test.hits GROUP BY CounterID ORDER BY c DESC LIMIT 10 SETTINGS optimize_aggregation_in_order = 1 diff --git a/tests/ast_json_fixtures/shapes/4bff5531b38a8678.json b/tests/ast_json_fixtures/shapes/4bff5531b38a8678.json new file mode 100644 index 000000000000..457cbe9101ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4bff5531b38a8678.json @@ -0,0 +1,83 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Identifier", + "name": "j" + }, + { + "type": "ColumnsListMatcher", + "columns": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Identifier", + "name": "j" + }, + { + "type": "Identifier", + "name": "k" + } + ], + "transformers": [ + { + "type": "ColumnsApplyTransformer", + "func_name": "toFloat64" + } + ] + }, + { + "type": "ColumnsListMatcher", + "columns": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Identifier", + "name": "j" + } + ], + "transformers": [ + { + "type": "ColumnsExceptTransformer", + "columns": [ + { + "type": "Identifier", + "name": "i" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "columns_transformers" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4bff5531b38a8678.sql b/tests/ast_json_fixtures/shapes/4bff5531b38a8678.sql new file mode 100644 index 000000000000..2bbaeffc4ea4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4bff5531b38a8678.sql @@ -0,0 +1 @@ +SELECT i, j, COLUMNS(i, j, k) APPLY(toFloat64), COLUMNS(i, j) EXCEPT (i) from columns_transformers diff --git a/tests/ast_json_fixtures/shapes/4c0331aa531ed0a4.json b/tests/ast_json_fixtures/shapes/4c0331aa531ed0a4.json new file mode 100644 index 000000000000..9e487a996a74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c0331aa531ed0a4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r2_01293@%.myhost.com"] + } +} diff --git a/tests/ast_json_fixtures/shapes/4c0331aa531ed0a4.sql b/tests/ast_json_fixtures/shapes/4c0331aa531ed0a4.sql new file mode 100644 index 000000000000..4d2dea3d83c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c0331aa531ed0a4.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE 'r2_01293@%.myhost.com' diff --git a/tests/ast_json_fixtures/shapes/4c05373c8ea06064.json b/tests/ast_json_fixtures/shapes/4c05373c8ea06064.json new file mode 100644 index 000000000000..27f4c50ffa9f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c05373c8ea06064.json @@ -0,0 +1,189 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "j" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2097152" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "nums", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "200000" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ANY", + "using": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "js2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "alias": "j", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "02402_external_disk_mertrics\/grace_join" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/4c05373c8ea06064.sql b/tests/ast_json_fixtures/shapes/4c05373c8ea06064.sql new file mode 100644 index 000000000000..a73bc9c76155 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c05373c8ea06064.sql @@ -0,0 +1,7 @@ +SELECT n, j * 2097152 FROM +(SELECT number * 200000 as n FROM numbers(5)) nums +ANY LEFT JOIN ( SELECT number * 2 AS n, number AS j FROM numbers(1000000) ) js2 +USING n +ORDER BY n +SETTINGS log_comment='02402_external_disk_mertrics/grace_join' +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/4c568e80cb9274e1.json b/tests/ast_json_fixtures/shapes/4c568e80cb9274e1.json new file mode 100644 index 000000000000..138abe15240b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c568e80cb9274e1.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "table": { + "type": "Identifier", + "name": "primary_key_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "v", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "v" + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "v" + }, + "order_by": { + "type": "Identifier", + "name": "v" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4c568e80cb9274e1.sql b/tests/ast_json_fixtures/shapes/4c568e80cb9274e1.sql new file mode 100644 index 000000000000..15506da567fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c568e80cb9274e1.sql @@ -0,0 +1 @@ +ATTACH TABLE primary_key_test(v Int32, PRIMARY KEY(v)) ENGINE=ReplacingMergeTree ORDER BY v diff --git a/tests/ast_json_fixtures/shapes/4c5b74a28b397ce8.json b/tests/ast_json_fixtures/shapes/4c5b74a28b397ce8.json new file mode 100644 index 000000000000..8efdca855579 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c5b74a28b397ce8.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q1_01297", "q2_01297"], + "limits": [ + { + "duration_sec": "86400", + "max": { + "ERRORS": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4c5b74a28b397ce8.sql b/tests/ast_json_fixtures/shapes/4c5b74a28b397ce8.sql new file mode 100644 index 000000000000..e67f8efa139a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c5b74a28b397ce8.sql @@ -0,0 +1 @@ +CREATE QUOTA q1_01297, q2_01297 FOR 1 day MAX errors=5 diff --git a/tests/ast_json_fixtures/shapes/4c619940fc21089f.json b/tests/ast_json_fixtures/shapes/4c619940fc21089f.json new file mode 100644 index 000000000000..93d21d611e66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c619940fc21089f.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "rmt", + "to_table": "rmt1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4c619940fc21089f.sql b/tests/ast_json_fixtures/shapes/4c619940fc21089f.sql new file mode 100644 index 000000000000..5b0a96f7aec9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c619940fc21089f.sql @@ -0,0 +1 @@ +RENAME TABLE rmt TO rmt1 diff --git a/tests/ast_json_fixtures/shapes/4c68a033de4ba37a.json b/tests/ast_json_fixtures/shapes/4c68a033de4ba37a.json new file mode 100644 index 000000000000..544e760f1b08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c68a033de4ba37a.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "DIV" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "DIV", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + } + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/4c68a033de4ba37a.sql b/tests/ast_json_fixtures/shapes/4c68a033de4ba37a.sql new file mode 100644 index 000000000000..8dbeaf5f111c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c68a033de4ba37a.sql @@ -0,0 +1 @@ +SELECT DIV MOD 1 FROM (SELECT 1 `DIV`) FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/4c7e66f5fac871cb.json b/tests/ast_json_fixtures/shapes/4c7e66f5fac871cb.json new file mode 100644 index 000000000000..8ea001e1f26b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c7e66f5fac871cb.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "j", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4c7e66f5fac871cb.sql b/tests/ast_json_fixtures/shapes/4c7e66f5fac871cb.sql new file mode 100644 index 000000000000..7769b8110d5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c7e66f5fac871cb.sql @@ -0,0 +1 @@ +ALTER TABLE t MODIFY COLUMN j Int64 SETTINGS mutations_sync = 2 diff --git a/tests/ast_json_fixtures/shapes/4c7f2c571255fa03.json b/tests/ast_json_fixtures/shapes/4c7f2c571255fa03.json new file mode 100644 index 000000000000..ed83f8529617 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c7f2c571255fa03.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "COUNT", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "query_5" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/4c7f2c571255fa03.sql b/tests/ast_json_fixtures/shapes/4c7f2c571255fa03.sql new file mode 100644 index 000000000000..fc2de0d5bd80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c7f2c571255fa03.sql @@ -0,0 +1 @@ +SELECT COUNT(*) FROM t WHERE a % 10 = 0 FORMAT Null SETTINGS log_comment='query_5' diff --git a/tests/ast_json_fixtures/shapes/4c87d0aa85a8ed70.json b/tests/ast_json_fixtures/shapes/4c87d0aa85a8ed70.json new file mode 100644 index 000000000000..688c9aaef55b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c87d0aa85a8ed70.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "i" + } + ], + "having": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "10" + }, + { + "value_type": "UInt64", + "value": "11" + }, + { + "value_type": "UInt64", + "value": "12" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/4c87d0aa85a8ed70.sql b/tests/ast_json_fixtures/shapes/4c87d0aa85a8ed70.sql new file mode 100644 index 000000000000..ca0bd9711f7a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4c87d0aa85a8ed70.sql @@ -0,0 +1 @@ +select * from test group by i having i in (10, 11, 12) order by i FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/4cbabd3df4fbdf6c.json b/tests/ast_json_fixtures/shapes/4cbabd3df4fbdf6c.json new file mode 100644 index 000000000000..5cdec6e65b04 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4cbabd3df4fbdf6c.json @@ -0,0 +1,157 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "recompression_table_compact" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "dt", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "key" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "RECOMPRESS", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt" + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "recompression_codec": { + "type": "Function", + "name": "CODEC", + "kind": "CODEC", + "arguments": [ + { + "type": "Function", + "name": "ZSTD", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "17" + } + ] + } + ] + } + }, + { + "type": "TTLElement", + "mode": "RECOMPRESS", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt" + }, + { + "type": "Function", + "name": "toIntervalYear", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "recompression_codec": { + "type": "Function", + "name": "CODEC", + "kind": "CODEC", + "arguments": [ + { + "type": "Function", + "name": "LZ4HC", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "min_rows_for_wide_part": "10000", + "min_bytes_for_full_part_storage": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4cbabd3df4fbdf6c.sql b/tests/ast_json_fixtures/shapes/4cbabd3df4fbdf6c.sql new file mode 100644 index 000000000000..210cd0406fd4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4cbabd3df4fbdf6c.sql @@ -0,0 +1,11 @@ +CREATE TABLE recompression_table_compact +( + dt DateTime, + key UInt64, + value String + +) ENGINE MergeTree() +ORDER BY tuple() +PARTITION BY key +TTL dt + INTERVAL 1 MONTH RECOMPRESS CODEC(ZSTD(17)), dt + INTERVAL 1 YEAR RECOMPRESS CODEC(LZ4HC(10)) +SETTINGS min_rows_for_wide_part = 10000, min_bytes_for_full_part_storage = 0 diff --git a/tests/ast_json_fixtures/shapes/4cbbc391143d767a.json b/tests/ast_json_fixtures/shapes/4cbbc391143d767a.json new file mode 100644 index 000000000000..ce792c73f766 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4cbbc391143d767a.json @@ -0,0 +1,196 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "ps_partkey" + }, + { + "type": "Identifier", + "name": "ps_suppkey" + }, + { + "type": "Subquery", + "alias": "half_sum_quantity", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "l_quantity" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lineitem" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l_partkey" + }, + { + "type": "Identifier", + "name": "ps_partkey" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l_suppkey" + }, + { + "type": "Identifier", + "name": "ps_suppkey" + } + ] + } + ] + } + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "partsupp" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ps_partkey" + }, + { + "type": "Identifier", + "name": "ps_suppkey" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "114" + }, + { + "value_type": "UInt64", + "value": "115" + } + ] + }, + { + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "369" + }, + { + "value_type": "UInt64", + "value": "7870" + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ps_partkey" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ps_suppkey" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4cbbc391143d767a.sql b/tests/ast_json_fixtures/shapes/4cbbc391143d767a.sql new file mode 100644 index 000000000000..9e47108ada8e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4cbbc391143d767a.sql @@ -0,0 +1,11 @@ +SELECT + ps_partkey, + ps_suppkey, + ( + SELECT 0.5 * sum(l_quantity) + FROM lineitem + WHERE (l_partkey = ps_partkey) AND (l_suppkey = ps_suppkey) + ) AS half_sum_quantity +FROM partsupp +WHERE (ps_partkey, ps_suppkey) IN ((114, 115), (369, 7870)) +ORDER BY ps_partkey, ps_suppkey diff --git a/tests/ast_json_fixtures/shapes/4cdacdd461a64393.json b/tests/ast_json_fixtures/shapes/4cdacdd461a64393.json new file mode 100644 index 000000000000..2959c6405ece --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4cdacdd461a64393.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateIndexQuery", + "table": { + "type": "Identifier", + "name": "t_index_3146" + }, + "index_name": { + "type": "Identifier", + "name": "i5" + }, + "index_declaration": { + "type": "Index", + "name": "i5", + "expression": { + "type": "Identifier", + "name": "a" + }, + "granularity": 1 + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4cdacdd461a64393.sql b/tests/ast_json_fixtures/shapes/4cdacdd461a64393.sql new file mode 100644 index 000000000000..52b91ecf5584 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4cdacdd461a64393.sql @@ -0,0 +1 @@ +CREATE INDEX i5 ON t_index_3146 (a) diff --git a/tests/ast_json_fixtures/shapes/4ce7a37dbccba16c.json b/tests/ast_json_fixtures/shapes/4ce7a37dbccba16c.json new file mode 100644 index 000000000000..e0fa23bd29cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ce7a37dbccba16c.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TabSeparatedWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/4ce7a37dbccba16c.sql b/tests/ast_json_fixtures/shapes/4ce7a37dbccba16c.sql new file mode 100644 index 000000000000..20d262591dc6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ce7a37dbccba16c.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TabSeparatedWithNames diff --git a/tests/ast_json_fixtures/shapes/4cfa7b2552de845f.json b/tests/ast_json_fixtures/shapes/4cfa7b2552de845f.json new file mode 100644 index 000000000000..4d17f8f4f127 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4cfa7b2552de845f.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "lambda", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Asterisk" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "lambda", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4cfa7b2552de845f.sql b/tests/ast_json_fixtures/shapes/4cfa7b2552de845f.sql new file mode 100644 index 000000000000..15144a243f15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4cfa7b2552de845f.sql @@ -0,0 +1 @@ +WITH x -> * AS lambda SELECT lambda(1) FROM test_table diff --git a/tests/ast_json_fixtures/shapes/4cffdcfb01a5ecac.json b/tests/ast_json_fixtures/shapes/4cffdcfb01a5ecac.json new file mode 100644 index 000000000000..598a8f4a2a8a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4cffdcfb01a5ecac.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1", + "enable_positional_arguments": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4cffdcfb01a5ecac.sql b/tests/ast_json_fixtures/shapes/4cffdcfb01a5ecac.sql new file mode 100644 index 000000000000..5520573c3de4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4cffdcfb01a5ecac.sql @@ -0,0 +1 @@ +SELECT tuple(2) = tuple(materialize(1)) GROUP BY 1 WITH CUBE SETTINGS group_by_use_nulls = 1, enable_positional_arguments = 1 diff --git a/tests/ast_json_fixtures/shapes/4d01d5528c2c056d.json b/tests/ast_json_fixtures/shapes/4d01d5528c2c056d.json new file mode 100644 index 000000000000..c18b4d54217c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d01d5528c2c056d.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "prop_table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "column_codec" + }, + "remove_property": "CODEC" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4d01d5528c2c056d.sql b/tests/ast_json_fixtures/shapes/4d01d5528c2c056d.sql new file mode 100644 index 000000000000..a8e8807c12aa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d01d5528c2c056d.sql @@ -0,0 +1 @@ +ALTER TABLE prop_table MODIFY COLUMN column_codec REMOVE CODEC diff --git a/tests/ast_json_fixtures/shapes/4d3d8326d1e13cf7.json b/tests/ast_json_fixtures/shapes/4d3d8326d1e13cf7.json new file mode 100644 index 000000000000..73aa651f2bcf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d3d8326d1e13cf7.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4d3d8326d1e13cf7.sql b/tests/ast_json_fixtures/shapes/4d3d8326d1e13cf7.sql new file mode 100644 index 000000000000..a9e6242eeb59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d3d8326d1e13cf7.sql @@ -0,0 +1 @@ +SELECT NULL GROUP BY NULL WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/4d3f3fe8bd591c98.json b/tests/ast_json_fixtures/shapes/4d3f3fe8bd591c98.json new file mode 100644 index 000000000000..1a09da17e138 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d3f3fe8bd591c98.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "uuid": "00000510-1000-4000-8000-000000000002", + "table": { + "type": "Identifier", + "name": "without_deduplication_mv" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "dummy", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Function", + "alias": "cnt", + "name": "countState", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "without_deduplication" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedAggregatingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/clickhouse\/tables\/{database}\/test_00510\/without_deduplication_mv" + }, + { + "type": "Literal", + "value_type": "String", + "value": "r1" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "dummy" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4d3f3fe8bd591c98.sql b/tests/ast_json_fixtures/shapes/4d3f3fe8bd591c98.sql new file mode 100644 index 000000000000..bdeffdfbf286 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d3f3fe8bd591c98.sql @@ -0,0 +1,3 @@ +CREATE MATERIALIZED VIEW without_deduplication_mv UUID '00000510-1000-4000-8000-000000000002' + ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{database}/test_00510/without_deduplication_mv', 'r1') ORDER BY dummy + AS SELECT 0 AS dummy, countState(x) AS cnt FROM without_deduplication diff --git a/tests/ast_json_fixtures/shapes/4d54f6575b29c0fa.json b/tests/ast_json_fixtures/shapes/4d54f6575b29c0fa.json new file mode 100644 index 000000000000..c68c6082a5b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d54f6575b29c0fa.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q1_01297"], + "key_type": "USER_NAME" + } +} diff --git a/tests/ast_json_fixtures/shapes/4d54f6575b29c0fa.sql b/tests/ast_json_fixtures/shapes/4d54f6575b29c0fa.sql new file mode 100644 index 000000000000..690f96660b6a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d54f6575b29c0fa.sql @@ -0,0 +1 @@ +ALTER QUOTA q1_01297 KEY BY user_name diff --git a/tests/ast_json_fixtures/shapes/4d85007707775d6a.json b/tests/ast_json_fixtures/shapes/4d85007707775d6a.json new file mode 100644 index 000000000000..2ab578e828a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d85007707775d6a.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u2_01292" + } + ] + }, + "hosts": { + "names": ["myhost.com"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4d85007707775d6a.sql b/tests/ast_json_fixtures/shapes/4d85007707775d6a.sql new file mode 100644 index 000000000000..6ad6fcf072e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d85007707775d6a.sql @@ -0,0 +1 @@ +ALTER USER u2_01292 HOST NAME 'myhost.com' diff --git a/tests/ast_json_fixtures/shapes/4d8a6763add73980.json b/tests/ast_json_fixtures/shapes/4d8a6763add73980.json new file mode 100644 index 000000000000..46160fef0ab9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d8a6763add73980.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Function", + "alias": "c8", + "name": "row_number", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "d" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c8" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4d8a6763add73980.sql b/tests/ast_json_fixtures/shapes/4d8a6763add73980.sql new file mode 100644 index 000000000000..7d191d19a1cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d8a6763add73980.sql @@ -0,0 +1 @@ +SELECT d, c, row_number() over (partition by d order by c) as c8 FROM t order by d, c8 settings max_threads=2 diff --git a/tests/ast_json_fixtures/shapes/4d8d9ac5cb6192a4.json b/tests/ast_json_fixtures/shapes/4d8d9ac5cb6192a4.json new file mode 100644 index 000000000000..96b120c650fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d8d9ac5cb6192a4.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_uuid" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ], + "format": "RowBinary" + } +} diff --git a/tests/ast_json_fixtures/shapes/4d8d9ac5cb6192a4.sql b/tests/ast_json_fixtures/shapes/4d8d9ac5cb6192a4.sql new file mode 100644 index 000000000000..36e1e6da0629 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d8d9ac5cb6192a4.sql @@ -0,0 +1 @@ +SELECT * FROM t_uuid ORDER BY x FORMAT RowBinary diff --git a/tests/ast_json_fixtures/shapes/4d8da2a7e821e1c5.json b/tests/ast_json_fixtures/shapes/4d8da2a7e821e1c5.json new file mode 100644 index 000000000000..4658bcdff411 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d8da2a7e821e1c5.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "alias": "a", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4d8da2a7e821e1c5.sql b/tests/ast_json_fixtures/shapes/4d8da2a7e821e1c5.sql new file mode 100644 index 000000000000..5e5684d6ecb7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d8da2a7e821e1c5.sql @@ -0,0 +1 @@ +SELECT tuple(toLowCardinality(1), 2) AS a GROUP BY GROUPING SETS ((1), (isNullable(19))) diff --git a/tests/ast_json_fixtures/shapes/4d933619c67c0c9e.json b/tests/ast_json_fixtures/shapes/4d933619c67c0c9e.json new file mode 100644 index 000000000000..4e61739c88b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d933619c67c0c9e.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "table_for_alter" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "Data2", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_SETTING", + "settings_changes": { + "type": "Settings", + "changes": { + "check_delay_period": "5", + "check_delay_period": "10", + "check_delay_period": "15" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4d933619c67c0c9e.sql b/tests/ast_json_fixtures/shapes/4d933619c67c0c9e.sql new file mode 100644 index 000000000000..4d4f17f06921 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4d933619c67c0c9e.sql @@ -0,0 +1 @@ +ALTER TABLE table_for_alter ADD COLUMN Data2 UInt64, MODIFY SETTING check_delay_period=5, check_delay_period=10, check_delay_period=15 diff --git a/tests/ast_json_fixtures/shapes/4db015851b59a0e6.json b/tests/ast_json_fixtures/shapes/4db015851b59a0e6.json new file mode 100644 index 000000000000..77f784b47fe5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4db015851b59a0e6.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["sqllt_quota"] + } +} diff --git a/tests/ast_json_fixtures/shapes/4db015851b59a0e6.sql b/tests/ast_json_fixtures/shapes/4db015851b59a0e6.sql new file mode 100644 index 000000000000..91115c1d55e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4db015851b59a0e6.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS sqllt_quota diff --git a/tests/ast_json_fixtures/shapes/4db434bf3d652fd7.json b/tests/ast_json_fixtures/shapes/4db434bf3d652fd7.json new file mode 100644 index 000000000000..ff5e982c1efd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4db434bf3d652fd7.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q4_01297"], + "limits": [ + { + "duration_sec": "2000", + "max": { + "ERRORS": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4db434bf3d652fd7.sql b/tests/ast_json_fixtures/shapes/4db434bf3d652fd7.sql new file mode 100644 index 000000000000..ad344a9bffb6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4db434bf3d652fd7.sql @@ -0,0 +1 @@ +CREATE QUOTA q4_01297 FOR 2000 SECOND errors MAX 5 diff --git a/tests/ast_json_fixtures/shapes/4ddf4318352d265d.json b/tests/ast_json_fixtures/shapes/4ddf4318352d265d.json new file mode 100644 index 000000000000..88150e9ea4da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ddf4318352d265d.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q4_01297"], + "limits": [ + { + "duration_sec": "2000", + "randomize_interval": true, + "max": { + "ERRORS": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4ddf4318352d265d.sql b/tests/ast_json_fixtures/shapes/4ddf4318352d265d.sql new file mode 100644 index 000000000000..37c315b44d10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ddf4318352d265d.sql @@ -0,0 +1 @@ +ALTER QUOTA q4_01297 FOR RANDOMIZED INTERVAL 2000 SECOND errors MAX 5 diff --git a/tests/ast_json_fixtures/shapes/4de0037c9015d59d.json b/tests/ast_json_fixtures/shapes/4de0037c9015d59d.json new file mode 100644 index 000000000000..6a59e8807109 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4de0037c9015d59d.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03701_sorted" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4de0037c9015d59d.sql b/tests/ast_json_fixtures/shapes/4de0037c9015d59d.sql new file mode 100644 index 000000000000..fd8fa2a4ece9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4de0037c9015d59d.sql @@ -0,0 +1 @@ +SELECT key FROM 03701_sorted ORDER BY key LIMIT 1 BY key LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/4e128ec23f1b83c8.json b/tests/ast_json_fixtures/shapes/4e128ec23f1b83c8.json new file mode 100644 index 000000000000..706f4f373968 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e128ec23f1b83c8.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_light" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_INDEX", + "index": { + "type": "Identifier", + "name": "i_c" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4e128ec23f1b83c8.sql b/tests/ast_json_fixtures/shapes/4e128ec23f1b83c8.sql new file mode 100644 index 000000000000..e8af5f3c7561 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e128ec23f1b83c8.sql @@ -0,0 +1 @@ +alter table t_light drop index i_c SETTINGS mutations_sync=2 diff --git a/tests/ast_json_fixtures/shapes/4e3710a864b24764.json b/tests/ast_json_fixtures/shapes/4e3710a864b24764.json new file mode 100644 index 000000000000..44c1df829cee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e3710a864b24764.json @@ -0,0 +1,98 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "{\"a\" : 42}" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(JSON)" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4e3710a864b24764.sql b/tests/ast_json_fixtures/shapes/4e3710a864b24764.sql new file mode 100644 index 000000000000..4bb886170230 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e3710a864b24764.sql @@ -0,0 +1 @@ +select (number % 2 ? null : '{"a" : 42}')::Nullable(JSON) as a from numbers(4) group by 1 order by a diff --git a/tests/ast_json_fixtures/shapes/4e4db5ab9e2c2ec6.json b/tests/ast_json_fixtures/shapes/4e4db5ab9e2c2ec6.json new file mode 100644 index 000000000000..61ce53bd149e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e4db5ab9e2c2ec6.json @@ -0,0 +1,281 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test1__fuzz_37" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "dictHas", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "dictHas", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "KeyKey" + } + ] + } + ] + }, + { + "type": "Function", + "name": "dictHas", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_dictionary" + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Ke\u0000" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "dictHas", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Ke\u0000Ke\u0000Ke\u0000Ke\u0000Ke\u0000Ke\u0000\u0000\u0000\u0000Ke\u0000" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "test_dicti\u0000nary" + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "name": "dictHas", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "dictHas", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "KeyKeyKeyKeyKeyKeyKeyKey" + } + ] + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4e4db5ab9e2c2ec6.sql b/tests/ast_json_fixtures/shapes/4e4db5ab9e2c2ec6.sql new file mode 100644 index 000000000000..9f21b532f710 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e4db5ab9e2c2ec6.sql @@ -0,0 +1 @@ +SELECT count() FROM test1__fuzz_37 GROUP BY dictHas(NULL, (dictHas(NULL, (('', materialize(NULL)), materialize(NULL))), 'KeyKey')), dictHas('test_dictionary', tuple(materialize('Ke\0'))), tuple(dictHas(NULL, (tuple('Ke\0Ke\0Ke\0Ke\0Ke\0Ke\0\0\0\0Ke\0'), materialize(NULL)))), 'test_dicti\0nary', (('', materialize(NULL)), dictHas(NULL, (dictHas(NULL, tuple(materialize(NULL))), 'KeyKeyKeyKeyKeyKeyKeyKey')), materialize(NULL)) diff --git a/tests/ast_json_fixtures/shapes/4e4df4a7e3312307.json b/tests/ast_json_fixtures/shapes/4e4df4a7e3312307.json new file mode 100644 index 000000000000..c1da9a09664c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e4df4a7e3312307.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4e4df4a7e3312307.sql b/tests/ast_json_fixtures/shapes/4e4df4a7e3312307.sql new file mode 100644 index 000000000000..b8f04c43af32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e4df4a7e3312307.sql @@ -0,0 +1 @@ +SELECT x FROM t GROUP BY x ORDER BY x diff --git a/tests/ast_json_fixtures/shapes/4e542ec244b14ea7.json b/tests/ast_json_fixtures/shapes/4e542ec244b14ea7.json new file mode 100644 index 000000000000..e3018ce438c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e542ec244b14ea7.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "TruncateQuery", + "kind": "TRUNCATE", + "table": { + "type": "Identifier", + "name": "tab" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4e542ec244b14ea7.sql b/tests/ast_json_fixtures/shapes/4e542ec244b14ea7.sql new file mode 100644 index 000000000000..f297bc115685 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e542ec244b14ea7.sql @@ -0,0 +1 @@ +TRUNCATE tab diff --git a/tests/ast_json_fixtures/shapes/4e5b980b2e64a386.json b/tests/ast_json_fixtures/shapes/4e5b980b2e64a386.json new file mode 100644 index 000000000000..7bf477a167cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e5b980b2e64a386.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + }, + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/4e5b980b2e64a386.sql b/tests/ast_json_fixtures/shapes/4e5b980b2e64a386.sql new file mode 100644 index 000000000000..5ca8dda309e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e5b980b2e64a386.sql @@ -0,0 +1 @@ +DESCRIBE test_table FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/4e5cb8a53dc127d5.json b/tests/ast_json_fixtures/shapes/4e5cb8a53dc127d5.json new file mode 100644 index 000000000000..35280e3d39a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e5cb8a53dc127d5.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "database": { + "type": "Identifier", + "name": "'" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4e5cb8a53dc127d5.sql b/tests/ast_json_fixtures/shapes/4e5cb8a53dc127d5.sql new file mode 100644 index 000000000000..58bb13bd6b15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e5cb8a53dc127d5.sql @@ -0,0 +1 @@ +DROP DATABASE `'` diff --git a/tests/ast_json_fixtures/shapes/4e6131885f8088d4.json b/tests/ast_json_fixtures/shapes/4e6131885f8088d4.json new file mode 100644 index 000000000000..e427972b7a2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e6131885f8088d4.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + { + "type": "Identifier", + "name": "s3" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s2" + }, + { + "type": "Literal", + "value_type": "String", + "value": "bbb" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4e6131885f8088d4.sql b/tests/ast_json_fixtures/shapes/4e6131885f8088d4.sql new file mode 100644 index 000000000000..cb15a1c0188c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e6131885f8088d4.sql @@ -0,0 +1 @@ +select ignore(date), s3 from t1 where s2='bbb' diff --git a/tests/ast_json_fixtures/shapes/4e77083b19beb8c2.json b/tests/ast_json_fixtures/shapes/4e77083b19beb8c2.json new file mode 100644 index 000000000000..77aecf8e2008 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e77083b19beb8c2.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "lol" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "n" + }, + "settings": { + "type": "Settings", + "changes": { + "min_bytes_for_wide_part": "123" + } + } + }, + "settings": { + "type": "Settings", + "changes": { + "log_queries": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4e77083b19beb8c2.sql b/tests/ast_json_fixtures/shapes/4e77083b19beb8c2.sql new file mode 100644 index 000000000000..3c3d47e1404a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e77083b19beb8c2.sql @@ -0,0 +1 @@ +CREATE TABLE lol (n int) ENGINE=MergeTree ORDER BY n SETTINGS min_bytes_for_wide_part=123 SETTINGS log_queries=1 diff --git a/tests/ast_json_fixtures/shapes/4e83b9772d897737.json b/tests/ast_json_fixtures/shapes/4e83b9772d897737.json new file mode 100644 index 000000000000..8ed189391bab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e83b9772d897737.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "t_proj2" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "a" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4e83b9772d897737.sql b/tests/ast_json_fixtures/shapes/4e83b9772d897737.sql new file mode 100644 index 000000000000..76e46a9db5e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e83b9772d897737.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE t_proj2 (a UInt32, b UInt32, PROJECTION p (SELECT a ORDER BY b * 2)) ENGINE = MergeTree ORDER BY a diff --git a/tests/ast_json_fixtures/shapes/4e856954c8bc9682.json b/tests/ast_json_fixtures/shapes/4e856954c8bc9682.json new file mode 100644 index 000000000000..cc2444d57e6c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e856954c8bc9682.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "alter": true, + "names": ["s2_01294"], + "to_roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4e856954c8bc9682.sql b/tests/ast_json_fixtures/shapes/4e856954c8bc9682.sql new file mode 100644 index 000000000000..374110a61e3d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4e856954c8bc9682.sql @@ -0,0 +1 @@ +ALTER PROFILE s2_01294 TO NONE diff --git a/tests/ast_json_fixtures/shapes/4ea4041a138f9505.json b/tests/ast_json_fixtures/shapes/4ea4041a138f9505.json new file mode 100644 index 000000000000..86db4a2fb4b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ea4041a138f9505.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "alias": "n", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } + ] + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/4ea4041a138f9505.sql b/tests/ast_json_fixtures/shapes/4ea4041a138f9505.sql new file mode 100644 index 000000000000..03a8468a4dc4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ea4041a138f9505.sql @@ -0,0 +1 @@ +SELECT (SELECT * FROM system.numbers LIMIT 1 OFFSET 1) AS n, toUInt64(10 / n) FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/4ea414f347eba269.json b/tests/ast_json_fixtures/shapes/4ea414f347eba269.json new file mode 100644 index 000000000000..41c36a4e5da0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ea414f347eba269.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t21" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/4ea414f347eba269.sql b/tests/ast_json_fixtures/shapes/4ea414f347eba269.sql new file mode 100644 index 000000000000..6a182efb89cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ea414f347eba269.sql @@ -0,0 +1 @@ +select a from t21 group by a limit 10 format Null diff --git a/tests/ast_json_fixtures/shapes/4eb2472ebac742ff.json b/tests/ast_json_fixtures/shapes/4eb2472ebac742ff.json new file mode 100644 index 000000000000..9a169bcad145 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4eb2472ebac742ff.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q2_01297"], + "roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4eb2472ebac742ff.sql b/tests/ast_json_fixtures/shapes/4eb2472ebac742ff.sql new file mode 100644 index 000000000000..6c9ca81c7214 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4eb2472ebac742ff.sql @@ -0,0 +1 @@ +CREATE QUOTA q2_01297 TO ALL diff --git a/tests/ast_json_fixtures/shapes/4ee1d658dadd6dff.json b/tests/ast_json_fixtures/shapes/4ee1d658dadd6dff.json new file mode 100644 index 000000000000..23dee73f16fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ee1d658dadd6dff.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "trace_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4ee1d658dadd6dff.sql b/tests/ast_json_fixtures/shapes/4ee1d658dadd6dff.sql new file mode 100644 index 000000000000..5cf66cc5356c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4ee1d658dadd6dff.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS trace_log diff --git a/tests/ast_json_fixtures/shapes/4efbe812696c328a.json b/tests/ast_json_fixtures/shapes/4efbe812696c328a.json new file mode 100644 index 000000000000..c24f7f205a13 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4efbe812696c328a.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "default_roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4efbe812696c328a.sql b/tests/ast_json_fixtures/shapes/4efbe812696c328a.sql new file mode 100644 index 000000000000..7b446910772f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4efbe812696c328a.sql @@ -0,0 +1 @@ +CREATE USER u1_01292 DEFAULT ROLE ALL diff --git a/tests/ast_json_fixtures/shapes/4f23fde65845e19d.json b/tests/ast_json_fixtures/shapes/4f23fde65845e19d.json new file mode 100644 index 000000000000..0f34e27a1f1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f23fde65845e19d.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "one", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.dummy", + "name_parts": ["t1", "dummy"] + }, + { + "type": "Identifier", + "name": "t2.dummy", + "name_parts": ["t2", "dummy"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "one", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ], + "format": "TabSeparated" + } +} diff --git a/tests/ast_json_fixtures/shapes/4f23fde65845e19d.sql b/tests/ast_json_fixtures/shapes/4f23fde65845e19d.sql new file mode 100644 index 000000000000..c92f3b907e7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f23fde65845e19d.sql @@ -0,0 +1,5 @@ +select * from system.one t1 +join system.one t2 +on t1.dummy = t2.dummy +limit 0 +FORMAT TabSeparated diff --git a/tests/ast_json_fixtures/shapes/4f253a8ee437f5a9.json b/tests/ast_json_fixtures/shapes/4f253a8ee437f5a9.json new file mode 100644 index 000000000000..ee8443410c68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f253a8ee437f5a9.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "y" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "_03914.parquet" + } + ] + } + ] + } + } + } + ] + }, + "prewhere": { + "type": "Identifier", + "name": "x" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_move_to_prewhere": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4f253a8ee437f5a9.sql b/tests/ast_json_fixtures/shapes/4f253a8ee437f5a9.sql new file mode 100644 index 000000000000..e6197df794e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f253a8ee437f5a9.sql @@ -0,0 +1 @@ +select sum(y) from file(currentDatabase() || '_03914.parquet') prewhere x settings optimize_move_to_prewhere = 0 diff --git a/tests/ast_json_fixtures/shapes/4f33b83a42d06de8.json b/tests/ast_json_fixtures/shapes/4f33b83a42d06de8.json new file mode 100644 index 000000000000..bf875ef7eece --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f33b83a42d06de8.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4f33b83a42d06de8.sql b/tests/ast_json_fixtures/shapes/4f33b83a42d06de8.sql new file mode 100644 index 000000000000..6146199f4d7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f33b83a42d06de8.sql @@ -0,0 +1 @@ +SELECT sum(n), 1 as x from t group by x diff --git a/tests/ast_json_fixtures/shapes/4f40cc648064c3e6.json b/tests/ast_json_fixtures/shapes/4f40cc648064c3e6.json new file mode 100644 index 000000000000..4a13d285b946 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f40cc648064c3e6.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "table": { + "type": "Identifier", + "name": "primary_key_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "v", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "v" + }, + "order_by": { + "type": "Identifier", + "name": "v" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/4f40cc648064c3e6.sql b/tests/ast_json_fixtures/shapes/4f40cc648064c3e6.sql new file mode 100644 index 000000000000..601a905698f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f40cc648064c3e6.sql @@ -0,0 +1 @@ +ATTACH TABLE primary_key_test(v Int32) ENGINE=ReplacingMergeTree ORDER BY v PRIMARY KEY(v) diff --git a/tests/ast_json_fixtures/shapes/4f5a5ed87dcd75b8.json b/tests/ast_json_fixtures/shapes/4f5a5ed87dcd75b8.json new file mode 100644 index 000000000000..07a32d9a7f4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f5a5ed87dcd75b8.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "S", + "value_type": "String", + "value": "2020-02-05 14:34:12.333" + }, + { + "type": "Function", + "alias": "DT64", + "name": "toDateTime64", + "arguments": [ + { + "type": "Identifier", + "name": "S" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "DT64" + }, + { + "type": "Identifier", + "name": "S" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4f5a5ed87dcd75b8.sql b/tests/ast_json_fixtures/shapes/4f5a5ed87dcd75b8.sql new file mode 100644 index 000000000000..dc7e8d8716b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f5a5ed87dcd75b8.sql @@ -0,0 +1 @@ +WITH '2020-02-05 14:34:12.333' as S, toDateTime64(S, 3) as DT64 SELECT DT64 = S diff --git a/tests/ast_json_fixtures/shapes/4f7ea907d6a83b3e.json b/tests/ast_json_fixtures/shapes/4f7ea907d6a83b3e.json new file mode 100644 index 000000000000..0d981e889363 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f7ea907d6a83b3e.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "alias_1", + "to_table": "alias_3" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4f7ea907d6a83b3e.sql b/tests/ast_json_fixtures/shapes/4f7ea907d6a83b3e.sql new file mode 100644 index 000000000000..c58f35a2e383 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f7ea907d6a83b3e.sql @@ -0,0 +1 @@ +RENAME TABLE alias_1 TO alias_3 diff --git a/tests/ast_json_fixtures/shapes/4f841e7d96a3690b.json b/tests/ast_json_fixtures/shapes/4f841e7d96a3690b.json new file mode 100644 index 000000000000..ccccf3107de9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f841e7d96a3690b.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4f841e7d96a3690b.sql b/tests/ast_json_fixtures/shapes/4f841e7d96a3690b.sql new file mode 100644 index 000000000000..e5128bbf9362 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f841e7d96a3690b.sql @@ -0,0 +1 @@ +select count() from t where id = 3 diff --git a/tests/ast_json_fixtures/shapes/4f96d99197470a1f.json b/tests/ast_json_fixtures/shapes/4f96d99197470a1f.json new file mode 100644 index 000000000000..8d2aac2a7826 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f96d99197470a1f.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + ], + "format": "PrettyNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/4f96d99197470a1f.sql b/tests/ast_json_fixtures/shapes/4f96d99197470a1f.sql new file mode 100644 index 000000000000..1a099c4df3a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4f96d99197470a1f.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a FORMAT PrettyNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/4fb2434e6fd607ad.json b/tests/ast_json_fixtures/shapes/4fb2434e6fd607ad.json new file mode 100644 index 000000000000..cac3d2006f14 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4fb2434e6fd607ad.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_lwu_replace" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "0" + } + }, + "replace": true, + "from_table": "t_lwu_replace" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/4fb2434e6fd607ad.sql b/tests/ast_json_fixtures/shapes/4fb2434e6fd607ad.sql new file mode 100644 index 000000000000..b0fedb8b3466 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4fb2434e6fd607ad.sql @@ -0,0 +1 @@ +ALTER TABLE t_lwu_replace REPLACE PARTITION ID '0' FROM t_lwu_replace diff --git a/tests/ast_json_fixtures/shapes/4fb40682a64a978d.json b/tests/ast_json_fixtures/shapes/4fb40682a64a978d.json new file mode 100644 index 000000000000..861fd3d7d208 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4fb40682a64a978d.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "c1" + } + ] + }, + { + "type": "Identifier", + "name": "c2" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "c2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "format", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "CSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1,Hello World!\n2,\"[1,2,3]\"\n3,\"2020-01-01\"\n" + } + ] + } + } + } + ] + } + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/4fb40682a64a978d.sql b/tests/ast_json_fixtures/shapes/4fb40682a64a978d.sql new file mode 100644 index 000000000000..3a948673270f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/4fb40682a64a978d.sql @@ -0,0 +1 @@ +SELECT c1, toTypeName(c1), c2, toTypeName(c2) FROM format('CSV', '1,Hello World!\n2,"[1,2,3]"\n3,"2020-01-01"\n') FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/505e6c9d32c37a01.json b/tests/ast_json_fixtures/shapes/505e6c9d32c37a01.json new file mode 100644 index 000000000000..56ea2095228b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/505e6c9d32c37a01.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "bool_test" + }, + "columns": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Identifier", + "name": "f" + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/505e6c9d32c37a01.sql b/tests/ast_json_fixtures/shapes/505e6c9d32c37a01.sql new file mode 100644 index 000000000000..5dce3926c30e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/505e6c9d32c37a01.sql @@ -0,0 +1,5 @@ +INSERT INTO bool_test (value,f) FORMAT CSV On,test + +INSERT INTO bool_test (value,f) FORMAT TSV Off test + +SELECT value,f FROM bool_test order by value FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/50627708c4d5c459.json b/tests/ast_json_fixtures/shapes/50627708c4d5c459.json new file mode 100644 index 000000000000..ed63447ee114 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50627708c4d5c459.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "github_events" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_type" + }, + { + "type": "Identifier", + "name": "repo_name" + }, + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192", + "index_granularity_bytes": "10Mi" + } + } + }, + "as_table": "gen" + } +} diff --git a/tests/ast_json_fixtures/shapes/50627708c4d5c459.sql b/tests/ast_json_fixtures/shapes/50627708c4d5c459.sql new file mode 100644 index 000000000000..d0d37de01fcb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50627708c4d5c459.sql @@ -0,0 +1 @@ +CREATE TABLE github_events AS gen ENGINE=MergeTree ORDER BY (event_type, repo_name, created_at) SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi' diff --git a/tests/ast_json_fixtures/shapes/5066dc631d8f22a4.json b/tests/ast_json_fixtures/shapes/5066dc631d8f22a4.json new file mode 100644 index 000000000000..cdd70705a688 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5066dc631d8f22a4.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_materialize" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REWRITE_PARTS" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5066dc631d8f22a4.sql b/tests/ast_json_fixtures/shapes/5066dc631d8f22a4.sql new file mode 100644 index 000000000000..07854c3d0dea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5066dc631d8f22a4.sql @@ -0,0 +1 @@ +alter table test_materialize rewrite parts diff --git a/tests/ast_json_fixtures/shapes/506a853486af390e.json b/tests/ast_json_fixtures/shapes/506a853486af390e.json new file mode 100644 index 000000000000..3c9a4f889bab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/506a853486af390e.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "final": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/506a853486af390e.sql b/tests/ast_json_fixtures/shapes/506a853486af390e.sql new file mode 100644 index 000000000000..7f3545332901 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/506a853486af390e.sql @@ -0,0 +1 @@ +select sum(number) from numbers(10) settings final=1 diff --git a/tests/ast_json_fixtures/shapes/50734a2562ddeffc.json b/tests/ast_json_fixtures/shapes/50734a2562ddeffc.json new file mode 100644 index 000000000000..a4ccc7d59c65 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50734a2562ddeffc.json @@ -0,0 +1,113 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "D" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "C" + }, + { + "type": "Identifier", + "name": "E" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "C" + }, + { + "type": "Identifier", + "name": "E" + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_extract_common_expressions": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/50734a2562ddeffc.sql b/tests/ast_json_fixtures/shapes/50734a2562ddeffc.sql new file mode 100644 index 000000000000..2fd389cb2a3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50734a2562ddeffc.sql @@ -0,0 +1 @@ +SELECT * FROM x WHERE (D AND 5) OR ((C AND E) AND (C AND E)) ORDER BY ALL LIMIT 3 SETTINGS optimize_extract_common_expressions = 0 diff --git a/tests/ast_json_fixtures/shapes/5095eec3426fe618.json b/tests/ast_json_fixtures/shapes/5095eec3426fe618.json new file mode 100644 index 000000000000..652fddcc2e44 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5095eec3426fe618.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "replace_table": true, + "create_or_replace": true, + "table": { + "type": "Identifier", + "name": "join" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Join", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "ANY" + }, + { + "type": "Identifier", + "name": "INNER" + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5095eec3426fe618.sql b/tests/ast_json_fixtures/shapes/5095eec3426fe618.sql new file mode 100644 index 000000000000..c6449d3b6704 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5095eec3426fe618.sql @@ -0,0 +1 @@ +create or replace table join engine=Join(ANY, INNER, n) as select * from t diff --git a/tests/ast_json_fixtures/shapes/50c1f649cf77fa04.json b/tests/ast_json_fixtures/shapes/50c1f649cf77fa04.json new file mode 100644 index 000000000000..cee4f3f1ab22 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50c1f649cf77fa04.json @@ -0,0 +1,141 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "database": { + "type": "Identifier", + "name": "ordinary_db" + }, + "table": { + "type": "Identifier", + "name": "dict1" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "key_column", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "second_column", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "third_column", + "data_type": { + "type": "DataType", + "name": "String" + }, + "default_value": { + "type": "Literal", + "value_type": "String", + "value": "qqq" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "key_column" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "user", + "value": { + "type": "Literal", + "value_type": "String", + "value": "default" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "table_for_dict" + } + }, + { + "type": "pair", + "key": "password", + "value": { + "type": "Literal", + "value_type": "String", + "value": "" + } + }, + { + "type": "pair", + "key": "db", + "value": { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 1, + "max_sec": 10 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + }, + "settings": { + "type": "DictionarySettings", + "changes": { + "max_result_bytes": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/50c1f649cf77fa04.sql b/tests/ast_json_fixtures/shapes/50c1f649cf77fa04.sql new file mode 100644 index 000000000000..9309315ff68e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50c1f649cf77fa04.sql @@ -0,0 +1,10 @@ +CREATE DICTIONARY ordinary_db.dict1 +( + key_column UInt64 DEFAULT 0, + second_column UInt64 DEFAULT 1, + third_column String DEFAULT 'qqq' +) +PRIMARY KEY key_column +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB currentDatabase())) +LIFETIME(MIN 1 MAX 10) +LAYOUT(FLAT()) SETTINGS(max_result_bytes=1) diff --git a/tests/ast_json_fixtures/shapes/50c5b0e3de1fe869.json b/tests/ast_json_fixtures/shapes/50c5b0e3de1fe869.json new file mode 100644 index 000000000000..7a98c7d9d1c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50c5b0e3de1fe869.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01223" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "distributed_aggregation_memory_efficient": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/50c5b0e3de1fe869.sql b/tests/ast_json_fixtures/shapes/50c5b0e3de1fe869.sql new file mode 100644 index 000000000000..87a83662f013 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50c5b0e3de1fe869.sql @@ -0,0 +1,2 @@ +select * from dist_01223 group by key order by key settings +distributed_aggregation_memory_efficient=1 diff --git a/tests/ast_json_fixtures/shapes/50e6118f46a9dd41.json b/tests/ast_json_fixtures/shapes/50e6118f46a9dd41.json new file mode 100644 index 000000000000..59425354eac5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50e6118f46a9dd41.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "numbers_10_00223" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/50e6118f46a9dd41.sql b/tests/ast_json_fixtures/shapes/50e6118f46a9dd41.sql new file mode 100644 index 000000000000..9d3b54f4f800 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50e6118f46a9dd41.sql @@ -0,0 +1,9 @@ +SELECT * +FROM +( + SELECT 1 + FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_10_00223) + WITH TOTALS +) +WHERE 1 +GROUP BY 1 diff --git a/tests/ast_json_fixtures/shapes/50e9c84e9ca0d05e.json b/tests/ast_json_fixtures/shapes/50e9c84e9ca0d05e.json new file mode 100644 index 000000000000..ef43608b3e57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50e9c84e9ca0d05e.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "roles": { + "type": "RolesOrUsersSet", + "names": ["r2_01292"] + }, + "grantees": { + "type": "RolesOrUsersSet", + "names": ["u1_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/50e9c84e9ca0d05e.sql b/tests/ast_json_fixtures/shapes/50e9c84e9ca0d05e.sql new file mode 100644 index 000000000000..8d41a1c6db9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/50e9c84e9ca0d05e.sql @@ -0,0 +1 @@ +GRANT r2_01292 TO u1_01292 diff --git a/tests/ast_json_fixtures/shapes/510ae0b381964481.json b/tests/ast_json_fixtures/shapes/510ae0b381964481.json new file mode 100644 index 000000000000..4cc3b5b5edae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/510ae0b381964481.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "localhost:9000" + }, + { + "type": "Function", + "name": "database", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "t0" + }, + { + "type": "Literal", + "value_type": "String", + "value": "default" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/510ae0b381964481.sql b/tests/ast_json_fixtures/shapes/510ae0b381964481.sql new file mode 100644 index 000000000000..c98d5b902180 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/510ae0b381964481.sql @@ -0,0 +1 @@ +INSERT INTO TABLE FUNCTION remote('localhost:9000', database(), 't0', 'default', '') VALUES (NULL) diff --git a/tests/ast_json_fixtures/shapes/5118f80ea7eca5df.json b/tests/ast_json_fixtures/shapes/5118f80ea7eca5df.json new file mode 100644 index 000000000000..7b9f34e78baf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5118f80ea7eca5df.json @@ -0,0 +1,203 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "dt_m", + "name": "toStartOfMinute", + "arguments": [ + { + "type": "Identifier", + "name": "datetime" + } + ] + }, + { + "type": "Identifier", + "name": "domain" + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "retry_count" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + }, + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "retry_count" + }, + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "block_count" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "first_time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "projection_test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "dt_m" + }, + { + "type": "Identifier", + "name": "domain" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "domain" + }, + { + "type": "Literal", + "value_type": "String", + "value": "19" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "dt_m" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "domain" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5118f80ea7eca5df.sql b/tests/ast_json_fixtures/shapes/5118f80ea7eca5df.sql new file mode 100644 index 000000000000..c3e3d7201b87 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5118f80ea7eca5df.sql @@ -0,0 +1 @@ +select toStartOfMinute(datetime) dt_m, domain, sum(retry_count) / sum(duration), avg(retry_count / duration), countIf(block_count > 0) / count(), countIf(first_time = 0) / count() from projection_test group by dt_m, domain having domain = '19' order by dt_m, domain diff --git a/tests/ast_json_fixtures/shapes/511e9c7685d8c0ed.json b/tests/ast_json_fixtures/shapes/511e9c7685d8c0ed.json new file mode 100644 index 000000000000..3f75c285065f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/511e9c7685d8c0ed.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "input_format_parquet_max_block_size": "1024" + } + }, + "out_file": { + "type": "Literal", + "value_type": "String", + "value": "\/dev\/null" + }, + "outfile_truncate": true, + "format": "Parquet" + } +} diff --git a/tests/ast_json_fixtures/shapes/511e9c7685d8c0ed.sql b/tests/ast_json_fixtures/shapes/511e9c7685d8c0ed.sql new file mode 100644 index 000000000000..d4733e2b61b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/511e9c7685d8c0ed.sql @@ -0,0 +1 @@ +SELECT 'a' INTO OUTFILE '/dev/null' TRUNCATE FORMAT Parquet SETTINGS input_format_parquet_max_block_size = 1024 diff --git a/tests/ast_json_fixtures/shapes/511f5ee6ab8313b4.json b/tests/ast_json_fixtures/shapes/511f5ee6ab8313b4.json new file mode 100644 index 000000000000..8963225e2992 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/511f5ee6ab8313b4.json @@ -0,0 +1,117 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "js1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "k", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ANY", + "using": [ + { + "type": "Identifier", + "name": "k" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/511f5ee6ab8313b4.sql b/tests/ast_json_fixtures/shapes/511f5ee6ab8313b4.sql new file mode 100644 index 000000000000..2cb532b7c141 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/511f5ee6ab8313b4.sql @@ -0,0 +1 @@ +SELECT 1, x, 2, s, 3, k, 4 FROM (SELECT number AS k FROM system.numbers LIMIT 10) js1 ANY LEFT JOIN t2 USING k diff --git a/tests/ast_json_fixtures/shapes/5153c72d42ff52c0.json b/tests/ast_json_fixtures/shapes/5153c72d42ff52c0.json new file mode 100644 index 000000000000..6aeed4016358 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5153c72d42ff52c0.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN PIPELINE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "read_in_order_two_level_merge_threshold": "0", + "max_threads": "4", + "read_in_order_use_buffering": "0" + } + } + } + ] + }, + "format": "tsv" + } +} diff --git a/tests/ast_json_fixtures/shapes/5153c72d42ff52c0.sql b/tests/ast_json_fixtures/shapes/5153c72d42ff52c0.sql new file mode 100644 index 000000000000..5c0e2a83b24a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5153c72d42ff52c0.sql @@ -0,0 +1,6 @@ +EXPLAIN PIPELINE +SELECT * +FROM tab +ORDER BY t ASC +SETTINGS read_in_order_two_level_merge_threshold = 0, max_threads = 4, read_in_order_use_buffering = 0 +FORMAT tsv diff --git a/tests/ast_json_fixtures/shapes/515f1bcf0a8b9cd0.json b/tests/ast_json_fixtures/shapes/515f1bcf0a8b9cd0.json new file mode 100644 index 000000000000..44db19f697bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/515f1bcf0a8b9cd0.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "shardNum", + "arguments": [] + }, + { + "type": "Function", + "alias": "c", + "name": "shardCount", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2,3}" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "prefer_localhost_replica": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/515f1bcf0a8b9cd0.sql b/tests/ast_json_fixtures/shapes/515f1bcf0a8b9cd0.sql new file mode 100644 index 000000000000..d47be211955f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/515f1bcf0a8b9cd0.sql @@ -0,0 +1 @@ +select shardNum() n, shardCount() c from remote('127.0.0.{1,2,3}', system.one) order by n settings prefer_localhost_replica = 0 diff --git a/tests/ast_json_fixtures/shapes/515f5120405157dc.json b/tests/ast_json_fixtures/shapes/515f5120405157dc.json new file mode 100644 index 000000000000..f4d2ad94bb86 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/515f5120405157dc.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "Dynamic" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/515f5120405157dc.sql b/tests/ast_json_fixtures/shapes/515f5120405157dc.sql new file mode 100644 index 000000000000..4f1a64c58d52 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/515f5120405157dc.sql @@ -0,0 +1 @@ +alter table test add column d Dynamic settings mutations_sync=1 diff --git a/tests/ast_json_fixtures/shapes/5166839fca2ac72d.json b/tests/ast_json_fixtures/shapes/5166839fca2ac72d.json new file mode 100644 index 000000000000..b28941cb8ec1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5166839fca2ac72d.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_alter_fail" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "c0" + } + }, + { + "type": "AlterCommand", + "command_type": "COMMENT_COLUMN", + "column": { + "type": "Identifier", + "name": "c0" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "this should fail" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5166839fca2ac72d.sql b/tests/ast_json_fixtures/shapes/5166839fca2ac72d.sql new file mode 100644 index 000000000000..895f18841e3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5166839fca2ac72d.sql @@ -0,0 +1,3 @@ +ALTER TABLE test_alter_fail + DROP COLUMN c0, + COMMENT COLUMN c0 'this should fail' diff --git a/tests/ast_json_fixtures/shapes/51edaadd5f6d0f18.json b/tests/ast_json_fixtures/shapes/51edaadd5f6d0f18.json new file mode 100644 index 000000000000..88bed3809c27 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/51edaadd5f6d0f18.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u5_01292@65:ff0c::\/96"] + } +} diff --git a/tests/ast_json_fixtures/shapes/51edaadd5f6d0f18.sql b/tests/ast_json_fixtures/shapes/51edaadd5f6d0f18.sql new file mode 100644 index 000000000000..d22c30baa711 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/51edaadd5f6d0f18.sql @@ -0,0 +1 @@ +SHOW CREATE USER 'u5_01292@65:ff0c::/96' diff --git a/tests/ast_json_fixtures/shapes/520c19c5785be7de.json b/tests/ast_json_fixtures/shapes/520c19c5785be7de.json new file mode 100644 index 000000000000..58a5df7e1013 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/520c19c5785be7de.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u5_01292@%.host.com", "u6_01292@%.host.com", "u7_01292@%.host.com", "u8_01292@%.otherhost.com"] + } +} diff --git a/tests/ast_json_fixtures/shapes/520c19c5785be7de.sql b/tests/ast_json_fixtures/shapes/520c19c5785be7de.sql new file mode 100644 index 000000000000..b63331362e8a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/520c19c5785be7de.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS u5_01292@'%.host.com', u6_01292@'%.host.com', u7_01292@'%.host.com', u8_01292@'%.otherhost.com' diff --git a/tests/ast_json_fixtures/shapes/52199d4323cf319f.json b/tests/ast_json_fixtures/shapes/52199d4323cf319f.json new file mode 100644 index 000000000000..c95a87f2d516 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52199d4323cf319f.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "alias": "k", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1025" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1023" + } + } + ], + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/52199d4323cf319f.sql b/tests/ast_json_fixtures/shapes/52199d4323cf319f.sql new file mode 100644 index 000000000000..fa2a14a82cc1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52199d4323cf319f.sql @@ -0,0 +1 @@ +SELECT number, 1 AS k FROM numbers(100000) ORDER BY k, number LIMIT 1025, 1023 FORMAT Values diff --git a/tests/ast_json_fixtures/shapes/523d79d0bd0abd11.json b/tests/ast_json_fixtures/shapes/523d79d0bd0abd11.json new file mode 100644 index 000000000000..71ffa4f8b5e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/523d79d0bd0abd11.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "replace_table": true, + "create_or_replace": true, + "table": { + "type": "Identifier", + "name": "tx" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Time" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/523d79d0bd0abd11.sql b/tests/ast_json_fixtures/shapes/523d79d0bd0abd11.sql new file mode 100644 index 000000000000..f28c23dd789a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/523d79d0bd0abd11.sql @@ -0,0 +1 @@ +CREATE OR REPLACE TABLE tx (c0 Time) ENGINE = Memory diff --git a/tests/ast_json_fixtures/shapes/52646c475c693eab.json b/tests/ast_json_fixtures/shapes/52646c475c693eab.json new file mode 100644 index 000000000000..6d5391f9c21d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52646c475c693eab.json @@ -0,0 +1,143 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a1" + }, + { + "type": "Identifier", + "name": "b1" + }, + { + "type": "Identifier", + "name": "a2" + }, + { + "type": "Identifier", + "name": "b2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ANY", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "z" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "z", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab2" + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/52646c475c693eab.sql b/tests/ast_json_fixtures/shapes/52646c475c693eab.sql new file mode 100644 index 000000000000..3dc72a80a936 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52646c475c693eab.sql @@ -0,0 +1 @@ +select a1, b1, a2, b2 from tab1 any left join (select *, a2 + 1 as z from tab2) on b1 + 2 = z + 1 format TSV diff --git a/tests/ast_json_fixtures/shapes/52752a3af457cc2f.json b/tests/ast_json_fixtures/shapes/52752a3af457cc2f.json new file mode 100644 index 000000000000..a4b69ed12b0b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52752a3af457cc2f.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/52752a3af457cc2f.sql b/tests/ast_json_fixtures/shapes/52752a3af457cc2f.sql new file mode 100644 index 000000000000..1dae6c8ceef5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52752a3af457cc2f.sql @@ -0,0 +1 @@ +SELECT 1 AS n WITH CUBE diff --git a/tests/ast_json_fixtures/shapes/528127388fe348be.json b/tests/ast_json_fixtures/shapes/528127388fe348be.json new file mode 100644 index 000000000000..efd8d383e7a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/528127388fe348be.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ], + "format": "JSONCompactStringsEachRowWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/528127388fe348be.sql b/tests/ast_json_fixtures/shapes/528127388fe348be.sql new file mode 100644 index 000000000000..128b409818db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/528127388fe348be.sql @@ -0,0 +1 @@ +SELECT * FROM test_table FORMAT JSONCompactStringsEachRowWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/52932bcf392ad9f0.json b/tests/ast_json_fixtures/shapes/52932bcf392ad9f0.json new file mode 100644 index 000000000000..87d93a639b74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52932bcf392ad9f0.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "is_dictionary": true, + "database": { + "type": "Identifier", + "name": "db_01018" + }, + "table": { + "type": "Identifier", + "name": "dict1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/52932bcf392ad9f0.sql b/tests/ast_json_fixtures/shapes/52932bcf392ad9f0.sql new file mode 100644 index 000000000000..478a134c2128 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52932bcf392ad9f0.sql @@ -0,0 +1 @@ +ATTACH DICTIONARY db_01018.dict1 diff --git a/tests/ast_json_fixtures/shapes/52a213515f77c470.json b/tests/ast_json_fixtures/shapes/52a213515f77c470.json new file mode 100644 index 000000000000..4ca33a029e72 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52a213515f77c470.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_block_mismatch_sk1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + }, + "primary_key": { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Identifier", + "name": "a" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/52a213515f77c470.sql b/tests/ast_json_fixtures/shapes/52a213515f77c470.sql new file mode 100644 index 000000000000..0b1626d69672 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52a213515f77c470.sql @@ -0,0 +1,9 @@ +CREATE TABLE test_block_mismatch_sk1 +( + a UInt32, + b DateTime +) +ENGINE = ReplacingMergeTree +PARTITION BY toYYYYMM(b) +PRIMARY KEY (toDate(b)) +ORDER BY (toDate(b), a) diff --git a/tests/ast_json_fixtures/shapes/52a2b51a1aa7e1f0.json b/tests/ast_json_fixtures/shapes/52a2b51a1aa7e1f0.json new file mode 100644 index 000000000000..fcf8233a3ee6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52a2b51a1aa7e1f0.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r5_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "max_value": "5000000" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/52a2b51a1aa7e1f0.sql b/tests/ast_json_fixtures/shapes/52a2b51a1aa7e1f0.sql new file mode 100644 index 000000000000..4094f1286cfc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52a2b51a1aa7e1f0.sql @@ -0,0 +1 @@ +CREATE ROLE r5_01293 SETTINGS max_memory_usage MAX=5000000 diff --git a/tests/ast_json_fixtures/shapes/52b29b683d110b3c.json b/tests/ast_json_fixtures/shapes/52b29b683d110b3c.json new file mode 100644 index 000000000000..8a5908d7c7cf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52b29b683d110b3c.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u12_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/52b29b683d110b3c.sql b/tests/ast_json_fixtures/shapes/52b29b683d110b3c.sql new file mode 100644 index 000000000000..d1589c3d9a44 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52b29b683d110b3c.sql @@ -0,0 +1 @@ +SHOW CREATE USER u12_01292 diff --git a/tests/ast_json_fixtures/shapes/52b6725a77f6fa0c.json b/tests/ast_json_fixtures/shapes/52b6725a77f6fa0c.json new file mode 100644 index 000000000000..2d7229d1bb01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52b6725a77f6fa0c.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "START DISTRIBUTED SENDS", + "database": { + "type": "Identifier", + "name": "db_01294" + }, + "table": { + "type": "Identifier", + "name": "dist_01294" + }, + "cluster": "test_shard_localhost" + } +} diff --git a/tests/ast_json_fixtures/shapes/52b6725a77f6fa0c.sql b/tests/ast_json_fixtures/shapes/52b6725a77f6fa0c.sql new file mode 100644 index 000000000000..7d034ac57553 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52b6725a77f6fa0c.sql @@ -0,0 +1 @@ +system start distributed sends on cluster test_shard_localhost db_01294.dist_01294 diff --git a/tests/ast_json_fixtures/shapes/52c38c82e371d9c0.json b/tests/ast_json_fixtures/shapes/52c38c82e371d9c0.json new file mode 100644 index 000000000000..073028c9be79 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52c38c82e371d9c0.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "f1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Float64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "StorageOrderByElement", + "expression": { + "type": "Identifier", + "name": "c0" + }, + "direction": "DESC" + }, + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_reverse_key": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/52c38c82e371d9c0.sql b/tests/ast_json_fixtures/shapes/52c38c82e371d9c0.sql new file mode 100644 index 000000000000..27576d0368e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52c38c82e371d9c0.sql @@ -0,0 +1 @@ +CREATE TABLE f1 (c0 Float64) ENGINE = MergeTree() ORDER BY c0 DESC SETTINGS allow_experimental_reverse_key=1 diff --git a/tests/ast_json_fixtures/shapes/52ce458f296f0917.json b/tests/ast_json_fixtures/shapes/52ce458f296f0917.json new file mode 100644 index 000000000000..8e75d5030d8f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52ce458f296f0917.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/52ce458f296f0917.sql b/tests/ast_json_fixtures/shapes/52ce458f296f0917.sql new file mode 100644 index 000000000000..27b79ee25929 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52ce458f296f0917.sql @@ -0,0 +1 @@ +SELECT number, count() FROM numbers(10) WHERE number = -1 GROUP BY number WITH TOTALS FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/52f17a33335b19e9.json b/tests/ast_json_fixtures/shapes/52f17a33335b19e9.json new file mode 100644 index 000000000000..b0bde9856032 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52f17a33335b19e9.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Identifier", + "name": "f" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "bool_test" + } + } + } + ] + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/52f17a33335b19e9.sql b/tests/ast_json_fixtures/shapes/52f17a33335b19e9.sql new file mode 100644 index 000000000000..5f6fd13b4033 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/52f17a33335b19e9.sql @@ -0,0 +1 @@ +SELECT value,f FROM bool_test FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/530c1e6d09ecf554.json b/tests/ast_json_fixtures/shapes/530c1e6d09ecf554.json new file mode 100644 index 000000000000..2377ed188dc5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/530c1e6d09ecf554.json @@ -0,0 +1,220 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "03789_rmv_mv" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "lower_limit", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + }, + { + "type": "Subquery", + "alias": "upper_limit", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "lower_limit" + } + ] + } + } + ] + } + }, + { + "type": "WithElement", + "name": "result", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "message", + "value_type": "String", + "value": "OH NO" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "lower_limit" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "upper_limit" + } + ] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "result" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "table": "03789_rmv_target" + } + ] + }, + "refresh": { + "type": "RefreshStrategy", + "schedule_kind": "EVERY", + "append": true, + "period": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Month", + "value": "1" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/530c1e6d09ecf554.sql b/tests/ast_json_fixtures/shapes/530c1e6d09ecf554.sql new file mode 100644 index 000000000000..81969f248f92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/530c1e6d09ecf554.sql @@ -0,0 +1,17 @@ +CREATE MATERIALIZED VIEW 03789_rmv_mv REFRESH EVERY 1 MONTH APPEND TO 03789_rmv_target AS WITH + ( + SELECT 1 + ) AS lower_limit, + ( + SELECT number + FROM numbers(10) + WHERE number = lower_limit + ) AS upper_limit, + result AS + ( + SELECT 'OH NO' AS message + FROM numbers(10) + WHERE (number >= lower_limit) AND (number <= upper_limit) + ) +SELECT * +FROM result diff --git a/tests/ast_json_fixtures/shapes/530d2d325df3a739.json b/tests/ast_json_fixtures/shapes/530d2d325df3a739.json new file mode 100644 index 000000000000..fa8ab5184509 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/530d2d325df3a739.json @@ -0,0 +1,83 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.4" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "02863_delayed_source" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_write_statistics": "0" + } + }, + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/530d2d325df3a739.sql b/tests/ast_json_fixtures/shapes/530d2d325df3a739.sql new file mode 100644 index 000000000000..4a848d6ecbc6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/530d2d325df3a739.sql @@ -0,0 +1 @@ +SELECT sum(a) FROM remote('127.0.0.4', currentDatabase(), '02863_delayed_source') GROUP BY a ORDER BY a LIMIT 1 FORMAT JSON settings output_format_write_statistics=0 diff --git a/tests/ast_json_fixtures/shapes/53160f662ad924ca.json b/tests/ast_json_fixtures/shapes/53160f662ad924ca.json new file mode 100644 index 000000000000..92467017d2c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53160f662ad924ca.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "k", + "name": "number" + } + ], + "select": [ + { + "type": "Identifier", + "name": "k" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/53160f662ad924ca.sql b/tests/ast_json_fixtures/shapes/53160f662ad924ca.sql new file mode 100644 index 000000000000..70f554b512b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53160f662ad924ca.sql @@ -0,0 +1 @@ +WITH number AS k SELECT k FROM system.numbers LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/531954d86e7a40f5.json b/tests/ast_json_fixtures/shapes/531954d86e7a40f5.json new file mode 100644 index 000000000000..60d31ad29916 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/531954d86e7a40f5.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p3_01296", + "table": "table" + }, + { + "short_name": "p3_01296", + "table": "table2" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet", + "names": ["u1_01296"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/531954d86e7a40f5.sql b/tests/ast_json_fixtures/shapes/531954d86e7a40f5.sql new file mode 100644 index 000000000000..d280e3ba1975 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/531954d86e7a40f5.sql @@ -0,0 +1 @@ +CREATE ROW POLICY p3_01296 ON table, table2 TO u1_01296 diff --git a/tests/ast_json_fixtures/shapes/532cdf6ebf85bf14.json b/tests/ast_json_fixtures/shapes/532cdf6ebf85bf14.json new file mode 100644 index 000000000000..39b96355210c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/532cdf6ebf85bf14.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "partition_all2" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "clear_column": true, + "column": { + "type": "Identifier", + "name": "q" + }, + "partition": { + "type": "Partition_ID", + "all": true + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/532cdf6ebf85bf14.sql b/tests/ast_json_fixtures/shapes/532cdf6ebf85bf14.sql new file mode 100644 index 000000000000..2c8eed63e93a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/532cdf6ebf85bf14.sql @@ -0,0 +1 @@ +ALTER TABLE partition_all2 CLEAR COLUMN q IN PARTITION ALL diff --git a/tests/ast_json_fixtures/shapes/5349acc2e87d6045.json b/tests/ast_json_fixtures/shapes/5349acc2e87d6045.json new file mode 100644 index 000000000000..a417bc3fc190 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5349acc2e87d6045.json @@ -0,0 +1,174 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "x", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "a", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "y", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "a", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "y" + } + } + } + ] + } + } + ] + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5349acc2e87d6045.sql b/tests/ast_json_fixtures/shapes/5349acc2e87d6045.sql new file mode 100644 index 000000000000..b00164a95f34 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5349acc2e87d6045.sql @@ -0,0 +1,5 @@ +WITH +x AS (SELECT number AS a FROM numbers(10)), +y AS (SELECT number AS a FROM numbers(5)) +SELECT * FROM x WHERE a in (SELECT a FROM y) +ORDER BY a diff --git a/tests/ast_json_fixtures/shapes/5358424f615e0703.json b/tests/ast_json_fixtures/shapes/5358424f615e0703.json new file mode 100644 index 000000000000..7f99fc0d5b7a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5358424f615e0703.json @@ -0,0 +1,213 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "%W" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-01-02 22:33:44" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + }, + { + "type": "Function", + "name": "hasSubsequence", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "garbage" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "gr" + } + ] + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-01-02 22:33:44" + }, + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-01-02 22:33:44" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "gr" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2018-01-02 22:33:44" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5358424f615e0703.sql b/tests/ast_json_fixtures/shapes/5358424f615e0703.sql new file mode 100644 index 000000000000..5b7571a9d8e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5358424f615e0703.sql @@ -0,0 +1,9 @@ +SELECT toFixedString(toFixedString(toFixedString(toFixedString(toFixedString(toFixedString('%W', 2), 2), 2),toLowCardinality(toLowCardinality(toNullable(2)))), 2), 2), + toFixedString(toFixedString('2018-01-02 22:33:44', 19), 19), + hasSubsequence(toNullable(materialize(toLowCardinality('garbage'))), 'gr') +GROUP BY + '2018-01-02 22:33:44', + toFixedString(toFixedString('2018-01-02 22:33:44', 19), 19), + 'gr', + '2018-01-02 22:33:44' +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/5359399effb1a745.json b/tests/ast_json_fixtures/shapes/5359399effb1a745.json new file mode 100644 index 000000000000..7f30f94a9b7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5359399effb1a745.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "zookeeper_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5359399effb1a745.sql b/tests/ast_json_fixtures/shapes/5359399effb1a745.sql new file mode 100644 index 000000000000..dee8cb5fcd84 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5359399effb1a745.sql @@ -0,0 +1 @@ +system flush logs zookeeper_log diff --git a/tests/ast_json_fixtures/shapes/535bbb4f23f96d16.json b/tests/ast_json_fixtures/shapes/535bbb4f23f96d16.json new file mode 100644 index 000000000000..3a021ccaff6c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/535bbb4f23f96d16.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "Num" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "order" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Type" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "Num" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/535bbb4f23f96d16.sql b/tests/ast_json_fixtures/shapes/535bbb4f23f96d16.sql new file mode 100644 index 000000000000..65b2aab686d9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/535bbb4f23f96d16.sql @@ -0,0 +1,5 @@ +SELECT Num +FROM order +PREWHERE Type = 1 +WHERE ID = 1 +ORDER BY Num ASC limit 5 diff --git a/tests/ast_json_fixtures/shapes/536a5bcba2892255.json b/tests/ast_json_fixtures/shapes/536a5bcba2892255.json new file mode 100644 index 000000000000..bbd799a2c00d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/536a5bcba2892255.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/536a5bcba2892255.sql b/tests/ast_json_fixtures/shapes/536a5bcba2892255.sql new file mode 100644 index 000000000000..2c2c78c1e17e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/536a5bcba2892255.sql @@ -0,0 +1 @@ +SELECT number FROM numbers(3) GROUP BY (number, number % 2) ORDER BY number diff --git a/tests/ast_json_fixtures/shapes/5371c088deec9864.json b/tests/ast_json_fixtures/shapes/5371c088deec9864.json new file mode 100644 index 000000000000..fdbc54890f89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5371c088deec9864.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "SET_SNAPSHOT", + "snapshot": "3" + } +} diff --git a/tests/ast_json_fixtures/shapes/5371c088deec9864.sql b/tests/ast_json_fixtures/shapes/5371c088deec9864.sql new file mode 100644 index 000000000000..dc730bf09508 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5371c088deec9864.sql @@ -0,0 +1 @@ +set transaction snapshot 3 diff --git a/tests/ast_json_fixtures/shapes/5386e6007b47aece.json b/tests/ast_json_fixtures/shapes/5386e6007b47aece.json new file mode 100644 index 000000000000..424baf3c1bb1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5386e6007b47aece.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": [" spaces "] + } +} diff --git a/tests/ast_json_fixtures/shapes/5386e6007b47aece.sql b/tests/ast_json_fixtures/shapes/5386e6007b47aece.sql new file mode 100644 index 000000000000..dbab9e373fab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5386e6007b47aece.sql @@ -0,0 +1 @@ +drop user if exists " spaces " diff --git a/tests/ast_json_fixtures/shapes/5389063ed77886b2.json b/tests/ast_json_fixtures/shapes/5389063ed77886b2.json new file mode 100644 index 000000000000..2f2a6de799a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5389063ed77886b2.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONCompactEachRowWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/5389063ed77886b2.sql b/tests/ast_json_fixtures/shapes/5389063ed77886b2.sql new file mode 100644 index 000000000000..e7e56d1c9f96 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5389063ed77886b2.sql @@ -0,0 +1 @@ +SELECT name, count() AS c FROM test_table GROUP BY name WITH TOTALS ORDER BY name FORMAT JSONCompactEachRowWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/5395d36769dabf18.json b/tests/ast_json_fixtures/shapes/5395d36769dabf18.json new file mode 100644 index 000000000000..fa75f888fcc2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5395d36769dabf18.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "number" + }, + { + "type": "Function", + "alias": "y", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "alias": "z", + "value_type": "String", + "value": "Hello" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ], + "format": "SQLInsert" + } +} diff --git a/tests/ast_json_fixtures/shapes/5395d36769dabf18.sql b/tests/ast_json_fixtures/shapes/5395d36769dabf18.sql new file mode 100644 index 000000000000..cf1e053f001e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5395d36769dabf18.sql @@ -0,0 +1 @@ +select number as x, number % 3 as y, 'Hello' as z from numbers(5) format SQLInsert diff --git a/tests/ast_json_fixtures/shapes/53995e8a8b05ed9e.json b/tests/ast_json_fixtures/shapes/53995e8a8b05ed9e.json new file mode 100644 index 000000000000..a07fa410934a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53995e8a8b05ed9e.json @@ -0,0 +1,230 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ] + }, + { + "type": "Function", + "name": "COUNT", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\n?pVa" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ], + "having": { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ] + }, + { + "type": "Function", + "name": "COUNT", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\n?pVa" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ], + "having": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ] + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ] + }, + { + "type": "Function", + "name": "COUNT", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\n?pVa" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ], + "having": { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "aggregate_functions_null_for_empty": "1", + "enable_optimize_predicate_expression": "0" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/53995e8a8b05ed9e.sql b/tests/ast_json_fixtures/shapes/53995e8a8b05ed9e.sql new file mode 100644 index 000000000000..ddc08eb6d1b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53995e8a8b05ed9e.sql @@ -0,0 +1,15 @@ +SELECT isNull(t0.c0) OR COUNT('\n?pVa') +FROM t0 +GROUP BY t0.c0 +HAVING isNull(t0.c0) +UNION ALL +SELECT isNull(t0.c0) OR COUNT('\n?pVa') +FROM t0 +GROUP BY t0.c0 +HAVING NOT isNull(t0.c0) +UNION ALL +SELECT isNull(t0.c0) OR COUNT('\n?pVa') +FROM t0 +GROUP BY t0.c0 +HAVING isNull(isNull(t0.c0)) +SETTINGS aggregate_functions_null_for_empty = 1, enable_optimize_predicate_expression = 0 format Null diff --git a/tests/ast_json_fixtures/shapes/53a56a33551387b6.json b/tests/ast_json_fixtures/shapes/53a56a33551387b6.json new file mode 100644 index 000000000000..9523dabd3156 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53a56a33551387b6.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "format", + "arguments": [ + { + "type": "Function", + "name": "untuple", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIntervalQuarter", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "assumeNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "hola" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "JSONEachRow" + } + ] + }, + "final": true + }, + "settings": { + "type": "Settings", + "changes": { + "schema_inference_hints": "ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/53a56a33551387b6.sql b/tests/ast_json_fixtures/shapes/53a56a33551387b6.sql new file mode 100644 index 000000000000..0929b96490ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53a56a33551387b6.sql @@ -0,0 +1,3 @@ +DESCRIBE TABLE format(untuple((toIntervalQuarter(1), assumeNotNull(8) IS NOT NULL, isNullable(7) % 1, 4, materialize('hola'), 4)), JSONEachRow) + FINAL + SETTINGS schema_inference_hints = 'ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼ð(Œ¼' diff --git a/tests/ast_json_fixtures/shapes/53ae0ac415c3982c.json b/tests/ast_json_fixtures/shapes/53ae0ac415c3982c.json new file mode 100644 index 000000000000..59d2eb491828 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53ae0ac415c3982c.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "type_json_dst" + }, + "as_table": "type_json_src" + } +} diff --git a/tests/ast_json_fixtures/shapes/53ae0ac415c3982c.sql b/tests/ast_json_fixtures/shapes/53ae0ac415c3982c.sql new file mode 100644 index 000000000000..3f9bcfca39fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53ae0ac415c3982c.sql @@ -0,0 +1 @@ +CREATE TABLE type_json_dst AS type_json_src diff --git a/tests/ast_json_fixtures/shapes/53afe9c22deaa3b4.json b/tests/ast_json_fixtures/shapes/53afe9c22deaa3b4.json new file mode 100644 index 000000000000..f07ea3a7a425 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53afe9c22deaa3b4.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/53afe9c22deaa3b4.sql b/tests/ast_json_fixtures/shapes/53afe9c22deaa3b4.sql new file mode 100644 index 000000000000..a8a37c608774 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53afe9c22deaa3b4.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/53eb0792239439aa.json b/tests/ast_json_fixtures/shapes/53eb0792239439aa.json new file mode 100644 index 000000000000..1cea949c3950 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53eb0792239439aa.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "partition_all2" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition_ID", + "all": true + }, + "replace": true, + "from_table": "partition_all" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/53eb0792239439aa.sql b/tests/ast_json_fixtures/shapes/53eb0792239439aa.sql new file mode 100644 index 000000000000..65640e4c8ddd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53eb0792239439aa.sql @@ -0,0 +1 @@ +ALTER TABLE partition_all2 REPLACE PARTITION ALL FROM partition_all diff --git a/tests/ast_json_fixtures/shapes/53fb8f5033d5edd6.json b/tests/ast_json_fixtures/shapes/53fb8f5033d5edd6.json new file mode 100644 index 000000000000..68a249781ea5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53fb8f5033d5edd6.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["test_user_01999"] + } +} diff --git a/tests/ast_json_fixtures/shapes/53fb8f5033d5edd6.sql b/tests/ast_json_fixtures/shapes/53fb8f5033d5edd6.sql new file mode 100644 index 000000000000..686f9428f9f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/53fb8f5033d5edd6.sql @@ -0,0 +1 @@ +SHOW CREATE USER test_user_01999 diff --git a/tests/ast_json_fixtures/shapes/5411921f733e22ba.json b/tests/ast_json_fixtures/shapes/5411921f733e22ba.json new file mode 100644 index 000000000000..13009b3f4d9c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5411921f733e22ba.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "cluster", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/5411921f733e22ba.sql b/tests/ast_json_fixtures/shapes/5411921f733e22ba.sql new file mode 100644 index 000000000000..9830310e4ebe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5411921f733e22ba.sql @@ -0,0 +1 @@ +select * from (select * from cluster(test_cluster_two_shards, currentDatabase(), test) where i < 10) order by i limit 1 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/54494d48b7f6e997.json b/tests/ast_json_fixtures/shapes/54494d48b7f6e997.json new file mode 100644 index 000000000000..7b41b51a6bbb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54494d48b7f6e997.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Identifier", + "name": "s.size", + "name_parts": ["s", "size"] + }, + { + "type": "Identifier", + "name": "t.a", + "name_parts": ["t", "a"] + }, + { + "type": "Identifier", + "name": "t.a.size", + "name_parts": ["t", "a", "size"] + }, + { + "type": "Identifier", + "name": "t.b", + "name_parts": ["t", "b"] + }, + { + "type": "Identifier", + "name": "t.b.size", + "name_parts": ["t", "b", "size"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_new_wide" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/54494d48b7f6e997.sql b/tests/ast_json_fixtures/shapes/54494d48b7f6e997.sql new file mode 100644 index 000000000000..11454b0a3cdd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54494d48b7f6e997.sql @@ -0,0 +1 @@ +select s, s.size, t.a, t.a.size, t.b, t.b.size from test_new_wide order by all limit 2 offset 3 diff --git a/tests/ast_json_fixtures/shapes/545646e2c5808b19.json b/tests/ast_json_fixtures/shapes/545646e2c5808b19.json new file mode 100644 index 000000000000..12b83b5c69ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/545646e2c5808b19.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "y", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "t" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "String", + "value": "true" + } + ] + } + } + ] + } + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/545646e2c5808b19.sql b/tests/ast_json_fixtures/shapes/545646e2c5808b19.sql new file mode 100644 index 000000000000..6df87e01c6d9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/545646e2c5808b19.sql @@ -0,0 +1,2 @@ +with ('t' || x) as y select * from + (select 1 from tab where y = 'true') settings enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/546424a1ba06a083.json b/tests/ast_json_fixtures/shapes/546424a1ba06a083.json new file mode 100644 index 000000000000..30bccf582676 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/546424a1ba06a083.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parallel_replicas_plain" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/546424a1ba06a083.sql b/tests/ast_json_fixtures/shapes/546424a1ba06a083.sql new file mode 100644 index 000000000000..c30cae1caff8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/546424a1ba06a083.sql @@ -0,0 +1 @@ +SELECT x FROM parallel_replicas_plain LIMIT 1 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/54684172b19e6cdd.json b/tests/ast_json_fixtures/shapes/54684172b19e6cdd.json new file mode 100644 index 000000000000..9ef3d04e9a7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54684172b19e6cdd.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "use_delayed_remote_source" + } +} diff --git a/tests/ast_json_fixtures/shapes/54684172b19e6cdd.sql b/tests/ast_json_fixtures/shapes/54684172b19e6cdd.sql new file mode 100644 index 000000000000..d027d709046a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54684172b19e6cdd.sql @@ -0,0 +1 @@ +SYSTEM ENABLE FAILPOINT use_delayed_remote_source diff --git a/tests/ast_json_fixtures/shapes/546b3e85a9c5840e.json b/tests/ast_json_fixtures/shapes/546b3e85a9c5840e.json new file mode 100644 index 000000000000..31481c070931 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/546b3e85a9c5840e.json @@ -0,0 +1,95 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "field1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "alias10__fuzz_13" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "arrayEnumerateDense", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0.2147483646" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "field1" + }, + { + "type": "Function", + "name": "arrayEnumerateDense", + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "String", + "value": "0.02" + }, + { + "value_type": "String", + "value": "0.1" + }, + { + "value_type": "String", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/546b3e85a9c5840e.sql b/tests/ast_json_fixtures/shapes/546b3e85a9c5840e.sql new file mode 100644 index 000000000000..6ce2b6d7ec65 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/546b3e85a9c5840e.sql @@ -0,0 +1 @@ +SELECT field1 FROM alias10__fuzz_13 WHERE arrayEnumerateDense(NULL, tuple('0.2147483646'), NULL) GROUP BY field1, arrayEnumerateDense(('0.02', '0.1', '0'), NULL) WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/548fe129eb492ccb.json b/tests/ast_json_fixtures/shapes/548fe129eb492ccb.json new file mode 100644 index 000000000000..da24810553e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/548fe129eb492ccb.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["READ"], + "parameter": "POSTGRES" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_03593"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/548fe129eb492ccb.sql b/tests/ast_json_fixtures/shapes/548fe129eb492ccb.sql new file mode 100644 index 000000000000..0ad613feaef6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/548fe129eb492ccb.sql @@ -0,0 +1 @@ +GRANT READ ON POSTGRES TO test_user_03593 diff --git a/tests/ast_json_fixtures/shapes/549dd099ea5460e4.json b/tests/ast_json_fixtures/shapes/549dd099ea5460e4.json new file mode 100644 index 000000000000..80c7a1a33280 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/549dd099ea5460e4.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "02416_test_memory" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "02416_test" + } +} diff --git a/tests/ast_json_fixtures/shapes/549dd099ea5460e4.sql b/tests/ast_json_fixtures/shapes/549dd099ea5460e4.sql new file mode 100644 index 000000000000..a1b97640e73d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/549dd099ea5460e4.sql @@ -0,0 +1 @@ +CREATE TABLE 02416_test_memory AS 02416_test Engine = Memory diff --git a/tests/ast_json_fixtures/shapes/54b5cd0ca6ef960e.json b/tests/ast_json_fixtures/shapes/54b5cd0ca6ef960e.json new file mode 100644 index 000000000000..bf726a968fb6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54b5cd0ca6ef960e.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettySpaceNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/54b5cd0ca6ef960e.sql b/tests/ast_json_fixtures/shapes/54b5cd0ca6ef960e.sql new file mode 100644 index 000000000000..c61dc7dc86a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54b5cd0ca6ef960e.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettySpaceNoEscapes diff --git a/tests/ast_json_fixtures/shapes/54d4154b378984fb.json b/tests/ast_json_fixtures/shapes/54d4154b378984fb.json new file mode 100644 index 000000000000..5abe915f07b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54d4154b378984fb.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "f0" + } +} diff --git a/tests/ast_json_fixtures/shapes/54d4154b378984fb.sql b/tests/ast_json_fixtures/shapes/54d4154b378984fb.sql new file mode 100644 index 000000000000..071574b0717c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54d4154b378984fb.sql @@ -0,0 +1 @@ +DROP FUNCTION f0 diff --git a/tests/ast_json_fixtures/shapes/54f264155b16607c.json b/tests/ast_json_fixtures/shapes/54f264155b16607c.json new file mode 100644 index 000000000000..8f737732790d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54f264155b16607c.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR TEXT INDEX HEADER CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/54f264155b16607c.sql b/tests/ast_json_fixtures/shapes/54f264155b16607c.sql new file mode 100644 index 000000000000..5d353676880b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54f264155b16607c.sql @@ -0,0 +1 @@ +SYSTEM CLEAR TEXT INDEX HEADER CACHE diff --git a/tests/ast_json_fixtures/shapes/54f32cf5fab1f608.json b/tests/ast_json_fixtures/shapes/54f32cf5fab1f608.json new file mode 100644 index 000000000000..ab672b296fca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54f32cf5fab1f608.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Identifier", + "name": "system.numbers", + "name_parts": ["system", "numbers"] + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/54f32cf5fab1f608.sql b/tests/ast_json_fixtures/shapes/54f32cf5fab1f608.sql new file mode 100644 index 000000000000..8f98cd6d62a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/54f32cf5fab1f608.sql @@ -0,0 +1 @@ +SELECT DISTINCT number FROM remote('127.0.0.{2,3}', system.numbers) LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/550ddd4df63d0d95.json b/tests/ast_json_fixtures/shapes/550ddd4df63d0d95.json new file mode 100644 index 000000000000..3925c67a3016 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/550ddd4df63d0d95.json @@ -0,0 +1,194 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "test1", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "alias": "b", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "alias": "m", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "with_test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "alias": "m", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "test1.m", + "name_parts": ["test1", "m"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "43" + } + ] + }, + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/550ddd4df63d0d95.sql b/tests/ast_json_fixtures/shapes/550ddd4df63d0d95.sql new file mode 100644 index 000000000000..557f7529c5c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/550ddd4df63d0d95.sql @@ -0,0 +1,2 @@ +WITH test1 AS (SELECT n, null b, n+1 m FROM with_test where 1=0 or n = 42 order by n limit 4) +SELECT max(n) m FROM test1 where test1.m=43 having max(n)=42 diff --git a/tests/ast_json_fixtures/shapes/551a16ea355e164d.json b/tests/ast_json_fixtures/shapes/551a16ea355e164d.json new file mode 100644 index 000000000000..fd928be4925d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/551a16ea355e164d.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "full_duplicates" + }, + "final": true, + "deduplicate": true + } +} diff --git a/tests/ast_json_fixtures/shapes/551a16ea355e164d.sql b/tests/ast_json_fixtures/shapes/551a16ea355e164d.sql new file mode 100644 index 000000000000..eb99636f55b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/551a16ea355e164d.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE full_duplicates FINAL DEDUPLICATE diff --git a/tests/ast_json_fixtures/shapes/5522b32a28bfdd2d.json b/tests/ast_json_fixtures/shapes/5522b32a28bfdd2d.json new file mode 100644 index 000000000000..4cc1aef11afa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5522b32a28bfdd2d.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "visits" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + }, + "final": true + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/5522b32a28bfdd2d.sql b/tests/ast_json_fixtures/shapes/5522b32a28bfdd2d.sql new file mode 100644 index 000000000000..7f40d8cce7e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5522b32a28bfdd2d.sql @@ -0,0 +1 @@ +SELECT id, visits FROM test_table FINAL ORDER BY id FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/552380e9ad017b0b.json b/tests/ast_json_fixtures/shapes/552380e9ad017b0b.json new file mode 100644 index 000000000000..b45802b11bdc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/552380e9ad017b0b.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/552380e9ad017b0b.sql b/tests/ast_json_fixtures/shapes/552380e9ad017b0b.sql new file mode 100644 index 000000000000..08b5a9c76135 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/552380e9ad017b0b.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number limit 1 diff --git a/tests/ast_json_fixtures/shapes/55263fcaf233c122.json b/tests/ast_json_fixtures/shapes/55263fcaf233c122.json new file mode 100644 index 000000000000..0f1f75a2c37d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/55263fcaf233c122.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int" + } + }, + { + "type": "ColumnDeclaration", + "name": "c1", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p0", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "c0" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/55263fcaf233c122.sql b/tests/ast_json_fixtures/shapes/55263fcaf233c122.sql new file mode 100644 index 000000000000..2ac66338835a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/55263fcaf233c122.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE t0 (c0 Int, c1 Int, PROJECTION p0 (SELECT c0 GROUP BY c0)) ENGINE = MergeTree() ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/559560ee289036e0.json b/tests/ast_json_fixtures/shapes/559560ee289036e0.json new file mode 100644 index 000000000000..d70b38c9d6b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/559560ee289036e0.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "merge_dist_01223" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "dist_01223" + } + ] + } + }, + "as_table": "dist_01223" + } +} diff --git a/tests/ast_json_fixtures/shapes/559560ee289036e0.sql b/tests/ast_json_fixtures/shapes/559560ee289036e0.sql new file mode 100644 index 000000000000..75f4a76ea8d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/559560ee289036e0.sql @@ -0,0 +1 @@ +create table merge_dist_01223 as dist_01223 engine=Merge(currentDatabase(), 'dist_01223') diff --git a/tests/ast_json_fixtures/shapes/5596240eb3ff9c3b.json b/tests/ast_json_fixtures/shapes/5596240eb3ff9c3b.json new file mode 100644 index 000000000000..2008060e189c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5596240eb3ff9c3b.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "t_306" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5596240eb3ff9c3b.sql b/tests/ast_json_fixtures/shapes/5596240eb3ff9c3b.sql new file mode 100644 index 000000000000..f542390478d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5596240eb3ff9c3b.sql @@ -0,0 +1 @@ +create table if not exists t_306 (a int) engine Memory diff --git a/tests/ast_json_fixtures/shapes/5596ad850ad4d7ee.json b/tests/ast_json_fixtures/shapes/5596ad850ad4d7ee.json new file mode 100644 index 000000000000..9f3b366e8774 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5596ad850ad4d7ee.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "val", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "val" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "val" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5596ad850ad4d7ee.sql b/tests/ast_json_fixtures/shapes/5596ad850ad4d7ee.sql new file mode 100644 index 000000000000..88a87e18b699 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5596ad850ad4d7ee.sql @@ -0,0 +1 @@ +select toLowCardinality('a') as val group by val order by val diff --git a/tests/ast_json_fixtures/shapes/55d8dd5ba9a653ae.json b/tests/ast_json_fixtures/shapes/55d8dd5ba9a653ae.json new file mode 100644 index 000000000000..efa0c048e362 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/55d8dd5ba9a653ae.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "x" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_INDEX", + "index_declaration": { + "type": "Index", + "name": "nn", + "expression": { + "type": "Function", + "name": "LOG2", + "arguments": [ + { + "type": "Identifier", + "name": "i" + } + ] + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + }, + { + "type": "AlterCommand", + "command_type": "ADD_PROJECTION", + "projection_declaration": { + "type": "Projection", + "name": "p2", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "i" + } + ] + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/55d8dd5ba9a653ae.sql b/tests/ast_json_fixtures/shapes/55d8dd5ba9a653ae.sql new file mode 100644 index 000000000000..398a61535e3a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/55d8dd5ba9a653ae.sql @@ -0,0 +1 @@ +alter table x add index nn LOG2(i) type minmax granularity 1, add projection p2 (select MIN(i)) diff --git a/tests/ast_json_fixtures/shapes/55e7b1ad35d4dc07.json b/tests/ast_json_fixtures/shapes/55e7b1ad35d4dc07.json new file mode 100644 index 000000000000..c777a709ef92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/55e7b1ad35d4dc07.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "database": { + "type": "Identifier", + "name": "02028_db" + }, + "cluster": "test_shard_localhost", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/55e7b1ad35d4dc07.sql b/tests/ast_json_fixtures/shapes/55e7b1ad35d4dc07.sql new file mode 100644 index 000000000000..396c9d4caffd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/55e7b1ad35d4dc07.sql @@ -0,0 +1 @@ +DROP DATABASE IF EXISTS 02028_db ON CLUSTER test_shard_localhost diff --git a/tests/ast_json_fixtures/shapes/562f75dd8afed519.json b/tests/ast_json_fixtures/shapes/562f75dd8afed519.json new file mode 100644 index 000000000000..1d64036dd1f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/562f75dd8afed519.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "replace_partition_dest1" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + "replace": true, + "from_table": "replace_partition_source" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/562f75dd8afed519.sql b/tests/ast_json_fixtures/shapes/562f75dd8afed519.sql new file mode 100644 index 000000000000..633aa201c3a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/562f75dd8afed519.sql @@ -0,0 +1 @@ +ALTER TABLE replace_partition_dest1 REPLACE PARTITION 1 FROM replace_partition_source diff --git a/tests/ast_json_fixtures/shapes/56658018d15b58a4.json b/tests/ast_json_fixtures/shapes/56658018d15b58a4.json new file mode 100644 index 000000000000..c125faf39e15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56658018d15b58a4.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t3" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/56658018d15b58a4.sql b/tests/ast_json_fixtures/shapes/56658018d15b58a4.sql new file mode 100644 index 000000000000..39df07817182 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56658018d15b58a4.sql @@ -0,0 +1 @@ +SELECT 1 FROM t3 WHERE x=1 diff --git a/tests/ast_json_fixtures/shapes/5671f74b76e1de08.json b/tests/ast_json_fixtures/shapes/5671f74b76e1de08.json new file mode 100644 index 000000000000..f7e50aec5198 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5671f74b76e1de08.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "query_log" + }, + { + "table": "text_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5671f74b76e1de08.sql b/tests/ast_json_fixtures/shapes/5671f74b76e1de08.sql new file mode 100644 index 000000000000..d32a24be554b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5671f74b76e1de08.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS query_log, text_log diff --git a/tests/ast_json_fixtures/shapes/5673e0d2d27cc97b.json b/tests/ast_json_fixtures/shapes/5673e0d2d27cc97b.json new file mode 100644 index 000000000000..228311d88eb0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5673e0d2d27cc97b.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "s", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "v" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "group_by_pk" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "0", + "max_block_size": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5673e0d2d27cc97b.sql b/tests/ast_json_fixtures/shapes/5673e0d2d27cc97b.sql new file mode 100644 index 000000000000..eb055073869a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5673e0d2d27cc97b.sql @@ -0,0 +1,2 @@ +SELECT sum(v) AS s FROM group_by_pk GROUP BY k ORDER BY s DESC LIMIT 5 +SETTINGS optimize_aggregation_in_order = 0, max_block_size = 1 diff --git a/tests/ast_json_fixtures/shapes/5689dce0a54d8cb8.json b/tests/ast_json_fixtures/shapes/5689dce0a54d8cb8.json new file mode 100644 index 000000000000..c8fd14368981 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5689dce0a54d8cb8.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p2_01295", + "database": "db", + "table": "table" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER" + } + ], + "roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5689dce0a54d8cb8.sql b/tests/ast_json_fixtures/shapes/5689dce0a54d8cb8.sql new file mode 100644 index 000000000000..6626808088d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5689dce0a54d8cb8.sql @@ -0,0 +1 @@ +CREATE ROW POLICY p2_01295 ON db.table USING NONE TO NONE diff --git a/tests/ast_json_fixtures/shapes/569b6504531c3147.json b/tests/ast_json_fixtures/shapes/569b6504531c3147.json new file mode 100644 index 000000000000..c41d08d08129 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/569b6504531c3147.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "RevokeQuery", + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "test" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["user_03141"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/569b6504531c3147.sql b/tests/ast_json_fixtures/shapes/569b6504531c3147.sql new file mode 100644 index 000000000000..3b2dcf8a0471 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/569b6504531c3147.sql @@ -0,0 +1 @@ +REVOKE SELECT ON test.* FROM user_03141 diff --git a/tests/ast_json_fixtures/shapes/56a52b5e12567ff2.json b/tests/ast_json_fixtures/shapes/56a52b5e12567ff2.json new file mode 100644 index 000000000000..ffbee0c338bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56a52b5e12567ff2.json @@ -0,0 +1,153 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + }, + { + "type": "Identifier", + "name": "d.id", + "name_parts": ["d", "id"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "d.id", + "name_parts": ["d", "id"] + } + ] + }, + { + "type": "Identifier", + "name": "d.values", + "name_parts": ["d", "values"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "d.values", + "name_parts": ["d", "values"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "a", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "value", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "SEMI", + "using": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "d", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "values", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/56a52b5e12567ff2.sql b/tests/ast_json_fixtures/shapes/56a52b5e12567ff2.sql new file mode 100644 index 000000000000..51d8050e1f6e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56a52b5e12567ff2.sql @@ -0,0 +1 @@ +SELECT id, toTypeName(id), value, toTypeName(value), d.id, toTypeName(d.id) , d.values, toTypeName(d.values) FROM ( SELECT 1 AS id, 2 AS value ) a SEMI LEFT JOIN ( SELECT 1 AS id, 3 AS values ) AS d USING id diff --git a/tests/ast_json_fixtures/shapes/56a94731b69c4c73.json b/tests/ast_json_fixtures/shapes/56a94731b69c4c73.json new file mode 100644 index 000000000000..acf2c84ff383 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56a94731b69c4c73.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_03363_mixed_partitioning" + } + } + } + ] + } + } + ], + "format": "null" + } +} diff --git a/tests/ast_json_fixtures/shapes/56a94731b69c4c73.sql b/tests/ast_json_fixtures/shapes/56a94731b69c4c73.sql new file mode 100644 index 000000000000..b15c15d1d8de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56a94731b69c4c73.sql @@ -0,0 +1 @@ +SELECT * FROM t_03363_mixed_partitioning Format null diff --git a/tests/ast_json_fixtures/shapes/56b7df18433069d4.json b/tests/ast_json_fixtures/shapes/56b7df18433069d4.json new file mode 100644 index 000000000000..c023b1060d2d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56b7df18433069d4.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Literal", + "alias": "key", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "alias": "value", + "value_type": "String", + "value": "b" + } + ], + "group_by": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/56b7df18433069d4.sql b/tests/ast_json_fixtures/shapes/56b7df18433069d4.sql new file mode 100644 index 000000000000..18eec515f5b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56b7df18433069d4.sql @@ -0,0 +1 @@ +SELECT 'a' AS key, 'b' as value GROUP BY ignore(1) WITH CUBE diff --git a/tests/ast_json_fixtures/shapes/56c89b8384a5dfc9.json b/tests/ast_json_fixtures/shapes/56c89b8384a5dfc9.json new file mode 100644 index 000000000000..bd71f25ff5bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56c89b8384a5dfc9.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "unhex", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "f0" + } + ] + } + ] + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/56c89b8384a5dfc9.sql b/tests/ast_json_fixtures/shapes/56c89b8384a5dfc9.sql new file mode 100644 index 000000000000..ca0e587ac9c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56c89b8384a5dfc9.sql @@ -0,0 +1 @@ +SELECT unhex('f0') FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/56d6fa865f08db6c.json b/tests/ast_json_fixtures/shapes/56d6fa865f08db6c.json new file mode 100644 index 000000000000..4e8faf6e23b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56d6fa865f08db6c.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "dist_tbl" + }, + "columns": [ + { + "type": "Identifier", + "name": "key" + } + ], + "format": "Values", + "settings": { + "type": "Settings", + "changes": { + "distributed_foreground_insert": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/56d6fa865f08db6c.sql b/tests/ast_json_fixtures/shapes/56d6fa865f08db6c.sql new file mode 100644 index 000000000000..7c72a9862f1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56d6fa865f08db6c.sql @@ -0,0 +1 @@ +INSERT INTO dist_tbl (key) SETTINGS distributed_foreground_insert=1 VALUES (99) diff --git a/tests/ast_json_fixtures/shapes/56e38d959d7eeade.json b/tests/ast_json_fixtures/shapes/56e38d959d7eeade.json new file mode 100644 index 000000000000..88f9877cb800 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56e38d959d7eeade.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "s3", + "arguments": [ + { + "type": "Identifier", + "name": "s3_conn" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "filename" + }, + { + "type": "Literal", + "value_type": "String", + "value": "half_baked" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "format" + }, + { + "type": "Identifier", + "name": "Parquet" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "partition_strategy" + }, + { + "type": "Literal", + "value_type": "String", + "value": "hive" + } + ] + } + ] + }, + "partition_by": { + "type": "Identifier", + "name": "year" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "key", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "year", + "value_type": "UInt64", + "value": "2020" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/56e38d959d7eeade.sql b/tests/ast_json_fixtures/shapes/56e38d959d7eeade.sql new file mode 100644 index 000000000000..04e7d9f4060f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56e38d959d7eeade.sql @@ -0,0 +1 @@ +INSERT INTO FUNCTION s3(s3_conn, filename='half_baked', format=Parquet, partition_strategy='hive') PARTITION BY year SELECT 1 AS key, 2020 AS year diff --git a/tests/ast_json_fixtures/shapes/56f60db75c3e511d.json b/tests/ast_json_fixtures/shapes/56f60db75c3e511d.json new file mode 100644 index 000000000000..cd32adf0ba9e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56f60db75c3e511d.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "number" + }, + { + "type": "Function", + "alias": "y", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "alias": "z", + "value_type": "String", + "value": "Hello" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_sql_insert_use_replace": "1" + } + }, + "format": "SQLInsert" + } +} diff --git a/tests/ast_json_fixtures/shapes/56f60db75c3e511d.sql b/tests/ast_json_fixtures/shapes/56f60db75c3e511d.sql new file mode 100644 index 000000000000..44ce195378e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/56f60db75c3e511d.sql @@ -0,0 +1 @@ +select number as x, number % 3 as y, 'Hello' as z from numbers(5) format SQLInsert settings output_format_sql_insert_use_replace=1 diff --git a/tests/ast_json_fixtures/shapes/5704997ce340ee81.json b/tests/ast_json_fixtures/shapes/5704997ce340ee81.json new file mode 100644 index 000000000000..6834812fd7da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5704997ce340ee81.json @@ -0,0 +1,381 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "cntrycode" + }, + { + "type": "Function", + "alias": "numcust", + "name": "count", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "alias": "totacctbal", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "c_acctbal" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "custsale", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "cntrycode", + "name": "substring", + "arguments": [ + { + "type": "Identifier", + "name": "c_phone" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "c_acctbal" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "customer" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Identifier", + "name": "c_phone" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "String", + "value": "13" + }, + { + "value_type": "String", + "value": "31" + }, + { + "value_type": "String", + "value": "23" + }, + { + "value_type": "String", + "value": "29" + }, + { + "value_type": "String", + "value": "30" + }, + { + "value_type": "String", + "value": "18" + }, + { + "value_type": "String", + "value": "17" + } + ] + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c_acctbal" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "c_acctbal" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "customer" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c_acctbal" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0 + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Identifier", + "name": "c_phone" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "String", + "value": "13" + }, + { + "value_type": "String", + "value": "31" + }, + { + "value_type": "String", + "value": "23" + }, + { + "value_type": "String", + "value": "29" + }, + { + "value_type": "String", + "value": "30" + }, + { + "value_type": "String", + "value": "18" + }, + { + "value_type": "String", + "value": "17" + } + ] + } + ] + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "exists", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "orders" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "o_custkey" + }, + { + "type": "Identifier", + "name": "c_custkey" + } + ] + } + } + ] + } + } + ] + } + ] + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "cntrycode" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "cntrycode" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/5704997ce340ee81.sql b/tests/ast_json_fixtures/shapes/5704997ce340ee81.sql new file mode 100644 index 000000000000..5bc3aca8ae88 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5704997ce340ee81.sql @@ -0,0 +1,37 @@ +SELECT + cntrycode, + count(*) AS numcust, + sum(c_acctbal) AS totacctbal +FROM ( + SELECT + substring(c_phone FROM 1 for 2) AS cntrycode, + c_acctbal + FROM + customer + WHERE + substring(c_phone FROM 1 for 2) in + ('13', '31', '23', '29', '30', '18', '17') + AND c_acctbal > ( + SELECT + avg(c_acctbal) + FROM + customer + WHERE + c_acctbal > 0.00 + AND substring(c_phone FROM 1 for 2) in + ('13', '31', '23', '29', '30', '18', '17') + ) + AND NOT EXISTS ( + SELECT + * + FROM + orders + WHERE + o_custkey = c_custkey + ) + ) AS custsale +GROUP BY + cntrycode +ORDER BY + cntrycode +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/570abf347d796cb5.json b/tests/ast_json_fixtures/shapes/570abf347d796cb5.json new file mode 100644 index 000000000000..bc2648d929bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/570abf347d796cb5.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateResourceQuery", + "or_replace": true, + "resource_name": { + "type": "Identifier", + "name": "03232_write" + }, + "unit": "IOByte", + "operations": [ + { + "mode": "WRITE", + "disk": "03232_fake_disk_2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/570abf347d796cb5.sql b/tests/ast_json_fixtures/shapes/570abf347d796cb5.sql new file mode 100644 index 000000000000..05d549f7d1f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/570abf347d796cb5.sql @@ -0,0 +1 @@ +create or replace resource 03232_write (write disk 03232_fake_disk_2) diff --git a/tests/ast_json_fixtures/shapes/572a14c8ed383e6f.json b/tests/ast_json_fixtures/shapes/572a14c8ed383e6f.json new file mode 100644 index 000000000000..09aee7f35f7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/572a14c8ed383e6f.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "t1tmp", + "to_table": "t2" + }, + { + "from_table": "t2tmp", + "to_table": "t1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/572a14c8ed383e6f.sql b/tests/ast_json_fixtures/shapes/572a14c8ed383e6f.sql new file mode 100644 index 000000000000..0294763bc12d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/572a14c8ed383e6f.sql @@ -0,0 +1 @@ +RENAME TABLE t1tmp TO t2, t2tmp TO t1 diff --git a/tests/ast_json_fixtures/shapes/5751c01606a261e3.json b/tests/ast_json_fixtures/shapes/5751c01606a261e3.json new file mode 100644 index 000000000000..78a538356fc2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5751c01606a261e3.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "ref_valueD" + }, + { + "type": "Identifier", + "name": "valueD" + }, + { + "type": "Function", + "alias": "dD", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ref_valueD" + }, + { + "type": "Identifier", + "name": "valueD" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "codecTest" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dD" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5751c01606a261e3.sql b/tests/ast_json_fixtures/shapes/5751c01606a261e3.sql new file mode 100644 index 000000000000..4b2a23cd9b8b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5751c01606a261e3.sql @@ -0,0 +1,7 @@ +SELECT + key, + ref_valueD, valueD, ref_valueD - valueD as dD +FROM codecTest +WHERE + dD != 0 +LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/5751e396d988b394.json b/tests/ast_json_fixtures/shapes/5751e396d988b394.json new file mode 100644 index 000000000000..a6722a94f072 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5751e396d988b394.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02484_plustwo" + } +} diff --git a/tests/ast_json_fixtures/shapes/5751e396d988b394.sql b/tests/ast_json_fixtures/shapes/5751e396d988b394.sql new file mode 100644 index 000000000000..fc64d815426a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5751e396d988b394.sql @@ -0,0 +1 @@ +DROP FUNCTION 02484_plustwo diff --git a/tests/ast_json_fixtures/shapes/57967b368e92c266.json b/tests/ast_json_fixtures/shapes/57967b368e92c266.json new file mode 100644 index 000000000000..c3891fded839 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57967b368e92c266.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "database", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "_test.csv" + } + ] + }, + { + "type": "Identifier", + "name": "CSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a Int, b Int DEFAULT 77" + } + ] + }, + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/57967b368e92c266.sql b/tests/ast_json_fixtures/shapes/57967b368e92c266.sql new file mode 100644 index 000000000000..260ee93e166c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57967b368e92c266.sql @@ -0,0 +1 @@ +INSERT INTO TABLE FUNCTION file(database() || '_test.csv', CSV, 'a Int, b Int DEFAULT 77') VALUES (3, 3), (4, NULL) diff --git a/tests/ast_json_fixtures/shapes/57bb211c742c8b31.json b/tests/ast_json_fixtures/shapes/57bb211c742c8b31.json new file mode 100644 index 000000000000..7418e33c7abc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57bb211c742c8b31.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tt_m" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/57bb211c742c8b31.sql b/tests/ast_json_fixtures/shapes/57bb211c742c8b31.sql new file mode 100644 index 000000000000..6d6fdad859d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57bb211c742c8b31.sql @@ -0,0 +1 @@ +SELECT b FROM tt_m WHERE b >= 0 order by b, a diff --git a/tests/ast_json_fixtures/shapes/57c0bbbaf1746200.json b/tests/ast_json_fixtures/shapes/57c0bbbaf1746200.json new file mode 100644 index 000000000000..8a9345f12ad1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57c0bbbaf1746200.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "key", + "name": "a" + } + ], + "select": [ + { + "type": "Identifier", + "alias": "k1", + "name": "key" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/57c0bbbaf1746200.sql b/tests/ast_json_fixtures/shapes/57c0bbbaf1746200.sql new file mode 100644 index 000000000000..110a760dcc36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57c0bbbaf1746200.sql @@ -0,0 +1 @@ +WITH a as key SELECT key as k1 FROM test ORDER BY key diff --git a/tests/ast_json_fixtures/shapes/57c34b95c8f8650b.json b/tests/ast_json_fixtures/shapes/57c34b95c8f8650b.json new file mode 100644 index 000000000000..fac14a808606 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57c34b95c8f8650b.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "col2" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "using": [ + { + "type": "Identifier", + "name": "col1" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test2" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt8" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/57c34b95c8f8650b.sql b/tests/ast_json_fixtures/shapes/57c34b95c8f8650b.sql new file mode 100644 index 000000000000..1bf86a0ed3c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57c34b95c8f8650b.sql @@ -0,0 +1,3 @@ +SELECT col2, col2 + 1 FROM test1 +FULL OUTER JOIN test2 USING (col1) +PREWHERE (col2 * 2) :: UInt8 diff --git a/tests/ast_json_fixtures/shapes/57cc60b7a0e0d918.json b/tests/ast_json_fixtures/shapes/57cc60b7a0e0d918.json new file mode 100644 index 000000000000..594bc7f7dc8b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57cc60b7a0e0d918.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "� �" + } + ] + } + ], + "format": "XML" + } +} diff --git a/tests/ast_json_fixtures/shapes/57cc60b7a0e0d918.sql b/tests/ast_json_fixtures/shapes/57cc60b7a0e0d918.sql new file mode 100644 index 000000000000..760df73ebdda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57cc60b7a0e0d918.sql @@ -0,0 +1 @@ +SELECT '\xED\x20\xA8' AS s FORMAT XML diff --git a/tests/ast_json_fixtures/shapes/57e72ee04993f703.json b/tests/ast_json_fixtures/shapes/57e72ee04993f703.json new file mode 100644 index 000000000000..983328ca8393 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57e72ee04993f703.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "rmt1" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "123" + } + ] + }, + "assignments": [ + { + "type": "Assignment", + "column": "n", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/57e72ee04993f703.sql b/tests/ast_json_fixtures/shapes/57e72ee04993f703.sql new file mode 100644 index 000000000000..b1cbf2135e1f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/57e72ee04993f703.sql @@ -0,0 +1 @@ +alter table rmt1 update n=10 where n=123 settings mutations_sync=1 diff --git a/tests/ast_json_fixtures/shapes/5801869b685ea8e0.json b/tests/ast_json_fixtures/shapes/5801869b685ea8e0.json new file mode 100644 index 000000000000..e92909c831b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5801869b685ea8e0.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t2" + }, + "as_table": "t1" + } +} diff --git a/tests/ast_json_fixtures/shapes/5801869b685ea8e0.sql b/tests/ast_json_fixtures/shapes/5801869b685ea8e0.sql new file mode 100644 index 000000000000..177fe32be8eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5801869b685ea8e0.sql @@ -0,0 +1 @@ +CREATE TABLE t2 AS t1 diff --git a/tests/ast_json_fixtures/shapes/58064a52ea93366a.json b/tests/ast_json_fixtures/shapes/58064a52ea93366a.json new file mode 100644 index 000000000000..1a4d0b629059 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58064a52ea93366a.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "v" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "s" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/58064a52ea93366a.sql b/tests/ast_json_fixtures/shapes/58064a52ea93366a.sql new file mode 100644 index 000000000000..83dcc8220384 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58064a52ea93366a.sql @@ -0,0 +1 @@ +select s, sum(n) from v group by s format Null diff --git a/tests/ast_json_fixtures/shapes/5851485eabf2b0a9.json b/tests/ast_json_fixtures/shapes/5851485eabf2b0a9.json new file mode 100644 index 000000000000..33fe2657a6ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5851485eabf2b0a9.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS" + } +} diff --git a/tests/ast_json_fixtures/shapes/5851485eabf2b0a9.sql b/tests/ast_json_fixtures/shapes/5851485eabf2b0a9.sql new file mode 100644 index 000000000000..e11ee5fdf7d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5851485eabf2b0a9.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS diff --git a/tests/ast_json_fixtures/shapes/586d3e70106ba366.json b/tests/ast_json_fixtures/shapes/586d3e70106ba366.json new file mode 100644 index 000000000000..57476ae53bf5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/586d3e70106ba366.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "i" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/586d3e70106ba366.sql b/tests/ast_json_fixtures/shapes/586d3e70106ba366.sql new file mode 100644 index 000000000000..ff22fe92c76c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/586d3e70106ba366.sql @@ -0,0 +1 @@ +select i from x where i = 1 diff --git a/tests/ast_json_fixtures/shapes/5884db8e03dbd382.json b/tests/ast_json_fixtures/shapes/5884db8e03dbd382.json new file mode 100644 index 000000000000..c1ee5d1fe759 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5884db8e03dbd382.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_filter" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "f" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "u" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5884db8e03dbd382.sql b/tests/ast_json_fixtures/shapes/5884db8e03dbd382.sql new file mode 100644 index 000000000000..0b554303c8c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5884db8e03dbd382.sql @@ -0,0 +1 @@ +SELECT * FROM t_filter WHERE f != 0 ORDER BY u LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/58ba2ec33996834f.json b/tests/ast_json_fixtures/shapes/58ba2ec33996834f.json new file mode 100644 index 000000000000..178e537b308d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58ba2ec33996834f.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/58ba2ec33996834f.sql b/tests/ast_json_fixtures/shapes/58ba2ec33996834f.sql new file mode 100644 index 000000000000..9ea871a01b63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58ba2ec33996834f.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/58bcc5b79725ef94.json b/tests/ast_json_fixtures/shapes/58bcc5b79725ef94.json new file mode 100644 index 000000000000..bcfa5eff53c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58bcc5b79725ef94.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "hostName", + "arguments": [] + }, + { + "type": "Identifier", + "name": "hostname" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_thread_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "select '02095_system_logs_hostname%" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "yesterday", + "arguments": [] + } + ] + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/58bcc5b79725ef94.sql b/tests/ast_json_fixtures/shapes/58bcc5b79725ef94.sql new file mode 100644 index 000000000000..256845db91a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58bcc5b79725ef94.sql @@ -0,0 +1,6 @@ +select hostName(), hostname +from system.query_thread_log +where + query like 'select \'02095_system_logs_hostname%' + and current_database = currentDatabase() + and event_date >= yesterday() LIMIT 1 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/58da496a8cca09dc.json b/tests/ast_json_fixtures/shapes/58da496a8cca09dc.json new file mode 100644 index 000000000000..c3ec55fd742d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58da496a8cca09dc.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "mem2" + } + ] + } + }, + "as_table": "mem2" + } +} diff --git a/tests/ast_json_fixtures/shapes/58da496a8cca09dc.sql b/tests/ast_json_fixtures/shapes/58da496a8cca09dc.sql new file mode 100644 index 000000000000..28fa24176e79 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58da496a8cca09dc.sql @@ -0,0 +1 @@ +CREATE TABLE dist_2 AS mem2 Engine=Distributed(test_cluster_two_shards_localhost, currentDatabase(), mem2) diff --git a/tests/ast_json_fixtures/shapes/58e44d8598e87449.json b/tests/ast_json_fixtures/shapes/58e44d8598e87449.json new file mode 100644 index 000000000000..273bda16b6e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58e44d8598e87449.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "column_swap_test_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "constraints": [ + { + "type": "Constraint", + "name": "c1", + "constraint_type": "ASSUME", + "expression": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "i" + }, + "settings": { + "type": "Settings", + "changes": { + "min_bytes_for_wide_part": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/58e44d8598e87449.sql b/tests/ast_json_fixtures/shapes/58e44d8598e87449.sql new file mode 100644 index 000000000000..e01083436f9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58e44d8598e87449.sql @@ -0,0 +1,3 @@ +CREATE TABLE column_swap_test_test (i Int64, a String, b UInt64, CONSTRAINT c1 ASSUME b = cityHash64(a)) +ENGINE = MergeTree() ORDER BY i +SETTINGS min_bytes_for_wide_part = 0 diff --git a/tests/ast_json_fixtures/shapes/58ef8534747b1235.json b/tests/ast_json_fixtures/shapes/58ef8534747b1235.json new file mode 100644 index 000000000000..8e41da1273de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58ef8534747b1235.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q1_01297"], + "key_type": "NONE" + } +} diff --git a/tests/ast_json_fixtures/shapes/58ef8534747b1235.sql b/tests/ast_json_fixtures/shapes/58ef8534747b1235.sql new file mode 100644 index 000000000000..9343e06d80cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/58ef8534747b1235.sql @@ -0,0 +1 @@ +CREATE QUOTA q1_01297 NOT KEYED diff --git a/tests/ast_json_fixtures/shapes/5914c6430324b284.json b/tests/ast_json_fixtures/shapes/5914c6430324b284.json new file mode 100644 index 000000000000..c1fa03437e8d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5914c6430324b284.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q10_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "EXECUTION_TIME": "12288000000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5914c6430324b284.sql b/tests/ast_json_fixtures/shapes/5914c6430324b284.sql new file mode 100644 index 000000000000..20e566916c71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5914c6430324b284.sql @@ -0,0 +1 @@ +CREATE QUOTA q10_01297 FOR INTERVAL 1 MINUTE MAX execution_time = '12Ki' diff --git a/tests/ast_json_fixtures/shapes/594d99177d1dc845.json b/tests/ast_json_fixtures/shapes/594d99177d1dc845.json new file mode 100644 index 000000000000..273b56186ef5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/594d99177d1dc845.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r1_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/594d99177d1dc845.sql b/tests/ast_json_fixtures/shapes/594d99177d1dc845.sql new file mode 100644 index 000000000000..53516d8b15be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/594d99177d1dc845.sql @@ -0,0 +1 @@ +CREATE ROLE r1_01293 SETTINGS readonly=1 diff --git a/tests/ast_json_fixtures/shapes/59692ac2350c823c.json b/tests/ast_json_fixtures/shapes/59692ac2350c823c.json new file mode 100644 index 000000000000..9acb63189f6c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59692ac2350c823c.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "dictionary": true, + "elements": [ + { + "from_database": "test_01191", + "from_table": "_", + "to_database": "test_01191", + "to_table": "dict" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/59692ac2350c823c.sql b/tests/ast_json_fixtures/shapes/59692ac2350c823c.sql new file mode 100644 index 000000000000..b904d1ebdca3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59692ac2350c823c.sql @@ -0,0 +1 @@ +EXCHANGE DICTIONARIES test_01191._ AND test_01191.dict diff --git a/tests/ast_json_fixtures/shapes/5976109698b0722e.json b/tests/ast_json_fixtures/shapes/5976109698b0722e.json new file mode 100644 index 000000000000..9e0c468868ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5976109698b0722e.json @@ -0,0 +1,174 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "prewhere": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Asterisk" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toTime64", + "arguments": [ + { + "type": "Function", + "name": "isZeroOrNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "13" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toTime64", + "arguments": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "13" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5976109698b0722e.sql b/tests/ast_json_fixtures/shapes/5976109698b0722e.sql new file mode 100644 index 000000000000..ceb1229c31cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5976109698b0722e.sql @@ -0,0 +1,6 @@ +SELECT * +PREWHERE * OR ((8 OR * OR 1) OR 1 OR (toTime64(isZeroOrNull(13), 2) <= *) OR materialize(2)) +GROUP BY + toLowCardinality(materialize(2)), + 1, + toTime64(isNullable(materialize(materialize(13))), * IS NULL) <= * diff --git a/tests/ast_json_fixtures/shapes/597cf6124ea51d93.json b/tests/ast_json_fixtures/shapes/597cf6124ea51d93.json new file mode 100644 index 000000000000..36a941e1a6de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/597cf6124ea51d93.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "CheckQuery", + "table": { + "type": "Identifier", + "name": "tab" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/597cf6124ea51d93.sql b/tests/ast_json_fixtures/shapes/597cf6124ea51d93.sql new file mode 100644 index 000000000000..ea58fe082b63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/597cf6124ea51d93.sql @@ -0,0 +1 @@ +check table tab diff --git a/tests/ast_json_fixtures/shapes/5990717d75d8e6ae.json b/tests/ast_json_fixtures/shapes/5990717d75d8e6ae.json new file mode 100644 index 000000000000..448a603228d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5990717d75d8e6ae.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "database": { + "type": "Identifier", + "name": "sqllt" + }, + "table": { + "type": "Identifier", + "name": "table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "new_col" + }, + "remove_property": "COMMENT" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5990717d75d8e6ae.sql b/tests/ast_json_fixtures/shapes/5990717d75d8e6ae.sql new file mode 100644 index 000000000000..b62b56ed3cd1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5990717d75d8e6ae.sql @@ -0,0 +1 @@ +ALTER TABLE sqllt.table MODIFY COLUMN new_col REMOVE COMMENT diff --git a/tests/ast_json_fixtures/shapes/5992838f7916f29c.json b/tests/ast_json_fixtures/shapes/5992838f7916f29c.json new file mode 100644 index 000000000000..ebe2bbdac551 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5992838f7916f29c.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s1_01294", "s2_01294", "s3_01294", "s4_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/5992838f7916f29c.sql b/tests/ast_json_fixtures/shapes/5992838f7916f29c.sql new file mode 100644 index 000000000000..59aad28bdfb6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5992838f7916f29c.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s1_01294, s2_01294, s3_01294, s4_01294 diff --git a/tests/ast_json_fixtures/shapes/59ac6e3c0b8b684f.json b/tests/ast_json_fixtures/shapes/59ac6e3c0b8b684f.json new file mode 100644 index 000000000000..8a4f24f15b48 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59ac6e3c0b8b684f.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "dictionary": true, + "elements": [ + { + "from_database": "test_01191", + "from_table": "dict", + "to_database": "test_01191", + "to_table": "dict1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/59ac6e3c0b8b684f.sql b/tests/ast_json_fixtures/shapes/59ac6e3c0b8b684f.sql new file mode 100644 index 000000000000..93c1ee5d64d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59ac6e3c0b8b684f.sql @@ -0,0 +1 @@ +RENAME DICTIONARY test_01191.dict TO test_01191.dict1 diff --git a/tests/ast_json_fixtures/shapes/59af29056ad63188.json b/tests/ast_json_fixtures/shapes/59af29056ad63188.json new file mode 100644 index 000000000000..e4a2fae37ae7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59af29056ad63188.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "numbers1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + "sample_by": { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/59af29056ad63188.sql b/tests/ast_json_fixtures/shapes/59af29056ad63188.sql new file mode 100644 index 000000000000..73382a0b7bcf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59af29056ad63188.sql @@ -0,0 +1 @@ +CREATE TABLE numbers1 ENGINE = MergeTree ORDER BY intHash32(number) SAMPLE BY intHash32(number) AS SELECT number FROM numbers(1000) diff --git a/tests/ast_json_fixtures/shapes/59b065235e0c1f69.json b/tests/ast_json_fixtures/shapes/59b065235e0c1f69.json new file mode 100644 index 000000000000..63babf355019 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59b065235e0c1f69.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "02131_filter_4", + "table": "02131_rptable" + } + ] + }, + "is_restrictive": true, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/59b065235e0c1f69.sql b/tests/ast_json_fixtures/shapes/59b065235e0c1f69.sql new file mode 100644 index 000000000000..8084b5088fdf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59b065235e0c1f69.sql @@ -0,0 +1 @@ +CREATE ROW POLICY 02131_filter_4 ON 02131_rptable USING x<=2 AS restrictive TO ALL diff --git a/tests/ast_json_fixtures/shapes/59b07ae886aec157.json b/tests/ast_json_fixtures/shapes/59b07ae886aec157.json new file mode 100644 index 000000000000..4dfdfe42036b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59b07ae886aec157.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "_file", + "value_type": "String", + "value": "a1" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_02302" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_file" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/59b07ae886aec157.sql b/tests/ast_json_fixtures/shapes/59b07ae886aec157.sql new file mode 100644 index 000000000000..db581139d1d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59b07ae886aec157.sql @@ -0,0 +1 @@ +select 'a1' as _file, * from test_02302 where _file like '%1' ORDER BY a diff --git a/tests/ast_json_fixtures/shapes/59cd12a33f6a23ab.json b/tests/ast_json_fixtures/shapes/59cd12a33f6a23ab.json new file mode 100644 index 000000000000..f4a8fe2e1f2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59cd12a33f6a23ab.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "key1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "optimize_lazy_materialization_with_map_data_type" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/59cd12a33f6a23ab.sql b/tests/ast_json_fixtures/shapes/59cd12a33f6a23ab.sql new file mode 100644 index 000000000000..59647e7981ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59cd12a33f6a23ab.sql @@ -0,0 +1 @@ +SELECT a, b, c['key1'] FROM optimize_lazy_materialization_with_map_data_type ORDER BY b LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/59dc242d56e0e506.json b/tests/ast_json_fixtures/shapes/59dc242d56e0e506.json new file mode 100644 index 000000000000..4eaaad37e6af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59dc242d56e0e506.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "default_table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "key" + }, + "remove_property": "MATERIALIZED" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/59dc242d56e0e506.sql b/tests/ast_json_fixtures/shapes/59dc242d56e0e506.sql new file mode 100644 index 000000000000..d5c4bc69ce1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59dc242d56e0e506.sql @@ -0,0 +1 @@ +ALTER TABLE default_table MODIFY COLUMN key REMOVE MATERIALIZED diff --git a/tests/ast_json_fixtures/shapes/59e3ea3a8098577b.json b/tests/ast_json_fixtures/shapes/59e3ea3a8098577b.json new file mode 100644 index 000000000000..b8261d7316f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59e3ea3a8098577b.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + { + "type": "Identifier", + "name": "n" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "rmt2" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/59e3ea3a8098577b.sql b/tests/ast_json_fixtures/shapes/59e3ea3a8098577b.sql new file mode 100644 index 000000000000..ff03775fda24 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59e3ea3a8098577b.sql @@ -0,0 +1 @@ +select 4, n from rmt2 order by n diff --git a/tests/ast_json_fixtures/shapes/59f049ab32457620.json b/tests/ast_json_fixtures/shapes/59f049ab32457620.json new file mode 100644 index 000000000000..dd4b22fc404d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59f049ab32457620.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "database_and_tables": { + "type": "ExpressionList", + "children": [ + { + "type": "TableIdentifier", + "name": "t1" + }, + { + "type": "TableIdentifier", + "name": "t2" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/59f049ab32457620.sql b/tests/ast_json_fixtures/shapes/59f049ab32457620.sql new file mode 100644 index 000000000000..fb43504f7a3b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/59f049ab32457620.sql @@ -0,0 +1 @@ +DROP TABLE t1, t2 diff --git a/tests/ast_json_fixtures/shapes/5a383044fbab92e9.json b/tests/ast_json_fixtures/shapes/5a383044fbab92e9.json new file mode 100644 index 000000000000..47532a57ba34 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a383044fbab92e9.json @@ -0,0 +1,194 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "source" + }, + { + "type": "Function", + "alias": "inter_p", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "inter" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "toFloat32", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "source", + "value_type": "String", + "value": "original" + }, + { + "type": "Identifier", + "alias": "inter", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC", + "with_fill": true, + "fill_from": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "fill_to": { + "type": "Literal", + "value_type": "Float64", + "value": 11.51 + }, + "fill_step": { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + } + } + ], + "interpolate": [ + { + "type": "InterpolateElement", + "column": "inter_p", + "expr": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "inter_p" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5a383044fbab92e9.sql b/tests/ast_json_fixtures/shapes/5a383044fbab92e9.sql new file mode 100644 index 000000000000..b7dbca73584d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a383044fbab92e9.sql @@ -0,0 +1,4 @@ +# Test INTERPOLATE with aliased column +SELECT n, source, inter + 1 AS inter_p FROM ( + SELECT toFloat32(number % 10) AS n, 'original' AS source, number AS inter FROM numbers(10) WHERE (number % 3) = 1 +) ORDER BY n ASC WITH FILL FROM 0 TO 11.51 STEP 0.5 INTERPOLATE ( inter_p AS inter_p + 1 ) diff --git a/tests/ast_json_fixtures/shapes/5a3c9b5cc93179d5.json b/tests/ast_json_fixtures/shapes/5a3c9b5cc93179d5.json new file mode 100644 index 000000000000..1348902b28ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a3c9b5cc93179d5.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x_as" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "EventDate" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Identifier", + "name": "EventDate" + }, + { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + } + ] + }, + "sample_by": { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_block_number_column": "1", + "enable_block_offset_column": "1" + } + } + }, + "as_table": "x" + } +} diff --git a/tests/ast_json_fixtures/shapes/5a3c9b5cc93179d5.sql b/tests/ast_json_fixtures/shapes/5a3c9b5cc93179d5.sql new file mode 100644 index 000000000000..bd2419558f32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a3c9b5cc93179d5.sql @@ -0,0 +1 @@ +CREATE TABLE x_as AS x ENGINE = MergeTree PARTITION BY toYYYYMM(EventDate) ORDER BY (CounterID, EventDate, intHash32(UserID)) SAMPLE BY intHash32(UserID) SETTINGS enable_block_number_column = 1, enable_block_offset_column = 1 diff --git a/tests/ast_json_fixtures/shapes/5a55f44c2f659e49.json b/tests/ast_json_fixtures/shapes/5a55f44c2f659e49.json new file mode 100644 index 000000000000..c41b0f761021 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a55f44c2f659e49.json @@ -0,0 +1,204 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "name", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "metric" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Identifier", + "alias": "value", + "name": "number" + }, + { + "type": "Function", + "alias": "help", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "info " + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "alias": "type", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "counter" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "alias": "timestamp", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1395066363000" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ], + "format": "Prometheus" + } +} diff --git a/tests/ast_json_fixtures/shapes/5a55f44c2f659e49.sql b/tests/ast_json_fixtures/shapes/5a55f44c2f659e49.sql new file mode 100644 index 000000000000..1d3c5e53cdc8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a55f44c2f659e49.sql @@ -0,0 +1,8 @@ +SELECT + 'metric' || toString(number) AS name, + number AS value, + if(number % 2 == 0, 'info ' || toString(number), NULL) AS help, + if(number % 3 == 0, 'counter', NULL) AS type, + if(number == 2, 1395066363000, NULL) AS timestamp +FROM numbers(5) +FORMAT Prometheus diff --git a/tests/ast_json_fixtures/shapes/5a611e9866932bdd.json b/tests/ast_json_fixtures/shapes/5a611e9866932bdd.json new file mode 100644 index 000000000000..3313556a4e28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a611e9866932bdd.json @@ -0,0 +1,139 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "id", + "name": "any", + "arguments": [ + { + "type": "Identifier", + "name": "uuid" + } + ] + }, + { + "type": "Function", + "alias": "time_delta", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "end_ts" + } + ] + }, + { + "type": "Function", + "name": "any", + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "start_ts", + "name": "any", + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + } + ] + }, + { + "type": "Function", + "alias": "end_ts", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "end_ts" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "mytable" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "uuid" + } + ], + "having": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "end_ts" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1620141001" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "any", + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + } + ] + }, + "direction": "DESC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "prefer_column_name_to_alias": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5a611e9866932bdd.sql b/tests/ast_json_fixtures/shapes/5a611e9866932bdd.sql new file mode 100644 index 000000000000..63a26b3648a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a611e9866932bdd.sql @@ -0,0 +1 @@ +SELECT any(uuid) AS id, max(end_ts) - any(start_ts) AS time_delta, any(start_ts) AS start_ts, max(end_ts) AS end_ts FROM mytable GROUP BY uuid HAVING max(end_ts) < 1620141001 ORDER BY any(start_ts) DESC SETTINGS prefer_column_name_to_alias=1 diff --git a/tests/ast_json_fixtures/shapes/5a66a86b3fe33e64.json b/tests/ast_json_fixtures/shapes/5a66a86b3fe33e64.json new file mode 100644 index 000000000000..e22701bf5bd2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a66a86b3fe33e64.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_materialize" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REWRITE_PARTS", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5a66a86b3fe33e64.sql b/tests/ast_json_fixtures/shapes/5a66a86b3fe33e64.sql new file mode 100644 index 000000000000..d00582700d0b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a66a86b3fe33e64.sql @@ -0,0 +1 @@ +alter table test_materialize rewrite parts in partition 1 settings mutations_sync=2 diff --git a/tests/ast_json_fixtures/shapes/5a92e0261abec006.json b/tests/ast_json_fixtures/shapes/5a92e0261abec006.json new file mode 100644 index 000000000000..fb33fa5c6b4f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a92e0261abec006.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "hello", + "name": "number" + }, + { + "type": "Function", + "alias": "world", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Identifier", + "name": "world" + } + ] + }, + { + "type": "Function", + "alias": "sometimes_nulls", + "name": "nullIf", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "5" + } + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/5a92e0261abec006.sql b/tests/ast_json_fixtures/shapes/5a92e0261abec006.sql new file mode 100644 index 000000000000..7de048de843b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a92e0261abec006.sql @@ -0,0 +1 @@ +SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 10 SETTINGS max_block_size = 5 FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/5a976ca8087c2ef2.json b/tests/ast_json_fixtures/shapes/5a976ca8087c2ef2.json new file mode 100644 index 000000000000..e1ead7d23746 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a976ca8087c2ef2.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "_row_exists", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5a976ca8087c2ef2.sql b/tests/ast_json_fixtures/shapes/5a976ca8087c2ef2.sql new file mode 100644 index 000000000000..6946f336f8c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5a976ca8087c2ef2.sql @@ -0,0 +1 @@ +create temporary table test (_row_exists UInt32) engine=MergeTree order by tuple() diff --git a/tests/ast_json_fixtures/shapes/5aa1128a84e0e82e.json b/tests/ast_json_fixtures/shapes/5aa1128a84e0e82e.json new file mode 100644 index 000000000000..13e773cb7332 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5aa1128a84e0e82e.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p1_01296", + "table": "table" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5aa1128a84e0e82e.sql b/tests/ast_json_fixtures/shapes/5aa1128a84e0e82e.sql new file mode 100644 index 000000000000..ce46bb513b29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5aa1128a84e0e82e.sql @@ -0,0 +1 @@ +CREATE POLICY p1_01296 ON table diff --git a/tests/ast_json_fixtures/shapes/5af7c707300a0f6d.json b/tests/ast_json_fixtures/shapes/5af7c707300a0f6d.json new file mode 100644 index 000000000000..2e87c84da7ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5af7c707300a0f6d.json @@ -0,0 +1,98 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "t" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5af7c707300a0f6d.sql b/tests/ast_json_fixtures/shapes/5af7c707300a0f6d.sql new file mode 100644 index 000000000000..0ddca9dc2b1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5af7c707300a0f6d.sql @@ -0,0 +1,5 @@ +WITH + t as (select number from numbers(5)) +SELECT * +FROM numbers(8) +WHERE number IN t diff --git a/tests/ast_json_fixtures/shapes/5af8aa86579f419f.json b/tests/ast_json_fixtures/shapes/5af8aa86579f419f.json new file mode 100644 index 000000000000..43196dd2495d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5af8aa86579f419f.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "runningDifference", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/5af8aa86579f419f.sql b/tests/ast_json_fixtures/shapes/5af8aa86579f419f.sql new file mode 100644 index 000000000000..0f145fcc90d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5af8aa86579f419f.sql @@ -0,0 +1 @@ +SELECT runningDifference(number) FROM system.numbers LIMIT 10 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/5b1b7d0887b4de26.json b/tests/ast_json_fixtures/shapes/5b1b7d0887b4de26.json new file mode 100644 index 000000000000..445a4d306cc6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b1b7d0887b4de26.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "named_tuples" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_json_named_tuples_as_objects": "1" + } + }, + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/5b1b7d0887b4de26.sql b/tests/ast_json_fixtures/shapes/5b1b7d0887b4de26.sql new file mode 100644 index 000000000000..9c2a465c8a9f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b1b7d0887b4de26.sql @@ -0,0 +1 @@ +select * from named_tuples format JSONEachRow settings output_format_json_named_tuples_as_objects = 1 diff --git a/tests/ast_json_fixtures/shapes/5b22e6b54e606c7b.json b/tests/ast_json_fixtures/shapes/5b22e6b54e606c7b.json new file mode 100644 index 000000000000..b5302d0b59c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b22e6b54e606c7b.json @@ -0,0 +1,135 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "UserID" + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "EventTime" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime('Asia\/Dubai')" + } + ] + }, + { + "type": "Identifier", + "name": "pp.Key1", + "name_parts": ["pp", "Key1"] + }, + { + "type": "Identifier", + "name": "pp.Key2", + "name_parts": ["pp", "Key2"] + }, + { + "type": "Identifier", + "name": "ParsedParams.Key1", + "name_parts": ["ParsedParams", "Key1"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "INNER", + "expressions": [ + { + "type": "Identifier", + "alias": "pp", + "name": "ParsedParams" + } + ] + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1704509" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "UserID" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "EventTime" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "pp.Key1", + "name_parts": ["pp", "Key1"] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "pp.Key2", + "name_parts": ["pp", "Key2"] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5b22e6b54e606c7b.sql b/tests/ast_json_fixtures/shapes/5b22e6b54e606c7b.sql new file mode 100644 index 000000000000..f9d2b90d4ef9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b22e6b54e606c7b.sql @@ -0,0 +1 @@ +SELECT UserID, EventTime::DateTime('Asia/Dubai'), pp.Key1, pp.Key2, ParsedParams.Key1 FROM test.hits ARRAY JOIN ParsedParams AS pp WHERE CounterID = 1704509 ORDER BY UserID, EventTime, pp.Key1, pp.Key2 LIMIT 100 diff --git a/tests/ast_json_fixtures/shapes/5b29fdc227961b4b.json b/tests/ast_json_fixtures/shapes/5b29fdc227961b4b.json new file mode 100644 index 000000000000..f674661b3a72 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b29fdc227961b4b.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "attach_from_path": "01721_file\/test", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "File", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "TSV" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5b29fdc227961b4b.sql b/tests/ast_json_fixtures/shapes/5b29fdc227961b4b.sql new file mode 100644 index 000000000000..59f510928d9e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b29fdc227961b4b.sql @@ -0,0 +1 @@ +ATTACH TABLE test FROM '01721_file/test' (id UInt8) ENGINE=File(TSV) diff --git a/tests/ast_json_fixtures/shapes/5b3ada1ff05e9065.json b/tests/ast_json_fixtures/shapes/5b3ada1ff05e9065.json new file mode 100644 index 000000000000..4ad44fdd7bea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b3ada1ff05e9065.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "s", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "123" + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "param_test", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "test_str" + }, + { + "type": "Identifier", + "name": "s" + } + ] + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5b3ada1ff05e9065.sql b/tests/ast_json_fixtures/shapes/5b3ada1ff05e9065.sql new file mode 100644 index 000000000000..a1467161b3d8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b3ada1ff05e9065.sql @@ -0,0 +1 @@ +WITH (SELECT 123) AS s SELECT * FROM param_test(test_str=s) diff --git a/tests/ast_json_fixtures/shapes/5b4337275e75a8df.json b/tests/ast_json_fixtures/shapes/5b4337275e75a8df.json new file mode 100644 index 000000000000..34374b554994 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b4337275e75a8df.json @@ -0,0 +1,329 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "table_uuid", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "uuid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tables", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "02581_trips" + } + ] + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Function", + "alias": "mutation_version", + "name": "CAST", + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "splitByChar", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "_" + }, + { + "type": "Identifier", + "name": "query_id" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt64" + } + ] + }, + { + "type": "Function", + "alias": "has_parts_for_which_set_was_built", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Created Set with % entries%" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "has_parts_that_shared_set", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Got set from cache%" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "text_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Identifier", + "name": "table_uuid" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "::all\\_%" + } + ] + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "yesterday", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Created Set with % entries%" + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Got set from cache%" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "mutation_version" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "mutation_version" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/5b4337275e75a8df.sql b/tests/ast_json_fixtures/shapes/5b4337275e75a8df.sql new file mode 100644 index 000000000000..5cd7853a3b9c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b4337275e75a8df.sql @@ -0,0 +1,15 @@ +WITH ( + SELECT uuid + FROM system.tables + WHERE (database = currentDatabase()) AND (name = '02581_trips') + ) AS table_uuid +SELECT + CAST(splitByChar('_', query_id)[5], 'UInt64') AS mutation_version, + sum(message LIKE 'Created Set with % entries%') >= 1 AS has_parts_for_which_set_was_built, + sum(message LIKE 'Got set from cache%') >= 1 AS has_parts_that_shared_set +FROM system.text_log +WHERE + query_id LIKE concat(CAST(table_uuid, 'String'), '::all\\_%') + AND (event_date >= yesterday()) + AND (message LIKE 'Created Set with % entries%' OR message LIKE 'Got set from cache%') +GROUP BY mutation_version ORDER BY mutation_version FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/5b51e8b6b5cff3bd.json b/tests/ast_json_fixtures/shapes/5b51e8b6b5cff3bd.json new file mode 100644 index 000000000000..3abce5096e5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b51e8b6b5cff3bd.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "k", + "name": "number" + }, + { + "type": "Function", + "alias": "v1", + "name": "repeat", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + }, + { + "type": "Function", + "alias": "v2", + "name": "repeat", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 3000000 + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "v1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "v2" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "Float64", + "value": 400000 + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/5b51e8b6b5cff3bd.sql b/tests/ast_json_fixtures/shapes/5b51e8b6b5cff3bd.sql new file mode 100644 index 000000000000..87690feb5d41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b51e8b6b5cff3bd.sql @@ -0,0 +1 @@ +select number k, repeat(toString(number), 11) v1, repeat(toString(number), 12) v2 from numbers(3e6) order by v1, v2 limit 400e3 format Null diff --git a/tests/ast_json_fixtures/shapes/5b534ef3066a003a.json b/tests/ast_json_fixtures/shapes/5b534ef3066a003a.json new file mode 100644 index 000000000000..622cfd7e6ef2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b534ef3066a003a.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "null_subcolumns" + } + } + } + ] + }, + "prewhere": { + "type": "Identifier", + "name": "n.null", + "name_parts": ["n", "null"] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5b534ef3066a003a.sql b/tests/ast_json_fixtures/shapes/5b534ef3066a003a.sql new file mode 100644 index 000000000000..57726c7d2c5e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b534ef3066a003a.sql @@ -0,0 +1 @@ +SELECT count() FROM null_subcolumns PREWHERE n.null diff --git a/tests/ast_json_fixtures/shapes/5b802eb19e3b2619.json b/tests/ast_json_fixtures/shapes/5b802eb19e3b2619.json new file mode 100644 index 000000000000..a26a5e66dae5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b802eb19e3b2619.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/5b802eb19e3b2619.sql b/tests/ast_json_fixtures/shapes/5b802eb19e3b2619.sql new file mode 100644 index 000000000000..d6b2b735db06 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b802eb19e3b2619.sql @@ -0,0 +1 @@ +DROP ROLE r1_01297 diff --git a/tests/ast_json_fixtures/shapes/5b898be3ca4f72f5.json b/tests/ast_json_fixtures/shapes/5b898be3ca4f72f5.json new file mode 100644 index 000000000000..f963e0028691 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b898be3ca4f72f5.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_database": "test_01191", + "from_table": "t", + "to_database": "test_01191", + "to_table": "dict" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5b898be3ca4f72f5.sql b/tests/ast_json_fixtures/shapes/5b898be3ca4f72f5.sql new file mode 100644 index 000000000000..cbb6a25aff75 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b898be3ca4f72f5.sql @@ -0,0 +1 @@ +EXCHANGE TABLES test_01191.t AND test_01191.dict diff --git a/tests/ast_json_fixtures/shapes/5b920e2c276a0f53.json b/tests/ast_json_fixtures/shapes/5b920e2c276a0f53.json new file mode 100644 index 000000000000..54c902fdce4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b920e2c276a0f53.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "long_string" + }, + "remove_property": "SETTINGS" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5b920e2c276a0f53.sql b/tests/ast_json_fixtures/shapes/5b920e2c276a0f53.sql new file mode 100644 index 000000000000..39847bd2169a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b920e2c276a0f53.sql @@ -0,0 +1 @@ +ALTER TABLE tab MODIFY COLUMN long_string REMOVE SETTINGS diff --git a/tests/ast_json_fixtures/shapes/5b92a84aed0186a3.json b/tests/ast_json_fixtures/shapes/5b92a84aed0186a3.json new file mode 100644 index 000000000000..ce69bf8f6c4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b92a84aed0186a3.json @@ -0,0 +1,136 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "alias": "t1_id", + "name": "t1.id", + "name_parts": ["t1", "id"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t1_id" + } + ] + }, + { + "type": "Identifier", + "alias": "t1_value", + "name": "t1.value", + "name_parts": ["t1", "value"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t1_value" + } + ] + }, + { + "type": "Identifier", + "alias": "t2_id", + "name": "t2.id", + "name_parts": ["t2", "id"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t2_id" + } + ] + }, + { + "type": "Identifier", + "alias": "t2_value", + "name": "t2.value", + "name_parts": ["t2", "value"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t2_value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "test_table_join_1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.id", + "name_parts": ["t1", "id"] + }, + { + "type": "Identifier", + "name": "t2.id", + "name_parts": ["t2", "id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "test_table_join_2" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5b92a84aed0186a3.sql b/tests/ast_json_fixtures/shapes/5b92a84aed0186a3.sql new file mode 100644 index 000000000000..a72d50af4de8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b92a84aed0186a3.sql @@ -0,0 +1,2 @@ +SELECT t1.id AS t1_id, toTypeName(t1_id), t1.value AS t1_value, toTypeName(t1_value), t2.id AS t2_id, toTypeName(t2_id), t2.value AS t2_value, toTypeName(t2_value) +FROM test_table_join_1 AS t1 FULL JOIN test_table_join_2 AS t2 ON t1.id = t2.id ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/5b9320b36dd7c0a9.json b/tests/ast_json_fixtures/shapes/5b9320b36dd7c0a9.json new file mode 100644 index 000000000000..9c62fa37b4d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b9320b36dd7c0a9.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/5b9320b36dd7c0a9.sql b/tests/ast_json_fixtures/shapes/5b9320b36dd7c0a9.sql new file mode 100644 index 000000000000..57375cb20586 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b9320b36dd7c0a9.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettySpace diff --git a/tests/ast_json_fixtures/shapes/5b98a638ef04c379.json b/tests/ast_json_fixtures/shapes/5b98a638ef04c379.json new file mode 100644 index 000000000000..fa0cc895d349 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b98a638ef04c379.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u3_01292" + }, + { + "type": "UserNameWithHost", + "name": "u4_01292" + } + ] + }, + "hosts": { + "like_patterns": ["%.%.myhost.com"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5b98a638ef04c379.sql b/tests/ast_json_fixtures/shapes/5b98a638ef04c379.sql new file mode 100644 index 000000000000..314834e76c77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b98a638ef04c379.sql @@ -0,0 +1 @@ +CREATE USER u3_01292, u4_01292 HOST LIKE '%.%.myhost.com' diff --git a/tests/ast_json_fixtures/shapes/5b995929b04a562d.json b/tests/ast_json_fixtures/shapes/5b995929b04a562d.json new file mode 100644 index 000000000000..c1cb1f459723 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b995929b04a562d.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "test 01119" + } + ] + }, + "new_name": " spaces " + } +} diff --git a/tests/ast_json_fixtures/shapes/5b995929b04a562d.sql b/tests/ast_json_fixtures/shapes/5b995929b04a562d.sql new file mode 100644 index 000000000000..923dd672a758 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5b995929b04a562d.sql @@ -0,0 +1 @@ +alter user `test 01119` rename to " spaces " diff --git a/tests/ast_json_fixtures/shapes/5ba63b2b29f171e8.json b/tests/ast_json_fixtures/shapes/5ba63b2b29f171e8.json new file mode 100644 index 000000000000..4c5187793251 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ba63b2b29f171e8.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "test1" + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5ba63b2b29f171e8.sql b/tests/ast_json_fixtures/shapes/5ba63b2b29f171e8.sql new file mode 100644 index 000000000000..43292d25a257 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ba63b2b29f171e8.sql @@ -0,0 +1 @@ +SELECT 'test1', number FROM system.numbers GROUP BY number diff --git a/tests/ast_json_fixtures/shapes/5bbbaef03c9064e1.json b/tests/ast_json_fixtures/shapes/5bbbaef03c9064e1.json new file mode 100644 index 000000000000..b995dabc6698 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5bbbaef03c9064e1.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "decimal" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "DESC" + } + ] + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/5bbbaef03c9064e1.sql b/tests/ast_json_fixtures/shapes/5bbbaef03c9064e1.sql new file mode 100644 index 000000000000..cbc50408ef4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5bbbaef03c9064e1.sql @@ -0,0 +1 @@ +SELECT * FROM decimal ORDER BY b DESC FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/5bc92ea48221efe5.json b/tests/ast_json_fixtures/shapes/5bc92ea48221efe5.json new file mode 100644 index 000000000000..7e71aa91b80c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5bc92ea48221efe5.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "y" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5bc92ea48221efe5.sql b/tests/ast_json_fixtures/shapes/5bc92ea48221efe5.sql new file mode 100644 index 000000000000..84229a540f42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5bc92ea48221efe5.sql @@ -0,0 +1 @@ +SELECT DISTINCT x / 2, y FROM tab diff --git a/tests/ast_json_fixtures/shapes/5bdb83bff3907590.json b/tests/ast_json_fixtures/shapes/5bdb83bff3907590.json new file mode 100644 index 000000000000..07004178164c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5bdb83bff3907590.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CheckQuery", + "table": { + "type": "Identifier", + "name": "check_query_tiny_log" + }, + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5bdb83bff3907590.sql b/tests/ast_json_fixtures/shapes/5bdb83bff3907590.sql new file mode 100644 index 000000000000..69b3ee1f7a5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5bdb83bff3907590.sql @@ -0,0 +1 @@ +CHECK TABLE check_query_tiny_log PARTITION tuple() diff --git a/tests/ast_json_fixtures/shapes/5bdcab08e5a08e76.json b/tests/ast_json_fixtures/shapes/5bdcab08e5a08e76.json new file mode 100644 index 000000000000..18ddd880db50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5bdcab08e5a08e76.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN QUERY TREE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "run_passes": "0" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5bdcab08e5a08e76.sql b/tests/ast_json_fixtures/shapes/5bdcab08e5a08e76.sql new file mode 100644 index 000000000000..2a5ad1f0f4d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5bdcab08e5a08e76.sql @@ -0,0 +1 @@ +EXPLAIN QUERY TREE run_passes = 0 SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/5c027e471bf9babf.json b/tests/ast_json_fixtures/shapes/5c027e471bf9babf.json new file mode 100644 index 000000000000..868ed1981fe8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5c027e471bf9babf.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "alias": "key", + "value_type": "String", + "value": "a" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "value", + "value_type": "String", + "value": "b" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5c027e471bf9babf.sql b/tests/ast_json_fixtures/shapes/5c027e471bf9babf.sql new file mode 100644 index 000000000000..1f9520e57a11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5c027e471bf9babf.sql @@ -0,0 +1 @@ +SELECT toLowCardinality(materialize('a' AS key)), 'b' AS value GROUP BY key WITH CUBE SETTINGS group_by_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/5c17a3620546705f.json b/tests/ast_json_fixtures/shapes/5c17a3620546705f.json new file mode 100644 index 000000000000..66ae4ed8a174 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5c17a3620546705f.json @@ -0,0 +1,214 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "%W" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-01-02 22:33:44" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + }, + { + "type": "Function", + "name": "hasSubsequence", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "garbage" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "gr" + } + ] + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-01-02 22:33:44" + }, + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-01-02 22:33:44" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "gr" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2018-01-02 22:33:44" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5c17a3620546705f.sql b/tests/ast_json_fixtures/shapes/5c17a3620546705f.sql new file mode 100644 index 000000000000..ba8392cef13a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5c17a3620546705f.sql @@ -0,0 +1,11 @@ +SELECT + toFixedString(toFixedString(toFixedString(toFixedString(toFixedString(toFixedString('%W', 2), 2), 2), toLowCardinality(toLowCardinality(toNullable(2)))), 2), 2), + toFixedString(toFixedString('2018-01-02 22:33:44', 19), 19), + hasSubsequence(toNullable(materialize(toLowCardinality('garbage'))), 'gr') +GROUP BY + '2018-01-02 22:33:44', + toFixedString(toFixedString('2018-01-02 22:33:44', 19), 19), + 'gr', + '2018-01-02 22:33:44' +WITH CUBE +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/5c6929e1bd50a9f1.json b/tests/ast_json_fixtures/shapes/5c6929e1bd50a9f1.json new file mode 100644 index 000000000000..1a93f0f963bf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5c6929e1bd50a9f1.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_detach_attach_patches" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + }, + "move_destination_type": "TABLE", + "to_table": "t_detach_attach_patches_dst" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5c6929e1bd50a9f1.sql b/tests/ast_json_fixtures/shapes/5c6929e1bd50a9f1.sql new file mode 100644 index 000000000000..ca072902eaea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5c6929e1bd50a9f1.sql @@ -0,0 +1 @@ +ALTER TABLE t_detach_attach_patches MOVE PARTITION 2 TO TABLE t_detach_attach_patches_dst diff --git a/tests/ast_json_fixtures/shapes/5c7066fcd5c30647.json b/tests/ast_json_fixtures/shapes/5c7066fcd5c30647.json new file mode 100644 index 000000000000..6bbcdbd8b3c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5c7066fcd5c30647.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/5c7066fcd5c30647.sql b/tests/ast_json_fixtures/shapes/5c7066fcd5c30647.sql new file mode 100644 index 000000000000..2449eb4d2161 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5c7066fcd5c30647.sql @@ -0,0 +1 @@ +SELECT * FROM t WHERE id2 = 3 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/5c8b5bd5b18ce942.json b/tests/ast_json_fixtures/shapes/5c8b5bd5b18ce942.json new file mode 100644 index 000000000000..264bbf2275cf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5c8b5bd5b18ce942.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "prefetched_reader_pool_failpoint" + } +} diff --git a/tests/ast_json_fixtures/shapes/5c8b5bd5b18ce942.sql b/tests/ast_json_fixtures/shapes/5c8b5bd5b18ce942.sql new file mode 100644 index 000000000000..d08f8c55ac2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5c8b5bd5b18ce942.sql @@ -0,0 +1 @@ +SYSTEM ENABLE FAILPOINT prefetched_reader_pool_failpoint diff --git a/tests/ast_json_fixtures/shapes/5caeb19f070a1138.json b/tests/ast_json_fixtures/shapes/5caeb19f070a1138.json new file mode 100644 index 000000000000..0d9487fa3196 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5caeb19f070a1138.json @@ -0,0 +1,134 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "A", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + ] + }, + "storage": { + "type": "Storage", + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "A" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "64" + } + ] + }, + "order_by": { + "type": "StorageOrderByElement", + "expression": { + "type": "Identifier", + "name": "A" + }, + "direction": "DESC" + }, + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_reverse_key": "1" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11111" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 700000 + } + ] + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 700000 + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5caeb19f070a1138.sql b/tests/ast_json_fixtures/shapes/5caeb19f070a1138.sql new file mode 100644 index 000000000000..3acece8ebde5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5caeb19f070a1138.sql @@ -0,0 +1,2 @@ +create table t(A Int64) partition by (A % 64) order by A desc settings allow_experimental_reverse_key=1 +as select intDiv(number,11111) from numbers(7e5) union all select number from numbers(7e5) diff --git a/tests/ast_json_fixtures/shapes/5cb68780efc7bc9d.json b/tests/ast_json_fixtures/shapes/5cb68780efc7bc9d.json new file mode 100644 index 000000000000..c77e90b63a34 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5cb68780efc7bc9d.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0 + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC", + "with_fill": true + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5cb68780efc7bc9d.sql b/tests/ast_json_fixtures/shapes/5cb68780efc7bc9d.sql new file mode 100644 index 000000000000..057516b12e61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5cb68780efc7bc9d.sql @@ -0,0 +1 @@ +SELECT 0./0. ORDER BY 1 WITH FILL diff --git a/tests/ast_json_fixtures/shapes/5cfdc393fd4ca47d.json b/tests/ast_json_fixtures/shapes/5cfdc393fd4ca47d.json new file mode 100644 index 000000000000..0bc6aa7ad3d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5cfdc393fd4ca47d.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "source_data" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "pk", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "sk", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "val", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "partition_key", + "data_type": { + "type": "DataType", + "name": "UInt32" + }, + "default_specifier": "DEFAULT", + "default_expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "pk" + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "pk" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "pk" + }, + { + "type": "Identifier", + "name": "sk" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5cfdc393fd4ca47d.sql b/tests/ast_json_fixtures/shapes/5cfdc393fd4ca47d.sql new file mode 100644 index 000000000000..43dde5d6edb3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5cfdc393fd4ca47d.sql @@ -0,0 +1,5 @@ +CREATE TABLE source_data ( + pk Int32, sk Int32, val UInt32, partition_key UInt32 DEFAULT 1, + PRIMARY KEY (pk) +) ENGINE=MergeTree +ORDER BY (pk, sk) diff --git a/tests/ast_json_fixtures/shapes/5d1e58bc3d5746ae.json b/tests/ast_json_fixtures/shapes/5d1e58bc3d5746ae.json new file mode 100644 index 000000000000..d3051987deaa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d1e58bc3d5746ae.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR QUERY CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/5d1e58bc3d5746ae.sql b/tests/ast_json_fixtures/shapes/5d1e58bc3d5746ae.sql new file mode 100644 index 000000000000..93bf0a3ed16f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d1e58bc3d5746ae.sql @@ -0,0 +1 @@ +SYSTEM CLEAR QUERY CACHE diff --git a/tests/ast_json_fixtures/shapes/5d5d1989bb4ebe6c.json b/tests/ast_json_fixtures/shapes/5d5d1989bb4ebe6c.json new file mode 100644 index 000000000000..e77e1ebe6d0a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d5d1989bb4ebe6c.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "name": "fact_3_id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "grouping_sets" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "fact_3_id" + }, + { + "type": "Identifier", + "name": "fact_4_id" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "fact_3_id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5d5d1989bb4ebe6c.sql b/tests/ast_json_fixtures/shapes/5d5d1989bb4ebe6c.sql new file mode 100644 index 000000000000..1d84b571d5ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d5d1989bb4ebe6c.sql @@ -0,0 +1,5 @@ +SELECT fact_3_id +FROM grouping_sets +GROUP BY + GROUPING SETS ((fact_3_id, fact_4_id)) +ORDER BY fact_3_id ASC diff --git a/tests/ast_json_fixtures/shapes/5d698152d9d2b7b9.json b/tests/ast_json_fixtures/shapes/5d698152d9d2b7b9.json new file mode 100644 index 000000000000..def9f39251b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d698152d9d2b7b9.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u10_01292", "u11_01292", "u12_01292", "u13_01292", "u14_01292", "u15_01292", "u16_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/5d698152d9d2b7b9.sql b/tests/ast_json_fixtures/shapes/5d698152d9d2b7b9.sql new file mode 100644 index 000000000000..445abb9c6fe6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d698152d9d2b7b9.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS u10_01292, u11_01292, u12_01292, u13_01292, u14_01292, u15_01292, u16_01292 diff --git a/tests/ast_json_fixtures/shapes/5d78c0336be41e38.json b/tests/ast_json_fixtures/shapes/5d78c0336be41e38.json new file mode 100644 index 000000000000..bf264568ed10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d78c0336be41e38.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CheckQuery", + "database": { + "type": "Identifier", + "name": "sqllt" + }, + "table": { + "type": "Identifier", + "name": "table" + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/5d78c0336be41e38.sql b/tests/ast_json_fixtures/shapes/5d78c0336be41e38.sql new file mode 100644 index 000000000000..6bff90e87d61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d78c0336be41e38.sql @@ -0,0 +1 @@ +CHECK TABLE sqllt.table FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/5d8c5f65a823f9e4.json b/tests/ast_json_fixtures/shapes/5d8c5f65a823f9e4.json new file mode 100644 index 000000000000..16aed2fea560 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d8c5f65a823f9e4.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["CREATE TEMPORARY TABLE"] + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_03727"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5d8c5f65a823f9e4.sql b/tests/ast_json_fixtures/shapes/5d8c5f65a823f9e4.sql new file mode 100644 index 000000000000..12797e9c2051 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d8c5f65a823f9e4.sql @@ -0,0 +1 @@ +GRANT CREATE TEMPORARY TABLE ON *.* TO test_03727 diff --git a/tests/ast_json_fixtures/shapes/5d9ebcf8564f1e9e.json b/tests/ast_json_fixtures/shapes/5d9ebcf8564f1e9e.json new file mode 100644 index 000000000000..aae6f6e1c817 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d9ebcf8564f1e9e.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "extract", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "10000000" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers_mt", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "..." + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "%10000000%" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5d9ebcf8564f1e9e.sql b/tests/ast_json_fixtures/shapes/5d9ebcf8564f1e9e.sql new file mode 100644 index 000000000000..34d0a7b0a7a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5d9ebcf8564f1e9e.sql @@ -0,0 +1 @@ +SELECT extract(toString(number), '10000000') FROM system.numbers_mt WHERE concat(materialize('1'), '...', toString(number)) LIKE '%10000000%' LIMIT 1 SETTINGS max_rows_to_read = 0 diff --git a/tests/ast_json_fixtures/shapes/5da4e489a5a17cb7.json b/tests/ast_json_fixtures/shapes/5da4e489a5a17cb7.json new file mode 100644 index 000000000000..e26b2cb94b89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5da4e489a5a17cb7.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "query_views_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5da4e489a5a17cb7.sql b/tests/ast_json_fixtures/shapes/5da4e489a5a17cb7.sql new file mode 100644 index 000000000000..8b9080b24214 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5da4e489a5a17cb7.sql @@ -0,0 +1 @@ +system flush logs query_views_log diff --git a/tests/ast_json_fixtures/shapes/5dffaf8f2d24d734.json b/tests/ast_json_fixtures/shapes/5dffaf8f2d24d734.json new file mode 100644 index 000000000000..adf7b07d9f33 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5dffaf8f2d24d734.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "UNLOAD PRIMARY KEY" + } +} diff --git a/tests/ast_json_fixtures/shapes/5dffaf8f2d24d734.sql b/tests/ast_json_fixtures/shapes/5dffaf8f2d24d734.sql new file mode 100644 index 000000000000..7b25dfb0ae39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5dffaf8f2d24d734.sql @@ -0,0 +1 @@ +SYSTEM UNLOAD PRIMARY KEY diff --git a/tests/ast_json_fixtures/shapes/5e3953d4240fb416.json b/tests/ast_json_fixtures/shapes/5e3953d4240fb416.json new file mode 100644 index 000000000000..26a146b768fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e3953d4240fb416.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "grp_aggreg" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data_02295" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "grp_aggreg" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "0" + } + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/5e3953d4240fb416.sql b/tests/ast_json_fixtures/shapes/5e3953d4240fb416.sql new file mode 100644 index 000000000000..eb51442aed7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e3953d4240fb416.sql @@ -0,0 +1 @@ +SELECT grp_aggreg FROM data_02295 GROUP BY a, grp_aggreg ORDER BY a SETTINGS optimize_aggregation_in_order = 0 FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/5e3dbd5c03546221.json b/tests/ast_json_fixtures/shapes/5e3dbd5c03546221.json new file mode 100644 index 000000000000..84e64a292a23 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e3dbd5c03546221.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "k" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_sparse_pk" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5e3dbd5c03546221.sql b/tests/ast_json_fixtures/shapes/5e3dbd5c03546221.sql new file mode 100644 index 000000000000..50b93c646fc2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e3dbd5c03546221.sql @@ -0,0 +1 @@ +SELECT range(k) FROM t_sparse_pk ORDER BY k LIMIT 3 diff --git a/tests/ast_json_fixtures/shapes/5e3f27c0466d2704.json b/tests/ast_json_fixtures/shapes/5e3f27c0466d2704.json new file mode 100644 index 000000000000..50606844b5af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e3f27c0466d2704.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r4_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/5e3f27c0466d2704.sql b/tests/ast_json_fixtures/shapes/5e3f27c0466d2704.sql new file mode 100644 index 000000000000..b7b4c80360cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e3f27c0466d2704.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r4_01293 diff --git a/tests/ast_json_fixtures/shapes/5e3fe8c83b1c6c34.json b/tests/ast_json_fixtures/shapes/5e3fe8c83b1c6c34.json new file mode 100644 index 000000000000..2b909fc53c27 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e3fe8c83b1c6c34.json @@ -0,0 +1,140 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "SLEEP #1 CHECK" + }, + { + "type": "Function", + "alias": "calls", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "SleepFunctionCalls" + } + ] + }, + { + "type": "Function", + "alias": "microseconds", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "SleepFunctionMicroseconds" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%SELECT 'SLEEP #1 TEST'%" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "yesterday", + "arguments": [] + } + ] + } + ] + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/5e3fe8c83b1c6c34.sql b/tests/ast_json_fixtures/shapes/5e3fe8c83b1c6c34.sql new file mode 100644 index 000000000000..d83aa4898d1b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e3fe8c83b1c6c34.sql @@ -0,0 +1,7 @@ +SELECT 'SLEEP #1 CHECK', ProfileEvents['SleepFunctionCalls'] as calls, ProfileEvents['SleepFunctionMicroseconds'] as microseconds +FROM system.query_log +WHERE query like '%SELECT ''SLEEP #1 TEST''%' + AND type > 1 + AND current_database = currentDatabase() + AND event_date >= yesterday() + FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/5e67274ea7874005.json b/tests/ast_json_fixtures/shapes/5e67274ea7874005.json new file mode 100644 index 000000000000..0b2dcaa43028 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e67274ea7874005.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONCompactEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/5e67274ea7874005.sql b/tests/ast_json_fixtures/shapes/5e67274ea7874005.sql new file mode 100644 index 000000000000..9f7b709333b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e67274ea7874005.sql @@ -0,0 +1 @@ +SELECT name, count() AS c FROM test_table GROUP BY name WITH TOTALS ORDER BY name FORMAT JSONCompactEachRow diff --git a/tests/ast_json_fixtures/shapes/5e8563381baa29db.json b/tests/ast_json_fixtures/shapes/5e8563381baa29db.json new file mode 100644 index 000000000000..d80689d5f84a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e8563381baa29db.json @@ -0,0 +1,313 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Lambda as function parameter" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Lambda as function parameter" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Lambda as function parameter" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Literal", + "value_type": "String", + "value": "world" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Lambda as function parameter" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + }, + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + } + ] + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + } + ] + } + ] + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "having": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "nullIf", + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC", + "nulls_first": true + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5e8563381baa29db.sql b/tests/ast_json_fixtures/shapes/5e8563381baa29db.sql new file mode 100644 index 000000000000..1b205990fc42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e8563381baa29db.sql @@ -0,0 +1 @@ +SELECT count('Lambda as function parameter') AS c FROM (SELECT ignore(ignore('Lambda as function parameter', 28, 28, 28, 28, 28, 28), 28), materialize('Lambda as function parameter'), 28, 28, 'world', 5 FROM system.numbers WHERE ignore(materialize('Lambda as function parameter'), materialize(toLowCardinality(28)), 28, 28, 28, 28, toUInt128(28)) LIMIT 2) GROUP BY GROUPING SETS ((toLowCardinality(0)), (toLowCardinality(toNullable(28))), (1)) HAVING nullIf(c, 10) < 50 ORDER BY c ASC NULLS FIRST settings group_by_use_nulls=1 diff --git a/tests/ast_json_fixtures/shapes/5e927970ffac12b8.json b/tests/ast_json_fixtures/shapes/5e927970ffac12b8.json new file mode 100644 index 000000000000..075d5678e393 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e927970ffac12b8.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "< 127.0.0.1" + }, + { + "type": "Identifier", + "name": "ipv4_" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ipv4_test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ipv4_" + }, + { + "type": "Function", + "name": "toIPv4", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.1" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ipv4_" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5e927970ffac12b8.sql b/tests/ast_json_fixtures/shapes/5e927970ffac12b8.sql new file mode 100644 index 000000000000..0cfcf3ea9808 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5e927970ffac12b8.sql @@ -0,0 +1,3 @@ +SELECT '< 127.0.0.1', ipv4_ FROM ipv4_test + WHERE ipv4_ < toIPv4('127.0.0.1') + ORDER BY ipv4_ diff --git a/tests/ast_json_fixtures/shapes/5eabeada4d540460.json b/tests/ast_json_fixtures/shapes/5eabeada4d540460.json new file mode 100644 index 000000000000..0f36a90e2f24 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5eabeada4d540460.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "gcd", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sign", + "arguments": [ + { + "type": "Identifier", + "name": "c0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_use_implicit_projections": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5eabeada4d540460.sql b/tests/ast_json_fixtures/shapes/5eabeada4d540460.sql new file mode 100644 index 000000000000..2d99cabbbd0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5eabeada4d540460.sql @@ -0,0 +1 @@ +SELECT count() FROM t0 GROUP BY gcd(-sign(c0), -c0) SETTINGS optimize_use_implicit_projections = 1 diff --git a/tests/ast_json_fixtures/shapes/5ed748d7d317e11e.json b/tests/ast_json_fixtures/shapes/5ed748d7d317e11e.json new file mode 100644 index 000000000000..f492357d5ee3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ed748d7d317e11e.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_file" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "02884_{1,2}.csv" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "_file" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5ed748d7d317e11e.sql b/tests/ast_json_fixtures/shapes/5ed748d7d317e11e.sql new file mode 100644 index 000000000000..50d2a3220982 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ed748d7d317e11e.sql @@ -0,0 +1 @@ +select _file, * from file('02884_{1,2}.csv') order by _file settings max_threads=1 diff --git a/tests/ast_json_fixtures/shapes/5edeb90fd3bfa633.json b/tests/ast_json_fixtures/shapes/5edeb90fd3bfa633.json new file mode 100644 index 000000000000..d854ba9411af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5edeb90fd3bfa633.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "src_table" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "time" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/5edeb90fd3bfa633.sql b/tests/ast_json_fixtures/shapes/5edeb90fd3bfa633.sql new file mode 100644 index 000000000000..4f2ce0a1b047 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5edeb90fd3bfa633.sql @@ -0,0 +1 @@ +SELECT * FROM src_table ORDER BY time FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/5ee4041ceaad9754.json b/tests/ast_json_fixtures/shapes/5ee4041ceaad9754.json new file mode 100644 index 000000000000..d3c7b23eddf0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ee4041ceaad9754.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_projection_deduplicate" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "string", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "test_projection", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "id" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5ee4041ceaad9754.sql b/tests/ast_json_fixtures/shapes/5ee4041ceaad9754.sql new file mode 100644 index 000000000000..423309131695 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ee4041ceaad9754.sql @@ -0,0 +1,12 @@ +CREATE TABLE test_projection_deduplicate +( + `id` Int32, + `string` String, + PROJECTION test_projection + ( + SELECT id + GROUP BY id + ) +) +ENGINE = MergeTree +PRIMARY KEY id diff --git a/tests/ast_json_fixtures/shapes/5ef210712b0069f8.json b/tests/ast_json_fixtures/shapes/5ef210712b0069f8.json new file mode 100644 index 000000000000..4b8b42b878d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ef210712b0069f8.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/5ef210712b0069f8.sql b/tests/ast_json_fixtures/shapes/5ef210712b0069f8.sql new file mode 100644 index 000000000000..ca3429dd52c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ef210712b0069f8.sql @@ -0,0 +1 @@ +select a from t2 group by a format Null diff --git a/tests/ast_json_fixtures/shapes/5efe3d329574c998.json b/tests/ast_json_fixtures/shapes/5efe3d329574c998.json new file mode 100644 index 000000000000..84861bc88cf7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5efe3d329574c998.json @@ -0,0 +1,227 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "group_by_with_totals": true, + "select": [ + { + "type": "Asterisk" + } + ], + "where": { + "type": "Function", + "name": "isNotDistinctFrom", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "qualify": { + "type": "Function", + "name": "isNotDistinctFrom", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotDistinctFrom", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + { + "type": "Asterisk" + }, + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Asterisk" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Asterisk" + }, + { + "type": "Asterisk" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5efe3d329574c998.sql b/tests/ast_json_fixtures/shapes/5efe3d329574c998.sql new file mode 100644 index 000000000000..c1d49117de71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5efe3d329574c998.sql @@ -0,0 +1,4 @@ +SELECT DISTINCT * WHERE 2 <=> materialize(2) +GROUP BY 1 +WITH TOTALS QUALIFY ((2 <=> 2) / ((2 IS NOT NULL) IS NULL), *, *, materialize(toNullable(2)), materialize(2), materialize(materialize(2)), 2) +<=> ((2 = *) * 2, *, *, 2, toNullable(2), 2, 2) diff --git a/tests/ast_json_fixtures/shapes/5f038a68e1fb1372.json b/tests/ast_json_fixtures/shapes/5f038a68e1fb1372.json new file mode 100644 index 000000000000..e5ca7ee694e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f038a68e1fb1372.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateTableQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "test" + }, + "format": "LineAsString" + } +} diff --git a/tests/ast_json_fixtures/shapes/5f038a68e1fb1372.sql b/tests/ast_json_fixtures/shapes/5f038a68e1fb1372.sql new file mode 100644 index 000000000000..a82d168ab6a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f038a68e1fb1372.sql @@ -0,0 +1 @@ +SHOW CREATE TEMPORARY test FORMAT LineAsString diff --git a/tests/ast_json_fixtures/shapes/5f049e236ca45c8c.json b/tests/ast_json_fixtures/shapes/5f049e236ca45c8c.json new file mode 100644 index 000000000000..846102ac5dc5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f049e236ca45c8c.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s10_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "parent_profile": "s1_01294" + }, + { + "type": "SettingsProfileElement", + "parent_profile": "s3_01294" + }, + { + "type": "SettingsProfileElement", + "parent_profile": "default" + }, + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "0" + }, + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "max_value": "6000000" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5f049e236ca45c8c.sql b/tests/ast_json_fixtures/shapes/5f049e236ca45c8c.sql new file mode 100644 index 000000000000..786036fda8ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f049e236ca45c8c.sql @@ -0,0 +1 @@ +CREATE PROFILE s10_01294 SETTINGS INHERIT s1_01294, s3_01294, INHERIT default, readonly=0, max_memory_usage MAX 6000000 diff --git a/tests/ast_json_fixtures/shapes/5f374df69881896f.json b/tests/ast_json_fixtures/shapes/5f374df69881896f.json new file mode 100644 index 000000000000..b8b563b8dca8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f374df69881896f.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "alter": true, + "names": ["s1_01294", "s2_01294"], + "alter_settings": { + "type": "AlterSettingsProfileElements", + "add_settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "value": "6000000" + } + ] + }, + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5f374df69881896f.sql b/tests/ast_json_fixtures/shapes/5f374df69881896f.sql new file mode 100644 index 000000000000..166b8e88687d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f374df69881896f.sql @@ -0,0 +1 @@ +ALTER PROFILE s1_01294, s2_01294 SETTINGS max_memory_usage=6000000 diff --git a/tests/ast_json_fixtures/shapes/5f37b5aa4f851f71.json b/tests/ast_json_fixtures/shapes/5f37b5aa4f851f71.json new file mode 100644 index 000000000000..080aa3516e24 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f37b5aa4f851f71.json @@ -0,0 +1,427 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "cutoff_time", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "now", + "arguments": [] + }, + { + "type": "Function", + "name": "toIntervalHour", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "WithElement", + "name": "query_ids", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "query_id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_time" + }, + { + "type": "Identifier", + "name": "cutoff_time" + } + ] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Identifier", + "name": "has_watch" + }, + { + "type": "Identifier", + "name": "op_num" + }, + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Identifier", + "name": "is_ephemeral" + }, + { + "type": "Identifier", + "name": "is_sequential" + }, + { + "type": "Identifier", + "name": "version" + }, + { + "type": "Identifier", + "name": "requests_size" + }, + { + "type": "Identifier", + "name": "request_idx" + }, + { + "type": "Identifier", + "name": "error" + }, + { + "type": "Identifier", + "name": "watch_type" + }, + { + "type": "Identifier", + "name": "watch_state" + }, + { + "type": "Identifier", + "name": "path_created" + }, + { + "type": "Identifier", + "name": "stat_version" + }, + { + "type": "Identifier", + "name": "stat_cversion" + }, + { + "type": "Identifier", + "name": "stat_dataLength" + }, + { + "type": "Identifier", + "name": "stat_numChildren" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "zookeeper_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_time" + }, + { + "type": "Identifier", + "name": "cutoff_time" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "session_id" + }, + { + "type": "Identifier", + "name": "xid" + } + ] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "session_id" + }, + { + "type": "Identifier", + "name": "xid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "zookeeper_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_time" + }, + { + "type": "Identifier", + "name": "cutoff_time" + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/test\/01158\/" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "\/rmt\/blocks\/%" + } + ] + } + ] + }, + { + "type": "Function", + "name": "notIn", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "op_num" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "12" + }, + { + "value_type": "UInt64", + "value": "500" + } + ] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Identifier", + "name": "query_ids" + } + ] + } + ] + } + ] + } + } + ] + } + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "xid" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "type" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "request_idx" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5f37b5aa4f851f71.sql b/tests/ast_json_fixtures/shapes/5f37b5aa4f851f71.sql new file mode 100644 index 000000000000..f03c27fe8a63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f37b5aa4f851f71.sql @@ -0,0 +1,15 @@ +with now() - interval 1 hour as cutoff_time, +query_ids as +( + select query_id from system.query_log where current_database=currentDatabase() and event_time>=cutoff_time +) +select type, has_watch, op_num, path, is_ephemeral, is_sequential, version, requests_size, request_idx, error, watch_type, + watch_state, path_created, stat_version, stat_cversion, stat_dataLength, stat_numChildren +from system.zookeeper_log +where event_time>=cutoff_time and (session_id, xid) in ( + select session_id, xid from system.zookeeper_log where event_time>=cutoff_time + and path like '/test/01158/' || currentDatabase() || '/rmt/blocks/%' + and op_num not in (1, 12, 500) + and (query_id='' or query_id in query_ids) +) +order by xid, type, request_idx diff --git a/tests/ast_json_fixtures/shapes/5f453002e6b59988.json b/tests/ast_json_fixtures/shapes/5f453002e6b59988.json new file mode 100644 index 000000000000..d6714a91d253 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f453002e6b59988.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distributed_00952" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "local_00952" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "local_00952" + } +} diff --git a/tests/ast_json_fixtures/shapes/5f453002e6b59988.sql b/tests/ast_json_fixtures/shapes/5f453002e6b59988.sql new file mode 100644 index 000000000000..6a8fa4a25e5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f453002e6b59988.sql @@ -0,0 +1 @@ +CREATE TABLE distributed_00952 AS local_00952 ENGINE = Distributed('test_cluster_two_shards', currentDatabase(), local_00952, rand()) diff --git a/tests/ast_json_fixtures/shapes/5f64fa00ed90e71f.json b/tests/ast_json_fixtures/shapes/5f64fa00ed90e71f.json new file mode 100644 index 000000000000..bdd610a7c7da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f64fa00ed90e71f.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "i" + } + ], + "having": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "10" + }, + { + "value_type": "UInt64", + "value": "11" + }, + { + "value_type": "UInt64", + "value": "12" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/5f64fa00ed90e71f.sql b/tests/ast_json_fixtures/shapes/5f64fa00ed90e71f.sql new file mode 100644 index 000000000000..083427393209 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f64fa00ed90e71f.sql @@ -0,0 +1 @@ +select * from test group by i having i in (10, 11, 12) order by i limit 1 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/5f7a78d8a261dd44.json b/tests/ast_json_fixtures/shapes/5f7a78d8a261dd44.json new file mode 100644 index 000000000000..118edd7caab1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f7a78d8a261dd44.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "xp_d" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "xp" + } + ] + } + }, + "as_table": "xp" + } +} diff --git a/tests/ast_json_fixtures/shapes/5f7a78d8a261dd44.sql b/tests/ast_json_fixtures/shapes/5f7a78d8a261dd44.sql new file mode 100644 index 000000000000..c4706467b6ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f7a78d8a261dd44.sql @@ -0,0 +1 @@ +create table xp_d as xp Engine=Distributed(test_shard_localhost, currentDatabase(), xp) diff --git a/tests/ast_json_fixtures/shapes/5f7bf2977fb50c02.json b/tests/ast_json_fixtures/shapes/5f7bf2977fb50c02.json new file mode 100644 index 000000000000..5e0b0ec93232 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f7bf2977fb50c02.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q2_01297"], + "limits": [ + { + "duration_sec": "1800", + "max": { + "ERRORS": "4" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5f7bf2977fb50c02.sql b/tests/ast_json_fixtures/shapes/5f7bf2977fb50c02.sql new file mode 100644 index 000000000000..277700d31e01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f7bf2977fb50c02.sql @@ -0,0 +1 @@ +CREATE QUOTA q2_01297 FOR INTERVAL 30 minute MAX ERRORS 4 diff --git a/tests/ast_json_fixtures/shapes/5f87ef2a11165580.json b/tests/ast_json_fixtures/shapes/5f87ef2a11165580.json new file mode 100644 index 000000000000..9a9afced2252 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f87ef2a11165580.json @@ -0,0 +1,352 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "255" + }, + { + "value_type": "UInt64", + "value": "1048575" + } + ] + } + ] + }, + { + "type": "Function", + "name": "sipHash128ReferenceKeyed", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483646" + } + ] + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775807" + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1024" + }, + { + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Function", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "sipHash128ReferenceKeyed", + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Int64", + "value": "-9223372036854775807" + }, + { + "value_type": "Float64", + "value": 1 + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "-1" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "65535" + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "9223372036854775807" + }, + { + "value_type": "UInt64", + "value": "9223372036854775806" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "65536" + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "UInt64", + "value": "65537" + }, + { + "value_type": "UInt64", + "value": "255" + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Int64", + "value": "-1" + } + ] + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5f87ef2a11165580.sql b/tests/ast_json_fixtures/shapes/5f87ef2a11165580.sql new file mode 100644 index 000000000000..734b9e518eaa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5f87ef2a11165580.sql @@ -0,0 +1 @@ +SELECT [(255, 1048575)], sipHash128ReferenceKeyed((toUInt64(2147483646), toUInt64(9223372036854775807)), ([(NULL, 100), (NULL, NULL), (1024, 10)], toUInt64(2), toUInt64(1024)), ''), hex(sipHash128ReferenceKeyed((-9223372036854775807, 1.), '-1', NULL)), ('', toUInt64(65535), [(9223372036854775807, 9223372036854775806)], toUInt64(65536)), arrayJoin((NULL, 65537, 255), [(NULL, NULL)]) GROUP BY tupleElement((NULL, NULL, NULL, -1), toUInt64(2), 2) = NULL SETTINGS enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/5fab7fce9cb80e9f.json b/tests/ast_json_fixtures/shapes/5fab7fce9cb80e9f.json new file mode 100644 index 000000000000..22194a46b790 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5fab7fce9cb80e9f.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5fab7fce9cb80e9f.sql b/tests/ast_json_fixtures/shapes/5fab7fce9cb80e9f.sql new file mode 100644 index 000000000000..f03908b02cc6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5fab7fce9cb80e9f.sql @@ -0,0 +1 @@ +SELECT * FROM t ORDER BY i diff --git a/tests/ast_json_fixtures/shapes/5fb1a414f6d535c2.json b/tests/ast_json_fixtures/shapes/5fb1a414f6d535c2.json new file mode 100644 index 000000000000..94d6f68e25c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5fb1a414f6d535c2.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Asterisk" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5fb1a414f6d535c2.sql b/tests/ast_json_fixtures/shapes/5fb1a414f6d535c2.sql new file mode 100644 index 000000000000..7d0e4814a8b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5fb1a414f6d535c2.sql @@ -0,0 +1 @@ +SELECT * ORDER BY * diff --git a/tests/ast_json_fixtures/shapes/5fce537758b76c8c.json b/tests/ast_json_fixtures/shapes/5fce537758b76c8c.json new file mode 100644 index 000000000000..3584952b244c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5fce537758b76c8c.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "function_name": { + "type": "Identifier", + "name": "f1" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "p0" + }, + { + "type": "Identifier", + "name": "p1" + } + ] + }, + { + "type": "Asterisk" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5fce537758b76c8c.sql b/tests/ast_json_fixtures/shapes/5fce537758b76c8c.sql new file mode 100644 index 000000000000..bf1765e0e378 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5fce537758b76c8c.sql @@ -0,0 +1 @@ +CREATE FUNCTION f1 AS (p0, p1) -> * diff --git a/tests/ast_json_fixtures/shapes/5fec6c27a35b27cf.json b/tests/ast_json_fixtures/shapes/5fec6c27a35b27cf.json new file mode 100644 index 000000000000..b5185ae8237c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5fec6c27a35b27cf.json @@ -0,0 +1,114 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mt" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + } + ], + "indices": [ + { + "type": "Index", + "name": "b_index", + "expression": { + "type": "Identifier", + "name": "b" + }, + "index_type": { + "type": "Function", + "name": "set", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "123" + } + ] + }, + "granularity": 1 + } + ], + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "coalesce", + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test" + } + ] + } + ] + } + }, + "storage": { + "type": "Storage", + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "coalesce", + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test" + } + ] + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5fec6c27a35b27cf.sql b/tests/ast_json_fixtures/shapes/5fec6c27a35b27cf.sql new file mode 100644 index 000000000000..48900bf8ec3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5fec6c27a35b27cf.sql @@ -0,0 +1 @@ +CREATE TABLE mt (a UInt64, b Nullable(String), PRIMARY KEY (a, coalesce(b, 'test')), INDEX b_index b TYPE set(123) GRANULARITY 1) diff --git a/tests/ast_json_fixtures/shapes/5ffaf2d4945f6183.json b/tests/ast_json_fixtures/shapes/5ffaf2d4945f6183.json new file mode 100644 index 000000000000..2e2328906d6b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ffaf2d4945f6183.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_lwd_mutations" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "assignments": [ + { + "type": "Assignment", + "column": "v", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + }, + { + "type": "AlterCommand", + "command_type": "DELETE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/5ffaf2d4945f6183.sql b/tests/ast_json_fixtures/shapes/5ffaf2d4945f6183.sql new file mode 100644 index 000000000000..b5e6ecd0e381 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ffaf2d4945f6183.sql @@ -0,0 +1 @@ +ALTER TABLE t_lwd_mutations UPDATE v = 1 WHERE id % 4 = 0, DELETE WHERE id % 10 = 1 diff --git a/tests/ast_json_fixtures/shapes/5ffe47232aa00766.json b/tests/ast_json_fixtures/shapes/5ffe47232aa00766.json new file mode 100644 index 000000000000..0d8a4aad9d01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ffe47232aa00766.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "eligible_test" + } + }, + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": true + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/5ffe47232aa00766.sql b/tests/ast_json_fixtures/shapes/5ffe47232aa00766.sql new file mode 100644 index 000000000000..8afe05fc0a41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/5ffe47232aa00766.sql @@ -0,0 +1 @@ +DESCRIBE TABLE eligible_test SETTINGS use_query_cache = true diff --git a/tests/ast_json_fixtures/shapes/6015e13797bd6a73.json b/tests/ast_json_fixtures/shapes/6015e13797bd6a73.json new file mode 100644 index 000000000000..fbae046a333c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6015e13797bd6a73.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p2_01295", + "database": "db", + "table": "table" + } + ] + }, + "is_restrictive": true, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "currentUser", + "arguments": [] + } + ] + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "names": ["u1_01295"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6015e13797bd6a73.sql b/tests/ast_json_fixtures/shapes/6015e13797bd6a73.sql new file mode 100644 index 000000000000..a18326400d50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6015e13797bd6a73.sql @@ -0,0 +1 @@ +CREATE ROW POLICY p2_01295 ON db.table USING id=currentUser() AS RESTRICTIVE TO u1_01295 diff --git a/tests/ast_json_fixtures/shapes/60275bea5bffc791.json b/tests/ast_json_fixtures/shapes/60275bea5bffc791.json new file mode 100644 index 000000000000..5a7f17f0450c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/60275bea5bffc791.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "v" + }, + "is_view": true + } +} diff --git a/tests/ast_json_fixtures/shapes/60275bea5bffc791.sql b/tests/ast_json_fixtures/shapes/60275bea5bffc791.sql new file mode 100644 index 000000000000..d4fa14e61511 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/60275bea5bffc791.sql @@ -0,0 +1 @@ +DROP VIEW v diff --git a/tests/ast_json_fixtures/shapes/6032fa8fbffd99f6.json b/tests/ast_json_fixtures/shapes/6032fa8fbffd99f6.json new file mode 100644 index 000000000000..5dfb99ff9f7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6032fa8fbffd99f6.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1704509" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "totals_mode": "after_having_auto", + "max_rows_to_group_by": "100000", + "group_by_overflow_mode": "any" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6032fa8fbffd99f6.sql b/tests/ast_json_fixtures/shapes/6032fa8fbffd99f6.sql new file mode 100644 index 000000000000..8b05245b1c46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6032fa8fbffd99f6.sql @@ -0,0 +1 @@ +SELECT count() AS c FROM test.hits WHERE CounterID = 1704509 WITH TOTALS SETTINGS totals_mode = 'after_having_auto', max_rows_to_group_by = 100000, group_by_overflow_mode = 'any' diff --git a/tests/ast_json_fixtures/shapes/6036bca07d20ee10.json b/tests/ast_json_fixtures/shapes/6036bca07d20ee10.json new file mode 100644 index 000000000000..b29ff27e6985 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6036bca07d20ee10.json @@ -0,0 +1,115 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "format": "CSV", + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x.number", + "name_parts": ["x", "number"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "x", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x.number", + "name_parts": ["x", "number"] + }, + { + "type": "Identifier", + "name": "y.a", + "name_parts": ["y", "a"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "y", + "name": "input", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a UInt64" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6036bca07d20ee10.sql b/tests/ast_json_fixtures/shapes/6036bca07d20ee10.sql new file mode 100644 index 000000000000..ff9f81aff550 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6036bca07d20ee10.sql @@ -0,0 +1,10 @@ +INSERT INTO test +SELECT x.number FROM ( + SELECT number + FROM system.numbers + LIMIT 10 +) AS x +INNER JOIN input('a UInt64') AS y ON x.number = y.a +Format CSV 2 + +select * from test diff --git a/tests/ast_json_fixtures/shapes/6039180e3a233381.json b/tests/ast_json_fixtures/shapes/6039180e3a233381.json new file mode 100644 index 000000000000..803d765febff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6039180e3a233381.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01293" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "null_01293" + }, + { + "type": "Identifier", + "name": "key" + } + ] + } + }, + "as_table": "null_01293" + } +} diff --git a/tests/ast_json_fixtures/shapes/6039180e3a233381.sql b/tests/ast_json_fixtures/shapes/6039180e3a233381.sql new file mode 100644 index 000000000000..4488c9312741 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6039180e3a233381.sql @@ -0,0 +1 @@ +create table dist_01293 as null_01293 engine=Distributed(test_cluster_two_shards, currentDatabase(), null_01293, key) diff --git a/tests/ast_json_fixtures/shapes/605f7893f345ae5c.json b/tests/ast_json_fixtures/shapes/605f7893f345ae5c.json new file mode 100644 index 000000000000..b90795278750 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/605f7893f345ae5c.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mt" + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Identifier", + "name": "n" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/605f7893f345ae5c.sql b/tests/ast_json_fixtures/shapes/605f7893f345ae5c.sql new file mode 100644 index 000000000000..d0c4e6543c1d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/605f7893f345ae5c.sql @@ -0,0 +1 @@ +CREATE TABLE mt ORDER BY n AS SELECT 1 as n diff --git a/tests/ast_json_fixtures/shapes/606fc1303c5ce7cd.json b/tests/ast_json_fixtures/shapes/606fc1303c5ce7cd.json new file mode 100644 index 000000000000..626cfd53940a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/606fc1303c5ce7cd.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ], + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/606fc1303c5ce7cd.sql b/tests/ast_json_fixtures/shapes/606fc1303c5ce7cd.sql new file mode 100644 index 000000000000..77371175ef15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/606fc1303c5ce7cd.sql @@ -0,0 +1 @@ +WITH 1 as a SELECT a, FROM numbers(1) diff --git a/tests/ast_json_fixtures/shapes/6095b8ccc62856a1.json b/tests/ast_json_fixtures/shapes/6095b8ccc62856a1.json new file mode 100644 index 000000000000..b9086390e6cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6095b8ccc62856a1.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "mt_00160" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "12345" + }, + { + "value_type": "UInt64", + "value": "67890" + } + ] + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "alias": "b", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "blockSize", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6095b8ccc62856a1.sql b/tests/ast_json_fixtures/shapes/6095b8ccc62856a1.sql new file mode 100644 index 000000000000..15d784330d9c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6095b8ccc62856a1.sql @@ -0,0 +1 @@ +SELECT *, b FROM mt_00160 WHERE x IN (12345, 67890) AND NOT ignore(blockSize() < 10 AS b) ORDER BY x diff --git a/tests/ast_json_fixtures/shapes/60a1128e4aee13be.json b/tests/ast_json_fixtures/shapes/60a1128e4aee13be.json new file mode 100644 index 000000000000..d0667c12de4e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/60a1128e4aee13be.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "v0" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "INTERSECT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/60a1128e4aee13be.sql b/tests/ast_json_fixtures/shapes/60a1128e4aee13be.sql new file mode 100644 index 000000000000..69cfdf25f305 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/60a1128e4aee13be.sql @@ -0,0 +1 @@ +CREATE MATERIALIZED VIEW v0 AS (SELECT 1) INTERSECT (SELECT 1) diff --git a/tests/ast_json_fixtures/shapes/60e597e1381f2ec7.json b/tests/ast_json_fixtures/shapes/60e597e1381f2ec7.json new file mode 100644 index 000000000000..590ac929b686 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/60e597e1381f2ec7.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_DISTINCT", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/60e597e1381f2ec7.sql b/tests/ast_json_fixtures/shapes/60e597e1381f2ec7.sql new file mode 100644 index 000000000000..c9c77960fbde --- /dev/null +++ b/tests/ast_json_fixtures/shapes/60e597e1381f2ec7.sql @@ -0,0 +1,2 @@ +EXPLAIN SYNTAX +(((((((((((((((SELECT 1 UNION DISTINCT SELECT 1))) UNION DISTINCT SELECT 1)))) UNION ALL SELECT 1)))))))) diff --git a/tests/ast_json_fixtures/shapes/60f739d92d35e12d.json b/tests/ast_json_fixtures/shapes/60f739d92d35e12d.json new file mode 100644 index 000000000000..93b68cb7c0c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/60f739d92d35e12d.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_00184" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "distributed_group_by_no_merge": "2" + } + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/60f739d92d35e12d.sql b/tests/ast_json_fixtures/shapes/60f739d92d35e12d.sql new file mode 100644 index 000000000000..109893e180b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/60f739d92d35e12d.sql @@ -0,0 +1 @@ +SELECT number FROM remote('127.0.0.{2,3}', currentDatabase(), data_00184) LIMIT 1 BY number LIMIT 1 SETTINGS distributed_group_by_no_merge=2 diff --git a/tests/ast_json_fixtures/shapes/61139ecb3d3303fc.json b/tests/ast_json_fixtures/shapes/61139ecb3d3303fc.json new file mode 100644 index 000000000000..768a943c9ac2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61139ecb3d3303fc.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "l", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Identifier", + "name": "l" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "l" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "s" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/61139ecb3d3303fc.sql b/tests/ast_json_fixtures/shapes/61139ecb3d3303fc.sql new file mode 100644 index 000000000000..b61c1fb83ed6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61139ecb3d3303fc.sql @@ -0,0 +1 @@ +create table t (s UInt16, l UInt16, projection p (select s, l order by l)) engine MergeTree order by s diff --git a/tests/ast_json_fixtures/shapes/61221062bc70c250.json b/tests/ast_json_fixtures/shapes/61221062bc70c250.json new file mode 100644 index 000000000000..9b6617f97266 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61221062bc70c250.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p7_01295", + "database": "db", + "table": "table" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r1_01295", "u1_01295"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/61221062bc70c250.sql b/tests/ast_json_fixtures/shapes/61221062bc70c250.sql new file mode 100644 index 000000000000..bcf043aceda6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61221062bc70c250.sql @@ -0,0 +1 @@ +CREATE POLICY p7_01295 ON db.table TO ALL EXCEPT r1_01295, u1_01295 diff --git a/tests/ast_json_fixtures/shapes/612ab0d5f4072133.json b/tests/ast_json_fixtures/shapes/612ab0d5f4072133.json new file mode 100644 index 000000000000..1c302fd00ae6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/612ab0d5f4072133.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/612ab0d5f4072133.sql b/tests/ast_json_fixtures/shapes/612ab0d5f4072133.sql new file mode 100644 index 000000000000..a3ff481a2721 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/612ab0d5f4072133.sql @@ -0,0 +1 @@ +SELECT * FROM t ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/613c8dc49dd82363.json b/tests/ast_json_fixtures/shapes/613c8dc49dd82363.json new file mode 100644 index 000000000000..c0abb4eace3d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/613c8dc49dd82363.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "--- CUBE ---" + } + ] + } + ], + "format": "TSVRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/613c8dc49dd82363.sql b/tests/ast_json_fixtures/shapes/613c8dc49dd82363.sql new file mode 100644 index 000000000000..9133a94e2505 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/613c8dc49dd82363.sql @@ -0,0 +1 @@ +select '--- CUBE ---' format TSVRaw diff --git a/tests/ast_json_fixtures/shapes/61685348900b44b0.json b/tests/ast_json_fixtures/shapes/61685348900b44b0.json new file mode 100644 index 000000000000..88afbfb79970 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61685348900b44b0.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab2" + }, + "as_table": "tab1" + } +} diff --git a/tests/ast_json_fixtures/shapes/61685348900b44b0.sql b/tests/ast_json_fixtures/shapes/61685348900b44b0.sql new file mode 100644 index 000000000000..5579c79af52d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61685348900b44b0.sql @@ -0,0 +1 @@ +CREATE TABLE tab2 AS tab1 diff --git a/tests/ast_json_fixtures/shapes/617fd0f6b23667f0.json b/tests/ast_json_fixtures/shapes/617fd0f6b23667f0.json new file mode 100644 index 000000000000..4877a68d8213 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/617fd0f6b23667f0.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "from": { + "type": "Identifier", + "name": "shard_0" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/617fd0f6b23667f0.sql b/tests/ast_json_fixtures/shapes/617fd0f6b23667f0.sql new file mode 100644 index 000000000000..13da28327a18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/617fd0f6b23667f0.sql @@ -0,0 +1 @@ +SHOW TABLES FROM shard_0 diff --git a/tests/ast_json_fixtures/shapes/618228cd77eb673d.json b/tests/ast_json_fixtures/shapes/618228cd77eb673d.json new file mode 100644 index 000000000000..c33c4540b5d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/618228cd77eb673d.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/618228cd77eb673d.sql b/tests/ast_json_fixtures/shapes/618228cd77eb673d.sql new file mode 100644 index 000000000000..3fee51042b28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/618228cd77eb673d.sql @@ -0,0 +1 @@ +SELECT number, count() FROM numbers(5) GROUP BY number WITH TOTALS ORDER BY number FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/618366a199e4663d.json b/tests/ast_json_fixtures/shapes/618366a199e4663d.json new file mode 100644 index 000000000000..ee77220ab75d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/618366a199e4663d.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lc" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/618366a199e4663d.sql b/tests/ast_json_fixtures/shapes/618366a199e4663d.sql new file mode 100644 index 000000000000..95f48482e921 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/618366a199e4663d.sql @@ -0,0 +1 @@ +SELECT a, count(a) FROM lc GROUP BY a WITH ROLLUP ORDER BY a diff --git a/tests/ast_json_fixtures/shapes/619e1bfabcee8ee2.json b/tests/ast_json_fixtures/shapes/619e1bfabcee8ee2.json new file mode 100644 index 000000000000..3bd7058d840c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/619e1bfabcee8ee2.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "test_01457" + }, + "table": { + "type": "Identifier", + "name": "tf_remote" + }, + "as_table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "tmp" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/619e1bfabcee8ee2.sql b/tests/ast_json_fixtures/shapes/619e1bfabcee8ee2.sql new file mode 100644 index 000000000000..7a607897ac1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/619e1bfabcee8ee2.sql @@ -0,0 +1 @@ +CREATE TABLE test_01457.tf_remote AS remote('localhost', currentDatabase(), 'tmp') diff --git a/tests/ast_json_fixtures/shapes/61b7c87f001f9be6.json b/tests/ast_json_fixtures/shapes/61b7c87f001f9be6.json new file mode 100644 index 000000000000..63f23c87bc44 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61b7c87f001f9be6.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "$4@^7" + } +} diff --git a/tests/ast_json_fixtures/shapes/61b7c87f001f9be6.sql b/tests/ast_json_fixtures/shapes/61b7c87f001f9be6.sql new file mode 100644 index 000000000000..8435680a4893 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61b7c87f001f9be6.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM `$4@^7` diff --git a/tests/ast_json_fixtures/shapes/61b86c4133f32353.json b/tests/ast_json_fixtures/shapes/61b86c4133f32353.json new file mode 100644 index 000000000000..7ff838e1fb1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61b86c4133f32353.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01756_str" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01756_str" + }, + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + ] + } + }, + "as_table": "data_01756_str" + } +} diff --git a/tests/ast_json_fixtures/shapes/61b86c4133f32353.sql b/tests/ast_json_fixtures/shapes/61b86c4133f32353.sql new file mode 100644 index 000000000000..3be148631124 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61b86c4133f32353.sql @@ -0,0 +1 @@ +create table dist_01756_str as data_01756_str engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01756_str, cityHash64(key)) diff --git a/tests/ast_json_fixtures/shapes/61c47a1f2e722e08.json b/tests/ast_json_fixtures/shapes/61c47a1f2e722e08.json new file mode 100644 index 000000000000..533d931eb775 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61c47a1f2e722e08.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "alter": true, + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p1_01295", + "database": "db", + "table": "table" + } + ] + }, + "is_restrictive": true, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/61c47a1f2e722e08.sql b/tests/ast_json_fixtures/shapes/61c47a1f2e722e08.sql new file mode 100644 index 000000000000..2f04bf2961a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61c47a1f2e722e08.sql @@ -0,0 +1 @@ +ALTER ROW POLICY p1_01295 ON db.table FOR SELECT USING 0 AS RESTRICTIVE diff --git a/tests/ast_json_fixtures/shapes/61c93a5ae40d948b.json b/tests/ast_json_fixtures/shapes/61c93a5ae40d948b.json new file mode 100644 index 000000000000..0d23970a330e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61c93a5ae40d948b.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table_csv_01375" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "File", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "CSVWithNames" + } + ] + } + }, + "as_table": "tmp_01375" + } +} diff --git a/tests/ast_json_fixtures/shapes/61c93a5ae40d948b.sql b/tests/ast_json_fixtures/shapes/61c93a5ae40d948b.sql new file mode 100644 index 000000000000..bff8ad0d9136 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61c93a5ae40d948b.sql @@ -0,0 +1 @@ +CREATE TABLE table_csv_01375 AS tmp_01375 ENGINE = File(CSVWithNames) diff --git a/tests/ast_json_fixtures/shapes/61cae38a8a90c4c1.json b/tests/ast_json_fixtures/shapes/61cae38a8a90c4c1.json new file mode 100644 index 000000000000..11f463b43651 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61cae38a8a90c4c1.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "settings": { + "type": "Settings", + "changes": { + "extremes": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/61cae38a8a90c4c1.sql b/tests/ast_json_fixtures/shapes/61cae38a8a90c4c1.sql new file mode 100644 index 000000000000..5c5140036ae2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61cae38a8a90c4c1.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number settings extremes=1 diff --git a/tests/ast_json_fixtures/shapes/61cfd11577675699.json b/tests/ast_json_fixtures/shapes/61cfd11577675699.json new file mode 100644 index 000000000000..f9183973f7dc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61cfd11577675699.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mt2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "f1" + } + }, + "as_table": "mt1" + } +} diff --git a/tests/ast_json_fixtures/shapes/61cfd11577675699.sql b/tests/ast_json_fixtures/shapes/61cfd11577675699.sql new file mode 100644 index 000000000000..a7953d022a2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61cfd11577675699.sql @@ -0,0 +1 @@ +create table mt2 as mt1 engine = MergeTree() order by f1 diff --git a/tests/ast_json_fixtures/shapes/61d938599d2f639c.json b/tests/ast_json_fixtures/shapes/61d938599d2f639c.json new file mode 100644 index 000000000000..77074e2d74f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61d938599d2f639c.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "CreateWorkloadQuery", + "workload_name": { + "type": "Identifier", + "name": "development" + }, + "workload_parent": { + "type": "Identifier", + "name": "all" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/61d938599d2f639c.sql b/tests/ast_json_fixtures/shapes/61d938599d2f639c.sql new file mode 100644 index 000000000000..b555670c1371 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/61d938599d2f639c.sql @@ -0,0 +1 @@ +CREATE WORKLOAD development IN all diff --git a/tests/ast_json_fixtures/shapes/6204cee9d9e52bc4.json b/tests/ast_json_fixtures/shapes/6204cee9d9e52bc4.json new file mode 100644 index 000000000000..996f32be6540 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6204cee9d9e52bc4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u1_01292@192.168.%.%", "u2_01292@192.168.%.%"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6204cee9d9e52bc4.sql b/tests/ast_json_fixtures/shapes/6204cee9d9e52bc4.sql new file mode 100644 index 000000000000..d413a45cca21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6204cee9d9e52bc4.sql @@ -0,0 +1 @@ +DROP USER u1_01292, u1_01292@'192.168.%.%', u2_01292@'192.168.%.%' diff --git a/tests/ast_json_fixtures/shapes/6214e8a5bd464d84.json b/tests/ast_json_fixtures/shapes/6214e8a5bd464d84.json new file mode 100644 index 000000000000..60f6a27f9f82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6214e8a5bd464d84.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p2_01295", + "database": "db", + "table": "table" + } + ] + }, + "is_restrictive": true, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "currentUser", + "arguments": [] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6214e8a5bd464d84.sql b/tests/ast_json_fixtures/shapes/6214e8a5bd464d84.sql new file mode 100644 index 000000000000..32c676f8d3ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6214e8a5bd464d84.sql @@ -0,0 +1 @@ +CREATE ROW POLICY p2_01295 ON db.table USING id=currentUser() AS RESTRICTIVE diff --git a/tests/ast_json_fixtures/shapes/6224d13e11c07289.json b/tests/ast_json_fixtures/shapes/6224d13e11c07289.json new file mode 100644 index 000000000000..a0b391bc4b48 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6224d13e11c07289.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "add_table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "value3", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + }, + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "if_not_exists": true, + "column_declaration": { + "type": "ColumnDeclaration", + "name": "value3", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6224d13e11c07289.sql b/tests/ast_json_fixtures/shapes/6224d13e11c07289.sql new file mode 100644 index 000000000000..7dc18f13b359 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6224d13e11c07289.sql @@ -0,0 +1 @@ +ALTER TABLE add_table ADD COLUMN value3 UInt64, ADD COLUMN IF NOT EXISTS value3 UInt32 diff --git a/tests/ast_json_fixtures/shapes/6258ae097ee1c613.json b/tests/ast_json_fixtures/shapes/6258ae097ee1c613.json new file mode 100644 index 000000000000..bf2cb277f629 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6258ae097ee1c613.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "INTERSECT ALL", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "EXCEPT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6258ae097ee1c613.sql b/tests/ast_json_fixtures/shapes/6258ae097ee1c613.sql new file mode 100644 index 000000000000..4e9b6d72bd41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6258ae097ee1c613.sql @@ -0,0 +1 @@ +select 1 intersect (select 1 except select 2) diff --git a/tests/ast_json_fixtures/shapes/6266f6823798a521.json b/tests/ast_json_fixtures/shapes/6266f6823798a521.json new file mode 100644 index 000000000000..6ca2f40edd98 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6266f6823798a521.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/6266f6823798a521.sql b/tests/ast_json_fixtures/shapes/6266f6823798a521.sql new file mode 100644 index 000000000000..e7abe7b61712 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6266f6823798a521.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/6270ef5cc1853f4d.json b/tests/ast_json_fixtures/shapes/6270ef5cc1853f4d.json new file mode 100644 index 000000000000..4ab541ce7b92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6270ef5cc1853f4d.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "database": { + "type": "Identifier", + "name": "02028_db" + }, + "cluster": "test_shard_localhost" + } +} diff --git a/tests/ast_json_fixtures/shapes/6270ef5cc1853f4d.sql b/tests/ast_json_fixtures/shapes/6270ef5cc1853f4d.sql new file mode 100644 index 000000000000..58a509f74fce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6270ef5cc1853f4d.sql @@ -0,0 +1 @@ +DROP DATABASE 02028_db ON CLUSTER test_shard_localhost diff --git a/tests/ast_json_fixtures/shapes/628de5eb77e19508.json b/tests/ast_json_fixtures/shapes/628de5eb77e19508.json new file mode 100644 index 000000000000..84f1f852f350 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/628de5eb77e19508.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "KillQueryQuery", + "kill_type": "MUTATION", + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "mutation_table" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/628de5eb77e19508.sql b/tests/ast_json_fixtures/shapes/628de5eb77e19508.sql new file mode 100644 index 000000000000..702fdb994760 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/628de5eb77e19508.sql @@ -0,0 +1 @@ +KILL MUTATION where table = 'mutation_table' and database = currentDatabase() diff --git a/tests/ast_json_fixtures/shapes/62aea05f1cab40c2.json b/tests/ast_json_fixtures/shapes/62aea05f1cab40c2.json new file mode 100644 index 000000000000..f74171eda214 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/62aea05f1cab40c2.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "b", + "name": "identity", + "arguments": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/62aea05f1cab40c2.sql b/tests/ast_json_fixtures/shapes/62aea05f1cab40c2.sql new file mode 100644 index 000000000000..dc994acb31d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/62aea05f1cab40c2.sql @@ -0,0 +1 @@ +SELECT identity(1 AS a) AS b, a, b diff --git a/tests/ast_json_fixtures/shapes/62cc39effd21d357.json b/tests/ast_json_fixtures/shapes/62cc39effd21d357.json new file mode 100644 index 000000000000..d0bce24b14e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/62cc39effd21d357.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropResourceQuery", + "resource_name": "03232_write", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/62cc39effd21d357.sql b/tests/ast_json_fixtures/shapes/62cc39effd21d357.sql new file mode 100644 index 000000000000..3f86450dd794 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/62cc39effd21d357.sql @@ -0,0 +1 @@ +drop resource if exists 03232_write diff --git a/tests/ast_json_fixtures/shapes/6302fe20693b4624.json b/tests/ast_json_fixtures/shapes/6302fe20693b4624.json new file mode 100644 index 000000000000..2c83b7387d37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6302fe20693b4624.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ], + "format": "LineAsString" + } +} diff --git a/tests/ast_json_fixtures/shapes/6302fe20693b4624.sql b/tests/ast_json_fixtures/shapes/6302fe20693b4624.sql new file mode 100644 index 000000000000..d44da4ede3c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6302fe20693b4624.sql @@ -0,0 +1 @@ +select '' format LineAsString diff --git a/tests/ast_json_fixtures/shapes/6305c19b912b8b62.json b/tests/ast_json_fixtures/shapes/6305c19b912b8b62.json new file mode 100644 index 000000000000..d70b450d45c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6305c19b912b8b62.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01293", "r2_01293@%.myhost.com"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6305c19b912b8b62.sql b/tests/ast_json_fixtures/shapes/6305c19b912b8b62.sql new file mode 100644 index 000000000000..04c895268e14 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6305c19b912b8b62.sql @@ -0,0 +1 @@ +DROP ROLE r1_01293@'%', 'r2_01293@%.myhost.com' diff --git a/tests/ast_json_fixtures/shapes/630a9b04fac54771.json b/tests/ast_json_fixtures/shapes/630a9b04fac54771.json new file mode 100644 index 000000000000..16178f1dfd4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/630a9b04fac54771.json @@ -0,0 +1,249 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "38" + }, + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "position", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "position", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "ca" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "NULLIF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "ca" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "NULLIF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "set_index_not__fuzz_0" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "NULLIF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/630a9b04fac54771.sql b/tests/ast_json_fixtures/shapes/630a9b04fac54771.sql new file mode 100644 index 000000000000..a7241cf38ba9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/630a9b04fac54771.sql @@ -0,0 +1,9 @@ +SELECT + 38, + concat(position(concat(concat(position(concat(toUInt256(3)), 'ca', 2), 3), NULLIF(1, materialize(toLowCardinality(1)))), toLowCardinality(toNullable('ca'))), concat(NULLIF(1, 1), concat(3), toNullable(3))) +FROM set_index_not__fuzz_0 +GROUP BY + toNullable(3), + concat(concat(NULLIF(1, 1), toNullable(toNullable(3)))) +WITH ROLLUP +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/63730a27a715cbab.json b/tests/ast_json_fixtures/shapes/63730a27a715cbab.json new file mode 100644 index 000000000000..4368c60aefff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/63730a27a715cbab.json @@ -0,0 +1,127 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "MutationSomePartColumns" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "MutatedUncompressedBytes" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "part_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "t_apply_patches" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "MutatePart" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/63730a27a715cbab.sql b/tests/ast_json_fixtures/shapes/63730a27a715cbab.sql new file mode 100644 index 000000000000..5d462d882aec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/63730a27a715cbab.sql @@ -0,0 +1,5 @@ +SELECT + ProfileEvents['MutationSomePartColumns'], + ProfileEvents['MutatedUncompressedBytes'] +FROM system.part_log WHERE database = currentDatabase() AND table = 't_apply_patches' AND event_type = 'MutatePart' +ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/63845381f4ca68cb.json b/tests/ast_json_fixtures/shapes/63845381f4ca68cb.json new file mode 100644 index 000000000000..aa34321386f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/63845381f4ca68cb.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "(forward, head) id < 10" + }, + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "next_node", + "name": "sequenceNextNode", + "arguments": [ + { + "type": "Identifier", + "name": "dt" + }, + { + "type": "Identifier", + "name": "action" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "String", + "value": "forward" + }, + { + "type": "Literal", + "value_type": "String", + "value": "head" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_sequenceNextNode" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/63845381f4ca68cb.sql b/tests/ast_json_fixtures/shapes/63845381f4ca68cb.sql new file mode 100644 index 000000000000..2b7281fe9f21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/63845381f4ca68cb.sql @@ -0,0 +1 @@ +SELECT '(forward, head) id < 10', id, sequenceNextNode('forward', 'head')(dt, action, 1) AS next_node FROM test_sequenceNextNode WHERE id < 10 GROUP BY id ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/638b19fabd3b6991.json b/tests/ast_json_fixtures/shapes/638b19fabd3b6991.json new file mode 100644 index 000000000000..36491851445c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/638b19fabd3b6991.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["sqllt_quota"], + "key_type": "USER_NAME", + "roles": { + "type": "RolesOrUsersSet", + "names": ["sqllt_role"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/638b19fabd3b6991.sql b/tests/ast_json_fixtures/shapes/638b19fabd3b6991.sql new file mode 100644 index 000000000000..804a31a8b179 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/638b19fabd3b6991.sql @@ -0,0 +1 @@ +CREATE QUOTA sqllt_quota KEYED BY user_name TO sqllt_role diff --git a/tests/ast_json_fixtures/shapes/63a62dbbc2718402.json b/tests/ast_json_fixtures/shapes/63a62dbbc2718402.json new file mode 100644 index 000000000000..74d278abddd7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/63a62dbbc2718402.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "val" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t", + "name": "03040_test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "val" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/63a62dbbc2718402.sql b/tests/ast_json_fixtures/shapes/63a62dbbc2718402.sql new file mode 100644 index 000000000000..8e9a93d97081 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/63a62dbbc2718402.sql @@ -0,0 +1 @@ +SELECT val FROM 03040_test t GROUP BY val diff --git a/tests/ast_json_fixtures/shapes/63d72fc6e2d1fe9c.json b/tests/ast_json_fixtures/shapes/63d72fc6e2d1fe9c.json new file mode 100644 index 000000000000..341c87173487 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/63d72fc6e2d1fe9c.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Function", + "alias": "a", + "name": "parseDateTime64BestEffortUS", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "s", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "01-02-1930 12:00:00" + }, + { + "value_type": "String", + "value": "12.02.1930 12:00:00" + }, + { + "value_type": "String", + "value": "13\/02\/1930 12:00:00" + }, + { + "value_type": "String", + "value": "02\/25\/1930 12:00:00" + } + ] + } + ] + } + ] + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettySpaceNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/63d72fc6e2d1fe9c.sql b/tests/ast_json_fixtures/shapes/63d72fc6e2d1fe9c.sql new file mode 100644 index 000000000000..023caf12e593 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/63d72fc6e2d1fe9c.sql @@ -0,0 +1,12 @@ +SELECT + s, + parseDateTime64BestEffortUS(s,3,'UTC') AS a +FROM +( + SELECT arrayJoin([ +'01-02-1930 12:00:00', +'12.02.1930 12:00:00', +'13/02/1930 12:00:00', +'02/25/1930 12:00:00' +]) AS s) +FORMAT PrettySpaceNoEscapes diff --git a/tests/ast_json_fixtures/shapes/63e62382c62e59c9.json b/tests/ast_json_fixtures/shapes/63e62382c62e59c9.json new file mode 100644 index 000000000000..b23fdc44797a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/63e62382c62e59c9.json @@ -0,0 +1,216 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "predicate", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Function", + "name": "minIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "maxIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "sumIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "avgIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "avgWeightedIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "groupBitOrIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "groupBitAndIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "groupBitXorIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "CounterID" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [] + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/63e62382c62e59c9.sql b/tests/ast_json_fixtures/shapes/63e62382c62e59c9.sql new file mode 100644 index 000000000000..259b812a56c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/63e62382c62e59c9.sql @@ -0,0 +1,14 @@ +WITH (WatchID % 2 == 0) AS predicate +SELECT + CounterID, + minIf(WatchID,predicate), + maxIf(WatchID, predicate), + sumIf(WatchID, predicate), + avgIf(WatchID, predicate), + avgWeightedIf(WatchID, CounterID, predicate), + countIf(WatchID, predicate), + groupBitOrIf(WatchID, predicate), + groupBitAndIf(WatchID, predicate), + groupBitXorIf(WatchID, predicate) +FROM test.hits +GROUP BY CounterID ORDER BY count() DESC LIMIT 20 diff --git a/tests/ast_json_fixtures/shapes/640ec2cb82fb28eb.json b/tests/ast_json_fixtures/shapes/640ec2cb82fb28eb.json new file mode 100644 index 000000000000..c3f2c119897d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/640ec2cb82fb28eb.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "PLAINTEXT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwe123" + } + ] + } + ], + "replace_authentication_methods": true, + "hosts": { + "local_host": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/640ec2cb82fb28eb.sql b/tests/ast_json_fixtures/shapes/640ec2cb82fb28eb.sql new file mode 100644 index 000000000000..0b61812bb66c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/640ec2cb82fb28eb.sql @@ -0,0 +1 @@ +CREATE USER u1_01292 IDENTIFIED WITH plaintext_password BY 'qwe123' HOST LOCAL diff --git a/tests/ast_json_fixtures/shapes/640ee70697674bf2.json b/tests/ast_json_fixtures/shapes/640ee70697674bf2.json new file mode 100644 index 000000000000..abdbf4e8b67f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/640ee70697674bf2.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "PREWARM MARK CACHE", + "table": { + "type": "Identifier", + "name": "t_prewarm_cache" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/640ee70697674bf2.sql b/tests/ast_json_fixtures/shapes/640ee70697674bf2.sql new file mode 100644 index 000000000000..c453f7785576 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/640ee70697674bf2.sql @@ -0,0 +1 @@ +SYSTEM PREWARM MARK CACHE t_prewarm_cache diff --git a/tests/ast_json_fixtures/shapes/642ec1719119c618.json b/tests/ast_json_fixtures/shapes/642ec1719119c618.json new file mode 100644 index 000000000000..c7126a011312 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/642ec1719119c618.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "RESET_SETTING", + "settings_resets": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "materialize_skip_indexes_on_merge" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/642ec1719119c618.sql b/tests/ast_json_fixtures/shapes/642ec1719119c618.sql new file mode 100644 index 000000000000..e939d8b9836f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/642ec1719119c618.sql @@ -0,0 +1 @@ +ALTER TABLE tab RESET SETTING materialize_skip_indexes_on_merge diff --git a/tests/ast_json_fixtures/shapes/64317f7fdb010493.json b/tests/ast_json_fixtures/shapes/64317f7fdb010493.json new file mode 100644 index 000000000000..1992369bf8e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/64317f7fdb010493.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01293", "r2_01293", "r3_01293", "r4_01293", "r5_01293", "r6_01293", "r7_01293", "r8_01293", "r9_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/64317f7fdb010493.sql b/tests/ast_json_fixtures/shapes/64317f7fdb010493.sql new file mode 100644 index 000000000000..685c63cb6272 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/64317f7fdb010493.sql @@ -0,0 +1 @@ +DROP ROLE r1_01293, r2_01293, r3_01293, r4_01293, r5_01293, r6_01293, r7_01293, r8_01293, r9_01293 diff --git a/tests/ast_json_fixtures/shapes/643bf24a923ddaa1.json b/tests/ast_json_fixtures/shapes/643bf24a923ddaa1.json new file mode 100644 index 000000000000..b31fda46bac8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/643bf24a923ddaa1.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "9223372036854775806" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03031_test" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + } + ] + }, + "where": { + "type": "Literal", + "value_type": "Float64", + "value": 0.0001 + }, + "group_by": [ + { + "type": "Literal", + "value_type": "String", + "value": "0.03" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_primary_key": "1", + "force_data_skipping_indices": "value_1_idx, value_2_idx", + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/643bf24a923ddaa1.sql b/tests/ast_json_fixtures/shapes/643bf24a923ddaa1.sql new file mode 100644 index 000000000000..8eb1b4d0b576 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/643bf24a923ddaa1.sql @@ -0,0 +1,8 @@ +SELECT + count('9223372036854775806'), + 7 +FROM 03031_test +PREWHERE (id = NULL) AND 1024 +WHERE 0.0001 +GROUP BY '0.03' +SETTINGS force_primary_key = 1, force_data_skipping_indices = 'value_1_idx, value_2_idx', enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/644b88c6025b8cb5.json b/tests/ast_json_fixtures/shapes/644b88c6025b8cb5.json new file mode 100644 index 000000000000..1d091d57498d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/644b88c6025b8cb5.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "like": "TeS%", + "not_like": true, + "case_insensitive_like": true + } +} diff --git a/tests/ast_json_fixtures/shapes/644b88c6025b8cb5.sql b/tests/ast_json_fixtures/shapes/644b88c6025b8cb5.sql new file mode 100644 index 000000000000..d653006702fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/644b88c6025b8cb5.sql @@ -0,0 +1 @@ +SHOW TABLES NOT ILIKE 'TeS%' diff --git a/tests/ast_json_fixtures/shapes/6474dcb709513d0d.json b/tests/ast_json_fixtures/shapes/6474dcb709513d0d.json new file mode 100644 index 000000000000..9683a587a041 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6474dcb709513d0d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "03215_udf_with_union", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/6474dcb709513d0d.sql b/tests/ast_json_fixtures/shapes/6474dcb709513d0d.sql new file mode 100644 index 000000000000..710df78351a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6474dcb709513d0d.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 03215_udf_with_union diff --git a/tests/ast_json_fixtures/shapes/648754d23f1592c9.json b/tests/ast_json_fixtures/shapes/648754d23f1592c9.json new file mode 100644 index 000000000000..320a5f69fede --- /dev/null +++ b/tests/ast_json_fixtures/shapes/648754d23f1592c9.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Identifier", + "name": "lc" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "mv" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Identifier", + "name": "lc" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/648754d23f1592c9.sql b/tests/ast_json_fixtures/shapes/648754d23f1592c9.sql new file mode 100644 index 000000000000..aa06abd0e057 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/648754d23f1592c9.sql @@ -0,0 +1 @@ +select s, lc from mv where not ignore(lc) settings enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/64a46cc26f2a7953.json b/tests/ast_json_fixtures/shapes/64a46cc26f2a7953.json new file mode 100644 index 000000000000..0a6f00b1d0d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/64a46cc26f2a7953.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q16_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "EXECUTION_TIME": "1500000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/64a46cc26f2a7953.sql b/tests/ast_json_fixtures/shapes/64a46cc26f2a7953.sql new file mode 100644 index 000000000000..2a9ab0314734 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/64a46cc26f2a7953.sql @@ -0,0 +1 @@ +CREATE QUOTA q16_01297 FOR INTERVAL 1 MINUTE MAX execution_time = 1.5 diff --git a/tests/ast_json_fixtures/shapes/64d94793c195f909.json b/tests/ast_json_fixtures/shapes/64d94793c195f909.json new file mode 100644 index 000000000000..c84f2ffc2143 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/64d94793c195f909.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-02-29" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Date" + } + ] + } + ] + } + ], + "format": "PrettyMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/64d94793c195f909.sql b/tests/ast_json_fixtures/shapes/64d94793c195f909.sql new file mode 100644 index 000000000000..4bd2d0d8e505 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/64d94793c195f909.sql @@ -0,0 +1 @@ +SELECT '2024-02-29'::Date FORMAT PrettyMonoBlock diff --git a/tests/ast_json_fixtures/shapes/64e257e43eefd2b4.json b/tests/ast_json_fixtures/shapes/64e257e43eefd2b4.json new file mode 100644 index 000000000000..50eef0d6cef7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/64e257e43eefd2b4.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "value", + "name": "id" + } + ], + "select": [ + { + "type": "Identifier", + "name": "value" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/64e257e43eefd2b4.sql b/tests/ast_json_fixtures/shapes/64e257e43eefd2b4.sql new file mode 100644 index 000000000000..51faa03041df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/64e257e43eefd2b4.sql @@ -0,0 +1 @@ +WITH id AS value SELECT value FROM test_table diff --git a/tests/ast_json_fixtures/shapes/64f6e1b398e3ab61.json b/tests/ast_json_fixtures/shapes/64f6e1b398e3ab61.json new file mode 100644 index 000000000000..1e214eed69f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/64f6e1b398e3ab61.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "MOD", + "name": "DIV" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "DIV", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + } + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/64f6e1b398e3ab61.sql b/tests/ast_json_fixtures/shapes/64f6e1b398e3ab61.sql new file mode 100644 index 000000000000..6d14d1585525 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/64f6e1b398e3ab61.sql @@ -0,0 +1 @@ +SELECT DIV `MOD` FROM (SELECT 1 `DIV`) FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/650a2dbe368de490.json b/tests/ast_json_fixtures/shapes/650a2dbe368de490.json new file mode 100644 index 000000000000..d8cbed605e91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/650a2dbe368de490.json @@ -0,0 +1,340 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "q", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "department__fuzz_0" + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "x", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "department__fuzz_0" + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "q" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "least", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "world" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": null + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "58" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "sipHash128", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "world" + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Function", + "name": "greatest", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "q" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/650a2dbe368de490.sql b/tests/ast_json_fixtures/shapes/650a2dbe368de490.sql new file mode 100644 index 000000000000..5a08953a0239 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/650a2dbe368de490.sql @@ -0,0 +1,27 @@ +WITH RECURSIVE q AS +( + SELECT * + FROM department__fuzz_0 + UNION ALL + ( + WITH RECURSIVE x AS + ( + SELECT * + FROM department__fuzz_0 + UNION ALL + ( + SELECT * + FROM q + WHERE least(toFixedString('world', 5), 5, 5, inf, 58, nan, NULL) + UNION ALL + SELECT * + FROM x + WHERE sipHash128(toLowCardinality('world'), toLowCardinality(materialize(5)), toUInt128(greatest(1, nan, NULL), toUInt128(5)), toUInt128(5), 5, toUInt128(5), materialize(5)) + ) + ) + SELECT * + FROM x + ) +) +SELECT 1 +FROM q diff --git a/tests/ast_json_fixtures/shapes/651deca059d752b0.json b/tests/ast_json_fixtures/shapes/651deca059d752b0.json new file mode 100644 index 000000000000..df7853d6b252 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/651deca059d752b0.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Identifier", + "name": "_part" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/651deca059d752b0.sql b/tests/ast_json_fixtures/shapes/651deca059d752b0.sql new file mode 100644 index 000000000000..88774cf01bf8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/651deca059d752b0.sql @@ -0,0 +1 @@ +SELECT c0, _part FROM t ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/6534701a15eb3052.json b/tests/ast_json_fixtures/shapes/6534701a15eb3052.json new file mode 100644 index 000000000000..a980cfd7924d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6534701a15eb3052.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pk_order" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6534701a15eb3052.sql b/tests/ast_json_fixtures/shapes/6534701a15eb3052.sql new file mode 100644 index 000000000000..07fc3697392b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6534701a15eb3052.sql @@ -0,0 +1 @@ +SELECT toString(d), avg(a) FROM pk_order GROUP BY toString(d) ORDER BY toString(d) LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/655a98cacd03a719.json b/tests/ast_json_fixtures/shapes/655a98cacd03a719.json new file mode 100644 index 000000000000..8d62fba9d00e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/655a98cacd03a719.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "COUNT", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2020-01-01" + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "11" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/655a98cacd03a719.sql b/tests/ast_json_fixtures/shapes/655a98cacd03a719.sql new file mode 100644 index 000000000000..99d0b70be196 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/655a98cacd03a719.sql @@ -0,0 +1 @@ +SELECT COUNT() = 10 FROM test_table WHERE day = '2020-01-01' UNION ALL SELECT 1 FROM numbers(1) SETTINGS max_rows_to_read = 11 diff --git a/tests/ast_json_fixtures/shapes/657328eebfd2b1cb.json b/tests/ast_json_fixtures/shapes/657328eebfd2b1cb.json new file mode 100644 index 000000000000..05819776b4c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/657328eebfd2b1cb.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u3_01292" + } + ] + }, + "add_hosts": { + "names": ["myhost.com"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/657328eebfd2b1cb.sql b/tests/ast_json_fixtures/shapes/657328eebfd2b1cb.sql new file mode 100644 index 000000000000..798bab38543f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/657328eebfd2b1cb.sql @@ -0,0 +1 @@ +ALTER USER u3_01292 ADD HOST NAME 'myhost.com' diff --git a/tests/ast_json_fixtures/shapes/6574ba8a19411a57.json b/tests/ast_json_fixtures/shapes/6574ba8a19411a57.json new file mode 100644 index 000000000000..37afadb9886c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6574ba8a19411a57.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u10_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6574ba8a19411a57.sql b/tests/ast_json_fixtures/shapes/6574ba8a19411a57.sql new file mode 100644 index 000000000000..45da0b72fbbc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6574ba8a19411a57.sql @@ -0,0 +1 @@ +SHOW CREATE USER u10_01292 diff --git a/tests/ast_json_fixtures/shapes/65cc78847d0d2c75.json b/tests/ast_json_fixtures/shapes/65cc78847d0d2c75.json new file mode 100644 index 000000000000..47433a66cbd7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/65cc78847d0d2c75.json @@ -0,0 +1,475 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "data", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "row_num", + "name": "number" + }, + { + "type": "Literal", + "alias": "top_ints", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "alias": "top_nulls", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "String", + "value": "Hello" + } + ] + }, + { + "type": "Literal", + "alias": "top_strs", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "Row1" + }, + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "alias": "ids", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "42" + }, + { + "value_type": "UInt64", + "value": "7" + } + ] + }, + { + "type": "Literal", + "alias": "names", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "ClickHouse" + }, + { + "value_type": "String", + "value": "Database" + } + ] + }, + { + "type": "Function", + "alias": "nesteds", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "String", + "value": "nested" + }, + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "String", + "value": "inner" + }, + { + "value_type": "UInt64", + "value": "123" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "arrs", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "100" + }, + { + "value_type": "String", + "value": "foo" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "200" + }, + { + "value_type": "String", + "value": "bar" + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "300" + }, + { + "value_type": "String", + "value": "baz" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "400" + }, + { + "value_type": "String", + "value": "qux" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "optionals", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "String", + "value": "Some text" + } + ] + }, + { + "type": "Literal", + "alias": "extra_ids", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "999" + }, + { + "value_type": "UInt64", + "value": "555" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "alias": "top_int", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "top_ints" + }, + { + "type": "Identifier", + "name": "row_num" + } + ] + }, + { + "type": "Function", + "alias": "top_null", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "top_nulls" + }, + { + "type": "Identifier", + "name": "row_num" + } + ] + }, + { + "type": "Function", + "alias": "top_str", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "top_strs" + }, + { + "type": "Identifier", + "name": "row_num" + } + ] + }, + { + "type": "Function", + "alias": "my_named_tuple", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ids" + }, + { + "type": "Identifier", + "name": "row_num" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "names" + }, + { + "type": "Identifier", + "name": "row_num" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "nesteds" + }, + { + "type": "Identifier", + "name": "row_num" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "arrs" + }, + { + "type": "Identifier", + "name": "row_num" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "optionals" + }, + { + "type": "Identifier", + "name": "row_num" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "extra_ids" + }, + { + "type": "Identifier", + "name": "row_num" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple(id UInt64, name String, nested Tuple(n_id UInt8, n_name String, n_null Nullable(Int32)), arr Array(Tuple(a UInt16, b String)), optional_field Nullable(String), extra_id UInt32)" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "top_int" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/65cc78847d0d2c75.sql b/tests/ast_json_fixtures/shapes/65cc78847d0d2c75.sql new file mode 100644 index 000000000000..7457f2446aa5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/65cc78847d0d2c75.sql @@ -0,0 +1,39 @@ +WITH data AS ( + SELECT + number AS row_num, + [1, 2] AS top_ints, + [NULL, 'Hello'] AS top_nulls, + ['Row1', NULL] AS top_strs, + [42, 7] AS ids, + ['ClickHouse', 'Database'] AS names, + [(1, 'nested', NULL), (2, 'inner', 123)] AS nesteds, + [ + [(100, 'foo'), (200, 'bar')], + [(300, 'baz'), (400, 'qux')] + ] AS arrs, + [NULL, 'Some text'] AS optionals, + [999, 555] AS extra_ids + FROM numbers(1, 2) +) +SELECT + top_ints[row_num] AS top_int, + top_nulls[row_num] AS top_null, + top_strs[row_num] AS top_str, + ( + ids[row_num], + names[row_num], + nesteds[row_num], + arrs[row_num], + optionals[row_num], + extra_ids[row_num] + )::Tuple( + id UInt64, + name String, + nested Tuple(n_id UInt8, n_name String, n_null Nullable(Int32)), + arr Array(Tuple(a UInt16, b String)), + optional_field Nullable(String), + extra_id UInt32 + ) AS my_named_tuple +FROM data +ORDER BY top_int +FORMAT PrettyMonoBlock diff --git a/tests/ast_json_fixtures/shapes/65d1fc596e9626d2.json b/tests/ast_json_fixtures/shapes/65d1fc596e9626d2.json new file mode 100644 index 000000000000..f7dffe9b95da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/65d1fc596e9626d2.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "text_log" + }, + { + "table": "query_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/65d1fc596e9626d2.sql b/tests/ast_json_fixtures/shapes/65d1fc596e9626d2.sql new file mode 100644 index 000000000000..0b61b3ba9be6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/65d1fc596e9626d2.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS text_log, query_log diff --git a/tests/ast_json_fixtures/shapes/65fe5dd20495890d.json b/tests/ast_json_fixtures/shapes/65fe5dd20495890d.json new file mode 100644 index 000000000000..4560662924db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/65fe5dd20495890d.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01223" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/65fe5dd20495890d.sql b/tests/ast_json_fixtures/shapes/65fe5dd20495890d.sql new file mode 100644 index 000000000000..c6d4fd3ee04a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/65fe5dd20495890d.sql @@ -0,0 +1 @@ +select * from dist_01223 group by key having key = 1 diff --git a/tests/ast_json_fixtures/shapes/6615a8f9f5cbedea.json b/tests/ast_json_fixtures/shapes/6615a8f9f5cbedea.json new file mode 100644 index 000000000000..45e70e12ef7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6615a8f9f5cbedea.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/6615a8f9f5cbedea.sql b/tests/ast_json_fixtures/shapes/6615a8f9f5cbedea.sql new file mode 100644 index 000000000000..10914beffd57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6615a8f9f5cbedea.sql @@ -0,0 +1 @@ +SELECT * FROM t FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/6630bc373b9bfa99.json b/tests/ast_json_fixtures/shapes/6630bc373b9bfa99.json new file mode 100644 index 000000000000..8b25bd2f5b30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6630bc373b9bfa99.json @@ -0,0 +1,127 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "NULL", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(Nothing)" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_02709__fuzz_23" + }, + "final": true + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t_02709__fuzz_23.sign", + "name_parts": ["t_02709__fuzz_23", "sign"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "1023" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "Float64", + "value": null + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "0" + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Array(Nullable(UInt8))" + } + ] + }, + "direction": "DESC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "receive_timeout": 10, + "receive_data_timeout_ms": "10000", + "use_hedged_requests": "0", + "allow_suspicious_low_cardinality_types": "1", + "max_parallel_replicas": "3", + "cluster_for_parallel_replicas": "test_cluster_one_shard_three_replicas_localhost", + "enable_parallel_replicas": "1", + "parallel_replicas_for_non_replicated_merge_tree": "1", + "log_queries": "1", + "table_function_remote_max_addresses": "200", + "enable_analyzer": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/6630bc373b9bfa99.sql b/tests/ast_json_fixtures/shapes/6630bc373b9bfa99.sql new file mode 100644 index 000000000000..566b37478f6d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6630bc373b9bfa99.sql @@ -0,0 +1,10 @@ +SELECT _CAST(NULL, 'Nullable(Nothing)') AS `NULL` +FROM t_02709__fuzz_23 FINAL +GROUP BY + t_02709__fuzz_23.sign, + '1023' +ORDER BY + nan DESC, + _CAST([0, NULL, NULL, NULL, NULL], 'Array(Nullable(UInt8))') DESC +FORMAT Null +SETTINGS receive_timeout = 10., receive_data_timeout_ms = 10000, use_hedged_requests = 0, allow_suspicious_low_cardinality_types = 1, max_parallel_replicas = 3, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', enable_parallel_replicas = 1, parallel_replicas_for_non_replicated_merge_tree = 1, log_queries = 1, table_function_remote_max_addresses = 200, enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/6634eccd42adf255.json b/tests/ast_json_fixtures/shapes/6634eccd42adf255.json new file mode 100644 index 000000000000..78235e7dbc05 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6634eccd42adf255.json @@ -0,0 +1,446 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "cutoff_time", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "now", + "arguments": [] + }, + { + "type": "Function", + "name": "toIntervalHour", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "WithElement", + "name": "query_ids", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "query_id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_time" + }, + { + "type": "Identifier", + "name": "cutoff_time" + } + ] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Identifier", + "name": "has_watch" + }, + { + "type": "Identifier", + "name": "op_num" + }, + { + "type": "Function", + "name": "replace", + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "serverUUID", + "arguments": [] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Identifier", + "name": "is_ephemeral" + }, + { + "type": "Identifier", + "name": "is_sequential" + }, + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "startsWith", + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\/clickhouse\/sessions" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "version" + } + ] + }, + { + "type": "Identifier", + "name": "requests_size" + }, + { + "type": "Identifier", + "name": "request_idx" + }, + { + "type": "Identifier", + "name": "error" + }, + { + "type": "Identifier", + "name": "watch_type" + }, + { + "type": "Identifier", + "name": "watch_state" + }, + { + "type": "Identifier", + "name": "path_created" + }, + { + "type": "Identifier", + "name": "stat_version" + }, + { + "type": "Identifier", + "name": "stat_cversion" + }, + { + "type": "Identifier", + "name": "stat_dataLength" + }, + { + "type": "Identifier", + "name": "stat_numChildren" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "zookeeper_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_time" + }, + { + "type": "Identifier", + "name": "cutoff_time" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "session_id" + }, + { + "type": "Identifier", + "name": "xid" + } + ] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "session_id" + }, + { + "type": "Identifier", + "name": "xid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "zookeeper_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_time" + }, + { + "type": "Identifier", + "name": "cutoff_time" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/test\/01158\/" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "\/rmt\/replicas\/1\/parts\/all_0_0_0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Identifier", + "name": "query_ids" + } + ] + } + ] + } + ] + } + } + ] + } + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "xid" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "type" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "request_idx" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6634eccd42adf255.sql b/tests/ast_json_fixtures/shapes/6634eccd42adf255.sql new file mode 100644 index 000000000000..bdf1b11d7d0c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6634eccd42adf255.sql @@ -0,0 +1,14 @@ +with now() - interval 1 hour as cutoff_time, +query_ids as +( + select query_id from system.query_log where current_database=currentDatabase() and event_time>=cutoff_time +) +select type, has_watch, op_num, replace(path, toString(serverUUID()), ''), is_ephemeral, is_sequential, if(startsWith(path, '/clickhouse/sessions'), 1, version), requests_size, request_idx, error, watch_type, + watch_state, path_created, stat_version, stat_cversion, stat_dataLength, stat_numChildren +from system.zookeeper_log +where event_time>=cutoff_time and (session_id, xid) in ( + select session_id, xid from system.zookeeper_log where event_time>=cutoff_time + and path='/test/01158/' || currentDatabase() || '/rmt/replicas/1/parts/all_0_0_0' + and (query_id='' or query_id in query_ids) +) +order by xid, type, request_idx diff --git a/tests/ast_json_fixtures/shapes/664ba8fa37007ff4.json b/tests/ast_json_fixtures/shapes/664ba8fa37007ff4.json new file mode 100644 index 000000000000..db58fa241665 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/664ba8fa37007ff4.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "editDistance" + }, + { + "type": "Identifier", + "name": "s1" + }, + { + "type": "Identifier", + "name": "s2" + }, + { + "type": "Function", + "name": "editDistance", + "arguments": [ + { + "type": "Identifier", + "name": "s1" + }, + { + "type": "Identifier", + "name": "s2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/664ba8fa37007ff4.sql b/tests/ast_json_fixtures/shapes/664ba8fa37007ff4.sql new file mode 100644 index 000000000000..1f6e36567977 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/664ba8fa37007ff4.sql @@ -0,0 +1 @@ +SELECT 'editDistance', s1, s2, editDistance(s1, s2) FROM t ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/66561cf927d52fd3.json b/tests/ast_json_fixtures/shapes/66561cf927d52fd3.json new file mode 100644 index 000000000000..7f7bedae230e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/66561cf927d52fd3.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "dictionary": true, + "elements": [ + { + "from_table": "test_dict_2", + "to_table": "test_dict" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/66561cf927d52fd3.sql b/tests/ast_json_fixtures/shapes/66561cf927d52fd3.sql new file mode 100644 index 000000000000..4dee2e2e5543 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/66561cf927d52fd3.sql @@ -0,0 +1 @@ +RENAME DICTIONARY test_dict_2 to test_dict diff --git a/tests/ast_json_fixtures/shapes/665b7476c8cc036f.json b/tests/ast_json_fixtures/shapes/665b7476c8cc036f.json new file mode 100644 index 000000000000..dc6bdf3b4018 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/665b7476c8cc036f.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "window": [ + { + "type": "WindowListElement", + "name": "w1", + "definition": { + "type": "WindowDefinition" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/665b7476c8cc036f.sql b/tests/ast_json_fixtures/shapes/665b7476c8cc036f.sql new file mode 100644 index 000000000000..2d77b70da42c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/665b7476c8cc036f.sql @@ -0,0 +1 @@ +select 1 window w1 as () diff --git a/tests/ast_json_fixtures/shapes/66643bec6527ca98.json b/tests/ast_json_fixtures/shapes/66643bec6527ca98.json new file mode 100644 index 000000000000..ce50e2e24b02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/66643bec6527ca98.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u5_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "NO_PASSWORD", + "arguments": [] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/66643bec6527ca98.sql b/tests/ast_json_fixtures/shapes/66643bec6527ca98.sql new file mode 100644 index 000000000000..36799f8463de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/66643bec6527ca98.sql @@ -0,0 +1 @@ +ALTER USER u5_01292 NOT IDENTIFIED diff --git a/tests/ast_json_fixtures/shapes/6669def730f8716c.json b/tests/ast_json_fixtures/shapes/6669def730f8716c.json new file mode 100644 index 000000000000..7a345ec0f109 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6669def730f8716c.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "temporary": true, + "table": { + "type": "Identifier", + "name": "tmp" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6669def730f8716c.sql b/tests/ast_json_fixtures/shapes/6669def730f8716c.sql new file mode 100644 index 000000000000..b6739068b57e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6669def730f8716c.sql @@ -0,0 +1 @@ +DROP TEMPORARY TABLE tmp diff --git a/tests/ast_json_fixtures/shapes/666a78b5eb35cae5.json b/tests/ast_json_fixtures/shapes/666a78b5eb35cae5.json new file mode 100644 index 000000000000..923bef77caeb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/666a78b5eb35cae5.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/666a78b5eb35cae5.sql b/tests/ast_json_fixtures/shapes/666a78b5eb35cae5.sql new file mode 100644 index 000000000000..d4541ae446e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/666a78b5eb35cae5.sql @@ -0,0 +1 @@ +SELECT * FROM test ORDER BY i OFFSET 20 diff --git a/tests/ast_json_fixtures/shapes/668263063abf0337.json b/tests/ast_json_fixtures/shapes/668263063abf0337.json new file mode 100644 index 000000000000..503bf9cdcc41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/668263063abf0337.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "agg" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tbl" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/668263063abf0337.sql b/tests/ast_json_fixtures/shapes/668263063abf0337.sql new file mode 100644 index 000000000000..f78eb288a099 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/668263063abf0337.sql @@ -0,0 +1 @@ +SELECT key, sum(agg) FROM tbl GROUP BY key WITH totals ORDER BY key SETTINGS use_query_cache = 1 diff --git a/tests/ast_json_fixtures/shapes/66da9e82ad059b26.json b/tests/ast_json_fixtures/shapes/66da9e82ad059b26.json new file mode 100644 index 000000000000..7293105dbf8a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/66da9e82ad059b26.json @@ -0,0 +1,825 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "INT" + } + ] + }, + { + "type": "Function", + "name": "CEIL", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "CEILING", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "CHAR", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "49" + } + ] + }, + { + "type": "Function", + "name": "CHAR_LENGTH", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "CHARACTER_LENGTH", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "COALESCE", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "CONCAT", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "CORR", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "COS", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "COUNT", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "COVAR_POP", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "COVAR_SAMP", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "DATABASE", + "arguments": [] + }, + { + "type": "Function", + "name": "SCHEMA", + "arguments": [] + }, + { + "type": "Function", + "name": "dateDiff", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "DAY" + }, + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2020-10-24" + } + ] + }, + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2019-10-24" + } + ] + } + ] + }, + { + "type": "Function", + "name": "EXP", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "FLATTEN", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "FLOOR", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "FQDN", + "arguments": [] + }, + { + "type": "Function", + "name": "GREATEST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "IF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "IFNULL", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "LCASE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "A" + } + ] + }, + { + "type": "Function", + "name": "LEAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "LENGTH", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "LN", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "LOG", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "LOG10", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "LOG2", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "LOWER", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "A" + } + ] + }, + { + "type": "Function", + "name": "MAX", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "MID", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "123" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "MOD", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "NOW", + "arguments": [] + }, + { + "type": "Function", + "name": "NOW64", + "arguments": [] + }, + { + "type": "Function", + "name": "NULLIF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "PI", + "arguments": [] + }, + { + "type": "Function", + "name": "position", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "123" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "POW", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "POWER", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "RAND", + "arguments": [] + }, + { + "type": "Function", + "name": "REPLACE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "REVERSE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "123" + } + ] + }, + { + "type": "Function", + "name": "ROUND", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "SIN", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "SQRT", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "STDDEV_POP", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "STDDEV_SAMP", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "SUBSTR", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "123" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "123" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "TAN", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "TANH", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "TRUNC", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "TRUNCATE", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "UCASE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "A" + } + ] + }, + { + "type": "Function", + "name": "UPPER", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "A" + } + ] + }, + { + "type": "Function", + "name": "USER", + "arguments": [] + }, + { + "type": "Function", + "name": "VAR_POP", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "VAR_SAMP", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "WEEK", + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2020-10-24" + } + ] + } + ] + }, + { + "type": "Function", + "name": "YEARWEEK", + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2020-10-24" + } + ] + } + ] + } + ] + } + ] + }, + "format": "TSVRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/66da9e82ad059b26.sql b/tests/ast_json_fixtures/shapes/66da9e82ad059b26.sql new file mode 100644 index 000000000000..8895502a7479 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/66da9e82ad059b26.sql @@ -0,0 +1 @@ +EXPLAIN SYNTAX SELECT CAST(1 AS INT), CEIL(1), CEILING(1), CHAR(49), CHAR_LENGTH('1'), CHARACTER_LENGTH('1'), COALESCE(1), CONCAT('1', '1'), CORR(1, 1), COS(1), COUNT(1), COVAR_POP(1, 1), COVAR_SAMP(1, 1), DATABASE(), SCHEMA(), DATEDIFF('DAY', toDate('2020-10-24'), toDate('2019-10-24')), EXP(1), FLATTEN([[1]]), FLOOR(1), FQDN(), GREATEST(1), IF(1, 1, 1), IFNULL(1, 1), LCASE('A'), LEAST(1), LENGTH('1'), LN(1), LOG(1), LOG10(1), LOG2(1), LOWER('A'), MAX(1), MID('123', 1, 1), MIN(1), MOD(1, 1), NOT(1), NOW(), NOW64(), NULLIF(1, 1), PI(), POSITION('123', '2'), POW(1, 1), POWER(1, 1), RAND(), REPLACE('1', '1', '2'), REVERSE('123'), ROUND(1), SIN(1), SQRT(1), STDDEV_POP(1), STDDEV_SAMP(1), SUBSTR('123', 2), SUBSTRING('123', 2), SUM(1), TAN(1), TANH(1), TRUNC(1), TRUNCATE(1), UCASE('A'), UPPER('A'), USER(), VAR_POP(1), VAR_SAMP(1), WEEK(toDate('2020-10-24')), YEARWEEK(toDate('2020-10-24')) format TSVRaw diff --git a/tests/ast_json_fixtures/shapes/66fde309ca0cf7e1.json b/tests/ast_json_fixtures/shapes/66fde309ca0cf7e1.json new file mode 100644 index 000000000000..b36b8f8431b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/66fde309ca0cf7e1.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t02006" + }, + "format": "Null", + "cluster": "test_shard_localhost", + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "if_not_exists": true, + "column_declaration": { + "type": "ColumnDeclaration", + "name": "f", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/66fde309ca0cf7e1.sql b/tests/ast_json_fixtures/shapes/66fde309ca0cf7e1.sql new file mode 100644 index 000000000000..bb393e2b194f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/66fde309ca0cf7e1.sql @@ -0,0 +1 @@ +ALTER TABLE t02006 on cluster test_shard_localhost ADD COLUMN IF NOT EXISTS f UInt64 format Null diff --git a/tests/ast_json_fixtures/shapes/67047aab174dc30b.json b/tests/ast_json_fixtures/shapes/67047aab174dc30b.json new file mode 100644 index 000000000000..f506fa4f3347 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67047aab174dc30b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02483_plusone", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/67047aab174dc30b.sql b/tests/ast_json_fixtures/shapes/67047aab174dc30b.sql new file mode 100644 index 000000000000..ce369a5d7459 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67047aab174dc30b.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02483_plusone diff --git a/tests/ast_json_fixtures/shapes/6718832c35bf5c65.json b/tests/ast_json_fixtures/shapes/6718832c35bf5c65.json new file mode 100644 index 000000000000..325f7af6a27b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6718832c35bf5c65.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_uuid" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "RowBinary" + } +} diff --git a/tests/ast_json_fixtures/shapes/6718832c35bf5c65.sql b/tests/ast_json_fixtures/shapes/6718832c35bf5c65.sql new file mode 100644 index 000000000000..35ab053b0e4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6718832c35bf5c65.sql @@ -0,0 +1 @@ +SELECT * FROM t_uuid ORDER BY x LIMIT 1 FORMAT RowBinary diff --git a/tests/ast_json_fixtures/shapes/6723bc307665d510.json b/tests/ast_json_fixtures/shapes/6723bc307665d510.json new file mode 100644 index 000000000000..8f802487b723 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6723bc307665d510.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "03000_traverse_shadow_system_data_path_table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "FREEZE_ALL", + "with_name": "03000_traverse_shadow_system_data_path_table_backup" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6723bc307665d510.sql b/tests/ast_json_fixtures/shapes/6723bc307665d510.sql new file mode 100644 index 000000000000..017dd50568e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6723bc307665d510.sql @@ -0,0 +1 @@ +ALTER TABLE 03000_traverse_shadow_system_data_path_table FREEZE WITH NAME '03000_traverse_shadow_system_data_path_table_backup' diff --git a/tests/ast_json_fixtures/shapes/6723e49926d0fc03.json b/tests/ast_json_fixtures/shapes/6723e49926d0fc03.json new file mode 100644 index 000000000000..164ec3977b22 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6723e49926d0fc03.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6723e49926d0fc03.sql b/tests/ast_json_fixtures/shapes/6723e49926d0fc03.sql new file mode 100644 index 000000000000..0f4d3cd8a905 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6723e49926d0fc03.sql @@ -0,0 +1 @@ +select * from test group by tuple(d) diff --git a/tests/ast_json_fixtures/shapes/674eb5c4c6036cc6.json b/tests/ast_json_fixtures/shapes/674eb5c4c6036cc6.json new file mode 100644 index 000000000000..a2f2b36ccea1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/674eb5c4c6036cc6.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "d" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "value", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "SEMI", + "using": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "d", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "values", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/674eb5c4c6036cc6.sql b/tests/ast_json_fixtures/shapes/674eb5c4c6036cc6.sql new file mode 100644 index 000000000000..53cb85f39c52 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/674eb5c4c6036cc6.sql @@ -0,0 +1 @@ +SELECT *, d.* FROM ( SELECT 1 AS id, 2 AS value ) SEMI LEFT JOIN ( SELECT 1 AS id, 3 AS values ) AS d USING id diff --git a/tests/ast_json_fixtures/shapes/67545ce7da381852.json b/tests/ast_json_fixtures/shapes/67545ce7da381852.json new file mode 100644 index 000000000000..11963df6b38d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67545ce7da381852.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "reference_vec", + "value_type": "Array", + "value": [ + { + "value_type": "Float64", + "value": 0 + }, + { + "value_type": "Float64", + "value": 2 + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/67545ce7da381852.sql b/tests/ast_json_fixtures/shapes/67545ce7da381852.sql new file mode 100644 index 000000000000..f5e679593838 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67545ce7da381852.sql @@ -0,0 +1,5 @@ +WITH [0.0, 2.0] AS reference_vec +SELECT id +FROM tab +ORDER BY L2Distance(vec, reference_vec) +LIMIT 3 diff --git a/tests/ast_json_fixtures/shapes/676b5b461972a64c.json b/tests/ast_json_fixtures/shapes/676b5b461972a64c.json new file mode 100644 index 000000000000..8add9daf5bdd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/676b5b461972a64c.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "b", + "name": "a" + } + ], + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/676b5b461972a64c.sql b/tests/ast_json_fixtures/shapes/676b5b461972a64c.sql new file mode 100644 index 000000000000..acdf2bddb3f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/676b5b461972a64c.sql @@ -0,0 +1 @@ +WITH a as b SELECT 1 as a, b diff --git a/tests/ast_json_fixtures/shapes/67752b2923586f8a.json b/tests/ast_json_fixtures/shapes/67752b2923586f8a.json new file mode 100644 index 000000000000..b3801bd3b644 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67752b2923586f8a.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "function_name": { + "type": "Identifier", + "name": "02181_invalid_lambda" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/67752b2923586f8a.sql b/tests/ast_json_fixtures/shapes/67752b2923586f8a.sql new file mode 100644 index 000000000000..fd97d43ed8a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67752b2923586f8a.sql @@ -0,0 +1 @@ +CREATE FUNCTION 02181_invalid_lambda AS lambda(tuple(x)) diff --git a/tests/ast_json_fixtures/shapes/67a479c960dbe268.json b/tests/ast_json_fixtures/shapes/67a479c960dbe268.json new file mode 100644 index 000000000000..e701889c7259 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67a479c960dbe268.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "age" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "users_wide" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "age" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_use_projections": "1", + "force_optimize_projection": "1", + "parallel_replicas_local_plan": "1", + "parallel_replicas_support_projection": "1", + "optimize_aggregation_in_order": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/67a479c960dbe268.sql b/tests/ast_json_fixtures/shapes/67a479c960dbe268.sql new file mode 100644 index 000000000000..af09b0ddfc3a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67a479c960dbe268.sql @@ -0,0 +1,6 @@ +SELECT + age, + count() +FROM users_wide +GROUP BY age +SETTINGS optimize_use_projections = 1, force_optimize_projection = 1, parallel_replicas_local_plan = 1, parallel_replicas_support_projection = 1, optimize_aggregation_in_order = 0 diff --git a/tests/ast_json_fixtures/shapes/67ae4905f21a6065.json b/tests/ast_json_fixtures/shapes/67ae4905f21a6065.json new file mode 100644 index 000000000000..d2071676ae89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67ae4905f21a6065.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02125_function_1", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/67ae4905f21a6065.sql b/tests/ast_json_fixtures/shapes/67ae4905f21a6065.sql new file mode 100644 index 000000000000..1415632d82c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67ae4905f21a6065.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02125_function_1 diff --git a/tests/ast_json_fixtures/shapes/67b4559d41e0f8c6.json b/tests/ast_json_fixtures/shapes/67b4559d41e0f8c6.json new file mode 100644 index 000000000000..657708032d1c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67b4559d41e0f8c6.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01071" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01071" + } + ] + } + }, + "as_table": "data_01071" + } +} diff --git a/tests/ast_json_fixtures/shapes/67b4559d41e0f8c6.sql b/tests/ast_json_fixtures/shapes/67b4559d41e0f8c6.sql new file mode 100644 index 000000000000..9a4815113214 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67b4559d41e0f8c6.sql @@ -0,0 +1 @@ +create table dist_01071 as data_01071 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01071) diff --git a/tests/ast_json_fixtures/shapes/67c167b84ba18bcf.json b/tests/ast_json_fixtures/shapes/67c167b84ba18bcf.json new file mode 100644 index 000000000000..7805ab9da667 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67c167b84ba18bcf.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/67c167b84ba18bcf.sql b/tests/ast_json_fixtures/shapes/67c167b84ba18bcf.sql new file mode 100644 index 000000000000..e3d10bbcad67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67c167b84ba18bcf.sql @@ -0,0 +1 @@ +SELECT number FROM numbers(10) OFFSET 0.1 diff --git a/tests/ast_json_fixtures/shapes/67c3a63c9295f924.json b/tests/ast_json_fixtures/shapes/67c3a63c9295f924.json new file mode 100644 index 000000000000..b863d04183ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67c3a63c9295f924.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "49" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/67c3a63c9295f924.sql b/tests/ast_json_fixtures/shapes/67c3a63c9295f924.sql new file mode 100644 index 000000000000..a935b883b524 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67c3a63c9295f924.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 49) FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/67e8580fe1f2e02c.json b/tests/ast_json_fixtures/shapes/67e8580fe1f2e02c.json new file mode 100644 index 000000000000..bec22b590ad4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67e8580fe1f2e02c.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "show_settings": true, + "changed": true, + "like": "%MEMORY%", + "case_insensitive_like": true + } +} diff --git a/tests/ast_json_fixtures/shapes/67e8580fe1f2e02c.sql b/tests/ast_json_fixtures/shapes/67e8580fe1f2e02c.sql new file mode 100644 index 000000000000..dd23150eebd4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/67e8580fe1f2e02c.sql @@ -0,0 +1 @@ +SHOW CHANGED SETTINGS ILIKE '%MEMORY%' diff --git a/tests/ast_json_fixtures/shapes/6829d694a05f07d8.json b/tests/ast_json_fixtures/shapes/6829d694a05f07d8.json new file mode 100644 index 000000000000..bea765bc0f01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6829d694a05f07d8.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "data_01283" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "key" + }, + "order_by": { + "type": "Identifier", + "name": "key" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "key", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6829d694a05f07d8.sql b/tests/ast_json_fixtures/shapes/6829d694a05f07d8.sql new file mode 100644 index 000000000000..2049e52dd544 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6829d694a05f07d8.sql @@ -0,0 +1,4 @@ +CREATE TABLE data_01283 engine=MergeTree() +ORDER BY key +PARTITION BY key +AS SELECT number key FROM numbers(10) diff --git a/tests/ast_json_fixtures/shapes/68350b6f33ffefa0.json b/tests/ast_json_fixtures/shapes/68350b6f33ffefa0.json new file mode 100644 index 000000000000..cacb11a869d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68350b6f33ffefa0.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": true + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/68350b6f33ffefa0.sql b/tests/ast_json_fixtures/shapes/68350b6f33ffefa0.sql new file mode 100644 index 000000000000..a1faa910a848 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68350b6f33ffefa0.sql @@ -0,0 +1 @@ +SELECT 1 + number from system.numbers LIMIT 1 SETTINGS use_query_cache = true diff --git a/tests/ast_json_fixtures/shapes/68450c5d2faddc6f.json b/tests/ast_json_fixtures/shapes/68450c5d2faddc6f.json new file mode 100644 index 000000000000..b496cdf1f9df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68450c5d2faddc6f.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "alter": true, + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p1_01296", + "table": "table" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/68450c5d2faddc6f.sql b/tests/ast_json_fixtures/shapes/68450c5d2faddc6f.sql new file mode 100644 index 000000000000..838dff7f9ed8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68450c5d2faddc6f.sql @@ -0,0 +1 @@ +ALTER POLICY p1_01296 ON table USING 1 diff --git a/tests/ast_json_fixtures/shapes/684f88ea48741a61.json b/tests/ast_json_fixtures/shapes/684f88ea48741a61.json new file mode 100644 index 000000000000..ca3b075d61cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/684f88ea48741a61.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COMMENT", + "comment": { + "type": "Literal", + "value_type": "String", + "value": "World" + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/684f88ea48741a61.sql b/tests/ast_json_fixtures/shapes/684f88ea48741a61.sql new file mode 100644 index 000000000000..f73cfb24c1a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/684f88ea48741a61.sql @@ -0,0 +1 @@ +ALTER TABLE t MODIFY COMMENT 'World', MODIFY COLUMN x UInt16 diff --git a/tests/ast_json_fixtures/shapes/6864df7f3b9c51c9.json b/tests/ast_json_fixtures/shapes/6864df7f3b9c51c9.json new file mode 100644 index 000000000000..bf1ff59540e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6864df7f3b9c51c9.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q9_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6864df7f3b9c51c9.sql b/tests/ast_json_fixtures/shapes/6864df7f3b9c51c9.sql new file mode 100644 index 000000000000..2cc332e1e743 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6864df7f3b9c51c9.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q9_01297 diff --git a/tests/ast_json_fixtures/shapes/68756b4d3d593d5f.json b/tests/ast_json_fixtures/shapes/68756b4d3d593d5f.json new file mode 100644 index 000000000000..73445552f548 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68756b4d3d593d5f.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "f2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "merge", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^abc$" + } + ] + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "f1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "abc" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/68756b4d3d593d5f.sql b/tests/ast_json_fixtures/shapes/68756b4d3d593d5f.sql new file mode 100644 index 000000000000..3d3a3eb82fc8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68756b4d3d593d5f.sql @@ -0,0 +1 @@ +SELECT f2 FROM merge(currentDatabase(), '^abc$') PREWHERE f1 = 'a' WHERE _table = 'abc' diff --git a/tests/ast_json_fixtures/shapes/688cbb750e39e45d.json b/tests/ast_json_fixtures/shapes/688cbb750e39e45d.json new file mode 100644 index 000000000000..81a09b953969 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/688cbb750e39e45d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u2_01292", "u3_01292", "u4_01292", "u5_01292@%.host.com", "u6_01292@%.host.com"] + } +} diff --git a/tests/ast_json_fixtures/shapes/688cbb750e39e45d.sql b/tests/ast_json_fixtures/shapes/688cbb750e39e45d.sql new file mode 100644 index 000000000000..4d1505fd5ad7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/688cbb750e39e45d.sql @@ -0,0 +1 @@ +SHOW CREATE USER u1_01292, u2_01292, u3_01292, u4_01292, u5_01292@'%.host.com', u6_01292@'%.host.com' diff --git a/tests/ast_json_fixtures/shapes/688fab29385f7035.json b/tests/ast_json_fixtures/shapes/688fab29385f7035.json new file mode 100644 index 000000000000..1e56ece9b829 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/688fab29385f7035.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1" + } + }, + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/688fab29385f7035.sql b/tests/ast_json_fixtures/shapes/688fab29385f7035.sql new file mode 100644 index 000000000000..c46975d11ece --- /dev/null +++ b/tests/ast_json_fixtures/shapes/688fab29385f7035.sql @@ -0,0 +1 @@ +SELECT 10 FORMAT Vertical SETTINGS use_query_cache = 1 diff --git a/tests/ast_json_fixtures/shapes/68aeea8cb8c1e872.json b/tests/ast_json_fixtures/shapes/68aeea8cb8c1e872.json new file mode 100644 index 000000000000..1bbcca0607c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68aeea8cb8c1e872.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02103_test_function" + } +} diff --git a/tests/ast_json_fixtures/shapes/68aeea8cb8c1e872.sql b/tests/ast_json_fixtures/shapes/68aeea8cb8c1e872.sql new file mode 100644 index 000000000000..3db68190fdcc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68aeea8cb8c1e872.sql @@ -0,0 +1 @@ +DROP FUNCTION 02103_test_function diff --git a/tests/ast_json_fixtures/shapes/68c42a2664d4ef4d.json b/tests/ast_json_fixtures/shapes/68c42a2664d4ef4d.json new file mode 100644 index 000000000000..cb7597c197af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68c42a2664d4ef4d.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "date_trunc", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "month" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Identifier", + "name": "c" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + }, + "final": true + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "f2" + }, + { + "type": "Literal", + "value_type": "String", + "value": "x" + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/68c42a2664d4ef4d.sql b/tests/ast_json_fixtures/shapes/68c42a2664d4ef4d.sql new file mode 100644 index 000000000000..25bd402068f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68c42a2664d4ef4d.sql @@ -0,0 +1,7 @@ +SELECT + date_trunc('month', d), + SUM(c) +FROM t +FINAL +WHERE f2 = 'x' +GROUP BY 1 diff --git a/tests/ast_json_fixtures/shapes/68d0836c1a542c5d.json b/tests/ast_json_fixtures/shapes/68d0836c1a542c5d.json new file mode 100644 index 000000000000..de9f4e2a4834 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68d0836c1a542c5d.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "tab", + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/68d0836c1a542c5d.sql b/tests/ast_json_fixtures/shapes/68d0836c1a542c5d.sql new file mode 100644 index 000000000000..10ccbb5c9be4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68d0836c1a542c5d.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM tab LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/68f4ce46864f7f5b.json b/tests/ast_json_fixtures/shapes/68f4ce46864f7f5b.json new file mode 100644 index 000000000000..184a44410dd9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68f4ce46864f7f5b.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distributed_01099_c" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "local_01099_c" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "local_01099_c" + } +} diff --git a/tests/ast_json_fixtures/shapes/68f4ce46864f7f5b.sql b/tests/ast_json_fixtures/shapes/68f4ce46864f7f5b.sql new file mode 100644 index 000000000000..6a5c58939e35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68f4ce46864f7f5b.sql @@ -0,0 +1 @@ +CREATE TABLE distributed_01099_c AS local_01099_c ENGINE = Distributed('test_shard_localhost', currentDatabase(), local_01099_c, rand()) diff --git a/tests/ast_json_fixtures/shapes/68f936a5c262f078.json b/tests/ast_json_fixtures/shapes/68f936a5c262f078.json new file mode 100644 index 000000000000..045a77349ecc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68f936a5c262f078.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "alias": "res", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "val" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1", + "read_in_order_two_level_merge_threshold": "0" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/68f936a5c262f078.sql b/tests/ast_json_fixtures/shapes/68f936a5c262f078.sql new file mode 100644 index 000000000000..33f68a642e1b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/68f936a5c262f078.sql @@ -0,0 +1 @@ +SELECT key, arrayJoin(val) as res FROM test ORDER BY ALL settings max_threads = 1, read_in_order_two_level_merge_threshold = 0 format Null diff --git a/tests/ast_json_fixtures/shapes/69098d292156b7e0.json b/tests/ast_json_fixtures/shapes/69098d292156b7e0.json new file mode 100644 index 000000000000..22cc34affe90 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69098d292156b7e0.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "STOP MOVES", + "database": { + "type": "Identifier", + "name": "sqllt" + }, + "table": { + "type": "Identifier", + "name": "table" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/69098d292156b7e0.sql b/tests/ast_json_fixtures/shapes/69098d292156b7e0.sql new file mode 100644 index 000000000000..789f7a4efa7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69098d292156b7e0.sql @@ -0,0 +1 @@ +SYSTEM STOP MOVES sqllt.table diff --git a/tests/ast_json_fixtures/shapes/69166b282f84409f.json b/tests/ast_json_fixtures/shapes/69166b282f84409f.json new file mode 100644 index 000000000000..48c0759845f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69166b282f84409f.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_table": "t1", + "to_table": "t3" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/69166b282f84409f.sql b/tests/ast_json_fixtures/shapes/69166b282f84409f.sql new file mode 100644 index 000000000000..9d91246f58ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69166b282f84409f.sql @@ -0,0 +1 @@ +EXCHANGE TABLES t1 AND t3 diff --git a/tests/ast_json_fixtures/shapes/6930c43c047a17b4.json b/tests/ast_json_fixtures/shapes/6930c43c047a17b4.json new file mode 100644 index 000000000000..05522f8ce23e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6930c43c047a17b4.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "from": { + "type": "Identifier", + "name": "system" + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "engine" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%System%" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "String", + "value": "numbers" + }, + { + "value_type": "String", + "value": "one" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Literal", + "value_type": "String", + "value": "system" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6930c43c047a17b4.sql b/tests/ast_json_fixtures/shapes/6930c43c047a17b4.sql new file mode 100644 index 000000000000..0486e6efecbd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6930c43c047a17b4.sql @@ -0,0 +1 @@ +SHOW TABLES IN system WHERE engine LIKE '%System%' AND name IN ('numbers', 'one') AND database = 'system' diff --git a/tests/ast_json_fixtures/shapes/693123914869fbaa.json b/tests/ast_json_fixtures/shapes/693123914869fbaa.json new file mode 100644 index 000000000000..3dbd1cf71736 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/693123914869fbaa.json @@ -0,0 +1,356 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "02577_keepermap_delete_update" + }, + "predicate": { + "type": "Function", + "name": "like", + "arguments": [ + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1 + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "name": "isZeroOrNull", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 1 + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "isZeroOrNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "15" + } + ] + }, + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "15" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "15" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Asterisk" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Asterisk" + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "15" + } + ] + } + ] + }, + { + "type": "Function", + "name": "indexHint", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Some%string" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/693123914869fbaa.sql b/tests/ast_json_fixtures/shapes/693123914869fbaa.sql new file mode 100644 index 000000000000..906be8bb782a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/693123914869fbaa.sql @@ -0,0 +1 @@ +DELETE FROM `02577_keepermap_delete_update` WHERE like(indexHint(*, indexHint(indexHint(toNullable(1.), 0, (20 IS NULL) IS NOT NULL, isNull(indexHint(indexHint(indexHint(indexHint(*), *), isZeroOrNull(materialize(indexHint(*, indexHint(toNullable(toInt128(100) IS NULL, 1.), toLowCardinality(0), isNullable(toNullable(20)) IS NULL, indexHint(isZeroOrNull(15), *, indexHint(*)), *), 100), 15))), indexHint(indexHint(isNullable(materialize(15 IS NOT NULL))), 100, *), 1, indexHint(indexHint(1, indexHint(100, *)), *)), toLowCardinality(15)), indexHint(*)), *)), value, 'Some%string') diff --git a/tests/ast_json_fixtures/shapes/6945781106619e5c.json b/tests/ast_json_fixtures/shapes/6945781106619e5c.json new file mode 100644 index 000000000000..a914ca2ea4eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6945781106619e5c.json @@ -0,0 +1,670 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "order_by_all": true, + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "foo", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "and", + "arguments": [ + { + "type": "Function", + "name": "and", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "assumeNotNull", + "arguments": [ + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Function", + "name": "isZeroOrNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Asterisk" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "assumeNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ANY", + "on": { + "type": "Function", + "name": "and", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "foo.b", + "name_parts": ["foo", "b"] + }, + { + "type": "Identifier", + "name": "bar.b", + "name_parts": ["bar", "b"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "foo.a", + "name_parts": ["foo", "a"] + }, + { + "type": "Identifier", + "name": "bar.b", + "name_parts": ["bar", "b"] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "bar", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Function", + "name": "isZeroOrNull", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "and", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "assumeNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "assumeNotNull", + "arguments": [ + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "isZeroOrNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC", + "nulls_first": true + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6945781106619e5c.sql b/tests/ast_json_fixtures/shapes/6945781106619e5c.sql new file mode 100644 index 000000000000..9cb120b0d336 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6945781106619e5c.sql @@ -0,0 +1 @@ +SELECT DISTINCT 2 FROM (SELECT 2 AS b, 1 AS a GROUP BY 1, toUInt256(1), 1, and(and(2, rand(materialize(toLowCardinality(2))), assumeNotNull(isNull(isNullable(2))) AND (and(rand(isZeroOrNull(2)), 2, *) AND 1) AND (assumeNotNull(2) AND rand(2)) AND (* AND isNotNull(toLowCardinality(2))), (* AND rand(isNullable(2))) AND isNotNull(2), isNullable(materialize(1)), *), 2, rand(toLowCardinality(2))) WITH CUBE WITH TOTALS) AS foo ANY LEFT JOIN (SELECT * AND ((isNullable(isZeroOrNull(toNullable(1))) AND *) AND rand(2)), 2 AS b, 1 AS a) AS bar ON and(foo.b = bar.b, foo.a = bar.b) WHERE (and(*, toNullable(2), * AND * AND isNotNull(2) AND * AND and(*) AND isNotNull(1), rand(2)) AND *) AND (1 AND assumeNotNull(2)) AND assumeNotNull(isNull(2)) AND (* AND (* AND isZeroOrNull(2)) AND isNull(toNullable(2))) ORDER BY ALL ASC NULLS FIRST diff --git a/tests/ast_json_fixtures/shapes/694a31cd467193cc.json b/tests/ast_json_fixtures/shapes/694a31cd467193cc.json new file mode 100644 index 000000000000..8742ec015837 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/694a31cd467193cc.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "database": { + "type": "Identifier", + "name": "01778_db" + }, + "table": { + "type": "Identifier", + "name": "hierarchy_direct_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "parent_id", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "hierarchical": true + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "user", + "value": { + "type": "Literal", + "value_type": "String", + "value": "default" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "hierarchy_source_table" + } + }, + { + "type": "pair", + "key": "db", + "value": { + "type": "Literal", + "value_type": "String", + "value": "01778_db" + } + } + ] + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "direct", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/694a31cd467193cc.sql b/tests/ast_json_fixtures/shapes/694a31cd467193cc.sql new file mode 100644 index 000000000000..7c358e3508d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/694a31cd467193cc.sql @@ -0,0 +1,8 @@ +CREATE DICTIONARY 01778_db.hierarchy_direct_dictionary +( + id UInt64, + parent_id UInt64 HIERARCHICAL +) +PRIMARY KEY id +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'hierarchy_source_table' DB '01778_db')) +LAYOUT(DIRECT()) diff --git a/tests/ast_json_fixtures/shapes/6952c386827bc15c.json b/tests/ast_json_fixtures/shapes/6952c386827bc15c.json new file mode 100644 index 000000000000..fbd96cc25b17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6952c386827bc15c.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6952c386827bc15c.sql b/tests/ast_json_fixtures/shapes/6952c386827bc15c.sql new file mode 100644 index 000000000000..31e613415efe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6952c386827bc15c.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number diff --git a/tests/ast_json_fixtures/shapes/69648df1fc4d4fd3.json b/tests/ast_json_fixtures/shapes/69648df1fc4d4fd3.json new file mode 100644 index 000000000000..dd3a730ce928 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69648df1fc4d4fd3.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p3_01295", + "database": "db", + "table": "table" + } + ] + }, + "is_restrictive": false, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r1_01295"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/69648df1fc4d4fd3.sql b/tests/ast_json_fixtures/shapes/69648df1fc4d4fd3.sql new file mode 100644 index 000000000000..23810c1094ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69648df1fc4d4fd3.sql @@ -0,0 +1 @@ +CREATE ROW POLICY p3_01295 ON db.table USING 1 AS PERMISSIVE TO ALL EXCEPT r1_01295 diff --git a/tests/ast_json_fixtures/shapes/69acba8481542185.json b/tests/ast_json_fixtures/shapes/69acba8481542185.json new file mode 100644 index 000000000000..23c3293c69b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69acba8481542185.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q5_01297"], + "limits": [ + { + "duration_sec": "31556952", + "max": { + "ERRORS": "111" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/69acba8481542185.sql b/tests/ast_json_fixtures/shapes/69acba8481542185.sql new file mode 100644 index 000000000000..d5ad13f1d0cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69acba8481542185.sql @@ -0,0 +1 @@ +ALTER QUOTA q5_01297 FOR 1 YEAR MAX errors = 111 diff --git a/tests/ast_json_fixtures/shapes/69addcea515075c6.json b/tests/ast_json_fixtures/shapes/69addcea515075c6.json new file mode 100644 index 000000000000..6d963a1fe397 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69addcea515075c6.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "null_02230_ttl" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Null", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "data_02230_ttl" + } +} diff --git a/tests/ast_json_fixtures/shapes/69addcea515075c6.sql b/tests/ast_json_fixtures/shapes/69addcea515075c6.sql new file mode 100644 index 000000000000..6b9afe0472f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69addcea515075c6.sql @@ -0,0 +1 @@ +create table null_02230_ttl engine=Null() as data_02230_ttl diff --git a/tests/ast_json_fixtures/shapes/69c3cd3036b8b7f5.json b/tests/ast_json_fixtures/shapes/69c3cd3036b8b7f5.json new file mode 100644 index 000000000000..6c512767d6b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69c3cd3036b8b7f5.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01320" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01320" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + ] + } + }, + "as_table": "data_01320" + } +} diff --git a/tests/ast_json_fixtures/shapes/69c3cd3036b8b7f5.sql b/tests/ast_json_fixtures/shapes/69c3cd3036b8b7f5.sql new file mode 100644 index 000000000000..81bde84da9fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69c3cd3036b8b7f5.sql @@ -0,0 +1 @@ +create table dist_01320 as data_01320 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01320, key + rand()) diff --git a/tests/ast_json_fixtures/shapes/69d1f0fbd8f1c5ca.json b/tests/ast_json_fixtures/shapes/69d1f0fbd8f1c5ca.json new file mode 100644 index 000000000000..6427feb23d9a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69d1f0fbd8f1c5ca.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TabSeparated" + } +} diff --git a/tests/ast_json_fixtures/shapes/69d1f0fbd8f1c5ca.sql b/tests/ast_json_fixtures/shapes/69d1f0fbd8f1c5ca.sql new file mode 100644 index 000000000000..d07b569900b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69d1f0fbd8f1c5ca.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TabSeparated diff --git a/tests/ast_json_fixtures/shapes/69e7a92f9e9e33d2.json b/tests/ast_json_fixtures/shapes/69e7a92f9e9e33d2.json new file mode 100644 index 000000000000..153855eee30f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69e7a92f9e9e33d2.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s7_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/69e7a92f9e9e33d2.sql b/tests/ast_json_fixtures/shapes/69e7a92f9e9e33d2.sql new file mode 100644 index 000000000000..7f85fcf4594d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69e7a92f9e9e33d2.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s7_01294 diff --git a/tests/ast_json_fixtures/shapes/69eb1854d7e904ff.json b/tests/ast_json_fixtures/shapes/69eb1854d7e904ff.json new file mode 100644 index 000000000000..0f9ff07b86d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69eb1854d7e904ff.json @@ -0,0 +1,177 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "[RE7" + }, + { + "type": "Subquery", + "alias": "riwwq", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "\u0000" + } + ] + } + ] + } + }, + { + "type": "Subquery", + "alias": "xuvv", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "reverse", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "bitTestAll", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + } + }, + { + "type": "Subquery", + "alias": "ddfweeuy", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "\u0000" + } + ] + } + ] + } + } + ] + } + ] + } + ] + } + ] + } + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Subquery", + "alias": "wqgdswyc", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [] + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [] + } + } + } + ] + } + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/69eb1854d7e904ff.sql b/tests/ast_json_fixtures/shapes/69eb1854d7e904ff.sql new file mode 100644 index 000000000000..86e78762c091 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/69eb1854d7e904ff.sql @@ -0,0 +1 @@ +SELECT '[RE7', ( SELECT '\0' ) AS riwwq, ( SELECT reverse([( SELECT bitTestAll(NULL) ) , ( SELECT '\0' ) AS ddfweeuy]) ) AS xuvv, '', ( SELECT * FROM file() ) AS wqgdswyc, ( SELECT * FROM file() ) diff --git a/tests/ast_json_fixtures/shapes/6a06b6d242d31ddd.json b/tests/ast_json_fixtures/shapes/6a06b6d242d31ddd.json new file mode 100644 index 000000000000..c810e957d21a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a06b6d242d31ddd.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_idx_pk_size" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "distributed_index_analysis": "1" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/6a06b6d242d31ddd.sql b/tests/ast_json_fixtures/shapes/6a06b6d242d31ddd.sql new file mode 100644 index 000000000000..e05d3eefd08d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a06b6d242d31ddd.sql @@ -0,0 +1 @@ +select key from dist_idx_pk_size settings distributed_index_analysis=1 format Null diff --git a/tests/ast_json_fixtures/shapes/6a3216da87eecaa7.json b/tests/ast_json_fixtures/shapes/6a3216da87eecaa7.json new file mode 100644 index 000000000000..5a9d10f9296c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a3216da87eecaa7.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "alias": "a", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tb" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tabc" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6a3216da87eecaa7.sql b/tests/ast_json_fixtures/shapes/6a3216da87eecaa7.sql new file mode 100644 index 000000000000..9a4945feeb41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a3216da87eecaa7.sql @@ -0,0 +1 @@ +SELECT b + 1 AS a, * FROM tb JOIN tabc USING (a) ORDER BY ALL SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/6a507e80b2816687.json b/tests/ast_json_fixtures/shapes/6a507e80b2816687.json new file mode 100644 index 000000000000..c3bed907f3de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a507e80b2816687.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "SearchPhrase" + }, + { + "type": "Function", + "alias": "c", + "name": "COUNT", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "SearchPhrase" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "SearchPhrase" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "query_12" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/6a507e80b2816687.sql b/tests/ast_json_fixtures/shapes/6a507e80b2816687.sql new file mode 100644 index 000000000000..a5af824700c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a507e80b2816687.sql @@ -0,0 +1 @@ +SELECT SearchPhrase, COUNT(*) AS c FROM test.hits WHERE SearchPhrase <> '' GROUP BY SearchPhrase ORDER BY c DESC LIMIT 10 FORMAT Null SETTINGS log_comment='query_12' diff --git a/tests/ast_json_fixtures/shapes/6a585cf3e0759bb7.json b/tests/ast_json_fixtures/shapes/6a585cf3e0759bb7.json new file mode 100644 index 000000000000..282b7cda270b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a585cf3e0759bb7.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s1_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6a585cf3e0759bb7.sql b/tests/ast_json_fixtures/shapes/6a585cf3e0759bb7.sql new file mode 100644 index 000000000000..e628b46c80e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a585cf3e0759bb7.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s1_01294 diff --git a/tests/ast_json_fixtures/shapes/6a6d2b00a9a56804.json b/tests/ast_json_fixtures/shapes/6a6d2b00a9a56804.json new file mode 100644 index 000000000000..2c9e901e79e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a6d2b00a9a56804.json @@ -0,0 +1,130 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_grouping_standard_compatibility": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6a6d2b00a9a56804.sql b/tests/ast_json_fixtures/shapes/6a6d2b00a9a56804.sql new file mode 100644 index 000000000000..6f1a04623e8d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a6d2b00a9a56804.sql @@ -0,0 +1,10 @@ +SELECT + number +FROM numbers(10) +GROUP BY + GROUPING SETS ( + (number), + (number % 2) + ) +ORDER BY number, grouping(number, number % 2) = 1 +SETTINGS force_grouping_standard_compatibility=0 diff --git a/tests/ast_json_fixtures/shapes/6a7e8aef40ae39cb.json b/tests/ast_json_fixtures/shapes/6a7e8aef40ae39cb.json new file mode 100644 index 000000000000..01fb9992b65a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a7e8aef40ae39cb.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u7_01292@%.host.com", "u8_01292@%.otherhost.com"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6a7e8aef40ae39cb.sql b/tests/ast_json_fixtures/shapes/6a7e8aef40ae39cb.sql new file mode 100644 index 000000000000..5e3697416408 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a7e8aef40ae39cb.sql @@ -0,0 +1 @@ +DROP USER u7_01292@'%.host.com', u8_01292@'%.otherhost.com' diff --git a/tests/ast_json_fixtures/shapes/6a9acc6fcd52f6f9.json b/tests/ast_json_fixtures/shapes/6a9acc6fcd52f6f9.json new file mode 100644 index 000000000000..91c9562177fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a9acc6fcd52f6f9.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "partition_all2" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "FREEZE_PARTITION", + "partition": { + "type": "Partition_ID", + "all": true + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6a9acc6fcd52f6f9.sql b/tests/ast_json_fixtures/shapes/6a9acc6fcd52f6f9.sql new file mode 100644 index 000000000000..23551dd6a084 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6a9acc6fcd52f6f9.sql @@ -0,0 +1 @@ +ALTER TABLE partition_all2 FREEZE PARTITION ALL diff --git a/tests/ast_json_fixtures/shapes/6ac58ade7182349a.json b/tests/ast_json_fixtures/shapes/6ac58ade7182349a.json new file mode 100644 index 000000000000..c12c20e48909 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ac58ade7182349a.json @@ -0,0 +1,755 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "data", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "val1", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val2", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val3", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val4", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val5", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val6", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val7", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val8", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val9", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val10", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val11", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val12", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val13", + "name": "rand64", + "arguments": [] + }, + { + "type": "Function", + "alias": "val14", + "name": "rand64", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "Subquery", + "alias": "value1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value3", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value4", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val4" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value5", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val5" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value6", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val6" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value7", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val7" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value8", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val8" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value9", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val9" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value10", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val10" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value11", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val11" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value12", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val12" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value13", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val13" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "value14", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "val14" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "alias": "v1", + "name": "value1" + }, + { + "type": "Identifier", + "alias": "v2", + "name": "value2" + }, + { + "type": "Identifier", + "alias": "v3", + "name": "value3" + }, + { + "type": "Identifier", + "alias": "v4", + "name": "value4" + }, + { + "type": "Identifier", + "alias": "v5", + "name": "value5" + }, + { + "type": "Identifier", + "alias": "v6", + "name": "value6" + }, + { + "type": "Identifier", + "alias": "v7", + "name": "value7" + }, + { + "type": "Identifier", + "alias": "v8", + "name": "value8" + }, + { + "type": "Identifier", + "alias": "v9", + "name": "value9" + }, + { + "type": "Identifier", + "alias": "v10", + "name": "value10" + }, + { + "type": "Identifier", + "alias": "v11", + "name": "value11" + }, + { + "type": "Identifier", + "alias": "v12", + "name": "value12" + }, + { + "type": "Identifier", + "alias": "v13", + "name": "value13" + }, + { + "type": "Identifier", + "alias": "v14", + "name": "value14" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/6ac58ade7182349a.sql b/tests/ast_json_fixtures/shapes/6ac58ade7182349a.sql new file mode 100644 index 000000000000..68807445e5ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ac58ade7182349a.sql @@ -0,0 +1,49 @@ +WITH + data AS ( + SELECT + rand64() AS val1, + rand64() AS val2, + rand64() AS val3, + rand64() AS val4, + rand64() AS val5, + rand64() AS val6, + rand64() AS val7, + rand64() AS val8, + rand64() AS val9, + rand64() AS val10, + rand64() AS val11, + rand64() AS val12, + rand64() AS val13, + rand64() AS val14 + FROM numbers(10) + ), + (SELECT avg(val1) FROM data) AS value1, + (SELECT avg(val2) FROM data) AS value2, + (SELECT avg(val3) FROM data) AS value3, + (SELECT avg(val4) FROM data) AS value4, + (SELECT avg(val5) FROM data) AS value5, + (SELECT avg(val6) FROM data) AS value6, + (SELECT avg(val7) FROM data) AS value7, + (SELECT avg(val8) FROM data) AS value8, + (SELECT avg(val9) FROM data) AS value9, + (SELECT avg(val10) FROM data) AS value10, + (SELECT avg(val11) FROM data) AS value11, + (SELECT avg(val12) FROM data) AS value12, + (SELECT avg(val13) FROM data) AS value13, + (SELECT avg(val14) FROM data) AS value14 +SELECT + value1 AS v1, + value2 AS v2, + value3 AS v3, + value4 AS v4, + value5 AS v5, + value6 AS v6, + value7 AS v7, + value8 AS v8, + value9 AS v9, + value10 AS v10, + value11 AS v11, + value12 AS v12, + value13 AS v13, + value14 AS v14 +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/6b0bdce1ff410cb3.json b/tests/ast_json_fixtures/shapes/6b0bdce1ff410cb3.json new file mode 100644 index 000000000000..23ec8cf64b57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b0bdce1ff410cb3.json @@ -0,0 +1,126 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_grouping_standard_compatibility": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6b0bdce1ff410cb3.sql b/tests/ast_json_fixtures/shapes/6b0bdce1ff410cb3.sql new file mode 100644 index 000000000000..8c6e4d63c301 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b0bdce1ff410cb3.sql @@ -0,0 +1,9 @@ +SELECT + number, + grouping(number, number % 2) = 3 +FROM remote('127.0.0.{2,3}', numbers(10)) +GROUP BY + number, + number % 2 +ORDER BY number +SETTINGS force_grouping_standard_compatibility=0 diff --git a/tests/ast_json_fixtures/shapes/6b0fcc177121ad39.json b/tests/ast_json_fixtures/shapes/6b0fcc177121ad39.json new file mode 100644 index 000000000000..b330b5b83b5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b0fcc177121ad39.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "src" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6b0fcc177121ad39.sql b/tests/ast_json_fixtures/shapes/6b0fcc177121ad39.sql new file mode 100644 index 000000000000..b56d1fd8b85f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b0fcc177121ad39.sql @@ -0,0 +1 @@ +CREATE TABLE src (x int) ORDER BY () diff --git a/tests/ast_json_fixtures/shapes/6b1548f55c09292d.json b/tests/ast_json_fixtures/shapes/6b1548f55c09292d.json new file mode 100644 index 000000000000..861663d76332 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b1548f55c09292d.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "T1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "using": [ + { + "type": "Identifier", + "name": "A" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "T2" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/6b1548f55c09292d.sql b/tests/ast_json_fixtures/shapes/6b1548f55c09292d.sql new file mode 100644 index 000000000000..d0dea65c07a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b1548f55c09292d.sql @@ -0,0 +1,2 @@ +SELECT * FROM T1 FULL JOIN T2 USING(A) ORDER BY ALL +FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/6b3e74b985a6f4a4.json b/tests/ast_json_fixtures/shapes/6b3e74b985a6f4a4.json new file mode 100644 index 000000000000..8d8f0fedf1f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b3e74b985a6f4a4.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "value", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1234" + } + ] + }, + { + "type": "Literal", + "alias": "type", + "value_type": "String", + "value": "Array(Tuple(UInt64, UInt64))" + } + ], + "select": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Identifier", + "name": "type" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + }, + { + "type": "Identifier", + "name": "type" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6b3e74b985a6f4a4.sql b/tests/ast_json_fixtures/shapes/6b3e74b985a6f4a4.sql new file mode 100644 index 000000000000..20c4e9553483 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b3e74b985a6f4a4.sql @@ -0,0 +1,2 @@ +WITH map(1, '1234') AS value, 'Array(Tuple(UInt64, UInt64))' AS type +SELECT value, cast(value, type), cast(materialize(value), type) diff --git a/tests/ast_json_fixtures/shapes/6b428388355f0030.json b/tests/ast_json_fixtures/shapes/6b428388355f0030.json new file mode 100644 index 000000000000..9c8f6dd4cd16 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b428388355f0030.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "replicated_constraints1" + }, + "settings": { + "type": "Settings", + "changes": { + "alter_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_CONSTRAINT", + "constraint_declaration": { + "type": "Constraint", + "name": "b_constraint", + "constraint_type": "CHECK", + "expression": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6b428388355f0030.sql b/tests/ast_json_fixtures/shapes/6b428388355f0030.sql new file mode 100644 index 000000000000..8a4039ae327a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b428388355f0030.sql @@ -0,0 +1 @@ +ALTER TABLE replicated_constraints1 ADD CONSTRAINT b_constraint CHECK b > 10 SETTINGS alter_sync=2 diff --git a/tests/ast_json_fixtures/shapes/6b67d99d75d12015.json b/tests/ast_json_fixtures/shapes/6b67d99d75d12015.json new file mode 100644 index 000000000000..039acee2d4bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b67d99d75d12015.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q7_01297"], + "limits": [ + { + "duration_sec": "7889238", + "max": { + "QUERIES": "100", + "ERRORS": "11" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6b67d99d75d12015.sql b/tests/ast_json_fixtures/shapes/6b67d99d75d12015.sql new file mode 100644 index 000000000000..870b6518b4c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b67d99d75d12015.sql @@ -0,0 +1 @@ +CREATE QUOTA q7_01297 FOR 1 QUARTER MAX errors 11, queries 100 diff --git a/tests/ast_json_fixtures/shapes/6b6bb80de86f99b1.json b/tests/ast_json_fixtures/shapes/6b6bb80de86f99b1.json new file mode 100644 index 000000000000..db91666958fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b6bb80de86f99b1.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "union2" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_ORDER_BY", + "order_by": { + "type": "Identifier", + "name": "a" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6b6bb80de86f99b1.sql b/tests/ast_json_fixtures/shapes/6b6bb80de86f99b1.sql new file mode 100644 index 000000000000..6337e77cf784 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b6bb80de86f99b1.sql @@ -0,0 +1 @@ +ALTER TABLE union2 MODIFY ORDER BY a diff --git a/tests/ast_json_fixtures/shapes/6b7829609c016a4c.json b/tests/ast_json_fixtures/shapes/6b7829609c016a4c.json new file mode 100644 index 000000000000..fb4957b35917 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b7829609c016a4c.json @@ -0,0 +1,147 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "having": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "z" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "y", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "z", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6b7829609c016a4c.sql b/tests/ast_json_fixtures/shapes/6b7829609c016a4c.sql new file mode 100644 index 000000000000..0b42c1a3dde3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b7829609c016a4c.sql @@ -0,0 +1,4 @@ +SELECT toUInt64(1) x FROM (select 1) +GROUP BY 1 +HAVING x +IN ( SELECT countIf(y, z == 1) FROM (SELECT 1 y, 1 z) ) diff --git a/tests/ast_json_fixtures/shapes/6b858c8b020e01c1.json b/tests/ast_json_fixtures/shapes/6b858c8b020e01c1.json new file mode 100644 index 000000000000..93a425c22214 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b858c8b020e01c1.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "hosts": { + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6b858c8b020e01c1.sql b/tests/ast_json_fixtures/shapes/6b858c8b020e01c1.sql new file mode 100644 index 000000000000..630f705dc96b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b858c8b020e01c1.sql @@ -0,0 +1 @@ +ALTER USER u1_01292 HOST NONE diff --git a/tests/ast_json_fixtures/shapes/6b895b51e61ac778.json b/tests/ast_json_fixtures/shapes/6b895b51e61ac778.json new file mode 100644 index 000000000000..7b3eedb5e1e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b895b51e61ac778.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_STATISTICS", + "statistics_declaration": { + "type": "Stat", + "columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6b895b51e61ac778.sql b/tests/ast_json_fixtures/shapes/6b895b51e61ac778.sql new file mode 100644 index 000000000000..1a8b43f6f97a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b895b51e61ac778.sql @@ -0,0 +1 @@ +ALTER TABLE tab MATERIALIZE STATISTICS b diff --git a/tests/ast_json_fixtures/shapes/6b90e7fb4927e7a0.json b/tests/ast_json_fixtures/shapes/6b90e7fb4927e7a0.json new file mode 100644 index 000000000000..5f9debc99358 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b90e7fb4927e7a0.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_lazy_mat_prewhere_parallel" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6b90e7fb4927e7a0.sql b/tests/ast_json_fixtures/shapes/6b90e7fb4927e7a0.sql new file mode 100644 index 000000000000..cfae840639ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b90e7fb4927e7a0.sql @@ -0,0 +1 @@ +SELECT * FROM t_lazy_mat_prewhere_parallel PREWHERE d > 1 ORDER BY c LIMIT 3 diff --git a/tests/ast_json_fixtures/shapes/6b99ee903ebf5f17.json b/tests/ast_json_fixtures/shapes/6b99ee903ebf5f17.json new file mode 100644 index 000000000000..30ae1503c603 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b99ee903ebf5f17.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN QUERY TREE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "ab" + }, + { + "type": "Identifier", + "name": "bcd" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6b99ee903ebf5f17.sql b/tests/ast_json_fixtures/shapes/6b99ee903ebf5f17.sql new file mode 100644 index 000000000000..9222337f7bc9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b99ee903ebf5f17.sql @@ -0,0 +1 @@ +explain query tree select ab, bcd from test diff --git a/tests/ast_json_fixtures/shapes/6b9dde5eded1fd54.json b/tests/ast_json_fixtures/shapes/6b9dde5eded1fd54.json new file mode 100644 index 000000000000..acabaeb16630 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b9dde5eded1fd54.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "hello", + "name": "number" + }, + { + "type": "Function", + "alias": "world", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Identifier", + "name": "world" + } + ] + }, + { + "type": "Function", + "alias": "sometimes_nulls", + "name": "nullIf", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "5" + } + } + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/6b9dde5eded1fd54.sql b/tests/ast_json_fixtures/shapes/6b9dde5eded1fd54.sql new file mode 100644 index 000000000000..b8705431b704 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6b9dde5eded1fd54.sql @@ -0,0 +1 @@ +SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 10 SETTINGS max_block_size = 5 FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/6baa7404c2c8d204.json b/tests/ast_json_fixtures/shapes/6baa7404c2c8d204.json new file mode 100644 index 000000000000..cc6f8bdd134e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6baa7404c2c8d204.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6baa7404c2c8d204.sql b/tests/ast_json_fixtures/shapes/6baa7404c2c8d204.sql new file mode 100644 index 000000000000..0b34bc28f47b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6baa7404c2c8d204.sql @@ -0,0 +1 @@ +WITH t AS (SELECT 1) SELECT t, (SELECT * FROM t) FROM t diff --git a/tests/ast_json_fixtures/shapes/6bacb826fc696787.json b/tests/ast_json_fixtures/shapes/6bacb826fc696787.json new file mode 100644 index 000000000000..7402825ec75b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6bacb826fc696787.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["INSERT"], + "default_database": true, + "table": "foobar", + "wildcard": true, + "grant_option": true + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["user_03141"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6bacb826fc696787.sql b/tests/ast_json_fixtures/shapes/6bacb826fc696787.sql new file mode 100644 index 000000000000..55de0445ddbc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6bacb826fc696787.sql @@ -0,0 +1 @@ +GRANT INSERT ON foobar* TO user_03141 WITH GRANT OPTION diff --git a/tests/ast_json_fixtures/shapes/6bb2dcc7c018a887.json b/tests/ast_json_fixtures/shapes/6bb2dcc7c018a887.json new file mode 100644 index 000000000000..438473a30997 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6bb2dcc7c018a887.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "03720_deletes" + }, + "predicate": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6bb2dcc7c018a887.sql b/tests/ast_json_fixtures/shapes/6bb2dcc7c018a887.sql new file mode 100644 index 000000000000..632e2380c40f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6bb2dcc7c018a887.sql @@ -0,0 +1 @@ +DELETE FROM 03720_deletes WHERE k1 = 1 AND k2 = 1 diff --git a/tests/ast_json_fixtures/shapes/6bbbd901cea64540.json b/tests/ast_json_fixtures/shapes/6bbbd901cea64540.json new file mode 100644 index 000000000000..0af798d6e416 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6bbbd901cea64540.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u2_01292", "u3_01292", "u4_01292", "u5_01292@%.host.com", "u6_01292@%.host.com"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6bbbd901cea64540.sql b/tests/ast_json_fixtures/shapes/6bbbd901cea64540.sql new file mode 100644 index 000000000000..c1b1f78e356f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6bbbd901cea64540.sql @@ -0,0 +1 @@ +DROP USER u1_01292, u2_01292, u3_01292, u4_01292, u5_01292@'%.host.com', u6_01292@'%.host.com' diff --git a/tests/ast_json_fixtures/shapes/6c0593b8be72bec2.json b/tests/ast_json_fixtures/shapes/6c0593b8be72bec2.json new file mode 100644 index 000000000000..f2f033f4abbf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c0593b8be72bec2.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "mt_compact" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + "replace": false, + "from_table": "mt_compact_2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6c0593b8be72bec2.sql b/tests/ast_json_fixtures/shapes/6c0593b8be72bec2.sql new file mode 100644 index 000000000000..fee825d19bfe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c0593b8be72bec2.sql @@ -0,0 +1 @@ +alter table mt_compact attach partition 1 from mt_compact_2 diff --git a/tests/ast_json_fixtures/shapes/6c1763b02d27ffb6.json b/tests/ast_json_fixtures/shapes/6c1763b02d27ffb6.json new file mode 100644 index 000000000000..805d36dca0b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c1763b02d27ffb6.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ExistsDictionaryQuery", + "table": { + "type": "Identifier", + "name": "t_01048" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6c1763b02d27ffb6.sql b/tests/ast_json_fixtures/shapes/6c1763b02d27ffb6.sql new file mode 100644 index 000000000000..8e830ed7b826 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c1763b02d27ffb6.sql @@ -0,0 +1 @@ +EXISTS DICTIONARY t_01048 diff --git a/tests/ast_json_fixtures/shapes/6c2535662054c3e0.json b/tests/ast_json_fixtures/shapes/6c2535662054c3e0.json new file mode 100644 index 000000000000..25b5b4cd48e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c2535662054c3e0.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "distributed_push_down_limit": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6c2535662054c3e0.sql b/tests/ast_json_fixtures/shapes/6c2535662054c3e0.sql new file mode 100644 index 000000000000..540efa6d1470 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c2535662054c3e0.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number order by count(), number offset 1 settings distributed_push_down_limit=1 diff --git a/tests/ast_json_fixtures/shapes/6c286b4cdaf60ecd.json b/tests/ast_json_fixtures/shapes/6c286b4cdaf60ecd.json new file mode 100644 index 000000000000..cc6979066bab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c286b4cdaf60ecd.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u5_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "SHA256_PASSWORD", + "contains_hash": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "18138372FAD4B94533CD4881F03DC6C69296DD897234E0CEE83F727E2E6B1F63" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/6c286b4cdaf60ecd.sql b/tests/ast_json_fixtures/shapes/6c286b4cdaf60ecd.sql new file mode 100644 index 000000000000..ff4a01c72886 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c286b4cdaf60ecd.sql @@ -0,0 +1 @@ +CREATE USER u5_01292 IDENTIFIED WITH sha256_hash BY '18138372FAD4B94533CD4881F03DC6C69296DD897234E0CEE83F727E2E6B1F63' diff --git a/tests/ast_json_fixtures/shapes/6c34b65a98039716.json b/tests/ast_json_fixtures/shapes/6c34b65a98039716.json new file mode 100644 index 000000000000..b3ad39211e66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c34b65a98039716.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "arraySplit", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "toUInt8", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "toUInt8", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6c34b65a98039716.sql b/tests/ast_json_fixtures/shapes/6c34b65a98039716.sql new file mode 100644 index 000000000000..8d9d25692e16 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c34b65a98039716.sql @@ -0,0 +1 @@ +SELECT arraySplit(x -> toUInt8(number), []) from numbers(1) GROUP BY toUInt8(number) WITH ROLLUP SETTINGS group_by_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/6c35b9e1ab5ce728.json b/tests/ast_json_fixtures/shapes/6c35b9e1ab5ce728.json new file mode 100644 index 000000000000..481f12d2f8c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c35b9e1ab5ce728.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "partition_all2" + }, + "partition": { + "type": "Partition_ID", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6c35b9e1ab5ce728.sql b/tests/ast_json_fixtures/shapes/6c35b9e1ab5ce728.sql new file mode 100644 index 000000000000..b6af7d708bdc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c35b9e1ab5ce728.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE partition_all2 PARTITION ALL diff --git a/tests/ast_json_fixtures/shapes/6c376a0ad0a968c7.json b/tests/ast_json_fixtures/shapes/6c376a0ad0a968c7.json new file mode 100644 index 000000000000..114fdba93898 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c376a0ad0a968c7.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "s" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1%" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "query_8" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/6c376a0ad0a968c7.sql b/tests/ast_json_fixtures/shapes/6c376a0ad0a968c7.sql new file mode 100644 index 000000000000..5902c64be4ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c376a0ad0a968c7.sql @@ -0,0 +1 @@ +SELECT a, s FROM t WHERE s LIKE '1%' ORDER BY a DESC LIMIT 10 FORMAT Null SETTINGS log_comment='query_8' diff --git a/tests/ast_json_fixtures/shapes/6c457aef1f25bd43.json b/tests/ast_json_fixtures/shapes/6c457aef1f25bd43.json new file mode 100644 index 000000000000..69332a99fbdb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c457aef1f25bd43.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_structure" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "t", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "TupleDataType", + "name": "Tuple", + "arguments": [ + { + "type": "DataType", + "name": "UInt32" + }, + { + "type": "DataType", + "name": "UInt64" + } + ], + "element_names": ["x", "y"] + } + ] + } + } + ], + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "ratio_of_defaults_for_sparse_serialization": "0", + "nullable_serialization_version": "allow_sparse", + "min_bytes_for_wide_part": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6c457aef1f25bd43.sql b/tests/ast_json_fixtures/shapes/6c457aef1f25bd43.sql new file mode 100644 index 000000000000..46c4ab01a4cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c457aef1f25bd43.sql @@ -0,0 +1,5 @@ +CREATE TABLE test_structure ( + t Nullable(Tuple(x UInt32, y UInt64)), + PRIMARY KEY () +) ENGINE = MergeTree +SETTINGS ratio_of_defaults_for_sparse_serialization = 0, nullable_serialization_version = 'allow_sparse', min_bytes_for_wide_part = 0 diff --git a/tests/ast_json_fixtures/shapes/6c61f52f0b06e628.json b/tests/ast_json_fixtures/shapes/6c61f52f0b06e628.json new file mode 100644 index 000000000000..711adda39dd0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c61f52f0b06e628.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "RESTART REPLICA", + "table": { + "type": "Identifier", + "name": "rmt" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6c61f52f0b06e628.sql b/tests/ast_json_fixtures/shapes/6c61f52f0b06e628.sql new file mode 100644 index 000000000000..ebb0e12f04c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c61f52f0b06e628.sql @@ -0,0 +1 @@ +system restart replica rmt diff --git a/tests/ast_json_fixtures/shapes/6c78bb3390451025.json b/tests/ast_json_fixtures/shapes/6c78bb3390451025.json new file mode 100644 index 000000000000..25c3b13c6a8b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c78bb3390451025.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t0" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "APPLY_DELETED_MASK", + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6c78bb3390451025.sql b/tests/ast_json_fixtures/shapes/6c78bb3390451025.sql new file mode 100644 index 000000000000..7f28c4780360 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c78bb3390451025.sql @@ -0,0 +1 @@ +ALTER TABLE t0 APPLY DELETED MASK IN PARTITION ID '1' diff --git a/tests/ast_json_fixtures/shapes/6c7923428601722b.json b/tests/ast_json_fixtures/shapes/6c7923428601722b.json new file mode 100644 index 000000000000..808730c477fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c7923428601722b.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "03215_udf_with_union" + } +} diff --git a/tests/ast_json_fixtures/shapes/6c7923428601722b.sql b/tests/ast_json_fixtures/shapes/6c7923428601722b.sql new file mode 100644 index 000000000000..70b681f3a107 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c7923428601722b.sql @@ -0,0 +1 @@ +DROP FUNCTION 03215_udf_with_union diff --git a/tests/ast_json_fixtures/shapes/6c86a296de6e3002.json b/tests/ast_json_fixtures/shapes/6c86a296de6e3002.json new file mode 100644 index 000000000000..abb352e65879 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c86a296de6e3002.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_STATISTICS", + "statistics_declaration": { + "type": "Stat", + "columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6c86a296de6e3002.sql b/tests/ast_json_fixtures/shapes/6c86a296de6e3002.sql new file mode 100644 index 000000000000..3fc8e28ac424 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c86a296de6e3002.sql @@ -0,0 +1 @@ +ALTER TABLE tab DROP STATISTICS b diff --git a/tests/ast_json_fixtures/shapes/6c90d8ee01dccc56.json b/tests/ast_json_fixtures/shapes/6c90d8ee01dccc56.json new file mode 100644 index 000000000000..6cd8cdd07a78 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c90d8ee01dccc56.json @@ -0,0 +1,276 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "orig", + "value_type": "String", + "value": "абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ" + }, + { + "type": "Function", + "alias": "cp1251_hex", + "name": "hex", + "arguments": [ + { + "type": "Function", + "alias": "cp1251", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "orig" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf-8" + }, + { + "type": "Literal", + "value_type": "String", + "value": "cp1251" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "utf7_hex", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "orig" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf-8" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf-7" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "bocu1_hex", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "orig" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf-8" + }, + { + "type": "Literal", + "value_type": "String", + "value": "bocu-1" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "scsu_hex", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "orig" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf-8" + }, + { + "type": "Literal", + "value_type": "String", + "value": "scsu" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "orig2", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "cp1251" + }, + { + "type": "Literal", + "value_type": "String", + "value": "cp1251" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf-8" + } + ] + }, + { + "type": "Function", + "alias": "broken1", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "orig" + }, + { + "type": "Literal", + "value_type": "String", + "value": "cp1251" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf8" + } + ] + }, + { + "type": "Function", + "alias": "broken2", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "orig" + }, + { + "type": "Literal", + "value_type": "String", + "value": "latin1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf8" + } + ] + }, + { + "type": "Function", + "alias": "broken3", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "orig" + }, + { + "type": "Literal", + "value_type": "String", + "value": "koi8-r" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf8" + } + ] + }, + { + "type": "Function", + "alias": "restored1", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "broken1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf-8" + }, + { + "type": "Literal", + "value_type": "String", + "value": "cp1251" + } + ] + }, + { + "type": "Function", + "alias": "restored2", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "broken2" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf-8" + }, + { + "type": "Literal", + "value_type": "String", + "value": "latin1" + } + ] + }, + { + "type": "Function", + "alias": "restored3", + "name": "convertCharset", + "arguments": [ + { + "type": "Identifier", + "name": "broken3" + }, + { + "type": "Literal", + "value_type": "String", + "value": "utf-8" + }, + { + "type": "Literal", + "value_type": "String", + "value": "koi8-r" + } + ] + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/6c90d8ee01dccc56.sql b/tests/ast_json_fixtures/shapes/6c90d8ee01dccc56.sql new file mode 100644 index 000000000000..b4ab7bc4dad5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6c90d8ee01dccc56.sql @@ -0,0 +1,14 @@ +SELECT + 'абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ' AS orig, + hex(convertCharset(orig, 'utf-8', 'cp1251') AS cp1251) AS cp1251_hex, + hex(convertCharset(orig, 'utf-8', 'utf-7')) AS utf7_hex, + hex(convertCharset(orig, 'utf-8', 'bocu-1')) AS bocu1_hex, + hex(convertCharset(orig, 'utf-8', 'scsu')) AS scsu_hex, + convertCharset(cp1251, 'cp1251', 'utf-8') AS orig2, + convertCharset(orig, 'cp1251', 'utf8') AS broken1, + convertCharset(orig, 'latin1', 'utf8') AS broken2, + convertCharset(orig, 'koi8-r', 'utf8') AS broken3, + convertCharset(broken1, 'utf-8', 'cp1251') AS restored1, + convertCharset(broken2, 'utf-8', 'latin1') AS restored2, + convertCharset(broken3, 'utf-8', 'koi8-r') AS restored3 +FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/6cb1d1e4fe341e50.json b/tests/ast_json_fixtures/shapes/6cb1d1e4fe341e50.json new file mode 100644 index 000000000000..882c540d8676 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6cb1d1e4fe341e50.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_alter_attach_01901D" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "2020-01-01" + } + }, + "replace": true, + "from_table": "test_alter_attach_01901S" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6cb1d1e4fe341e50.sql b/tests/ast_json_fixtures/shapes/6cb1d1e4fe341e50.sql new file mode 100644 index 000000000000..e41aaa6b0386 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6cb1d1e4fe341e50.sql @@ -0,0 +1 @@ +ALTER TABLE test_alter_attach_01901D REPLACE PARTITION '2020-01-01' FROM test_alter_attach_01901S diff --git a/tests/ast_json_fixtures/shapes/6cc2b541b9738e76.json b/tests/ast_json_fixtures/shapes/6cc2b541b9738e76.json new file mode 100644 index 000000000000..5d287c0bdfc5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6cc2b541b9738e76.json @@ -0,0 +1,104 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "name": "groupArrayMovingAvg", + "arguments": [ + { + "type": "Identifier", + "name": "v" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "moving_sum_num" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "dt" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TabSeparatedWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/6cc2b541b9738e76.sql b/tests/ast_json_fixtures/shapes/6cc2b541b9738e76.sql new file mode 100644 index 000000000000..d03658bcdf3e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6cc2b541b9738e76.sql @@ -0,0 +1 @@ +SELECT k, groupArrayMovingAvg(v) FROM (SELECT * FROM moving_sum_num ORDER BY k, dt) GROUP BY k ORDER BY k FORMAT TabSeparatedWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/6ce7727bb253fa15.json b/tests/ast_json_fixtures/shapes/6ce7727bb253fa15.json new file mode 100644 index 000000000000..38383850225b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ce7727bb253fa15.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "mm", + "expression": { + "type": "Function", + "name": "LOG2", + "arguments": [ + { + "type": "Identifier", + "name": "i" + } + ] + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Function", + "name": "MAX", + "arguments": [ + { + "type": "Identifier", + "name": "i" + } + ] + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/clickhouse\/tables\/{database}\/x" + }, + { + "type": "Literal", + "value_type": "String", + "value": "r" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "i" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6ce7727bb253fa15.sql b/tests/ast_json_fixtures/shapes/6ce7727bb253fa15.sql new file mode 100644 index 000000000000..923ea27b88a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ce7727bb253fa15.sql @@ -0,0 +1 @@ +create table x(i int, index mm LOG2(i) type minmax granularity 1, projection p (select MAX(i))) engine ReplicatedMergeTree('/clickhouse/tables/{database}/x', 'r') order by i diff --git a/tests/ast_json_fixtures/shapes/6cebc531e2c1c317.json b/tests/ast_json_fixtures/shapes/6cebc531e2c1c317.json new file mode 100644 index 000000000000..40b4c9d57b5c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6cebc531e2c1c317.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "d", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "c", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "format": "TSKV" + } +} diff --git a/tests/ast_json_fixtures/shapes/6cebc531e2c1c317.sql b/tests/ast_json_fixtures/shapes/6cebc531e2c1c317.sql new file mode 100644 index 000000000000..f8170832bcae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6cebc531e2c1c317.sql @@ -0,0 +1 @@ +SELECT (0 as a) ? (2 as b) : (3 as c) as d, a, b, c, d FORMAT TSKV diff --git a/tests/ast_json_fixtures/shapes/6cfb94bbe57d6ce0.json b/tests/ast_json_fixtures/shapes/6cfb94bbe57d6ce0.json new file mode 100644 index 000000000000..b0b4b70360fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6cfb94bbe57d6ce0.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "category" + }, + { + "type": "Identifier", + "name": "value" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_all" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "200" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "category" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6cfb94bbe57d6ce0.sql b/tests/ast_json_fixtures/shapes/6cfb94bbe57d6ce0.sql new file mode 100644 index 000000000000..6025180d4780 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6cfb94bbe57d6ce0.sql @@ -0,0 +1,5 @@ +SELECT id, category, value +FROM test_limit_by_all +WHERE value > 200 +ORDER BY id, category, value +LIMIT 1 BY ALL diff --git a/tests/ast_json_fixtures/shapes/6d03d5b94eb43a35.json b/tests/ast_json_fixtures/shapes/6d03d5b94eb43a35.json new file mode 100644 index 000000000000..995c1ffe2d37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d03d5b94eb43a35.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "s", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6d03d5b94eb43a35.sql b/tests/ast_json_fixtures/shapes/6d03d5b94eb43a35.sql new file mode 100644 index 000000000000..d32eeff3486b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d03d5b94eb43a35.sql @@ -0,0 +1 @@ +with x + y as s select x, y from tab where s = 2 diff --git a/tests/ast_json_fixtures/shapes/6d0a813bca2db665.json b/tests/ast_json_fixtures/shapes/6d0a813bca2db665.json new file mode 100644 index 000000000000..7e7710e48d7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d0a813bca2db665.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "fuzzQuery", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "SELECT *\nFROM (\n SELECT\n ([toString(number % 2)] :: Array(LowCardinality(String))) AS item_id,\n count()\n FROM numbers(3)\n GROUP BY item_id WITH TOTALS\n) AS l FULL JOIN (\n SELECT\n ([toString((number % 2) * 2)] :: Array(String)) AS item_id\n FROM numbers(3)\n) AS r\nON l.item_id = r.item_id\nORDER BY 1,2,3;\n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "500" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8956" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "NULL" + } +} diff --git a/tests/ast_json_fixtures/shapes/6d0a813bca2db665.sql b/tests/ast_json_fixtures/shapes/6d0a813bca2db665.sql new file mode 100644 index 000000000000..07580fc93782 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d0a813bca2db665.sql @@ -0,0 +1,15 @@ +SELECT * FROM fuzzQuery('SELECT * +FROM ( + SELECT + ([toString(number % 2)] :: Array(LowCardinality(String))) AS item_id, + count() + FROM numbers(3) + GROUP BY item_id WITH TOTALS +) AS l FULL JOIN ( + SELECT + ([toString((number % 2) * 2)] :: Array(String)) AS item_id + FROM numbers(3) +) AS r +ON l.item_id = r.item_id +ORDER BY 1,2,3; +', 500, 8956) LIMIT 10 FORMAT NULL diff --git a/tests/ast_json_fixtures/shapes/6d2a3927dfd1e751.json b/tests/ast_json_fixtures/shapes/6d2a3927dfd1e751.json new file mode 100644 index 000000000000..7f8d54e954d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d2a3927dfd1e751.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_clone_as": true, + "table": { + "type": "Identifier", + "name": "clone_as_foo_replicated_merge_tree_p_x" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/clickhouse\/tables\/{database}\/clone_as_foo_replicated_merge_tree_p_x" + }, + { + "type": "Literal", + "value_type": "String", + "value": "r1" + } + ] + }, + "primary_key": { + "type": "Identifier", + "name": "x" + } + }, + "as_table": "foo_replicated_merge_tree" + } +} diff --git a/tests/ast_json_fixtures/shapes/6d2a3927dfd1e751.sql b/tests/ast_json_fixtures/shapes/6d2a3927dfd1e751.sql new file mode 100644 index 000000000000..bca5a0758dab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d2a3927dfd1e751.sql @@ -0,0 +1 @@ +CREATE TABLE clone_as_foo_replicated_merge_tree_p_x CLONE AS foo_replicated_merge_tree ENGINE=ReplicatedMergeTree('/clickhouse/tables/{database}/clone_as_foo_replicated_merge_tree_p_x', 'r1') PRIMARY KEY x diff --git a/tests/ast_json_fixtures/shapes/6d3ca991bb7bab13.json b/tests/ast_json_fixtures/shapes/6d3ca991bb7bab13.json new file mode 100644 index 000000000000..56460664d1e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d3ca991bb7bab13.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_rollup": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "rollup" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6d3ca991bb7bab13.sql b/tests/ast_json_fixtures/shapes/6d3ca991bb7bab13.sql new file mode 100644 index 000000000000..bcfdf37a8fdc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d3ca991bb7bab13.sql @@ -0,0 +1 @@ +SELECT a, sum(s), count() from rollup GROUP BY a WITH ROLLUP WITH TOTALS ORDER BY a diff --git a/tests/ast_json_fixtures/shapes/6d47e966e58343b3.json b/tests/ast_json_fixtures/shapes/6d47e966e58343b3.json new file mode 100644 index 000000000000..3eda897c42fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d47e966e58343b3.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02483_plusone" + } +} diff --git a/tests/ast_json_fixtures/shapes/6d47e966e58343b3.sql b/tests/ast_json_fixtures/shapes/6d47e966e58343b3.sql new file mode 100644 index 000000000000..0b53227c9230 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d47e966e58343b3.sql @@ -0,0 +1 @@ +DROP FUNCTION 02483_plusone diff --git a/tests/ast_json_fixtures/shapes/6d7a1ae488bebe44.json b/tests/ast_json_fixtures/shapes/6d7a1ae488bebe44.json new file mode 100644 index 000000000000..8726ac56d754 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d7a1ae488bebe44.json @@ -0,0 +1,114 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "arraySort", + "arguments": [ + { + "type": "Identifier", + "name": "used_data_type_families" + } + ] + }, + { + "type": "Identifier", + "name": "used_storages" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryFinish" + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%TABLE test%" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "query_start_time" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "TabSeparatedWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/6d7a1ae488bebe44.sql b/tests/ast_json_fixtures/shapes/6d7a1ae488bebe44.sql new file mode 100644 index 000000000000..1834d8515580 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d7a1ae488bebe44.sql @@ -0,0 +1,4 @@ +SELECT arraySort(used_data_type_families), used_storages +FROM system.query_log +WHERE current_database = currentDatabase() AND type == 'QueryFinish' AND (query LIKE '%TABLE test%') +ORDER BY query_start_time DESC LIMIT 1 FORMAT TabSeparatedWithNames diff --git a/tests/ast_json_fixtures/shapes/6d8ae0c84a2bff9b.json b/tests/ast_json_fixtures/shapes/6d8ae0c84a2bff9b.json new file mode 100644 index 000000000000..aca7d58d4f94 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d8ae0c84a2bff9b.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateViewQuery", + "table": { + "type": "Identifier", + "name": "prices_by_year_view" + }, + "settings": { + "type": "Settings", + "changes": { + "show_create_query_identifier_quoting_rule": "always", + "show_create_query_identifier_quoting_style": "Backticks" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6d8ae0c84a2bff9b.sql b/tests/ast_json_fixtures/shapes/6d8ae0c84a2bff9b.sql new file mode 100644 index 000000000000..ad392a8775fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d8ae0c84a2bff9b.sql @@ -0,0 +1,4 @@ +SHOW CREATE VIEW prices_by_year_view +SETTINGS + show_create_query_identifier_quoting_rule='always', + show_create_query_identifier_quoting_style='Backticks' diff --git a/tests/ast_json_fixtures/shapes/6d9002bc8bb65dd3.json b/tests/ast_json_fixtures/shapes/6d9002bc8bb65dd3.json new file mode 100644 index 000000000000..8432d91c2a32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d9002bc8bb65dd3.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettyNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/6d9002bc8bb65dd3.sql b/tests/ast_json_fixtures/shapes/6d9002bc8bb65dd3.sql new file mode 100644 index 000000000000..db8811b0409d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d9002bc8bb65dd3.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettyNoEscapes diff --git a/tests/ast_json_fixtures/shapes/6d9089d01c893855.json b/tests/ast_json_fixtures/shapes/6d9089d01c893855.json new file mode 100644 index 000000000000..79c0a6042017 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d9089d01c893855.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "with": [ + { + "type": "WithElement", + "name": "cte_4", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "c_2_c2398_0", + "name": "rank", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_name": "w0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "ref_15", + "name": "t3" + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w0", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "ref_15.c_2_c16_0", + "name_parts": ["ref_15", "c_2_c16_0"] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ref_15.c_2_c16_0", + "name_parts": ["ref_15", "c_2_c16_0"] + }, + "direction": "DESC" + } + ] + } + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "alias": "c_9_c2479_0", + "name": "ref_39.c_2_c2398_0", + "name_parts": ["ref_39", "c_2_c2398_0"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "ref_39", + "name": "cte_4" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6d9089d01c893855.sql b/tests/ast_json_fixtures/shapes/6d9089d01c893855.sql new file mode 100644 index 000000000000..c0a62e5b4b15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d9089d01c893855.sql @@ -0,0 +1,9 @@ +with cte_4 as (select + rank() over w0 as c_2_c2398_0 + from + t3 as ref_15 + window w0 as (partition by ref_15.c_2_c16_0 order by ref_15.c_2_c16_0 desc)) +select distinct + ref_39.c_2_c2398_0 as c_9_c2479_0 + from + cte_4 as ref_39 diff --git a/tests/ast_json_fixtures/shapes/6d98f06bf5bffc76.json b/tests/ast_json_fixtures/shapes/6d98f06bf5bffc76.json new file mode 100644 index 000000000000..82f2549d7228 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d98f06bf5bffc76.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettyCompactNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/6d98f06bf5bffc76.sql b/tests/ast_json_fixtures/shapes/6d98f06bf5bffc76.sql new file mode 100644 index 000000000000..43c988588f28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d98f06bf5bffc76.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettyCompactNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/6d9bfe4e58faebf5.json b/tests/ast_json_fixtures/shapes/6d9bfe4e58faebf5.json new file mode 100644 index 000000000000..41a0558c12a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d9bfe4e58faebf5.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "ttl_00933_1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Log", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6d9bfe4e58faebf5.sql b/tests/ast_json_fixtures/shapes/6d9bfe4e58faebf5.sql new file mode 100644 index 000000000000..5e37609af85b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6d9bfe4e58faebf5.sql @@ -0,0 +1 @@ +create table ttl_00933_1 (d DateTime, a Int) engine = Log ttl d + interval 1 day diff --git a/tests/ast_json_fixtures/shapes/6dadaafb1f0ef593.json b/tests/ast_json_fixtures/shapes/6dadaafb1f0ef593.json new file mode 100644 index 000000000000..72b68e348521 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6dadaafb1f0ef593.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q4_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6dadaafb1f0ef593.sql b/tests/ast_json_fixtures/shapes/6dadaafb1f0ef593.sql new file mode 100644 index 000000000000..a037093464c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6dadaafb1f0ef593.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q4_01297 diff --git a/tests/ast_json_fixtures/shapes/6dbf7537780c7dd2.json b/tests/ast_json_fixtures/shapes/6dbf7537780c7dd2.json new file mode 100644 index 000000000000..73f8e180dfaa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6dbf7537780c7dd2.json @@ -0,0 +1,95 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "subquery", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "subquery" + } + } + } + ] + } + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6dbf7537780c7dd2.sql b/tests/ast_json_fixtures/shapes/6dbf7537780c7dd2.sql new file mode 100644 index 000000000000..7f2d432bbf92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6dbf7537780c7dd2.sql @@ -0,0 +1 @@ +WITH subquery AS (SELECT sum(number) FROM numbers(10)) SELECT (SELECT * FROM subquery) diff --git a/tests/ast_json_fixtures/shapes/6dd284f4335623b1.json b/tests/ast_json_fixtures/shapes/6dd284f4335623b1.json new file mode 100644 index 000000000000..516e368cd87d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6dd284f4335623b1.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "A" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6dd284f4335623b1.sql b/tests/ast_json_fixtures/shapes/6dd284f4335623b1.sql new file mode 100644 index 000000000000..836b8be136c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6dd284f4335623b1.sql @@ -0,0 +1 @@ +DROP TABLE A diff --git a/tests/ast_json_fixtures/shapes/6dd7ad80bc7755bf.json b/tests/ast_json_fixtures/shapes/6dd7ad80bc7755bf.json new file mode 100644 index 000000000000..78a4a82ebf31 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6dd7ad80bc7755bf.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "yesterday", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "memory_usage" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 100000000 + } + ] + } + ] + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/6dd7ad80bc7755bf.sql b/tests/ast_json_fixtures/shapes/6dd7ad80bc7755bf.sql new file mode 100644 index 000000000000..a60a2bac7a66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6dd7ad80bc7755bf.sql @@ -0,0 +1 @@ +SELECT * FROM system.query_log WHERE event_date >= yesterday() AND current_database = currentDatabase() AND memory_usage > 100e6 FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/6df191c278c5d819.json b/tests/ast_json_fixtures/shapes/6df191c278c5d819.json new file mode 100644 index 000000000000..706419c1ca73 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6df191c278c5d819.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "limit_by" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "val" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6df191c278c5d819.sql b/tests/ast_json_fixtures/shapes/6df191c278c5d819.sql new file mode 100644 index 000000000000..e7a850366962 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6df191c278c5d819.sql @@ -0,0 +1 @@ +select * from limit_by order by id, val limit 1, 2 by id limit 3 offset 1 diff --git a/tests/ast_json_fixtures/shapes/6df56cc285ddd212.json b/tests/ast_json_fixtures/shapes/6df56cc285ddd212.json new file mode 100644 index 000000000000..5882a89b54dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6df56cc285ddd212.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6df56cc285ddd212.sql b/tests/ast_json_fixtures/shapes/6df56cc285ddd212.sql new file mode 100644 index 000000000000..c445b31d145b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6df56cc285ddd212.sql @@ -0,0 +1 @@ +SHOW CREATE USER u1_01292 diff --git a/tests/ast_json_fixtures/shapes/6e0c79790a077ba6.json b/tests/ast_json_fixtures/shapes/6e0c79790a077ba6.json new file mode 100644 index 000000000000..79a847eaaf92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e0c79790a077ba6.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u4_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6e0c79790a077ba6.sql b/tests/ast_json_fixtures/shapes/6e0c79790a077ba6.sql new file mode 100644 index 000000000000..2e879fe4c76f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e0c79790a077ba6.sql @@ -0,0 +1 @@ +SHOW CREATE USER u4_01292 diff --git a/tests/ast_json_fixtures/shapes/6e1061cdd6d995d9.json b/tests/ast_json_fixtures/shapes/6e1061cdd6d995d9.json new file mode 100644 index 000000000000..06c58ef0d11a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e1061cdd6d995d9.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "� �" + } + ] + } + ], + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/6e1061cdd6d995d9.sql b/tests/ast_json_fixtures/shapes/6e1061cdd6d995d9.sql new file mode 100644 index 000000000000..7143b19f01d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e1061cdd6d995d9.sql @@ -0,0 +1 @@ +SELECT '\xED\x20\xA8' AS s FORMAT JSON diff --git a/tests/ast_json_fixtures/shapes/6e16a7af21892f16.json b/tests/ast_json_fixtures/shapes/6e16a7af21892f16.json new file mode 100644 index 000000000000..f3cb4b7ecdc0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e16a7af21892f16.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_STATISTICS", + "clear_statistics": true, + "if_exists": true, + "statistics_declaration": { + "type": "Stat", + "columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "s" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6e16a7af21892f16.sql b/tests/ast_json_fixtures/shapes/6e16a7af21892f16.sql new file mode 100644 index 000000000000..ac5b057f6fbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e16a7af21892f16.sql @@ -0,0 +1 @@ +ALTER TABLE tab CLEAR STATISTICS IF EXISTS s diff --git a/tests/ast_json_fixtures/shapes/6e21c972c7367d76.json b/tests/ast_json_fixtures/shapes/6e21c972c7367d76.json new file mode 100644 index 000000000000..5f1ca6cb07f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e21c972c7367d76.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CheckQuery", + "table": { + "type": "Identifier", + "name": "check_query_tiny_log" + }, + "part_name": "all_0_0_0" + } +} diff --git a/tests/ast_json_fixtures/shapes/6e21c972c7367d76.sql b/tests/ast_json_fixtures/shapes/6e21c972c7367d76.sql new file mode 100644 index 000000000000..ecfc45d12783 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e21c972c7367d76.sql @@ -0,0 +1 @@ +CHECK TABLE check_query_tiny_log PART 'all_0_0_0' diff --git a/tests/ast_json_fixtures/shapes/6e3a12d50377c0fa.json b/tests/ast_json_fixtures/shapes/6e3a12d50377c0fa.json new file mode 100644 index 000000000000..1d460f47bf53 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e3a12d50377c0fa.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateTableQuery", + "table": { + "type": "Identifier", + "name": "t" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6e3a12d50377c0fa.sql b/tests/ast_json_fixtures/shapes/6e3a12d50377c0fa.sql new file mode 100644 index 000000000000..087aab236502 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e3a12d50377c0fa.sql @@ -0,0 +1 @@ +SHOW CREATE t diff --git a/tests/ast_json_fixtures/shapes/6e528ff042cd8f5c.json b/tests/ast_json_fixtures/shapes/6e528ff042cd8f5c.json new file mode 100644 index 000000000000..d208ba4b8e0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e528ff042cd8f5c.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "m" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Log", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6e528ff042cd8f5c.sql b/tests/ast_json_fixtures/shapes/6e528ff042cd8f5c.sql new file mode 100644 index 000000000000..2ce7394951c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e528ff042cd8f5c.sql @@ -0,0 +1 @@ +create table m (a int) engine Log diff --git a/tests/ast_json_fixtures/shapes/6e6a65c3671cb0bd.json b/tests/ast_json_fixtures/shapes/6e6a65c3671cb0bd.json new file mode 100644 index 000000000000..955215248907 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e6a65c3671cb0bd.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "arr" + } + ] + }, + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_column_names" + } + } + } + ] + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/6e6a65c3671cb0bd.sql b/tests/ast_json_fixtures/shapes/6e6a65c3671cb0bd.sql new file mode 100644 index 000000000000..138fa4ec6c20 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e6a65c3671cb0bd.sql @@ -0,0 +1 @@ +SELECT length(arr), isNull(n) FROM t_column_names FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/6e862947969f38cd.json b/tests/ast_json_fixtures/shapes/6e862947969f38cd.json new file mode 100644 index 000000000000..2de27225fb82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e862947969f38cd.json @@ -0,0 +1,1063 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "top_repos", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_DISTINCT", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "github_events" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "WatchEvent" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [] + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "github_events" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "WatchEvent" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toMonday", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + { + "type": "Function", + "name": "toMonday", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + }, + { + "type": "Function", + "name": "toIntervalWeek", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [] + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "github_events" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "WatchEvent" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toStartOfMonth", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toStartOfMonth", + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [] + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "github_events" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "WatchEvent" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toYear", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toYear", + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [] + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "last_day", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "repo_name" + }, + { + "type": "Function", + "alias": "count_last_day", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "alias": "position_last_day", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rowNumberInAllBlocks", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "github_events" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "repo_name" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "top_repos" + } + } + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "count_last_day" + }, + "direction": "DESC" + } + ] + } + ] + } + } + }, + { + "type": "WithElement", + "name": "last_week", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "repo_name" + }, + { + "type": "Function", + "alias": "count_last_week", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "alias": "position_last_week", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rowNumberInAllBlocks", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "github_events" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "repo_name" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "top_repos" + } + } + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toMonday", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toMonday", + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "toIntervalWeek", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "count_last_week" + }, + "direction": "DESC" + } + ] + } + ] + } + } + }, + { + "type": "WithElement", + "name": "last_month", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "repo_name" + }, + { + "type": "Function", + "alias": "count_last_month", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "alias": "position_last_month", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rowNumberInAllBlocks", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "github_events" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "repo_name" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "top_repos" + } + } + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toStartOfMonth", + "arguments": [ + { + "type": "Identifier", + "name": "created_at" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toStartOfMonth", + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "repo_name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "count_last_month" + }, + "direction": "DESC" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "d.repo_name", + "name_parts": ["d", "repo_name"] + }, + { + "type": "ColumnsRegexpMatcher", + "pattern": "count" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "d", + "name": "last_day" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d.repo_name", + "name_parts": ["d", "repo_name"] + }, + { + "type": "Identifier", + "name": "w.repo_name", + "name_parts": ["w", "repo_name"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "w", + "name": "last_week" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d.repo_name", + "name_parts": ["d", "repo_name"] + }, + { + "type": "Identifier", + "name": "m.repo_name", + "name_parts": ["m", "repo_name"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "m", + "name": "last_month" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6e862947969f38cd.sql b/tests/ast_json_fixtures/shapes/6e862947969f38cd.sql new file mode 100644 index 000000000000..3ddd1cb1d5fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e862947969f38cd.sql @@ -0,0 +1,6 @@ +with + top_repos as ( select repo_name from github_events where event_type = 'WatchEvent' and toDate(created_at) = today() - 1 group by repo_name order by count() desc limit 100 union distinct select repo_name from github_events where event_type = 'WatchEvent' and toMonday(created_at) = toMonday(today() - interval 1 week) group by repo_name order by count() desc limit 100 union distinct select repo_name from github_events where event_type = 'WatchEvent' and toStartOfMonth(created_at) = toStartOfMonth(today()) - interval 1 month group by repo_name order by count() desc limit 100 union distinct select repo_name from github_events where event_type = 'WatchEvent' and toYear(created_at) = toYear(today()) - 1 group by repo_name order by count() desc limit 100 ), + last_day as ( select repo_name, count() as count_last_day, rowNumberInAllBlocks() + 1 as position_last_day from github_events where repo_name in (select repo_name from top_repos) and toDate(created_at) = today() - 1 group by repo_name order by count_last_day desc ), + last_week as ( select repo_name, count() as count_last_week, rowNumberInAllBlocks() + 1 as position_last_week from github_events where repo_name in (select repo_name from top_repos) and toMonday(created_at) = toMonday(today()) - interval 1 week group by repo_name order by count_last_week desc ), + last_month as ( select repo_name, count() as count_last_month, rowNumberInAllBlocks() + 1 as position_last_month from github_events where repo_name in (select repo_name from top_repos) and toStartOfMonth(created_at) = toStartOfMonth(today()) - interval 1 month group by repo_name order by count_last_month desc ) +select d.repo_name, columns('count') from last_day d join last_week w on d.repo_name = w.repo_name join last_month m on d.repo_name = m.repo_name diff --git a/tests/ast_json_fixtures/shapes/6e9b8ecb46c02899.json b/tests/ast_json_fixtures/shapes/6e9b8ecb46c02899.json new file mode 100644 index 000000000000..116a1ec57332 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e9b8ecb46c02899.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "alias": "x", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "array", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "array", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6e9b8ecb46c02899.sql b/tests/ast_json_fixtures/shapes/6e9b8ecb46c02899.sql new file mode 100644 index 000000000000..6dcc7e50c1e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6e9b8ecb46c02899.sql @@ -0,0 +1 @@ +select tuple(array(number)) as x FROM numbers(10) GROUP BY number, array(number) WITH ROLLUP order by x diff --git a/tests/ast_json_fixtures/shapes/6eb0d6dae55ac679.json b/tests/ast_json_fixtures/shapes/6eb0d6dae55ac679.json new file mode 100644 index 000000000000..d5e0f1cb492c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6eb0d6dae55ac679.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "uuid": "3bd68e3c-2693-4352-ad66-a66eba9e345e", + "table": { + "type": "Identifier", + "name": ".inner_id.e15f3ab5-6cae-4df3-b879-f40deafd82c2" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "n2", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "n" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6eb0d6dae55ac679.sql b/tests/ast_json_fixtures/shapes/6eb0d6dae55ac679.sql new file mode 100644 index 000000000000..932631abf438 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6eb0d6dae55ac679.sql @@ -0,0 +1 @@ +CREATE TABLE ".inner_id.e15f3ab5-6cae-4df3-b879-f40deafd82c2" UUID '3bd68e3c-2693-4352-ad66-a66eba9e345e' (n Int32, n2 Int64) ENGINE = MergeTree PARTITION BY n % 10 ORDER BY n diff --git a/tests/ast_json_fixtures/shapes/6ec20d493fe84b37.json b/tests/ast_json_fixtures/shapes/6ec20d493fe84b37.json new file mode 100644 index 000000000000..07efee047225 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ec20d493fe84b37.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0__fuzz_29" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "using": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1__fuzz_4" + } + } + } + ] + }, + "prewhere": { + "type": "Literal", + "value_type": "Null", + "value": null + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6ec20d493fe84b37.sql b/tests/ast_json_fixtures/shapes/6ec20d493fe84b37.sql new file mode 100644 index 000000000000..c22ee44fb5fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ec20d493fe84b37.sql @@ -0,0 +1 @@ +SELECT sum(0), NULL FROM t0__fuzz_29 FULL OUTER JOIN t1__fuzz_4 USING (x) PREWHERE NULL diff --git a/tests/ast_json_fixtures/shapes/6ed8331f9940f36a.json b/tests/ast_json_fixtures/shapes/6ed8331f9940f36a.json new file mode 100644 index 000000000000..afdb2c166f30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ed8331f9940f36a.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u13_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/6ed8331f9940f36a.sql b/tests/ast_json_fixtures/shapes/6ed8331f9940f36a.sql new file mode 100644 index 000000000000..b9c1d78fac56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ed8331f9940f36a.sql @@ -0,0 +1 @@ +SHOW CREATE USER u13_01292 diff --git a/tests/ast_json_fixtures/shapes/6ef39e559ff26f47.json b/tests/ast_json_fixtures/shapes/6ef39e559ff26f47.json new file mode 100644 index 000000000000..de8a4f9240af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ef39e559ff26f47.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "udf", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/6ef39e559ff26f47.sql b/tests/ast_json_fixtures/shapes/6ef39e559ff26f47.sql new file mode 100644 index 000000000000..bdd973484ca5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ef39e559ff26f47.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS udf diff --git a/tests/ast_json_fixtures/shapes/6f1123f5873226c6.json b/tests/ast_json_fixtures/shapes/6f1123f5873226c6.json new file mode 100644 index 000000000000..200cdbe8269e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f1123f5873226c6.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropWorkloadQuery", + "workload_name": "all" + } +} diff --git a/tests/ast_json_fixtures/shapes/6f1123f5873226c6.sql b/tests/ast_json_fixtures/shapes/6f1123f5873226c6.sql new file mode 100644 index 000000000000..c41ea6207982 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f1123f5873226c6.sql @@ -0,0 +1 @@ +DROP WORKLOAD all diff --git a/tests/ast_json_fixtures/shapes/6f29fb3afb791ff0.json b/tests/ast_json_fixtures/shapes/6f29fb3afb791ff0.json new file mode 100644 index 000000000000..a1ff344b6dca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f29fb3afb791ff0.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u7_01292" + } + ] + }, + "hosts": { + "name_regexps": [".*\\.myhost\\.com"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6f29fb3afb791ff0.sql b/tests/ast_json_fixtures/shapes/6f29fb3afb791ff0.sql new file mode 100644 index 000000000000..19532f143461 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f29fb3afb791ff0.sql @@ -0,0 +1 @@ +CREATE USER u7_01292 HOST REGEXP '.*\\.myhost\\.com' diff --git a/tests/ast_json_fixtures/shapes/6f4ef21e631b5c23.json b/tests/ast_json_fixtures/shapes/6f4ef21e631b5c23.json new file mode 100644 index 000000000000..707f67608213 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f4ef21e631b5c23.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "mut" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DELETE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6f4ef21e631b5c23.sql b/tests/ast_json_fixtures/shapes/6f4ef21e631b5c23.sql new file mode 100644 index 000000000000..344c8169908e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f4ef21e631b5c23.sql @@ -0,0 +1 @@ +alter table mut delete where n = 10 diff --git a/tests/ast_json_fixtures/shapes/6f595bbeba71df67.json b/tests/ast_json_fixtures/shapes/6f595bbeba71df67.json new file mode 100644 index 000000000000..654b37ee33f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f595bbeba71df67.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_database": "test_01109_other_atomic", + "from_table": "t3", + "to_database": "test_01109_ordinary", + "to_table": "t4" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6f595bbeba71df67.sql b/tests/ast_json_fixtures/shapes/6f595bbeba71df67.sql new file mode 100644 index 000000000000..f41bff1c5a67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f595bbeba71df67.sql @@ -0,0 +1 @@ +EXCHANGE TABLES test_01109_other_atomic.t3 AND test_01109_ordinary.t4 diff --git a/tests/ast_json_fixtures/shapes/6f6efa9c96a805db.json b/tests/ast_json_fixtures/shapes/6f6efa9c96a805db.json new file mode 100644 index 000000000000..f12cc70a6ac6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f6efa9c96a805db.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "String", + "value": "default" + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6f6efa9c96a805db.sql b/tests/ast_json_fixtures/shapes/6f6efa9c96a805db.sql new file mode 100644 index 000000000000..989fa096296c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f6efa9c96a805db.sql @@ -0,0 +1 @@ +INSERT INTO FUNCTION remote('127.0.0.{1,2}', currentDatabase(), y, 'default') SELECT * FROM numbers(10) diff --git a/tests/ast_json_fixtures/shapes/6f74e3ebde230d18.json b/tests/ast_json_fixtures/shapes/6f74e3ebde230d18.json new file mode 100644 index 000000000000..ea68ecdfd65f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f74e3ebde230d18.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "SET_SNAPSHOT", + "snapshot": "1" + } +} diff --git a/tests/ast_json_fixtures/shapes/6f74e3ebde230d18.sql b/tests/ast_json_fixtures/shapes/6f74e3ebde230d18.sql new file mode 100644 index 000000000000..5c21247f56bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6f74e3ebde230d18.sql @@ -0,0 +1 @@ +set transaction snapshot 1 diff --git a/tests/ast_json_fixtures/shapes/6fba8b00ccf4b2fc.json b/tests/ast_json_fixtures/shapes/6fba8b00ccf4b2fc.json new file mode 100644 index 000000000000..1612d15c480d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6fba8b00ccf4b2fc.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "alias": "y", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "t0" + } + ] + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "c1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "cluster_for_parallel_replicas": "test_cluster_one_shard_three_replicas_localhost", + "parallel_replicas_for_non_replicated_merge_tree": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6fba8b00ccf4b2fc.sql b/tests/ast_json_fixtures/shapes/6fba8b00ccf4b2fc.sql new file mode 100644 index 000000000000..bf9ac1cf414f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6fba8b00ccf4b2fc.sql @@ -0,0 +1,7 @@ +( + SELECT 1 x, x y FROM remote('localhost', currentDatabase(), t0) +) +UNION ALL +( + SELECT 1, c1 FROM t0 SETTINGS cluster_for_parallel_replicas='test_cluster_one_shard_three_replicas_localhost', parallel_replicas_for_non_replicated_merge_tree = 1 +) diff --git a/tests/ast_json_fixtures/shapes/6fca34677f26bc47.json b/tests/ast_json_fixtures/shapes/6fca34677f26bc47.json new file mode 100644 index 000000000000..940065342145 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6fca34677f26bc47.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6fca34677f26bc47.sql b/tests/ast_json_fixtures/shapes/6fca34677f26bc47.sql new file mode 100644 index 000000000000..1b98994bd686 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6fca34677f26bc47.sql @@ -0,0 +1 @@ +SELECT * SETTINGS use_query_cache = 1 diff --git a/tests/ast_json_fixtures/shapes/6fd90946e5c86749.json b/tests/ast_json_fixtures/shapes/6fd90946e5c86749.json new file mode 100644 index 000000000000..9245cf3ee1d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6fd90946e5c86749.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "pk_test1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "String" + }, + "primary_key_specifier": true + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "c", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "primary_key_from_columns": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + }, + "storage": { + "type": "Storage", + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6fd90946e5c86749.sql b/tests/ast_json_fixtures/shapes/6fd90946e5c86749.sql new file mode 100644 index 000000000000..a69e09730972 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6fd90946e5c86749.sql @@ -0,0 +1 @@ +CREATE TABLE pk_test1 (a String PRIMARY KEY, b String, c String) diff --git a/tests/ast_json_fixtures/shapes/6fdf4bc400914da7.json b/tests/ast_json_fixtures/shapes/6fdf4bc400914da7.json new file mode 100644 index 000000000000..c6494b79e803 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6fdf4bc400914da7.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "j", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "i" + }, + "order_by": { + "type": "Identifier", + "name": "j" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/6fdf4bc400914da7.sql b/tests/ast_json_fixtures/shapes/6fdf4bc400914da7.sql new file mode 100644 index 000000000000..cbb0e1d303d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6fdf4bc400914da7.sql @@ -0,0 +1 @@ +create table x (i int, j int) engine MergeTree partition by i order by j settings index_granularity = 1 diff --git a/tests/ast_json_fixtures/shapes/6fe7ca288dba89b2.json b/tests/ast_json_fixtures/shapes/6fe7ca288dba89b2.json new file mode 100644 index 000000000000..565695bc751a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6fe7ca288dba89b2.json @@ -0,0 +1,127 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "filtered_groups", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pr_1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pr_2" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "pr_2.a", + "name_parts": ["pr_2", "a"] + }, + { + "type": "Identifier", + "name": "filtered_groups.a", + "name_parts": ["filtered_groups", "a"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "filtered_groups" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_parallel_replicas": "1", + "parallel_replicas_for_non_replicated_merge_tree": "1", + "cluster_for_parallel_replicas": "test_cluster_one_shard_three_replicas_localhost", + "max_parallel_replicas": "3" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6fe7ca288dba89b2.sql b/tests/ast_json_fixtures/shapes/6fe7ca288dba89b2.sql new file mode 100644 index 000000000000..90fa2a388be8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6fe7ca288dba89b2.sql @@ -0,0 +1,3 @@ +WITH filtered_groups AS (SELECT a FROM pr_1 WHERE a >= 100) +SELECT count() FROM pr_2 INNER JOIN filtered_groups ON pr_2.a = filtered_groups.a +SETTINGS enable_parallel_replicas = 1, parallel_replicas_for_non_replicated_merge_tree = 1, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', max_parallel_replicas = 3 diff --git a/tests/ast_json_fixtures/shapes/6ff8e640465c0e9d.json b/tests/ast_json_fixtures/shapes/6ff8e640465c0e9d.json new file mode 100644 index 000000000000..37d6ad40ae1b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ff8e640465c0e9d.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/6ff8e640465c0e9d.sql b/tests/ast_json_fixtures/shapes/6ff8e640465c0e9d.sql new file mode 100644 index 000000000000..17a041d7b7f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ff8e640465c0e9d.sql @@ -0,0 +1 @@ +SELECT 1 FORMAT PrettySpace diff --git a/tests/ast_json_fixtures/shapes/6ffa0439a5802bb9.json b/tests/ast_json_fixtures/shapes/6ffa0439a5802bb9.json new file mode 100644 index 000000000000..a2c75d7e6fe9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ffa0439a5802bb9.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "cube" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/6ffa0439a5802bb9.sql b/tests/ast_json_fixtures/shapes/6ffa0439a5802bb9.sql new file mode 100644 index 000000000000..f546bfc6d8ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/6ffa0439a5802bb9.sql @@ -0,0 +1 @@ +SELECT a, b, sum(s), count() from cube GROUP BY CUBE(a, b) WITH TOTALS ORDER BY a, b diff --git a/tests/ast_json_fixtures/shapes/702cd6c1b1dcdbf7.json b/tests/ast_json_fixtures/shapes/702cd6c1b1dcdbf7.json new file mode 100644 index 000000000000..76d99e768705 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/702cd6c1b1dcdbf7.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "alias": "amount", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test02416" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "amount" + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/702cd6c1b1dcdbf7.sql b/tests/ast_json_fixtures/shapes/702cd6c1b1dcdbf7.sql new file mode 100644 index 000000000000..b13eb6736655 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/702cd6c1b1dcdbf7.sql @@ -0,0 +1 @@ +SELECT count() AS amount, a, b, GROUPING(a, b) FROM test02416 GROUP BY ROLLUP(a, b) ORDER BY (amount, a, b) diff --git a/tests/ast_json_fixtures/shapes/703731bf0bf730ad.json b/tests/ast_json_fixtures/shapes/703731bf0bf730ad.json new file mode 100644 index 000000000000..98d4b3f6999e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/703731bf0bf730ad.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "replaceRegexpOne", + "arguments": [ + { + "type": "Identifier", + "name": "create_table_query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "CREATE TABLE [^ ]*" + }, + { + "type": "Literal", + "value_type": "String", + "value": "CREATE TABLE x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tables", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": ".inner%" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC" + } + ] + } + ], + "format": "LineAsString" + } +} diff --git a/tests/ast_json_fixtures/shapes/703731bf0bf730ad.sql b/tests/ast_json_fixtures/shapes/703731bf0bf730ad.sql new file mode 100644 index 000000000000..d0f80b116a7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/703731bf0bf730ad.sql @@ -0,0 +1 @@ +SELECT replaceRegexpOne(create_table_query, 'CREATE TABLE [^ ]*', 'CREATE TABLE x') FROM system.tables WHERE database = currentDatabase() and table LIKE '.inner%' ORDER BY 1 FORMAT LineAsString diff --git a/tests/ast_json_fixtures/shapes/703888135ff19db3.json b/tests/ast_json_fixtures/shapes/703888135ff19db3.json new file mode 100644 index 000000000000..9b775616137f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/703888135ff19db3.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_atomic", + "from_table": "src", + "to_database": "test_01155_ordinary", + "to_table": "src" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/703888135ff19db3.sql b/tests/ast_json_fixtures/shapes/703888135ff19db3.sql new file mode 100644 index 000000000000..436d6aa23cee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/703888135ff19db3.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_atomic.src TO test_01155_ordinary.src diff --git a/tests/ast_json_fixtures/shapes/703ae6e7c4f16c0b.json b/tests/ast_json_fixtures/shapes/703ae6e7c4f16c0b.json new file mode 100644 index 000000000000..87dd2ddea576 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/703ae6e7c4f16c0b.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_SAMPLE_BY", + "sample_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/703ae6e7c4f16c0b.sql b/tests/ast_json_fixtures/shapes/703ae6e7c4f16c0b.sql new file mode 100644 index 000000000000..a6d21d9058e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/703ae6e7c4f16c0b.sql @@ -0,0 +1 @@ +ALTER TABLE t MODIFY SAMPLE BY tuple() diff --git a/tests/ast_json_fixtures/shapes/703c365612a89877.json b/tests/ast_json_fixtures/shapes/703c365612a89877.json new file mode 100644 index 000000000000..1ee442b6ebbb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/703c365612a89877.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettySpaceNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/703c365612a89877.sql b/tests/ast_json_fixtures/shapes/703c365612a89877.sql new file mode 100644 index 000000000000..d0a584556dbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/703c365612a89877.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) ORDER BY number FORMAT PrettySpaceNoEscapes diff --git a/tests/ast_json_fixtures/shapes/70661115b09f8fb0.json b/tests/ast_json_fixtures/shapes/70661115b09f8fb0.json new file mode 100644 index 000000000000..7b7a6e8039fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/70661115b09f8fb0.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p1_01295", + "database": "db", + "table": "table" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/70661115b09f8fb0.sql b/tests/ast_json_fixtures/shapes/70661115b09f8fb0.sql new file mode 100644 index 000000000000..a503907aee0a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/70661115b09f8fb0.sql @@ -0,0 +1 @@ +CREATE ROW POLICY p1_01295 ON db.table USING ad diff --git a/tests/ast_json_fixtures/shapes/7068f30d17ea8dbd.json b/tests/ast_json_fixtures/shapes/7068f30d17ea8dbd.json new file mode 100644 index 000000000000..f57e74286dec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7068f30d17ea8dbd.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "recursive_cte", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recursive_cte" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "n" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recursive_cte" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7068f30d17ea8dbd.sql b/tests/ast_json_fixtures/shapes/7068f30d17ea8dbd.sql new file mode 100644 index 000000000000..9635077b4a9e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7068f30d17ea8dbd.sql @@ -0,0 +1,2 @@ +WITH RECURSIVE recursive_cte AS (SELECT 1 AS n UNION ALL SELECT n + 1 FROM recursive_cte) +SELECT n FROM recursive_cte LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/7076e485199ab2fa.json b/tests/ast_json_fixtures/shapes/7076e485199ab2fa.json new file mode 100644 index 000000000000..46c3a782d1e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7076e485199ab2fa.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "d" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "d" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7076e485199ab2fa.sql b/tests/ast_json_fixtures/shapes/7076e485199ab2fa.sql new file mode 100644 index 000000000000..393b129db510 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7076e485199ab2fa.sql @@ -0,0 +1 @@ +select count(), d from test group by d order by d diff --git a/tests/ast_json_fixtures/shapes/709aa4c3de4cec18.json b/tests/ast_json_fixtures/shapes/709aa4c3de4cec18.json new file mode 100644 index 000000000000..72b8b052953f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/709aa4c3de4cec18.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_table": "table_a_exchange", + "to_table": "table_b_exchange" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/709aa4c3de4cec18.sql b/tests/ast_json_fixtures/shapes/709aa4c3de4cec18.sql new file mode 100644 index 000000000000..55bbc4995501 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/709aa4c3de4cec18.sql @@ -0,0 +1 @@ +EXCHANGE TABLES table_a_exchange AND table_b_exchange diff --git a/tests/ast_json_fixtures/shapes/709c21d4fd9137cc.json b/tests/ast_json_fixtures/shapes/709c21d4fd9137cc.json new file mode 100644 index 000000000000..03eaec2b5542 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/709c21d4fd9137cc.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH DISTRIBUTED", + "table": { + "type": "Identifier", + "name": "dist_in" + }, + "settings": { + "type": "Settings", + "changes": { + "max_memory_usage": "0" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/709c21d4fd9137cc.sql b/tests/ast_json_fixtures/shapes/709c21d4fd9137cc.sql new file mode 100644 index 000000000000..f089f1899451 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/709c21d4fd9137cc.sql @@ -0,0 +1 @@ +system flush distributed dist_in settings max_memory_usage=0 diff --git a/tests/ast_json_fixtures/shapes/709cf504ab8e4120.json b/tests/ast_json_fixtures/shapes/709cf504ab8e4120.json new file mode 100644 index 000000000000..299343cb131f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/709cf504ab8e4120.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "Hash" + } +} diff --git a/tests/ast_json_fixtures/shapes/709cf504ab8e4120.sql b/tests/ast_json_fixtures/shapes/709cf504ab8e4120.sql new file mode 100644 index 000000000000..e80276716e28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/709cf504ab8e4120.sql @@ -0,0 +1 @@ +SELECT number FROM system.numbers LIMIT 1 FORMAT Hash diff --git a/tests/ast_json_fixtures/shapes/70b8cabf3eb3cfbe.json b/tests/ast_json_fixtures/shapes/70b8cabf3eb3cfbe.json new file mode 100644 index 000000000000..eaeec17129a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/70b8cabf3eb3cfbe.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "restore_01640" + }, + "settings": { + "type": "Settings", + "changes": { + "insert_keeper_fault_injection_probability": "0" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ATTACH_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2021-01-01" + } + ] + } + ] + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/70b8cabf3eb3cfbe.sql b/tests/ast_json_fixtures/shapes/70b8cabf3eb3cfbe.sql new file mode 100644 index 000000000000..8170353dc6a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/70b8cabf3eb3cfbe.sql @@ -0,0 +1 @@ +ALTER TABLE restore_01640 ATTACH PARTITION tuple(toYYYYMM(toDate('2021-01-01'))) SETTINGS insert_keeper_fault_injection_probability=0 diff --git a/tests/ast_json_fixtures/shapes/70d131e2bd0bce00.json b/tests/ast_json_fixtures/shapes/70d131e2bd0bce00.json new file mode 100644 index 000000000000..d4c8ce25e26f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/70d131e2bd0bce00.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/70d131e2bd0bce00.sql b/tests/ast_json_fixtures/shapes/70d131e2bd0bce00.sql new file mode 100644 index 000000000000..7a3b807d5cb8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/70d131e2bd0bce00.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number with totals order by number diff --git a/tests/ast_json_fixtures/shapes/70d8788a31d08e13.json b/tests/ast_json_fixtures/shapes/70d8788a31d08e13.json new file mode 100644 index 000000000000..3e853e7489c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/70d8788a31d08e13.json @@ -0,0 +1,117 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "resolutions", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + { + "type": "Function", + "alias": "ring", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": -122.40898669999721 + }, + { + "value_type": "Float64", + "value": 37.81331899998324 + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": -122.35447369999936 + }, + { + "value_type": "Float64", + "value": 37.71980619999785 + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": -122.4798767000009 + }, + { + "value_type": "Float64", + "value": 37.815157199999845 + } + ] + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "resolution" + }, + { + "type": "Function", + "name": "h3PolygonToCells", + "arguments": [ + { + "type": "Identifier", + "name": "ring" + }, + { + "type": "Function", + "alias": "resolution", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "resolutions" + } + ] + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "resolution" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/70d8788a31d08e13.sql b/tests/ast_json_fixtures/shapes/70d8788a31d08e13.sql new file mode 100644 index 000000000000..705ca2f59cbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/70d8788a31d08e13.sql @@ -0,0 +1,4 @@ +WITH range(0, 8) AS resolutions, + [(-122.40898669999721, 37.81331899998324), (-122.35447369999936, 37.71980619999785), (-122.4798767000009, 37.815157199999845)] AS ring +SELECT resolution, h3PolygonToCells(ring, arrayJoin(resolutions) AS resolution) +ORDER BY resolution diff --git a/tests/ast_json_fixtures/shapes/70eb670d0b25b8f2.json b/tests/ast_json_fixtures/shapes/70eb670d0b25b8f2.json new file mode 100644 index 000000000000..6f937fc58f8c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/70eb670d0b25b8f2.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pk_order" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/70eb670d0b25b8f2.sql b/tests/ast_json_fixtures/shapes/70eb670d0b25b8f2.sql new file mode 100644 index 000000000000..570c70e6f294 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/70eb670d0b25b8f2.sql @@ -0,0 +1 @@ +SELECT d FROM pk_order ORDER BY d LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/7130bb0157dbfed7.json b/tests/ast_json_fixtures/shapes/7130bb0157dbfed7.json new file mode 100644 index 000000000000..d146f4179f2d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7130bb0157dbfed7.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "age" + } + ] + } + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "users" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7130bb0157dbfed7.sql b/tests/ast_json_fixtures/shapes/7130bb0157dbfed7.sql new file mode 100644 index 000000000000..f071d2e1a471 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7130bb0157dbfed7.sql @@ -0,0 +1,3 @@ +SELECT name, (SELECT count() FROM numbers(50) WHERE number = age) +FROM users +ORDER BY name diff --git a/tests/ast_json_fixtures/shapes/7151fd0f5c2b09cb.json b/tests/ast_json_fixtures/shapes/7151fd0f5c2b09cb.json new file mode 100644 index 000000000000..eb8bc08aeb28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7151fd0f5c2b09cb.json @@ -0,0 +1,199 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000000" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + ], + "having": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7151fd0f5c2b09cb.sql b/tests/ast_json_fixtures/shapes/7151fd0f5c2b09cb.sql new file mode 100644 index 000000000000..11726a907d85 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7151fd0f5c2b09cb.sql @@ -0,0 +1 @@ +SELECT (number % 5) * (number % 5) AS k FROM numbers(10000000) GROUP BY number % 5, ((number % 5) * (number % 5)) HAVING ((number % 5) * (number % 5)) < 5 ORDER BY k SETTINGS enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/7154eba0ab427bfa.json b/tests/ast_json_fixtures/shapes/7154eba0ab427bfa.json new file mode 100644 index 000000000000..19b2caf1744a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7154eba0ab427bfa.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "region" + }, + { + "type": "Literal", + "value_type": "String", + "value": "asia" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "user_id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "101" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "test_4" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7154eba0ab427bfa.sql b/tests/ast_json_fixtures/shapes/7154eba0ab427bfa.sql new file mode 100644 index 000000000000..e1b7cbc9fcdc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7154eba0ab427bfa.sql @@ -0,0 +1 @@ +SELECT * FROM test WHERE region = 'asia' OR user_id = 101 ORDER BY ALL SETTINGS log_comment = 'test_4' diff --git a/tests/ast_json_fixtures/shapes/7181ce9b57eec61d.json b/tests/ast_json_fixtures/shapes/7181ce9b57eec61d.json new file mode 100644 index 000000000000..663e97903b84 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7181ce9b57eec61d.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "DetachQuery", + "kind": "DETACH", + "database": { + "type": "Identifier", + "name": "db_01870" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7181ce9b57eec61d.sql b/tests/ast_json_fixtures/shapes/7181ce9b57eec61d.sql new file mode 100644 index 000000000000..97e5e8585869 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7181ce9b57eec61d.sql @@ -0,0 +1 @@ +detach database db_01870 diff --git a/tests/ast_json_fixtures/shapes/71a3b1a2370910f7.json b/tests/ast_json_fixtures/shapes/71a3b1a2370910f7.json new file mode 100644 index 000000000000..592f8f7f702c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71a3b1a2370910f7.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "cnt", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cnt" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/71a3b1a2370910f7.sql b/tests/ast_json_fixtures/shapes/71a3b1a2370910f7.sql new file mode 100644 index 000000000000..89b44f1e8532 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71a3b1a2370910f7.sql @@ -0,0 +1 @@ +select count() cnt, * from dist_01247 group by number having cnt == 1 limit 1 diff --git a/tests/ast_json_fixtures/shapes/71b1d427f555d254.json b/tests/ast_json_fixtures/shapes/71b1d427f555d254.json new file mode 100644 index 000000000000..a9f24d88aab0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71b1d427f555d254.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "CreateIndexQuery", + "table": { + "type": "Identifier", + "name": "t_index" + }, + "if_not_exists": true, + "index_name": { + "type": "Identifier", + "name": "i_a" + }, + "index_declaration": { + "type": "Index", + "name": "i_a", + "expression": { + "type": "Identifier", + "name": "a" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 2 + } + } +} diff --git a/tests/ast_json_fixtures/shapes/71b1d427f555d254.sql b/tests/ast_json_fixtures/shapes/71b1d427f555d254.sql new file mode 100644 index 000000000000..7f3d75531cfe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71b1d427f555d254.sql @@ -0,0 +1 @@ +create index if not exists i_a on t_index(a) TYPE minmax GRANULARITY 2 diff --git a/tests/ast_json_fixtures/shapes/71b3bd0e14eca7ca.json b/tests/ast_json_fixtures/shapes/71b3bd0e14eca7ca.json new file mode 100644 index 000000000000..9a828165cafd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71b3bd0e14eca7ca.json @@ -0,0 +1,133 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "232" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test54378" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "part_date" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-04-19" + } + ] + } + ] + } + ] + } + } + ] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-04-19" + } + ] + } + ] + } + ] + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-2147483649" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": null + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/71b3bd0e14eca7ca.sql b/tests/ast_json_fixtures/shapes/71b3bd0e14eca7ca.sql new file mode 100644 index 000000000000..8ec13d87c90a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71b3bd0e14eca7ca.sql @@ -0,0 +1 @@ +SELECT 232 FROM test54378 PREWHERE (part_date = (SELECT toDate('2018-04-19'))) IN (SELECT toDate('2018-04-19')) GROUP BY toDate(toDate(-2147483649, NULL), NULL), -inf diff --git a/tests/ast_json_fixtures/shapes/71bad23cad2fdd7a.json b/tests/ast_json_fixtures/shapes/71bad23cad2fdd7a.json new file mode 100644 index 000000000000..51d40cf09e25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71bad23cad2fdd7a.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "true" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Bool" + } + ] + } + ] + } + ], + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/71bad23cad2fdd7a.sql b/tests/ast_json_fixtures/shapes/71bad23cad2fdd7a.sql new file mode 100644 index 000000000000..925c44f7ced6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71bad23cad2fdd7a.sql @@ -0,0 +1 @@ +SELECT CAST('true', 'Bool') format Values diff --git a/tests/ast_json_fixtures/shapes/71cb49995b19bc25.json b/tests/ast_json_fixtures/shapes/71cb49995b19bc25.json new file mode 100644 index 000000000000..86e0722ff482 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71cb49995b19bc25.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC", + "nulls_first": true + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/71cb49995b19bc25.sql b/tests/ast_json_fixtures/shapes/71cb49995b19bc25.sql new file mode 100644 index 000000000000..71b60af5b4db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71cb49995b19bc25.sql @@ -0,0 +1 @@ +SELECT * FROM test ORDER BY ALL ASC NULLS FIRST LIMIT 1 FORMAT PrettySpace diff --git a/tests/ast_json_fixtures/shapes/71e2cc3cd69bcab6.json b/tests/ast_json_fixtures/shapes/71e2cc3cd69bcab6.json new file mode 100644 index 000000000000..55c1276ae0a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71e2cc3cd69bcab6.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "bool_test" + }, + "columns": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Identifier", + "name": "f" + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/71e2cc3cd69bcab6.sql b/tests/ast_json_fixtures/shapes/71e2cc3cd69bcab6.sql new file mode 100644 index 000000000000..42743a927a36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71e2cc3cd69bcab6.sql @@ -0,0 +1,3 @@ +INSERT INTO bool_test (value,f) FORMAT JSONEachRow {"value":false,"f":"test"}{"value":true,"f":"test"}{"value":0,"f":"test"}{"value":1,"f":"test"} + +SELECT value,f FROM bool_test diff --git a/tests/ast_json_fixtures/shapes/71f67c65e96ca864.json b/tests/ast_json_fixtures/shapes/71f67c65e96ca864.json new file mode 100644 index 000000000000..0db4afc6fb3b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71f67c65e96ca864.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "alias": "k", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Identifier", + "name": "system" + }, + { + "type": "Identifier", + "name": "one" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/71f67c65e96ca864.sql b/tests/ast_json_fixtures/shapes/71f67c65e96ca864.sql new file mode 100644 index 000000000000..8112d90be95b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71f67c65e96ca864.sql @@ -0,0 +1 @@ +SELECT dummy + 1 AS k, count() FROM remote('127.0.0.{2,3}', system, one) GROUP BY k WITH TOTALS ORDER BY k diff --git a/tests/ast_json_fixtures/shapes/71fb47f458df2dfd.json b/tests/ast_json_fixtures/shapes/71fb47f458df2dfd.json new file mode 100644 index 000000000000..36a4a16dc077 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71fb47f458df2dfd.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q3_01297"], + "key_type": "IP_ADDRESS" + } +} diff --git a/tests/ast_json_fixtures/shapes/71fb47f458df2dfd.sql b/tests/ast_json_fixtures/shapes/71fb47f458df2dfd.sql new file mode 100644 index 000000000000..5577dfbfef6f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71fb47f458df2dfd.sql @@ -0,0 +1 @@ +CREATE QUOTA q3_01297 KEY BY ip_address diff --git a/tests/ast_json_fixtures/shapes/71fba750d2f30f2a.json b/tests/ast_json_fixtures/shapes/71fba750d2f30f2a.json new file mode 100644 index 000000000000..8259df478fed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71fba750d2f30f2a.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s5_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "max_value": "5000000" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/71fba750d2f30f2a.sql b/tests/ast_json_fixtures/shapes/71fba750d2f30f2a.sql new file mode 100644 index 000000000000..e6f7f13ec4eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/71fba750d2f30f2a.sql @@ -0,0 +1 @@ +CREATE PROFILE s5_01294 SETTINGS max_memory_usage MAX=5000000 diff --git a/tests/ast_json_fixtures/shapes/720929ca3189c14a.json b/tests/ast_json_fixtures/shapes/720929ca3189c14a.json new file mode 100644 index 000000000000..f22c7dc719c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/720929ca3189c14a.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_1" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "additional_result_filter": "x != 2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/720929ca3189c14a.sql b/tests/ast_json_fixtures/shapes/720929ca3189c14a.sql new file mode 100644 index 000000000000..ec51dbb39897 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/720929ca3189c14a.sql @@ -0,0 +1 @@ +select *, x != 2 from table_1 settings additional_result_filter='x != 2' diff --git a/tests/ast_json_fixtures/shapes/720f7f7f674f349d.json b/tests/ast_json_fixtures/shapes/720f7f7f674f349d.json new file mode 100644 index 000000000000..777797258aa4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/720f7f7f674f349d.json @@ -0,0 +1,94 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "alias": "x", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/720f7f7f674f349d.sql b/tests/ast_json_fixtures/shapes/720f7f7f674f349d.sql new file mode 100644 index 000000000000..85f9f8919dd8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/720f7f7f674f349d.sql @@ -0,0 +1 @@ +SELECT tuple(number + 1) AS x FROM numbers(10) GROUP BY number + 1, toString(x) WITH CUBE settings group_by_use_nulls=1 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/7237bf3c77a8f0bd.json b/tests/ast_json_fixtures/shapes/7237bf3c77a8f0bd.json new file mode 100644 index 000000000000..f906edc741d8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7237bf3c77a8f0bd.json @@ -0,0 +1,201 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tan", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "cos", + "arguments": [ + { + "type": "Function", + "name": "sin", + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "gcd", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "sqrt", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Function", + "name": "erf", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7237bf3c77a8f0bd.sql b/tests/ast_json_fixtures/shapes/7237bf3c77a8f0bd.sql new file mode 100644 index 000000000000..7c110f96333e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7237bf3c77a8f0bd.sql @@ -0,0 +1 @@ +SELECT (- ((((tan (t1.c0)))+(t1.c0)))), (cos ((sin (pow(t1.c0,t1.c0))))), ((gcd((- (t1.c0)),((t1.c0)+(t1.c0))))*((- ((- (t1.c0)))))) FROM t1 GROUP BY (sqrt ((- (t1.c0)))), t1.c0, pow((erf ((- (t1.c0)))),t1.c0) diff --git a/tests/ast_json_fixtures/shapes/72429d56e83636c0.json b/tests/ast_json_fixtures/shapes/72429d56e83636c0.json new file mode 100644 index 000000000000..6c2ac5d1a6ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/72429d56e83636c0.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "t_group_by_lowcardinality" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "p_date", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "val", + "data_type": { + "type": "DataType", + "name": "LowCardinality", + "arguments": [ + { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "p_date" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/72429d56e83636c0.sql b/tests/ast_json_fixtures/shapes/72429d56e83636c0.sql new file mode 100644 index 000000000000..95fd9d111032 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/72429d56e83636c0.sql @@ -0,0 +1,2 @@ +create table if not exists t_group_by_lowcardinality(p_date Date, val LowCardinality(Nullable(String))) +engine=MergeTree() partition by p_date order by tuple() diff --git a/tests/ast_json_fixtures/shapes/72496c16cd2d013c.json b/tests/ast_json_fixtures/shapes/72496c16cd2d013c.json new file mode 100644 index 000000000000..eefe6654c1ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/72496c16cd2d013c.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "replaceAll", + "arguments": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\n" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\\n" + } + ] + }, + { + "type": "Function", + "name": "lower", + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + } + ] + }, + { + "type": "Function", + "name": "errorCodeToName", + "arguments": [ + { + "type": "Identifier", + "name": "exception_code" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time_microseconds" + }, + "direction": "ASC" + } + ] + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/72496c16cd2d013c.sql b/tests/ast_json_fixtures/shapes/72496c16cd2d013c.sql new file mode 100644 index 000000000000..06c0fa779751 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/72496c16cd2d013c.sql @@ -0,0 +1,5 @@ +select replaceAll(query, '\n', '\\n'), lower(type::String), errorCodeToName(exception_code) + from system.query_log + where current_database = currentDatabase() + order by event_time_microseconds + format CSV diff --git a/tests/ast_json_fixtures/shapes/724e6bdf616833a6.json b/tests/ast_json_fixtures/shapes/724e6bdf616833a6.json new file mode 100644 index 000000000000..b18ce053dfe8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/724e6bdf616833a6.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "STOP FETCHES", + "table": { + "type": "Identifier", + "name": "r2" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/724e6bdf616833a6.sql b/tests/ast_json_fixtures/shapes/724e6bdf616833a6.sql new file mode 100644 index 000000000000..6bfac89576e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/724e6bdf616833a6.sql @@ -0,0 +1 @@ +SYSTEM STOP FETCHES r2 diff --git a/tests/ast_json_fixtures/shapes/724fffb681a758a8.json b/tests/ast_json_fixtures/shapes/724fffb681a758a8.json new file mode 100644 index 000000000000..f84724e05598 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/724fffb681a758a8.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "replace_table": true, + "create_or_replace": true, + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "INT" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "x" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/724fffb681a758a8.sql b/tests/ast_json_fixtures/shapes/724fffb681a758a8.sql new file mode 100644 index 000000000000..080fea72ae9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/724fffb681a758a8.sql @@ -0,0 +1 @@ +CREATE OR REPLACE TABLE t (x INT) ENGINE=MergeTree ORDER BY x diff --git a/tests/ast_json_fixtures/shapes/7258b18efe0d3f13.json b/tests/ast_json_fixtures/shapes/7258b18efe0d3f13.json new file mode 100644 index 000000000000..c51a76caffbf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7258b18efe0d3f13.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_column_ops" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "column": { + "type": "Identifier", + "name": "c" + }, + "rename_to": { + "type": "Identifier", + "name": "old_b" + } + }, + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_specifier": "DEFAULT", + "default_expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7258b18efe0d3f13.sql b/tests/ast_json_fixtures/shapes/7258b18efe0d3f13.sql new file mode 100644 index 000000000000..3c10bb703347 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7258b18efe0d3f13.sql @@ -0,0 +1 @@ +ALTER TABLE t_column_ops RENAME COLUMN c TO old_b, ADD COLUMN d UInt64 DEFAULT 0 diff --git a/tests/ast_json_fixtures/shapes/7272e7025e7bcd3f.json b/tests/ast_json_fixtures/shapes/7272e7025e7bcd3f.json new file mode 100644 index 000000000000..b74fedf25681 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7272e7025e7bcd3f.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR MMAP CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/7272e7025e7bcd3f.sql b/tests/ast_json_fixtures/shapes/7272e7025e7bcd3f.sql new file mode 100644 index 000000000000..60e1acb15ac0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7272e7025e7bcd3f.sql @@ -0,0 +1 @@ +SYSTEM CLEAR MMAP CACHE diff --git a/tests/ast_json_fixtures/shapes/727544d7f1f14ab2.json b/tests/ast_json_fixtures/shapes/727544d7f1f14ab2.json new file mode 100644 index 000000000000..088a716f2598 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/727544d7f1f14ab2.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r5_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/727544d7f1f14ab2.sql b/tests/ast_json_fixtures/shapes/727544d7f1f14ab2.sql new file mode 100644 index 000000000000..691cd736fe0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/727544d7f1f14ab2.sql @@ -0,0 +1 @@ +CREATE ROLE r5_01293 SETTINGS NONE diff --git a/tests/ast_json_fixtures/shapes/7276f4f1712f656d.json b/tests/ast_json_fixtures/shapes/7276f4f1712f656d.json new file mode 100644 index 000000000000..b8ed2582c46f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7276f4f1712f656d.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "t", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-10-16 18:00:30" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDateTime64", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "toIntervalMillisecond", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "t" + } + ] + } + ] + } + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "transform_null_in": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7276f4f1712f656d.sql b/tests/ast_json_fixtures/shapes/7276f4f1712f656d.sql new file mode 100644 index 000000000000..b3a279faa05c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7276f4f1712f656d.sql @@ -0,0 +1,2 @@ +WITH toDateTime('2024-10-16 18:00:30') as t +SELECT toDateTime64(t, 3) + interval 100 milliseconds IN (SELECT t) settings transform_null_in=0 diff --git a/tests/ast_json_fixtures/shapes/72b5e409805a6dfd.json b/tests/ast_json_fixtures/shapes/72b5e409805a6dfd.json new file mode 100644 index 000000000000..ca63c11acf43 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/72b5e409805a6dfd.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/72b5e409805a6dfd.sql b/tests/ast_json_fixtures/shapes/72b5e409805a6dfd.sql new file mode 100644 index 000000000000..1a49874b2d5c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/72b5e409805a6dfd.sql @@ -0,0 +1 @@ +SELECT tuple(*), 2 a FROM t0 JOIN t1 USING (a) diff --git a/tests/ast_json_fixtures/shapes/7322f7ad50012329.json b/tests/ast_json_fixtures/shapes/7322f7ad50012329.json new file mode 100644 index 000000000000..62ea605b874f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7322f7ad50012329.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR DNS CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/7322f7ad50012329.sql b/tests/ast_json_fixtures/shapes/7322f7ad50012329.sql new file mode 100644 index 000000000000..f5881c5673a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7322f7ad50012329.sql @@ -0,0 +1 @@ +SYSTEM CLEAR DNS CACHE diff --git a/tests/ast_json_fixtures/shapes/7328b2b0ae5bd473.json b/tests/ast_json_fixtures/shapes/7328b2b0ae5bd473.json new file mode 100644 index 000000000000..2132d6f1b25e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7328b2b0ae5bd473.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u_03254_alter_user"] + } +} diff --git a/tests/ast_json_fixtures/shapes/7328b2b0ae5bd473.sql b/tests/ast_json_fixtures/shapes/7328b2b0ae5bd473.sql new file mode 100644 index 000000000000..5fb095488d50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7328b2b0ae5bd473.sql @@ -0,0 +1 @@ +drop user u_03254_alter_user diff --git a/tests/ast_json_fixtures/shapes/732f68f6f3a7cbb8.json b/tests/ast_json_fixtures/shapes/732f68f6f3a7cbb8.json new file mode 100644 index 000000000000..b7efc3a04515 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/732f68f6f3a7cbb8.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "allow_suspicious_types_in_order_by": "1", + "use_variant_as_common_type": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/732f68f6f3a7cbb8.sql b/tests/ast_json_fixtures/shapes/732f68f6f3a7cbb8.sql new file mode 100644 index 000000000000..a15fd5b8b79c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/732f68f6f3a7cbb8.sql @@ -0,0 +1 @@ +SELECT 1 FROM numbers(3) ORDER BY [1, ()] FETCH FIRST 1 ROW ONLY SETTINGS allow_suspicious_types_in_order_by = 1, use_variant_as_common_type = 1 diff --git a/tests/ast_json_fixtures/shapes/732fa47e66921e99.json b/tests/ast_json_fixtures/shapes/732fa47e66921e99.json new file mode 100644 index 000000000000..e2b8a5733de0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/732fa47e66921e99.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "rmt" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "0" + } + }, + "replace": true, + "from_table": "mt" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/732fa47e66921e99.sql b/tests/ast_json_fixtures/shapes/732fa47e66921e99.sql new file mode 100644 index 000000000000..50f044e2095c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/732fa47e66921e99.sql @@ -0,0 +1 @@ +alter table rmt replace partition '0' from mt diff --git a/tests/ast_json_fixtures/shapes/7373207ca3714ea4.json b/tests/ast_json_fixtures/shapes/7373207ca3714ea4.json new file mode 100644 index 000000000000..634ba9a952c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7373207ca3714ea4.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/7373207ca3714ea4.sql b/tests/ast_json_fixtures/shapes/7373207ca3714ea4.sql new file mode 100644 index 000000000000..628eea414c64 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7373207ca3714ea4.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/73741b89226308db.json b/tests/ast_json_fixtures/shapes/73741b89226308db.json new file mode 100644 index 000000000000..f6598104476c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73741b89226308db.json @@ -0,0 +1,165 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "replace_table": true, + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "timestamp", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "toStartOfDay", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + } + ] + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "GROUP_BY", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + }, + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "group_by_key": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "toStartOfDay", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + } + ], + "group_by_assignments": [ + { + "type": "Assignment", + "column": "timestamp", + "expression": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + { + "type": "Function", + "name": "toIntervalYear", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + } + }, + { + "type": "Assignment", + "column": "id", + "expression": { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + } + } + ] + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/73741b89226308db.sql b/tests/ast_json_fixtures/shapes/73741b89226308db.sql new file mode 100644 index 000000000000..476855f3367b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73741b89226308db.sql @@ -0,0 +1,11 @@ +REPLACE TABLE t +( + `timestamp` DateTime, + `id` String, + `value` String, +) +ENGINE = MergeTree +ORDER BY (id, toStartOfDay(timestamp)) +TTL timestamp + toIntervalDay(1) + GROUP BY id, toStartOfDay(timestamp) + SET timestamp = max(timestamp) + interval 100 years, id = max(value) diff --git a/tests/ast_json_fixtures/shapes/738c4f37377fb6e3.json b/tests/ast_json_fixtures/shapes/738c4f37377fb6e3.json new file mode 100644 index 000000000000..4627cc3f36ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/738c4f37377fb6e3.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "test_table with spaces" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Identifier", + "name": "id" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/738c4f37377fb6e3.sql b/tests/ast_json_fixtures/shapes/738c4f37377fb6e3.sql new file mode 100644 index 000000000000..4ee6e660c762 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/738c4f37377fb6e3.sql @@ -0,0 +1,6 @@ +create table if not exists `test_table with spaces` +( + `id` UInt64, + `value` String +) +ORDER by id diff --git a/tests/ast_json_fixtures/shapes/73a801156de24877.json b/tests/ast_json_fixtures/shapes/73a801156de24877.json new file mode 100644 index 000000000000..7489d547d29d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73a801156de24877.json @@ -0,0 +1,83 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "nORX" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "B" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "A" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "B" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/73a801156de24877.sql b/tests/ast_json_fixtures/shapes/73a801156de24877.sql new file mode 100644 index 000000000000..431bc1a8f57a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73a801156de24877.sql @@ -0,0 +1,8 @@ +SELECT * +FROM nORX +WHERE B >= 1000 +ORDER BY + A ASC, + -B ASC +LIMIT 3 +SETTINGS max_threads = 1 diff --git a/tests/ast_json_fixtures/shapes/73b51ca144c5df0b.json b/tests/ast_json_fixtures/shapes/73b51ca144c5df0b.json new file mode 100644 index 000000000000..a0c40982fc25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73b51ca144c5df0b.json @@ -0,0 +1,219 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "alias": "toNullable(toNullable(materialize(toLowCardinality(30))))", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + }, + { + "type": "Literal", + "value_type": "String", + "value": "LowCardinality(UInt8)" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "makeDate(-1980.1, -1980.1, 10)", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Date" + } + ] + }, + { + "type": "Function", + "alias": "toLowCardinality(30)", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + }, + { + "type": "Literal", + "value_type": "String", + "value": "LowCardinality(UInt8)" + } + ] + }, + { + "type": "Literal", + "alias": "30", + "value_type": "UInt64", + "value": "30" + }, + { + "type": "Function", + "alias": "makeDate(materialize(toLowCardinality(30)), 10, toNullable(toNullable(30)))", + "name": "makeDate", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + }, + { + "type": "Literal", + "value_type": "String", + "value": "LowCardinality(UInt8)" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(UInt8)" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "-1980.1", + "value_type": "Float64", + "value": -1980.1 + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "__table1", + "name": "one", + "database": "system" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(UInt8)" + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": -1980.1 + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + } + ] + }, + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(UInt8)" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/73b51ca144c5df0b.sql b/tests/ast_json_fixtures/shapes/73b51ca144c5df0b.sql new file mode 100644 index 000000000000..600cedb000ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73b51ca144c5df0b.sql @@ -0,0 +1,16 @@ +SELECT + toNullable(toNullable(materialize(_CAST(30, 'LowCardinality(UInt8)')))) AS `toNullable(toNullable(materialize(toLowCardinality(30))))`, + _CAST(0, 'Date') AS `makeDate(-1980.1, -1980.1, 10)`, + _CAST(30, 'LowCardinality(UInt8)') AS `toLowCardinality(30)`, + 30 AS `30`, + makeDate(materialize(_CAST(30, 'LowCardinality(UInt8)')), 10, _CAST(30, 'Nullable(UInt8)')) AS `makeDate(materialize(toLowCardinality(30)), 10, toNullable(toNullable(30)))`, + -1980.1 AS `-1980.1` +FROM system.one AS __table1 +GROUP BY + _CAST(30, 'Nullable(UInt8)'), + -1980.1, + materialize(30), + _CAST(30, 'Nullable(UInt8)') +WITH CUBE +WITH TOTALS +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/73baa5c52b6d7b0f.json b/tests/ast_json_fixtures/shapes/73baa5c52b6d7b0f.json new file mode 100644 index 000000000000..0fc006b377c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73baa5c52b6d7b0f.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_table": "t1", + "to_database": "test_01109_other_atomic", + "to_table": "t3" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/73baa5c52b6d7b0f.sql b/tests/ast_json_fixtures/shapes/73baa5c52b6d7b0f.sql new file mode 100644 index 000000000000..72b7505e7065 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73baa5c52b6d7b0f.sql @@ -0,0 +1 @@ +EXCHANGE TABLES t1 AND test_01109_other_atomic.t3 diff --git a/tests/ast_json_fixtures/shapes/73cb5c29e11ecc7f.json b/tests/ast_json_fixtures/shapes/73cb5c29e11ecc7f.json new file mode 100644 index 000000000000..c3d38e7fe122 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73cb5c29e11ecc7f.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02102_test_function" + } +} diff --git a/tests/ast_json_fixtures/shapes/73cb5c29e11ecc7f.sql b/tests/ast_json_fixtures/shapes/73cb5c29e11ecc7f.sql new file mode 100644 index 000000000000..0e066f95b6de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73cb5c29e11ecc7f.sql @@ -0,0 +1 @@ +DROP FUNCTION 02102_test_function diff --git a/tests/ast_json_fixtures/shapes/73d63d9cc8269ffc.json b/tests/ast_json_fixtures/shapes/73d63d9cc8269ffc.json new file mode 100644 index 000000000000..8a277cbdb309 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73d63d9cc8269ffc.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "u" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_sparse_full" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/73d63d9cc8269ffc.sql b/tests/ast_json_fixtures/shapes/73d63d9cc8269ffc.sql new file mode 100644 index 000000000000..80a8550ba4bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73d63d9cc8269ffc.sql @@ -0,0 +1 @@ +SELECT DISTINCT u FROM t_sparse_full ORDER BY id LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/73dc224582739c71.json b/tests/ast_json_fixtures/shapes/73dc224582739c71.json new file mode 100644 index 000000000000..0d3321264e3c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73dc224582739c71.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s3_01294", "s4_01294"], + "to_roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/73dc224582739c71.sql b/tests/ast_json_fixtures/shapes/73dc224582739c71.sql new file mode 100644 index 000000000000..717debecd1b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73dc224582739c71.sql @@ -0,0 +1 @@ +CREATE PROFILE s3_01294, s4_01294 TO ALL diff --git a/tests/ast_json_fixtures/shapes/73fd45c0f7f15512.json b/tests/ast_json_fixtures/shapes/73fd45c0f7f15512.json new file mode 100644 index 000000000000..e211df2d7aba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73fd45c0f7f15512.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "t_json_10" + }, + "format": "JSONAsObject" + } +} diff --git a/tests/ast_json_fixtures/shapes/73fd45c0f7f15512.sql b/tests/ast_json_fixtures/shapes/73fd45c0f7f15512.sql new file mode 100644 index 000000000000..afcd95f6fadb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/73fd45c0f7f15512.sql @@ -0,0 +1,5 @@ +INSERT INTO t_json_10 FORMAT JSONAsObject {"a": {"b": 1, "c": [{"d": 10, "e": [31]}, {"d": 20, "e": [63, 127]}]}} {"a": {"b": 2, "c": []}} + +INSERT INTO t_json_10 FORMAT JSONAsObject {"a": {"b": 3, "c": [{"f": 20, "e": [32]}, {"f": 30, "e": [64, 128]}]}} {"a": {"b": 4, "c": []}} + +SELECT DISTINCT arrayJoin(JSONAllPathsWithTypes(o)) as path FROM t_json_10 order by path diff --git a/tests/ast_json_fixtures/shapes/7430447755024a5a.json b/tests/ast_json_fixtures/shapes/7430447755024a5a.json new file mode 100644 index 000000000000..c3dde3d4e2bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7430447755024a5a.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ], + "select": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7430447755024a5a.sql b/tests/ast_json_fixtures/shapes/7430447755024a5a.sql new file mode 100644 index 000000000000..0e8a6e99493e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7430447755024a5a.sql @@ -0,0 +1 @@ +WITH 1 as n FROM numbers(1) SELECT number * n diff --git a/tests/ast_json_fixtures/shapes/7442d7f883708e82.json b/tests/ast_json_fixtures/shapes/7442d7f883708e82.json new file mode 100644 index 000000000000..22f6dc507e06 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7442d7f883708e82.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02484_plusthree", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/7442d7f883708e82.sql b/tests/ast_json_fixtures/shapes/7442d7f883708e82.sql new file mode 100644 index 000000000000..3440c7a64898 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7442d7f883708e82.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02484_plusthree diff --git a/tests/ast_json_fixtures/shapes/745397d537847f71.json b/tests/ast_json_fixtures/shapes/745397d537847f71.json new file mode 100644 index 000000000000..dd8ce2e29bbd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/745397d537847f71.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q1_01297", "q2_01297", "q3_01297", "q4_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/745397d537847f71.sql b/tests/ast_json_fixtures/shapes/745397d537847f71.sql new file mode 100644 index 000000000000..effbd7e9bcec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/745397d537847f71.sql @@ -0,0 +1 @@ +DROP QUOTA q1_01297, q2_01297, q3_01297, q4_01297 diff --git a/tests/ast_json_fixtures/shapes/745dc84ccbb1e4cf.json b/tests/ast_json_fixtures/shapes/745dc84ccbb1e4cf.json new file mode 100644 index 000000000000..26cabd52c051 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/745dc84ccbb1e4cf.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "_part_granule_offset" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_part_granule_offset" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/745dc84ccbb1e4cf.sql b/tests/ast_json_fixtures/shapes/745dc84ccbb1e4cf.sql new file mode 100644 index 000000000000..eb1428f9c07f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/745dc84ccbb1e4cf.sql @@ -0,0 +1 @@ +SELECT _part_granule_offset FROM test_part_granule_offset WHERE n < 10 ORDER BY all diff --git a/tests/ast_json_fixtures/shapes/747bd83b2427a814.json b/tests/ast_json_fixtures/shapes/747bd83b2427a814.json new file mode 100644 index 000000000000..0b60c3321489 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/747bd83b2427a814.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "alias": "key", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/747bd83b2427a814.sql b/tests/ast_json_fixtures/shapes/747bd83b2427a814.sql new file mode 100644 index 000000000000..27105770f734 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/747bd83b2427a814.sql @@ -0,0 +1 @@ +SELECT number % toUInt256(2) AS key, count() FROM numbers(10) GROUP BY key WITH CUBE WITH TOTALS QUALIFY key = toNullable(toNullable(0)) diff --git a/tests/ast_json_fixtures/shapes/747d01e4f774c7d8.json b/tests/ast_json_fixtures/shapes/747d01e4f774c7d8.json new file mode 100644 index 000000000000..95c48c42d9e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/747d01e4f774c7d8.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "UInt32" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/747d01e4f774c7d8.sql b/tests/ast_json_fixtures/shapes/747d01e4f774c7d8.sql new file mode 100644 index 000000000000..56f14b64dc1f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/747d01e4f774c7d8.sql @@ -0,0 +1 @@ +create table t1(a Array(UInt32)) ENGINE = MergeTree ORDER BY tuple() as select [1,2] diff --git a/tests/ast_json_fixtures/shapes/749f819198004ff2.json b/tests/ast_json_fixtures/shapes/749f819198004ff2.json new file mode 100644 index 000000000000..fceb5f6013c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/749f819198004ff2.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u7_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "DOUBLE_SHA1_PASSWORD", + "contains_hash": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "8DCDD69CE7D121DE8013062AEAEB2A148910D50E" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/749f819198004ff2.sql b/tests/ast_json_fixtures/shapes/749f819198004ff2.sql new file mode 100644 index 000000000000..6b0681043932 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/749f819198004ff2.sql @@ -0,0 +1 @@ +CREATE USER u7_01292 IDENTIFIED WITH double_sha1_hash BY '8DCDD69CE7D121DE8013062AEAEB2A148910D50E' diff --git a/tests/ast_json_fixtures/shapes/74d9d68587916eb7.json b/tests/ast_json_fixtures/shapes/74d9d68587916eb7.json new file mode 100644 index 000000000000..a1dc9d0a5647 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/74d9d68587916eb7.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u10_01292", "u11_01292", "u12_01292", "u13_01292", "u14_01292", "u15_01292", "u16_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/74d9d68587916eb7.sql b/tests/ast_json_fixtures/shapes/74d9d68587916eb7.sql new file mode 100644 index 000000000000..3e10afd64d6e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/74d9d68587916eb7.sql @@ -0,0 +1 @@ +DROP USER u10_01292, u11_01292, u12_01292, u13_01292, u14_01292, u15_01292, u16_01292 diff --git a/tests/ast_json_fixtures/shapes/74f1cadfe447f7f7.json b/tests/ast_json_fixtures/shapes/74f1cadfe447f7f7.json new file mode 100644 index 000000000000..19b6db634111 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/74f1cadfe447f7f7.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "sqllt_policy", + "database": "sqllt", + "table": "table" + }, + { + "short_name": "sqllt_policy", + "database": "sqllt", + "table": "view" + }, + { + "short_name": "sqllt_policy", + "database": "sqllt", + "table": "dictionary" + } + ] + }, + "is_restrictive": false, + "roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/74f1cadfe447f7f7.sql b/tests/ast_json_fixtures/shapes/74f1cadfe447f7f7.sql new file mode 100644 index 000000000000..fc9387054553 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/74f1cadfe447f7f7.sql @@ -0,0 +1 @@ +CREATE POLICY sqllt_policy ON sqllt.table, sqllt.view, sqllt.dictionary AS PERMISSIVE TO ALL diff --git a/tests/ast_json_fixtures/shapes/751537349d31a892.json b/tests/ast_json_fixtures/shapes/751537349d31a892.json new file mode 100644 index 000000000000..14958b4ee7e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/751537349d31a892.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s1_01294"], + "to_roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/751537349d31a892.sql b/tests/ast_json_fixtures/shapes/751537349d31a892.sql new file mode 100644 index 000000000000..7331d18fe826 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/751537349d31a892.sql @@ -0,0 +1 @@ +CREATE PROFILE s1_01294 TO NONE diff --git a/tests/ast_json_fixtures/shapes/751d9a534d9c9b3d.json b/tests/ast_json_fixtures/shapes/751d9a534d9c9b3d.json new file mode 100644 index 000000000000..cc8f95a596bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/751d9a534d9c9b3d.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "db1_03101" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tbl" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/751d9a534d9c9b3d.sql b/tests/ast_json_fixtures/shapes/751d9a534d9c9b3d.sql new file mode 100644 index 000000000000..6e4f639808fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/751d9a534d9c9b3d.sql @@ -0,0 +1 @@ +SELECT db1_03101.* FROM tbl diff --git a/tests/ast_json_fixtures/shapes/75214efbbb17445a.json b/tests/ast_json_fixtures/shapes/75214efbbb17445a.json new file mode 100644 index 000000000000..976f58c10daa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/75214efbbb17445a.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "t_lwu_merges" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_throw_if_noop": "1" + } + }, + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + }, + "final": true + } +} diff --git a/tests/ast_json_fixtures/shapes/75214efbbb17445a.sql b/tests/ast_json_fixtures/shapes/75214efbbb17445a.sql new file mode 100644 index 000000000000..d31783d68e09 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/75214efbbb17445a.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE t_lwu_merges PARTITION 0 FINAL SETTINGS optimize_throw_if_noop = 1 diff --git a/tests/ast_json_fixtures/shapes/755b3d9e5d46b32f.json b/tests/ast_json_fixtures/shapes/755b3d9e5d46b32f.json new file mode 100644 index 000000000000..0e42a6e2696e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/755b3d9e5d46b32f.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "BFloat16" + }, + "primary_key_specifier": true + } + ], + "primary_key_from_columns": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + } + ] + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "SummingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "ratio_of_defaults_for_sparse_serialization": 1 + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/755b3d9e5d46b32f.sql b/tests/ast_json_fixtures/shapes/755b3d9e5d46b32f.sql new file mode 100644 index 000000000000..f67bc7fcca6c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/755b3d9e5d46b32f.sql @@ -0,0 +1 @@ +CREATE TABLE tab (c0 BFloat16 PRIMARY KEY) ENGINE = SummingMergeTree() SETTINGS ratio_of_defaults_for_sparse_serialization = 1.0 diff --git a/tests/ast_json_fixtures/shapes/75605b38e3db1544.json b/tests/ast_json_fixtures/shapes/75605b38e3db1544.json new file mode 100644 index 000000000000..2e4e55f4c676 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/75605b38e3db1544.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "prop_table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REMOVE_TTL" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/75605b38e3db1544.sql b/tests/ast_json_fixtures/shapes/75605b38e3db1544.sql new file mode 100644 index 000000000000..d3a174a0fd89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/75605b38e3db1544.sql @@ -0,0 +1 @@ +ALTER TABLE prop_table REMOVE TTL diff --git a/tests/ast_json_fixtures/shapes/757143d948081008.json b/tests/ast_json_fixtures/shapes/757143d948081008.json new file mode 100644 index 000000000000..00aa9bfb925a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/757143d948081008.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowIndexes", + "table": "$4@^7" + } +} diff --git a/tests/ast_json_fixtures/shapes/757143d948081008.sql b/tests/ast_json_fixtures/shapes/757143d948081008.sql new file mode 100644 index 000000000000..1da07e35cc98 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/757143d948081008.sql @@ -0,0 +1 @@ +SHOW INDEX FROM `$4@^7` diff --git a/tests/ast_json_fixtures/shapes/758464edf8a2d845.json b/tests/ast_json_fixtures/shapes/758464edf8a2d845.json new file mode 100644 index 000000000000..7e5cc14b446c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/758464edf8a2d845.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "c0.size", + "name_parts": ["c0", "size"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Identifier", + "name": "c0.size", + "name_parts": ["c0", "size"] + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/758464edf8a2d845.sql b/tests/ast_json_fixtures/shapes/758464edf8a2d845.sql new file mode 100644 index 000000000000..f896e9a3c1a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/758464edf8a2d845.sql @@ -0,0 +1 @@ +SELECT [1] || c0.size FROM t0 GROUP BY 1, c0, c0.size WITH ROLLUP format Null diff --git a/tests/ast_json_fixtures/shapes/759a6227ae7aaba9.json b/tests/ast_json_fixtures/shapes/759a6227ae7aaba9.json new file mode 100644 index 000000000000..3cb0229e5d3e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/759a6227ae7aaba9.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "BackupQuery", + "kind": "BACKUP", + "elements": [ + { + "element_type": "TABLE", + "table": "03593_backup_with_broken_projection" + } + ], + "backup_name": { + "type": "Function", + "name": "Null", + "kind": "BACKUP_NAME", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_backup_broken_projections": true, + "check_projection_parts": false + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/759a6227ae7aaba9.sql b/tests/ast_json_fixtures/shapes/759a6227ae7aaba9.sql new file mode 100644 index 000000000000..5ae539d45952 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/759a6227ae7aaba9.sql @@ -0,0 +1 @@ +BACKUP TABLE 03593_backup_with_broken_projection TO Null SETTINGS allow_backup_broken_projections = true, check_projection_parts = false FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/75a9397bddb44bb9.json b/tests/ast_json_fixtures/shapes/75a9397bddb44bb9.json new file mode 100644 index 000000000000..48d6ee345f80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/75a9397bddb44bb9.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distr" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "local" + } + ] + } + }, + "as_table": "local" + } +} diff --git a/tests/ast_json_fixtures/shapes/75a9397bddb44bb9.sql b/tests/ast_json_fixtures/shapes/75a9397bddb44bb9.sql new file mode 100644 index 000000000000..f39d185ba608 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/75a9397bddb44bb9.sql @@ -0,0 +1 @@ +create table distr as local engine = Distributed('test_cluster_two_shards', currentDatabase(), local) diff --git a/tests/ast_json_fixtures/shapes/75bdc0e1472ad7f8.json b/tests/ast_json_fixtures/shapes/75bdc0e1472ad7f8.json new file mode 100644 index 000000000000..7be63fb2bcf4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/75bdc0e1472ad7f8.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "name", + "name": "concat", + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Identifier", + "name": "table" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "clusterAllReplicas", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Identifier", + "name": "system.tables", + "name_parts": ["system", "tables"] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "name" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/75bdc0e1472ad7f8.sql b/tests/ast_json_fixtures/shapes/75bdc0e1472ad7f8.sql new file mode 100644 index 000000000000..fad9c68e45a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/75bdc0e1472ad7f8.sql @@ -0,0 +1,7 @@ +SELECT + concat(database, table) AS name, + count() +FROM clusterAllReplicas(test_shard_localhost, system.tables) +WHERE database=currentDatabase() +GROUP BY name +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/75febe6e2b3597ff.json b/tests/ast_json_fixtures/shapes/75febe6e2b3597ff.json new file mode 100644 index 000000000000..c7522a184805 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/75febe6e2b3597ff.json @@ -0,0 +1,584 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Function", + "alias": "dt64_typename", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "<" + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + } + ] + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Function", + "name": "toDateTime64", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "<=" + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + } + ] + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Function", + "name": "toDateTime64", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "=" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + } + ] + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Function", + "name": "toDateTime64", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": ">=" + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + } + ] + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Function", + "name": "toDateTime64", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": ">" + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + } + ] + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Function", + "name": "toDateTime64", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "!=" + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + } + ] + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dt64" + }, + { + "type": "Function", + "name": "toDateTime64", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "val", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2019-09-16 19:20:11" + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "n", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "dt64", + "name": "toDateTime64", + "arguments": [ + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/75febe6e2b3597ff.sql b/tests/ast_json_fixtures/shapes/75febe6e2b3597ff.sql new file mode 100644 index 000000000000..a61bcff4db7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/75febe6e2b3597ff.sql @@ -0,0 +1,43 @@ +SELECT + n, + toTypeName(dt64) AS dt64_typename, + + '<', + dt64 < d, + toDate(dt64) < d, + dt64 < toDateTime64(d, 1, 'UTC'), + + '<=', + dt64 <= d, + toDate(dt64) <= d, + dt64 <= toDateTime64(d, 1, 'UTC'), + + '=', + dt64 = d, + toDate(dt64) = d, + dt64 = toDateTime64(d, 1, 'UTC'), + + '>=', + dt64 >= d, + toDate(dt64) >= d, + dt64 >= toDateTime64(d, 1, 'UTC'), + + '>', + dt64 > d, + toDate(dt64) > d, + dt64 > toDateTime64(d, 1, 'UTC'), + + '!=', + dt64 != d, + toDate(dt64) != d, + dt64 != toDateTime64(d, 1, 'UTC') +FROM +( + WITH toDateTime('2019-09-16 19:20:11') as val + SELECT + number - 1 as n, + toDateTime64(val, 1, 'UTC') AS dt64, + toDate(val, 'UTC') - n as d + FROM system.numbers + LIMIT 3 +) diff --git a/tests/ast_json_fixtures/shapes/7603342213c295ae.json b/tests/ast_json_fixtures/shapes/7603342213c295ae.json new file mode 100644 index 000000000000..715b968c057f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7603342213c295ae.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distributed_table2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "source_table2" + } + ] + } + }, + "as_table": "source_table2" + } +} diff --git a/tests/ast_json_fixtures/shapes/7603342213c295ae.sql b/tests/ast_json_fixtures/shapes/7603342213c295ae.sql new file mode 100644 index 000000000000..63b274dfa708 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7603342213c295ae.sql @@ -0,0 +1,2 @@ +CREATE TABLE distributed_table2 AS source_table2 +ENGINE = Distributed('test_shard_localhost', currentDatabase(), source_table2) diff --git a/tests/ast_json_fixtures/shapes/7604ca3b31246815.json b/tests/ast_json_fixtures/shapes/7604ca3b31246815.json new file mode 100644 index 000000000000..842796e404fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7604ca3b31246815.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "i" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/7604ca3b31246815.sql b/tests/ast_json_fixtures/shapes/7604ca3b31246815.sql new file mode 100644 index 000000000000..0cd1bb40f9b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7604ca3b31246815.sql @@ -0,0 +1 @@ +select max(i) from test where i < 20 limit 1 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/760af25fbeb79d8b.json b/tests/ast_json_fixtures/shapes/760af25fbeb79d8b.json new file mode 100644 index 000000000000..ef8795ea7c23 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/760af25fbeb79d8b.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "name", + "name": "concat", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "name_" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + } + ], + "format": "JSONObjectEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/760af25fbeb79d8b.sql b/tests/ast_json_fixtures/shapes/760af25fbeb79d8b.sql new file mode 100644 index 000000000000..6f8944aa9bec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/760af25fbeb79d8b.sql @@ -0,0 +1 @@ +select number, concat('name_', toString(number)) as name from numbers(3) format JSONObjectEachRow diff --git a/tests/ast_json_fixtures/shapes/760d465d55ae7628.json b/tests/ast_json_fixtures/shapes/760d465d55ae7628.json new file mode 100644 index 000000000000..055ac99395e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/760d465d55ae7628.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "value", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "String", + "value": "Value" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple (id UInt64, value String)" + } + ] + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "value" + }, + "transformers": [ + { + "type": "ColumnsApplyTransformer", + "func_name": "toString" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/760d465d55ae7628.sql b/tests/ast_json_fixtures/shapes/760d465d55ae7628.sql new file mode 100644 index 000000000000..b333fee19009 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/760d465d55ae7628.sql @@ -0,0 +1 @@ +SELECT cast((1, 'Value'), 'Tuple (id UInt64, value String)') AS value, value.* APPLY toString diff --git a/tests/ast_json_fixtures/shapes/761e6386538eecf9.json b/tests/ast_json_fixtures/shapes/761e6386538eecf9.json new file mode 100644 index 000000000000..574e72613d6f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/761e6386538eecf9.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u5_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/761e6386538eecf9.sql b/tests/ast_json_fixtures/shapes/761e6386538eecf9.sql new file mode 100644 index 000000000000..718d43e92e3a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/761e6386538eecf9.sql @@ -0,0 +1 @@ +SHOW CREATE USER u5_01292 diff --git a/tests/ast_json_fixtures/shapes/763c029c6f86ae33.json b/tests/ast_json_fixtures/shapes/763c029c6f86ae33.json new file mode 100644 index 000000000000..ade7bc98f031 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/763c029c6f86ae33.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "lwd_test_02521" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_TTL", + "ttl": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_time" + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/763c029c6f86ae33.sql b/tests/ast_json_fixtures/shapes/763c029c6f86ae33.sql new file mode 100644 index 000000000000..c741813e7263 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/763c029c6f86ae33.sql @@ -0,0 +1 @@ +ALTER TABLE lwd_test_02521 MODIFY TTL event_time + INTERVAL 1 MONTH SETTINGS mutations_sync = 1 diff --git a/tests/ast_json_fixtures/shapes/763cc5057352bcd1.json b/tests/ast_json_fixtures/shapes/763cc5057352bcd1.json new file mode 100644 index 000000000000..da367c112d37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/763cc5057352bcd1.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "lambda", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Subquery", + "alias": "lambda", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/763cc5057352bcd1.sql b/tests/ast_json_fixtures/shapes/763cc5057352bcd1.sql new file mode 100644 index 000000000000..041e20478b9c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/763cc5057352bcd1.sql @@ -0,0 +1 @@ +WITH x -> x + 1 AS lambda SELECT (SELECT 1) AS lambda diff --git a/tests/ast_json_fixtures/shapes/764d46a084d668e4.json b/tests/ast_json_fixtures/shapes/764d46a084d668e4.json new file mode 100644 index 000000000000..fbabfe3bf35e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/764d46a084d668e4.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "12" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/764d46a084d668e4.sql b/tests/ast_json_fixtures/shapes/764d46a084d668e4.sql new file mode 100644 index 000000000000..3a02429357b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/764d46a084d668e4.sql @@ -0,0 +1 @@ +SELECT 12 AS n GROUP BY n WITH ROLLUP diff --git a/tests/ast_json_fixtures/shapes/764eea3aaae29035.json b/tests/ast_json_fixtures/shapes/764eea3aaae29035.json new file mode 100644 index 000000000000..742d1f70f8c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/764eea3aaae29035.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data_01801" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "9" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/764eea3aaae29035.sql b/tests/ast_json_fixtures/shapes/764eea3aaae29035.sql new file mode 100644 index 000000000000..f14cfca09cbd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/764eea3aaae29035.sql @@ -0,0 +1 @@ +select * from data_01801 where key = 0 order by key settings max_rows_to_read=9 format Null diff --git a/tests/ast_json_fixtures/shapes/764ff1efefc6d17f.json b/tests/ast_json_fixtures/shapes/764ff1efefc6d17f.json new file mode 100644 index 000000000000..87267a524cc6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/764ff1efefc6d17f.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t1" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "using": [ + { + "type": "Identifier", + "name": "y" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "y" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/764ff1efefc6d17f.sql b/tests/ast_json_fixtures/shapes/764ff1efefc6d17f.sql new file mode 100644 index 000000000000..f9a0a01ada00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/764ff1efefc6d17f.sql @@ -0,0 +1 @@ +SELECT t1.* FROM t0 FULL JOIN t1 USING (y) JOIN t2 USING (y) PREWHERE toLowCardinality(1) diff --git a/tests/ast_json_fixtures/shapes/7680a607290aa236.json b/tests/ast_json_fixtures/shapes/7680a607290aa236.json new file mode 100644 index 000000000000..272932541892 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7680a607290aa236.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "replace_table": true, + "table": { + "type": "Identifier", + "name": "join" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Join", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "ANY" + }, + { + "type": "Identifier", + "name": "INNER" + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7680a607290aa236.sql b/tests/ast_json_fixtures/shapes/7680a607290aa236.sql new file mode 100644 index 000000000000..561d935fb7d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7680a607290aa236.sql @@ -0,0 +1 @@ +replace table join engine=Join(ANY, INNER, n) as select * from t diff --git a/tests/ast_json_fixtures/shapes/768986774a10f345.json b/tests/ast_json_fixtures/shapes/768986774a10f345.json new file mode 100644 index 000000000000..93d339a5a0a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/768986774a10f345.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "i" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "cluster", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/768986774a10f345.sql b/tests/ast_json_fixtures/shapes/768986774a10f345.sql new file mode 100644 index 000000000000..0d8d185b949b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/768986774a10f345.sql @@ -0,0 +1 @@ +select max(i) from cluster(test_cluster_two_shards, currentDatabase(), test) where i < 20 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/76b539c7fb1b7bc7.json b/tests/ast_json_fixtures/shapes/76b539c7fb1b7bc7.json new file mode 100644 index 000000000000..f85f90fd54a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76b539c7fb1b7bc7.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "DISABLE FAILPOINT", + "fail_point_name": "use_delayed_remote_source" + } +} diff --git a/tests/ast_json_fixtures/shapes/76b539c7fb1b7bc7.sql b/tests/ast_json_fixtures/shapes/76b539c7fb1b7bc7.sql new file mode 100644 index 000000000000..d59dea948d77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76b539c7fb1b7bc7.sql @@ -0,0 +1 @@ +SYSTEM DISABLE FAILPOINT use_delayed_remote_source diff --git a/tests/ast_json_fixtures/shapes/76c9856536b62570.json b/tests/ast_json_fixtures/shapes/76c9856536b62570.json new file mode 100644 index 000000000000..96ebe4288599 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76c9856536b62570.json @@ -0,0 +1,104 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "257" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_having" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775808" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-2147483649" + }, + { + "type": "Identifier", + "name": "c0" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775808" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_optimize_predicate_expression": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/76c9856536b62570.sql b/tests/ast_json_fixtures/shapes/76c9856536b62570.sql new file mode 100644 index 000000000000..c04a7ddf150f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76c9856536b62570.sql @@ -0,0 +1 @@ +SELECT sum(c0 + 257) FROM t_having GROUP BY c0 = -9223372036854775808, NULL, -2147483649, c0 HAVING c0 = -9223372036854775808 SETTINGS enable_optimize_predicate_expression = 0 diff --git a/tests/ast_json_fixtures/shapes/76dd556c480c919f.json b/tests/ast_json_fixtures/shapes/76dd556c480c919f.json new file mode 100644 index 000000000000..d91b0838e608 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76dd556c480c919f.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q14_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/76dd556c480c919f.sql b/tests/ast_json_fixtures/shapes/76dd556c480c919f.sql new file mode 100644 index 000000000000..f8a386d909cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76dd556c480c919f.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q14_01297 diff --git a/tests/ast_json_fixtures/shapes/76df46755d90938a.json b/tests/ast_json_fixtures/shapes/76df46755d90938a.json new file mode 100644 index 000000000000..000aa9573759 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76df46755d90938a.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "CreateIndexQuery", + "table": { + "type": "Identifier", + "name": "t_index_3146" + }, + "index_name": { + "type": "Identifier", + "name": "i2" + }, + "index_declaration": { + "type": "Index", + "name": "i2", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + } +} diff --git a/tests/ast_json_fixtures/shapes/76df46755d90938a.sql b/tests/ast_json_fixtures/shapes/76df46755d90938a.sql new file mode 100644 index 000000000000..91005b8ef706 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76df46755d90938a.sql @@ -0,0 +1 @@ +CREATE INDEX i2 ON t_index_3146 (a, b) TYPE minmax diff --git a/tests/ast_json_fixtures/shapes/76e55a9ac87620b8.json b/tests/ast_json_fixtures/shapes/76e55a9ac87620b8.json new file mode 100644 index 000000000000..480e768a6749 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76e55a9ac87620b8.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u6_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/76e55a9ac87620b8.sql b/tests/ast_json_fixtures/shapes/76e55a9ac87620b8.sql new file mode 100644 index 000000000000..de40a00ead9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76e55a9ac87620b8.sql @@ -0,0 +1 @@ +SHOW CREATE USER u6_01292 diff --git a/tests/ast_json_fixtures/shapes/76e57e11b60511ae.json b/tests/ast_json_fixtures/shapes/76e57e11b60511ae.json new file mode 100644 index 000000000000..bd5931639329 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76e57e11b60511ae.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["WRITE"], + "parameter": "ODBC" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_03593"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/76e57e11b60511ae.sql b/tests/ast_json_fixtures/shapes/76e57e11b60511ae.sql new file mode 100644 index 000000000000..f9f5a7f7feeb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76e57e11b60511ae.sql @@ -0,0 +1 @@ +GRANT WRITE ON ODBC TO test_user_03593 diff --git a/tests/ast_json_fixtures/shapes/76ecfb2bc24f98cd.json b/tests/ast_json_fixtures/shapes/76ecfb2bc24f98cd.json new file mode 100644 index 000000000000..edf59e96448e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76ecfb2bc24f98cd.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "summing" + }, + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "197001" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/76ecfb2bc24f98cd.sql b/tests/ast_json_fixtures/shapes/76ecfb2bc24f98cd.sql new file mode 100644 index 000000000000..a81d375ddb4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/76ecfb2bc24f98cd.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE summing PARTITION 197001 diff --git a/tests/ast_json_fixtures/shapes/7708c6b2ab5dab8e.json b/tests/ast_json_fixtures/shapes/7708c6b2ab5dab8e.json new file mode 100644 index 000000000000..02288a84ee1f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7708c6b2ab5dab8e.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r1_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7708c6b2ab5dab8e.sql b/tests/ast_json_fixtures/shapes/7708c6b2ab5dab8e.sql new file mode 100644 index 000000000000..e0e364fe17a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7708c6b2ab5dab8e.sql @@ -0,0 +1 @@ +CREATE ROLE r1_01293 SETTINGS NONE diff --git a/tests/ast_json_fixtures/shapes/770d358621f62d8e.json b/tests/ast_json_fixtures/shapes/770d358621f62d8e.json new file mode 100644 index 000000000000..c951108e8c27 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/770d358621f62d8e.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01223" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/770d358621f62d8e.sql b/tests/ast_json_fixtures/shapes/770d358621f62d8e.sql new file mode 100644 index 000000000000..b8c029e896e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/770d358621f62d8e.sql @@ -0,0 +1 @@ +select * from dist_01223 group by key order by key diff --git a/tests/ast_json_fixtures/shapes/770d3ec7f7b4785f.json b/tests/ast_json_fixtures/shapes/770d3ec7f7b4785f.json new file mode 100644 index 000000000000..3cb749bc70f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/770d3ec7f7b4785f.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "database": { + "type": "Identifier", + "name": "db_dict" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/770d3ec7f7b4785f.sql b/tests/ast_json_fixtures/shapes/770d3ec7f7b4785f.sql new file mode 100644 index 000000000000..0b6255c2faf1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/770d3ec7f7b4785f.sql @@ -0,0 +1 @@ +CREATE DATABASE IF NOT EXISTS db_dict diff --git a/tests/ast_json_fixtures/shapes/7717c1eb431188a2.json b/tests/ast_json_fixtures/shapes/7717c1eb431188a2.json new file mode 100644 index 000000000000..d9437fdeb595 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7717c1eb431188a2.json @@ -0,0 +1,122 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/7717c1eb431188a2.sql b/tests/ast_json_fixtures/shapes/7717c1eb431188a2.sql new file mode 100644 index 000000000000..b8d9ab15c546 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7717c1eb431188a2.sql @@ -0,0 +1 @@ +SELECT ignore(x), count() FROM (SELECT number AS x FROM system.numbers LIMIT 1000 UNION ALL SELECT number AS x FROM system.numbers LIMIT 1000) GROUP BY x WITH TOTALS LIMIT 10 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/7742c6545de7a9d9.json b/tests/ast_json_fixtures/shapes/7742c6545de7a9d9.json new file mode 100644 index 000000000000..c73eff5e3008 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7742c6545de7a9d9.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "1", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ] + } + ], + "format": "JSONLines" + } +} diff --git a/tests/ast_json_fixtures/shapes/7742c6545de7a9d9.sql b/tests/ast_json_fixtures/shapes/7742c6545de7a9d9.sql new file mode 100644 index 000000000000..328dd46203af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7742c6545de7a9d9.sql @@ -0,0 +1 @@ +SELECT ‘’ = '' AS “1” FORMAT JSONLines diff --git a/tests/ast_json_fixtures/shapes/7747c3cf6b6248cd.json b/tests/ast_json_fixtures/shapes/7747c3cf6b6248cd.json new file mode 100644 index 000000000000..189a07df8f12 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7747c3cf6b6248cd.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "query_log" + }, + { + "table": "processors_profile_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7747c3cf6b6248cd.sql b/tests/ast_json_fixtures/shapes/7747c3cf6b6248cd.sql new file mode 100644 index 000000000000..9b0a841871e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7747c3cf6b6248cd.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS query_log, processors_profile_log diff --git a/tests/ast_json_fixtures/shapes/778b460a5dd01490.json b/tests/ast_json_fixtures/shapes/778b460a5dd01490.json new file mode 100644 index 000000000000..6b7c52dd6b4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/778b460a5dd01490.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "repeat", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "80" + } + ] + } + ] + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/778b460a5dd01490.sql b/tests/ast_json_fixtures/shapes/778b460a5dd01490.sql new file mode 100644 index 000000000000..737e8f2f11f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/778b460a5dd01490.sql @@ -0,0 +1 @@ +select repeat('-', 80) format JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/778d907bbe783145.json b/tests/ast_json_fixtures/shapes/778d907bbe783145.json new file mode 100644 index 000000000000..4302aa290cdc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/778d907bbe783145.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "attach_partition_t2" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "replace": false, + "from_table": "attach_partition_t1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/778d907bbe783145.sql b/tests/ast_json_fixtures/shapes/778d907bbe783145.sql new file mode 100644 index 000000000000..bd07d2dc50c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/778d907bbe783145.sql @@ -0,0 +1 @@ +ALTER TABLE attach_partition_t2 ATTACH PARTITION tuple() FROM attach_partition_t1 diff --git a/tests/ast_json_fixtures/shapes/77d66ef76b3322a9.json b/tests/ast_json_fixtures/shapes/77d66ef76b3322a9.json new file mode 100644 index 000000000000..0519945c24ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/77d66ef76b3322a9.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u2_01292_renamed"] + } +} diff --git a/tests/ast_json_fixtures/shapes/77d66ef76b3322a9.sql b/tests/ast_json_fixtures/shapes/77d66ef76b3322a9.sql new file mode 100644 index 000000000000..e432ca1643b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/77d66ef76b3322a9.sql @@ -0,0 +1 @@ +SHOW CREATE USER u2_01292_renamed diff --git a/tests/ast_json_fixtures/shapes/78106eadc6d71e51.json b/tests/ast_json_fixtures/shapes/78106eadc6d71e51.json new file mode 100644 index 000000000000..c3f1eb4acb9f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78106eadc6d71e51.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "INTERSECT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/78106eadc6d71e51.sql b/tests/ast_json_fixtures/shapes/78106eadc6d71e51.sql new file mode 100644 index 000000000000..e9599875619d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78106eadc6d71e51.sql @@ -0,0 +1 @@ +(((select 1) intersect select 1)) diff --git a/tests/ast_json_fixtures/shapes/781373be9aefa162.json b/tests/ast_json_fixtures/shapes/781373be9aefa162.json new file mode 100644 index 000000000000..b9aaf6c31de2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/781373be9aefa162.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u11_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/781373be9aefa162.sql b/tests/ast_json_fixtures/shapes/781373be9aefa162.sql new file mode 100644 index 000000000000..9cddbfb0f098 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/781373be9aefa162.sql @@ -0,0 +1 @@ +SHOW CREATE USER u11_01292 diff --git a/tests/ast_json_fixtures/shapes/782bbb5a916cd501.json b/tests/ast_json_fixtures/shapes/782bbb5a916cd501.json new file mode 100644 index 000000000000..21972b25cedc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/782bbb5a916cd501.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "is_ordinary_view": true, + "database": { + "type": "Identifier", + "name": "default" + }, + "table": { + "type": "Identifier", + "name": "tview_db" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/782bbb5a916cd501.sql b/tests/ast_json_fixtures/shapes/782bbb5a916cd501.sql new file mode 100644 index 000000000000..2289c1b0ff45 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/782bbb5a916cd501.sql @@ -0,0 +1 @@ +CREATE TEMPORARY VIEW default.tview_db AS SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/782e0dde0896ce6c.json b/tests/ast_json_fixtures/shapes/782e0dde0896ce6c.json new file mode 100644 index 000000000000..128839ce5c0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/782e0dde0896ce6c.json @@ -0,0 +1,136 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "g" + }, + { + "type": "Identifier", + "name": "s" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "g" + }, + { + "type": "Function", + "alias": "s", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "alias": "g", + "name": "bitAnd", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "g" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "INNER", + "expressions": [ + { + "type": "Literal", + "alias": "a", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + ] + } + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/782e0dde0896ce6c.sql b/tests/ast_json_fixtures/shapes/782e0dde0896ce6c.sql new file mode 100644 index 000000000000..d3b849c2dbbb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/782e0dde0896ce6c.sql @@ -0,0 +1 @@ +select g, s from (select g, sum(number) as s from numbers(4) group by bitAnd(number, 1) as g with totals order by g) array join [1, 2] as a format Pretty diff --git a/tests/ast_json_fixtures/shapes/7831cb9e4923c346.json b/tests/ast_json_fixtures/shapes/7831cb9e4923c346.json new file mode 100644 index 000000000000..eab45e8a7eec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7831cb9e4923c346.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "reference_vec", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Float64", + "value": 0 + }, + { + "value_type": "Float64", + "value": 2 + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Array(Float64)" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab_f32" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7831cb9e4923c346.sql b/tests/ast_json_fixtures/shapes/7831cb9e4923c346.sql new file mode 100644 index 000000000000..a5108573aba5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7831cb9e4923c346.sql @@ -0,0 +1,5 @@ +WITH CAST([0.0, 2.0] AS Array(Float64)) AS reference_vec +SELECT id, L2Distance(vec, reference_vec) +FROM tab_f32 +ORDER BY L2Distance(vec, reference_vec) +LIMIT 4 diff --git a/tests/ast_json_fixtures/shapes/784efca355f83e1d.json b/tests/ast_json_fixtures/shapes/784efca355f83e1d.json new file mode 100644 index 000000000000..958c8dc1178a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/784efca355f83e1d.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test1" + }, + "settings": { + "type": "Settings", + "changes": { + "alter_sync": "2", + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DELETE", + "predicate": { + "type": "Identifier", + "name": "t.a", + "name_parts": ["t", "a"] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/784efca355f83e1d.sql b/tests/ast_json_fixtures/shapes/784efca355f83e1d.sql new file mode 100644 index 000000000000..447b31895d2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/784efca355f83e1d.sql @@ -0,0 +1 @@ +ALTER TABLE test1 (DELETE WHERE t.a) SETTINGS alter_sync = 2, mutations_sync = 2 diff --git a/tests/ast_json_fixtures/shapes/786baab63807a766.json b/tests/ast_json_fixtures/shapes/786baab63807a766.json new file mode 100644 index 000000000000..4a6e6730a4a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/786baab63807a766.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_alter_if_exists" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "c0" + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "if_exists": true, + "column_declaration": { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/786baab63807a766.sql b/tests/ast_json_fixtures/shapes/786baab63807a766.sql new file mode 100644 index 000000000000..9c97a0a96d49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/786baab63807a766.sql @@ -0,0 +1 @@ +ALTER TABLE test_alter_if_exists DROP COLUMN c0, MODIFY COLUMN IF EXISTS c0 Int64 diff --git a/tests/ast_json_fixtures/shapes/786e31ce313ca450.json b/tests/ast_json_fixtures/shapes/786e31ce313ca450.json new file mode 100644 index 000000000000..ce1607a201c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/786e31ce313ca450.json @@ -0,0 +1,188 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "table_x", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "col_a" + }, + { + "type": "Identifier", + "name": "col_b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "col_a", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "alias": "col_b", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "b" + }, + { + "value_type": "String", + "value": "c" + } + ] + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "INNER", + "expressions": [ + { + "type": "Identifier", + "name": "col_b" + } + ] + } + } + ] + } + } + ] + } + } + }, + { + "type": "Subquery", + "alias": "group_a", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col_a" + }, + { + "type": "Identifier", + "name": "col_b" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_x" + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "group_a" + }, + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col_a" + }, + { + "type": "Identifier", + "name": "col_b" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_x" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/786e31ce313ca450.sql b/tests/ast_json_fixtures/shapes/786e31ce313ca450.sql new file mode 100644 index 000000000000..5b782f4d6cab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/786e31ce313ca450.sql @@ -0,0 +1,8 @@ +WITH + table_x AS ( + SELECT col_a, col_b + FROM (SELECT 'a' AS col_a, ['b', 'c'] AS col_b) + ARRAY JOIN col_b + ), + (SELECT groupArray((col_a, col_b)) FROM table_x) AS group_a +SELECT group_a, groupArray((col_a, col_b)) FROM table_x diff --git a/tests/ast_json_fixtures/shapes/7874b63aefae8736.json b/tests/ast_json_fixtures/shapes/7874b63aefae8736.json new file mode 100644 index 000000000000..372eab593463 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7874b63aefae8736.json @@ -0,0 +1,125 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "maxMap", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7874b63aefae8736.sql b/tests/ast_json_fixtures/shapes/7874b63aefae8736.sql new file mode 100644 index 000000000000..94309387a5ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7874b63aefae8736.sql @@ -0,0 +1 @@ +SELECT maxMap([number % 3, number % 4 - 1], [number, NULL]) FROM numbers(3) GROUP BY number WITH ROLLUP ORDER BY number diff --git a/tests/ast_json_fixtures/shapes/78904132475d2287.json b/tests/ast_json_fixtures/shapes/78904132475d2287.json new file mode 100644 index 000000000000..9f799d63f5b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78904132475d2287.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test", + "from_table": "hits10", + "to_database": "test", + "to_table": "hits" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/78904132475d2287.sql b/tests/ast_json_fixtures/shapes/78904132475d2287.sql new file mode 100644 index 000000000000..ee104ac47c3c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78904132475d2287.sql @@ -0,0 +1 @@ +RENAME TABLE test.hits10 TO test.hits diff --git a/tests/ast_json_fixtures/shapes/7892b4d001de80f6.json b/tests/ast_json_fixtures/shapes/7892b4d001de80f6.json new file mode 100644 index 000000000000..ea2546e85bc4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7892b4d001de80f6.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "constrained" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ], + "constraints": [ + { + "type": "Constraint", + "name": "bogus", + "constraint_type": "CHECK", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7892b4d001de80f6.sql b/tests/ast_json_fixtures/shapes/7892b4d001de80f6.sql new file mode 100644 index 000000000000..a581af402852 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7892b4d001de80f6.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE constrained (x UInt8, CONSTRAINT bogus CHECK 0) diff --git a/tests/ast_json_fixtures/shapes/78a3b9fa3cb43d52.json b/tests/ast_json_fixtures/shapes/78a3b9fa3cb43d52.json new file mode 100644 index 000000000000..00705904bd3b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78a3b9fa3cb43d52.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "src", + "value_type": "String", + "value": "dict" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "TestTblDict" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/78a3b9fa3cb43d52.sql b/tests/ast_json_fixtures/shapes/78a3b9fa3cb43d52.sql new file mode 100644 index 000000000000..fab4a020043b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78a3b9fa3cb43d52.sql @@ -0,0 +1 @@ +select 'dict' src,* FROM TestTblDict diff --git a/tests/ast_json_fixtures/shapes/78c14687b0e60fdf.json b/tests/ast_json_fixtures/shapes/78c14687b0e60fdf.json new file mode 100644 index 000000000000..c5161298b735 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78c14687b0e60fdf.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "alias": "n", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "arr" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "v" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_func_to_subcolumns_use_nulls" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "n" + } + ], + "having": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/78c14687b0e60fdf.sql b/tests/ast_json_fixtures/shapes/78c14687b0e60fdf.sql new file mode 100644 index 000000000000..f6fd78ca1b8a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78c14687b0e60fdf.sql @@ -0,0 +1 @@ +SELECT length(arr) AS n, sum(v) FROM t_func_to_subcolumns_use_nulls GROUP BY n WITH ROLLUP HAVING n <= 4 OR isNull(n) ORDER BY n SETTINGS group_by_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/78d25c5d3bfa44de.json b/tests/ast_json_fixtures/shapes/78d25c5d3bfa44de.json new file mode 100644 index 000000000000..82656062cbd1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78d25c5d3bfa44de.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "arraySort", + "arguments": [ + { + "type": "Function", + "name": "groupArrayIntersect", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_numbers__fuzz_29" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/78d25c5d3bfa44de.sql b/tests/ast_json_fixtures/shapes/78d25c5d3bfa44de.sql new file mode 100644 index 000000000000..ba32b0df3232 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78d25c5d3bfa44de.sql @@ -0,0 +1 @@ +SELECT arraySort(groupArrayIntersect(*)) FROM test_numbers__fuzz_29 GROUP BY a WITH ROLLUP ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/78dd347209c79572.json b/tests/ast_json_fixtures/shapes/78dd347209c79572.json new file mode 100644 index 000000000000..ef65e83f58ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78dd347209c79572.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "primary_key_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "v1", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "v2", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/78dd347209c79572.sql b/tests/ast_json_fixtures/shapes/78dd347209c79572.sql new file mode 100644 index 000000000000..21a371bd9b55 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78dd347209c79572.sql @@ -0,0 +1 @@ +CREATE TABLE primary_key_test(v1 Int32, v2 Int32) ENGINE=ReplacingMergeTree ORDER BY (v1, v2) PRIMARY KEY(v1, v2) diff --git a/tests/ast_json_fixtures/shapes/78f54c0d62adfe76.json b/tests/ast_json_fixtures/shapes/78f54c0d62adfe76.json new file mode 100644 index 000000000000..12b36be6db37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78f54c0d62adfe76.json @@ -0,0 +1,123 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "uniqState", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "x", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/78f54c0d62adfe76.sql b/tests/ast_json_fixtures/shapes/78f54c0d62adfe76.sql new file mode 100644 index 000000000000..b4d24f656b2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78f54c0d62adfe76.sql @@ -0,0 +1 @@ +SELECT DISTINCT hex(toString(uniqState(x))) FROM (SELECT materialize(1) AS k, toNullable(1) AS x FROM numbers(1)) GROUP BY k WITH ROLLUP ORDER BY k diff --git a/tests/ast_json_fixtures/shapes/78fb8903682afec5.json b/tests/ast_json_fixtures/shapes/78fb8903682afec5.json new file mode 100644 index 000000000000..26d7da3b9532 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78fb8903682afec5.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pr_t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "500" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/78fb8903682afec5.sql b/tests/ast_json_fixtures/shapes/78fb8903682afec5.sql new file mode 100644 index 000000000000..4c3bf3c8afcb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/78fb8903682afec5.sql @@ -0,0 +1 @@ +select sum(b) from pr_t group by a order by a limit 5 offset 500 diff --git a/tests/ast_json_fixtures/shapes/790bb97b8282ffd0.json b/tests/ast_json_fixtures/shapes/790bb97b8282ffd0.json new file mode 100644 index 000000000000..bcb37d74068b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/790bb97b8282ffd0.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "BackupQuery", + "kind": "BACKUP", + "elements": [ + { + "element_type": "TABLE", + "table": "03760_backup_memory" + } + ], + "backup_name": { + "type": "Function", + "name": "Null", + "kind": "BACKUP_NAME", + "arguments": [] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/790bb97b8282ffd0.sql b/tests/ast_json_fixtures/shapes/790bb97b8282ffd0.sql new file mode 100644 index 000000000000..b0c51143247c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/790bb97b8282ffd0.sql @@ -0,0 +1 @@ +BACKUP TABLE 03760_backup_memory TO Null FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/790e56fcc5cea270.json b/tests/ast_json_fixtures/shapes/790e56fcc5cea270.json new file mode 100644 index 000000000000..217452643724 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/790e56fcc5cea270.json @@ -0,0 +1,138 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "lambda", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ] + }, + { + "type": "Identifier", + "name": "y" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Function", + "name": "lambda", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/790e56fcc5cea270.sql b/tests/ast_json_fixtures/shapes/790e56fcc5cea270.sql new file mode 100644 index 000000000000..60b639ba07ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/790e56fcc5cea270.sql @@ -0,0 +1,2 @@ +WITH (x, y) -> y AS lambda +SELECT arrayMap(lambda(tuple(x), x + 1), [1, 2, 3]), lambda(tuple(x), x + 1), 1 AS x diff --git a/tests/ast_json_fixtures/shapes/790e70d68ae56ce6.json b/tests/ast_json_fixtures/shapes/790e70d68ae56ce6.json new file mode 100644 index 000000000000..b918769622a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/790e70d68ae56ce6.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "x", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/790e70d68ae56ce6.sql b/tests/ast_json_fixtures/shapes/790e70d68ae56ce6.sql new file mode 100644 index 000000000000..33ff9d03beff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/790e70d68ae56ce6.sql @@ -0,0 +1,2 @@ +WITH RECURSIVE x AS (SELECT n FROM x) + SELECT * FROM x diff --git a/tests/ast_json_fixtures/shapes/79194a62b732cd02.json b/tests/ast_json_fixtures/shapes/79194a62b732cd02.json new file mode 100644 index 000000000000..d03ccdd8036e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79194a62b732cd02.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "roles": { + "type": "RolesOrUsersSet", + "names": ["sqllt_role"] + }, + "grantees": { + "type": "RolesOrUsersSet", + "names": ["sqllt_user"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/79194a62b732cd02.sql b/tests/ast_json_fixtures/shapes/79194a62b732cd02.sql new file mode 100644 index 000000000000..57507f0042eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79194a62b732cd02.sql @@ -0,0 +1 @@ +GRANT sqllt_role TO sqllt_user diff --git a/tests/ast_json_fixtures/shapes/7920cce94114b7f5.json b/tests/ast_json_fixtures/shapes/7920cce94114b7f5.json new file mode 100644 index 000000000000..4786ca2c1345 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7920cce94114b7f5.json @@ -0,0 +1,136 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "derived_metrics_local" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "timestamp", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "bytes", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "SummingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMMDD", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toStartOfHour", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "GROUP_BY", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toStartOfHour", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + { + "type": "Function", + "name": "toIntervalHour", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "group_by_key": [ + { + "type": "Function", + "name": "toStartOfHour", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + } + ], + "group_by_assignments": [ + { + "type": "Assignment", + "column": "bytes", + "expression": { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "bytes" + } + ] + } + } + ] + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7920cce94114b7f5.sql b/tests/ast_json_fixtures/shapes/7920cce94114b7f5.sql new file mode 100644 index 000000000000..d6c65b8b4fc2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7920cce94114b7f5.sql @@ -0,0 +1,10 @@ +CREATE TABLE derived_metrics_local +( + timestamp DateTime, + bytes UInt64 +) +ENGINE=SummingMergeTree() +PARTITION BY toYYYYMMDD(timestamp) +ORDER BY (toStartOfHour(timestamp), timestamp) +TTL toStartOfHour(timestamp) + INTERVAL 1 HOUR GROUP BY toStartOfHour(timestamp) +SET bytes=max(bytes) diff --git a/tests/ast_json_fixtures/shapes/7925543f4040cd27.json b/tests/ast_json_fixtures/shapes/7925543f4040cd27.json new file mode 100644 index 000000000000..f208c025fefa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7925543f4040cd27.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "y", + "value_type": "UInt64", + "value": "2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "distinct_in_order" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7925543f4040cd27.sql b/tests/ast_json_fixtures/shapes/7925543f4040cd27.sql new file mode 100644 index 000000000000..eac8b581bb7a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7925543f4040cd27.sql @@ -0,0 +1 @@ +select distinct 1 as x, 2 as y from distinct_in_order order by x diff --git a/tests/ast_json_fixtures/shapes/7928799db03170fa.json b/tests/ast_json_fixtures/shapes/7928799db03170fa.json new file mode 100644 index 000000000000..1ca1f8bc0a42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7928799db03170fa.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_bloom_filter_index" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "uint8", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "uint16", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "index_column", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "test1", + "expression": { + "type": "Identifier", + "name": "index_column" + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7928799db03170fa.sql b/tests/ast_json_fixtures/shapes/7928799db03170fa.sql new file mode 100644 index 000000000000..f39d138d37fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7928799db03170fa.sql @@ -0,0 +1 @@ +CREATE TABLE test_bloom_filter_index(`uint8` UInt8, `uint16` UInt16, `index_column` UInt64, INDEX test1 `index_column` TYPE bloom_filter GRANULARITY 1) ENGINE = MergeTree() PARTITION BY tuple() ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/79381d1991de6e6b.json b/tests/ast_json_fixtures/shapes/79381d1991de6e6b.json new file mode 100644 index 000000000000..65cfa7a47181 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79381d1991de6e6b.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/79381d1991de6e6b.sql b/tests/ast_json_fixtures/shapes/79381d1991de6e6b.sql new file mode 100644 index 000000000000..3b59df6d6691 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79381d1991de6e6b.sql @@ -0,0 +1 @@ +create table t(a UInt32) engine=MergeTree order by tuple() partition by a % 16 diff --git a/tests/ast_json_fixtures/shapes/793c82468fc5b60b.json b/tests/ast_json_fixtures/shapes/793c82468fc5b60b.json new file mode 100644 index 000000000000..a039cf24d280 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/793c82468fc5b60b.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "dist_01213" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "local_01213" + }, + { + "type": "Identifier", + "name": "id" + } + ] + } + }, + "as_table": "local_01213" + } +} diff --git a/tests/ast_json_fixtures/shapes/793c82468fc5b60b.sql b/tests/ast_json_fixtures/shapes/793c82468fc5b60b.sql new file mode 100644 index 000000000000..da1e62eef2da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/793c82468fc5b60b.sql @@ -0,0 +1 @@ +CREATE TABLE IF NOT EXISTS dist_01213 AS local_01213 ENGINE = Distributed(test_cluster_two_shards_localhost, currentDatabase(), local_01213, id) diff --git a/tests/ast_json_fixtures/shapes/79477cb44394d800.json b/tests/ast_json_fixtures/shapes/79477cb44394d800.json new file mode 100644 index 000000000000..b730352a4c37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79477cb44394d800.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "part_info" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "FREEZE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "1970-10-02" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/79477cb44394d800.sql b/tests/ast_json_fixtures/shapes/79477cb44394d800.sql new file mode 100644 index 000000000000..1ef1cb6c1c41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79477cb44394d800.sql @@ -0,0 +1 @@ +ALTER TABLE part_info FREEZE PARTITION '1970-10-02' diff --git a/tests/ast_json_fixtures/shapes/796cc5c3d60a19d5.json b/tests/ast_json_fixtures/shapes/796cc5c3d60a19d5.json new file mode 100644 index 000000000000..8e3921a2bce3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/796cc5c3d60a19d5.json @@ -0,0 +1,125 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t22" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DELETE", + "predicate": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "叫" + }, + { + "type": "Identifier", + "name": "c1" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 792.3673220441809 + }, + { + "type": "Identifier", + "name": "c0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Identifier", + "name": "c1" + } + ] + } + ] + } + ] + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_SETTING", + "settings_changes": { + "type": "Settings", + "changes": { + "persistent": "1" + } + } + }, + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "f2", + "arguments": [] + } + ] + }, + "assignments": [ + { + "type": "Assignment", + "column": "c1", + "expression": { + "type": "Literal", + "value_type": "String", + "value": "would" + } + } + ] + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_SETTING", + "settings_changes": { + "type": "Settings", + "changes": { + "persistent": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/796cc5c3d60a19d5.sql b/tests/ast_json_fixtures/shapes/796cc5c3d60a19d5.sql new file mode 100644 index 000000000000..e0f1257425e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/796cc5c3d60a19d5.sql @@ -0,0 +1 @@ +ALTER TABLE t22 (DELETE WHERE ('叫' = c1) OR ((792.3673220441809 = c0) AND (c0 = c1))), (MODIFY SETTING persistent = 1), (UPDATE c1 = 'would' WHERE NOT f2()), (MODIFY SETTING persistent = 0) diff --git a/tests/ast_json_fixtures/shapes/7996ed7e11f513ff.json b/tests/ast_json_fixtures/shapes/7996ed7e11f513ff.json new file mode 100644 index 000000000000..f949c4000ffe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7996ed7e11f513ff.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "max_a", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + { + "type": "Function", + "alias": "max_b", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03611_t_nullsafe" + } + } + } + ] + }, + "having": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotDistinctFrom", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "max_a" + }, + { + "type": "Identifier", + "name": "max_b" + } + ] + }, + { + "type": "Function", + "name": "isDistinctFrom", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "max_a" + }, + { + "type": "Identifier", + "name": "max_b" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "max_a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7996ed7e11f513ff.sql b/tests/ast_json_fixtures/shapes/7996ed7e11f513ff.sql new file mode 100644 index 000000000000..c51cc66c9de7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7996ed7e11f513ff.sql @@ -0,0 +1,6 @@ +SELECT + max(a) AS max_a, + max(b) AS max_b +FROM `03611_t_nullsafe` +HAVING (max_a <=> max_b) OR (max_a IS DISTINCT FROM max_b) +ORDER BY max_a diff --git a/tests/ast_json_fixtures/shapes/799a27b4e185a8d9.json b/tests/ast_json_fixtures/shapes/799a27b4e185a8d9.json new file mode 100644 index 000000000000..ea00586ecb29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/799a27b4e185a8d9.json @@ -0,0 +1,98 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_all" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "category" + } + ], + "having": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "category" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/799a27b4e185a8d9.sql b/tests/ast_json_fixtures/shapes/799a27b4e185a8d9.sql new file mode 100644 index 000000000000..189e7af5f302 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/799a27b4e185a8d9.sql @@ -0,0 +1,6 @@ +SELECT id, count() AS c +FROM test_limit_by_all +GROUP BY id, category +HAVING c >= 1 +ORDER BY id, c DESC, category +LIMIT 1 BY ALL diff --git a/tests/ast_json_fixtures/shapes/79a8e3f36ff7aa5f.json b/tests/ast_json_fixtures/shapes/79a8e3f36ff7aa5f.json new file mode 100644 index 000000000000..57feebe6cd9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79a8e3f36ff7aa5f.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02103_test_function_with_nested_function_empty_args" + } +} diff --git a/tests/ast_json_fixtures/shapes/79a8e3f36ff7aa5f.sql b/tests/ast_json_fixtures/shapes/79a8e3f36ff7aa5f.sql new file mode 100644 index 000000000000..bb869fb08073 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79a8e3f36ff7aa5f.sql @@ -0,0 +1 @@ +DROP FUNCTION 02103_test_function_with_nested_function_empty_args diff --git a/tests/ast_json_fixtures/shapes/79c88cb437626de9.json b/tests/ast_json_fixtures/shapes/79c88cb437626de9.json new file mode 100644 index 000000000000..07bc63bcc803 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79c88cb437626de9.json @@ -0,0 +1,116 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "test2", + "name": "test2" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "INNER", + "expressions": [ + { + "type": "Function", + "alias": "test2_b", + "name": "arrayFilter", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + { + "type": "Function", + "name": "globalIn", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "alias": "ym:a", + "name": "now", + "arguments": [] + } + ], + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "test2.b", + "name_parts": ["test2", "b"] + } + ] + } + ] + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/79c88cb437626de9.sql b/tests/ast_json_fixtures/shapes/79c88cb437626de9.sql new file mode 100644 index 000000000000..089713752d2b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79c88cb437626de9.sql @@ -0,0 +1,8 @@ +SELECT 1 +FROM test2 AS test2 +ARRAY JOIN arrayFilter(t -> (t GLOBAL IN + ( + SELECT DISTINCT now() AS `ym:a` + WHERE 1 + )), test2.b) AS test2_b +WHERE 1 diff --git a/tests/ast_json_fixtures/shapes/79cacea8cc65e1ab.json b/tests/ast_json_fixtures/shapes/79cacea8cc65e1ab.json new file mode 100644 index 000000000000..1062871324e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79cacea8cc65e1ab.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "local_table" + } + ] + } + }, + "as_table": "local_table" + } +} diff --git a/tests/ast_json_fixtures/shapes/79cacea8cc65e1ab.sql b/tests/ast_json_fixtures/shapes/79cacea8cc65e1ab.sql new file mode 100644 index 000000000000..935e47aa4ec5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79cacea8cc65e1ab.sql @@ -0,0 +1 @@ +CREATE TABLE dist AS local_table ENGINE = Distributed(test_cluster_two_shards_localhost, currentDatabase(), local_table) diff --git a/tests/ast_json_fixtures/shapes/79ddd6cf9ce16bc8.json b/tests/ast_json_fixtures/shapes/79ddd6cf9ce16bc8.json new file mode 100644 index 000000000000..2187ca2ae7a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79ddd6cf9ce16bc8.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01293", "r2_01293", "r3_01293", "r4_01293", "r5_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/79ddd6cf9ce16bc8.sql b/tests/ast_json_fixtures/shapes/79ddd6cf9ce16bc8.sql new file mode 100644 index 000000000000..b7f5de885fd8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79ddd6cf9ce16bc8.sql @@ -0,0 +1 @@ +DROP ROLE r1_01293, r2_01293, r3_01293, r4_01293, r5_01293 diff --git a/tests/ast_json_fixtures/shapes/79f40b7ac42760e7.json b/tests/ast_json_fixtures/shapes/79f40b7ac42760e7.json new file mode 100644 index 000000000000..cc7d903f006c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79f40b7ac42760e7.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "alias": "res", + "name": "runningAccumulate", + "arguments": [ + { + "type": "Identifier", + "name": "sum_k" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "k", + "name": "number" + }, + { + "type": "Function", + "alias": "sum_k", + "name": "sumState", + "arguments": [ + { + "type": "Identifier", + "name": "k" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/79f40b7ac42760e7.sql b/tests/ast_json_fixtures/shapes/79f40b7ac42760e7.sql new file mode 100644 index 000000000000..80f3eae7cd11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/79f40b7ac42760e7.sql @@ -0,0 +1 @@ +SELECT k, runningAccumulate(sum_k) AS res FROM (SELECT number as k, sumState(k) AS sum_k FROM numbers(10) GROUP BY k ORDER BY k) FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/7a0e34d67fd81d0d.json b/tests/ast_json_fixtures/shapes/7a0e34d67fd81d0d.json new file mode 100644 index 000000000000..2d9045b03534 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a0e34d67fd81d0d.json @@ -0,0 +1,110 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "arraySort", + "arguments": [ + { + "type": "Identifier", + "name": "used_table_functions" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryFinish" + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%toDate('2000-12-05')%" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "query_start_time" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "TabSeparatedWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/7a0e34d67fd81d0d.sql b/tests/ast_json_fixtures/shapes/7a0e34d67fd81d0d.sql new file mode 100644 index 000000000000..e10055f2b14f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a0e34d67fd81d0d.sql @@ -0,0 +1,3 @@ +SELECT arraySort(used_table_functions) +FROM system.query_log WHERE current_database = currentDatabase() AND type = 'QueryFinish' AND (query LIKE '%toDate(\'2000-12-05\')%') +ORDER BY query_start_time DESC LIMIT 1 FORMAT TabSeparatedWithNames diff --git a/tests/ast_json_fixtures/shapes/7a2790792b82d4e6.json b/tests/ast_json_fixtures/shapes/7a2790792b82d4e6.json new file mode 100644 index 000000000000..87a59b7d7a9c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a2790792b82d4e6.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "settings": { + "type": "SettingsProfileElements", + "elements": [] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7a2790792b82d4e6.sql b/tests/ast_json_fixtures/shapes/7a2790792b82d4e6.sql new file mode 100644 index 000000000000..151ddf115ea0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a2790792b82d4e6.sql @@ -0,0 +1 @@ +CREATE USER u1_01292 SETTINGS NONE diff --git a/tests/ast_json_fixtures/shapes/7a377fd3aed76cdf.json b/tests/ast_json_fixtures/shapes/7a377fd3aed76cdf.json new file mode 100644 index 000000000000..e2a57ba6f461 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a377fd3aed76cdf.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "alias": "all", + "name": "format", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "{} {}" + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "order_by_all" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_order_by_all": false + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7a377fd3aed76cdf.sql b/tests/ast_json_fixtures/shapes/7a377fd3aed76cdf.sql new file mode 100644 index 000000000000..673ad7f4b798 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a377fd3aed76cdf.sql @@ -0,0 +1 @@ +SELECT format('{} {}', a, b) AS all FROM order_by_all ORDER BY all SETTINGS enable_order_by_all = false diff --git a/tests/ast_json_fixtures/shapes/7a3c8318ad60196a.json b/tests/ast_json_fixtures/shapes/7a3c8318ad60196a.json new file mode 100644 index 000000000000..8aa83a4b06c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a3c8318ad60196a.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "merge_00401" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^stripe\\d+" + } + ] + } + }, + "as_table": "stripe1" + } +} diff --git a/tests/ast_json_fixtures/shapes/7a3c8318ad60196a.sql b/tests/ast_json_fixtures/shapes/7a3c8318ad60196a.sql new file mode 100644 index 000000000000..410f7e431aa1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a3c8318ad60196a.sql @@ -0,0 +1 @@ +CREATE TABLE merge_00401 AS stripe1 ENGINE = Merge(currentDatabase(), '^stripe\\d+') diff --git a/tests/ast_json_fixtures/shapes/7a6192d71321cb4b.json b/tests/ast_json_fixtures/shapes/7a6192d71321cb4b.json new file mode 100644 index 000000000000..10f84757cf60 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a6192d71321cb4b.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "y", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "dummy" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "y" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7a6192d71321cb4b.sql b/tests/ast_json_fixtures/shapes/7a6192d71321cb4b.sql new file mode 100644 index 000000000000..09e439713acd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a6192d71321cb4b.sql @@ -0,0 +1,9 @@ +WITH ( + SELECT dummy AS x + FROM system.one + ) AS y +SELECT + y, + min(dummy) +FROM remote('127.0.0.{1,2}', system.one) +GROUP BY y diff --git a/tests/ast_json_fixtures/shapes/7a632e7341b06bfa.json b/tests/ast_json_fixtures/shapes/7a632e7341b06bfa.json new file mode 100644 index 000000000000..def48bf22dd7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a632e7341b06bfa.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "RIGHT", + "using": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "right_join" + } + } + } + ] + }, + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7a632e7341b06bfa.sql b/tests/ast_json_fixtures/shapes/7a632e7341b06bfa.sql new file mode 100644 index 000000000000..352490044620 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a632e7341b06bfa.sql @@ -0,0 +1,3 @@ +SELECT * +FROM t1 RIGHT JOIN right_join USING (x) +QUALIFY x = 1 diff --git a/tests/ast_json_fixtures/shapes/7a8a63b66f089819.json b/tests/ast_json_fixtures/shapes/7a8a63b66f089819.json new file mode 100644 index 000000000000..bae18a74ed97 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a8a63b66f089819.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH ASYNC INSERT QUEUE", + "tables": [ + { + "table": "src_table" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7a8a63b66f089819.sql b/tests/ast_json_fixtures/shapes/7a8a63b66f089819.sql new file mode 100644 index 000000000000..6bd83da3ae69 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a8a63b66f089819.sql @@ -0,0 +1 @@ +system flush async insert queue src_table diff --git a/tests/ast_json_fixtures/shapes/7a967ff4fbf43202.json b/tests/ast_json_fixtures/shapes/7a967ff4fbf43202.json new file mode 100644 index 000000000000..7584d5ff6156 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a967ff4fbf43202.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "if_exists": true, + "names": ["r1_01293", "r2_01293", "r3_01293", "r4_01293", "r5_01293", "r6_01293", "r7_01293", "r8_01293", "r9_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/7a967ff4fbf43202.sql b/tests/ast_json_fixtures/shapes/7a967ff4fbf43202.sql new file mode 100644 index 000000000000..0612c3a84e6a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7a967ff4fbf43202.sql @@ -0,0 +1 @@ +DROP ROLE IF EXISTS r1_01293, r2_01293, r3_01293, r4_01293, r5_01293, r6_01293, r7_01293, r8_01293, r9_01293 diff --git a/tests/ast_json_fixtures/shapes/7ab6684576751957.json b/tests/ast_json_fixtures/shapes/7ab6684576751957.json new file mode 100644 index 000000000000..2592786bf12e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ab6684576751957.json @@ -0,0 +1,106 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "alias": "d", + "name": "marks" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parts", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "six_rows_per_granule" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "active" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7ab6684576751957.sql b/tests/ast_json_fixtures/shapes/7ab6684576751957.sql new file mode 100644 index 000000000000..68b4f2435c30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ab6684576751957.sql @@ -0,0 +1 @@ +SELECT distinct(marks) d from system.parts WHERE table = 'six_rows_per_granule' and database=currentDatabase() and active=1 having d > 0 diff --git a/tests/ast_json_fixtures/shapes/7adfd190d8f7f29f.json b/tests/ast_json_fixtures/shapes/7adfd190d8f7f29f.json new file mode 100644 index 000000000000..8e2ec9501ab3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7adfd190d8f7f29f.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["TABLE ENGINE"], + "parameter": "TinyLog" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_03593"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7adfd190d8f7f29f.sql b/tests/ast_json_fixtures/shapes/7adfd190d8f7f29f.sql new file mode 100644 index 000000000000..f07688113835 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7adfd190d8f7f29f.sql @@ -0,0 +1 @@ +GRANT TABLE ENGINE ON TinyLog TO test_user_03593 diff --git a/tests/ast_json_fixtures/shapes/7af4e25ab0a82195.json b/tests/ast_json_fixtures/shapes/7af4e25ab0a82195.json new file mode 100644 index 000000000000..31ccd1f71d9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7af4e25ab0a82195.json @@ -0,0 +1,348 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "w1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "w2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "w3", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "w4", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "w5", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "w6", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7af4e25ab0a82195.sql b/tests/ast_json_fixtures/shapes/7af4e25ab0a82195.sql new file mode 100644 index 000000000000..9cb6923a18f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7af4e25ab0a82195.sql @@ -0,0 +1,13 @@ +WITH +(SELECT number FROM system.numbers LIMIT 1) as w1, +(SELECT number FROM system.numbers LIMIT 1) as w2, +(SELECT number FROM system.numbers LIMIT 1) as w3, +(SELECT number FROM system.numbers LIMIT 1) as w4, +(SELECT number FROM system.numbers LIMIT 1) as w5, +(SELECT number FROM system.numbers LIMIT 1) as w6 +SELECT number FROM ( + SELECT number FROM system.numbers LIMIT 10 + UNION ALL + SELECT number FROM system.numbers LIMIT 10 +) +WHERE number < 5 diff --git a/tests/ast_json_fixtures/shapes/7aff37df7aed0c7e.json b/tests/ast_json_fixtures/shapes/7aff37df7aed0c7e.json new file mode 100644 index 000000000000..40c17cfdd9da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7aff37df7aed0c7e.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "log" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7aff37df7aed0c7e.sql b/tests/ast_json_fixtures/shapes/7aff37df7aed0c7e.sql new file mode 100644 index 000000000000..61aef415501b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7aff37df7aed0c7e.sql @@ -0,0 +1 @@ +SELECT * FROM log LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/7aff5797c9d0cad4.json b/tests/ast_json_fixtures/shapes/7aff5797c9d0cad4.json new file mode 100644 index 000000000000..343675875f20 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7aff5797c9d0cad4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "DISABLE FAILPOINT", + "fail_point_name": "replicated_merge_tree_commit_zk_fail_when_recovering_from_hw_fault" + } +} diff --git a/tests/ast_json_fixtures/shapes/7aff5797c9d0cad4.sql b/tests/ast_json_fixtures/shapes/7aff5797c9d0cad4.sql new file mode 100644 index 000000000000..2116aaa41bcd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7aff5797c9d0cad4.sql @@ -0,0 +1 @@ +system disable failpoint replicated_merge_tree_commit_zk_fail_when_recovering_from_hw_fault diff --git a/tests/ast_json_fixtures/shapes/7b1ee4551e300e76.json b/tests/ast_json_fixtures/shapes/7b1ee4551e300e76.json new file mode 100644 index 000000000000..f5104f138287 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b1ee4551e300e76.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_const_name_size": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7b1ee4551e300e76.sql b/tests/ast_json_fixtures/shapes/7b1ee4551e300e76.sql new file mode 100644 index 000000000000..fc8cb97cdd20 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b1ee4551e300e76.sql @@ -0,0 +1 @@ +SELECT c0 FROM t1 OFFSET 10 ROWS SETTINGS optimize_const_name_size = 1 diff --git a/tests/ast_json_fixtures/shapes/7b2348625db24d8a.json b/tests/ast_json_fixtures/shapes/7b2348625db24d8a.json new file mode 100644 index 000000000000..6af7caa70629 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b2348625db24d8a.json @@ -0,0 +1,98 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mt1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "time", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "proj", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "toIntervalSecond", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "remove_empty_parts": "0", + "merge_with_ttl_timeout": "0", + "deduplicate_merge_projection_mode": "ignore" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7b2348625db24d8a.sql b/tests/ast_json_fixtures/shapes/7b2348625db24d8a.sql new file mode 100644 index 000000000000..ab23aa2983cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b2348625db24d8a.sql @@ -0,0 +1 @@ +create table mt1 (time DateTime, projection proj (select min(time))) engine MergeTree order by () TTL time + interval 1 second settings remove_empty_parts=0, merge_with_ttl_timeout=0, deduplicate_merge_projection_mode='ignore' diff --git a/tests/ast_json_fixtures/shapes/7b30e6be386b3f9e.json b/tests/ast_json_fixtures/shapes/7b30e6be386b3f9e.json new file mode 100644 index 000000000000..f97cddc09e37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b30e6be386b3f9e.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "02577_keepermap_delete_update" + }, + "cluster": "test_shard_localhost", + "commands": [ + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "value2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + "assignments": [ + { + "type": "Assignment", + "column": "value2", + "expression": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "value2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7b30e6be386b3f9e.sql b/tests/ast_json_fixtures/shapes/7b30e6be386b3f9e.sql new file mode 100644 index 000000000000..518069fd7caf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b30e6be386b3f9e.sql @@ -0,0 +1 @@ +ALTER TABLE 02577_keepermap_delete_update ON CLUSTER test_shard_localhost UPDATE value2 = value2 * 10 + 2 WHERE value2 < 100 diff --git a/tests/ast_json_fixtures/shapes/7b4a2187e8cf995c.json b/tests/ast_json_fixtures/shapes/7b4a2187e8cf995c.json new file mode 100644 index 000000000000..8c756aa3e001 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b4a2187e8cf995c.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_distributed_2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test_local_2" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "test_local_2" + } +} diff --git a/tests/ast_json_fixtures/shapes/7b4a2187e8cf995c.sql b/tests/ast_json_fixtures/shapes/7b4a2187e8cf995c.sql new file mode 100644 index 000000000000..97005c631e40 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b4a2187e8cf995c.sql @@ -0,0 +1 @@ +CREATE TABLE test_distributed_2 AS test_local_2 ENGINE = Distributed('test_shard_localhost', currentDatabase(), test_local_2, rand()) diff --git a/tests/ast_json_fixtures/shapes/7b59531840449a5c.json b/tests/ast_json_fixtures/shapes/7b59531840449a5c.json new file mode 100644 index 000000000000..809fe78e4e7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b59531840449a5c.json @@ -0,0 +1,93 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "t2.x", + "name_parts": ["t2", "x"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.x", + "name_parts": ["t1", "x"] + }, + { + "type": "Identifier", + "name": "t2.x", + "name_parts": ["t2", "x"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t1.x", + "name_parts": ["t1", "x"] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7b59531840449a5c.sql b/tests/ast_json_fixtures/shapes/7b59531840449a5c.sql new file mode 100644 index 000000000000..e11a482046dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b59531840449a5c.sql @@ -0,0 +1 @@ +SELECT x, sum(t2.x) FROM t1 JOIN t1 as t2 ON t1.x = t2.x GROUP BY t1.x ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/7b5c9b0c2d2f7966.json b/tests/ast_json_fixtures/shapes/7b5c9b0c2d2f7966.json new file mode 100644 index 000000000000..27e8b2d15e08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b5c9b0c2d2f7966.json @@ -0,0 +1,133 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_rollup": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "alias": "val", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "val" + } + ] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7b5c9b0c2d2f7966.sql b/tests/ast_json_fixtures/shapes/7b5c9b0c2d2f7966.sql new file mode 100644 index 000000000000..982c30b439ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b5c9b0c2d2f7966.sql @@ -0,0 +1,5 @@ +SELECT number, number % 2, sum(number) AS val +FROM numbers(10) +GROUP BY ROLLUP(number, number % 2) WITH TOTALS +ORDER BY (number, number % 2, val) +SETTINGS group_by_use_nulls=1 diff --git a/tests/ast_json_fixtures/shapes/7b70dcade1f39d57.json b/tests/ast_json_fixtures/shapes/7b70dcade1f39d57.json new file mode 100644 index 000000000000..477e88dd7bbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b70dcade1f39d57.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u8_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/7b70dcade1f39d57.sql b/tests/ast_json_fixtures/shapes/7b70dcade1f39d57.sql new file mode 100644 index 000000000000..5f2071f27eb1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7b70dcade1f39d57.sql @@ -0,0 +1 @@ +SHOW CREATE USER u8_01292 diff --git a/tests/ast_json_fixtures/shapes/7bb6ffac6b35456c.json b/tests/ast_json_fixtures/shapes/7bb6ffac6b35456c.json new file mode 100644 index 000000000000..edc9a85ead1b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7bb6ffac6b35456c.json @@ -0,0 +1,125 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t1" + }, + "transformers": [ + { + "type": "ColumnsApplyTransformer", + "lambda": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "lambda_arg": "x" + } + ] + }, + { + "type": "Function", + "alias": "a", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7bb6ffac6b35456c.sql b/tests/ast_json_fixtures/shapes/7bb6ffac6b35456c.sql new file mode 100644 index 000000000000..ecd9d061c484 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7bb6ffac6b35456c.sql @@ -0,0 +1 @@ +SELECT t1.* APPLY ((x) -> x+1), b + 1 AS a FROM t1 INNER JOIN t2 USING (a) ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/7bc853cc419cb594.json b/tests/ast_json_fixtures/shapes/7bc853cc419cb594.json new file mode 100644 index 000000000000..5361fc74e57d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7bc853cc419cb594.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "query_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7bc853cc419cb594.sql b/tests/ast_json_fixtures/shapes/7bc853cc419cb594.sql new file mode 100644 index 000000000000..17976aacc2e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7bc853cc419cb594.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS query_log diff --git a/tests/ast_json_fixtures/shapes/7bc9ca5e5876b9ea.json b/tests/ast_json_fixtures/shapes/7bc9ca5e5876b9ea.json new file mode 100644 index 000000000000..e96c7b5bcf35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7bc9ca5e5876b9ea.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": [" spaces "] + } +} diff --git a/tests/ast_json_fixtures/shapes/7bc9ca5e5876b9ea.sql b/tests/ast_json_fixtures/shapes/7bc9ca5e5876b9ea.sql new file mode 100644 index 000000000000..923e1e7259a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7bc9ca5e5876b9ea.sql @@ -0,0 +1 @@ +drop user " spaces " diff --git a/tests/ast_json_fixtures/shapes/7bd1b5aa95dfb8e5.json b/tests/ast_json_fixtures/shapes/7bd1b5aa95dfb8e5.json new file mode 100644 index 000000000000..431eb9432540 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7bd1b5aa95dfb8e5.json @@ -0,0 +1,165 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "post_state" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "ts", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "state", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "UInt8" + } + ] + }, + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ts" + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p_digest_posts_state", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "state", + "name": "argMax", + "arguments": [ + { + "type": "Identifier", + "name": "state" + }, + { + "type": "Identifier", + "name": "ts" + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "id" + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ts" + }, + { + "type": "Function", + "name": "toIntervalSecond", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + "where": { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "state" + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192", + "deduplicate_merge_projection_mode": "rebuild" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7bd1b5aa95dfb8e5.sql b/tests/ast_json_fixtures/shapes/7bd1b5aa95dfb8e5.sql new file mode 100644 index 000000000000..c11828f87bd6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7bd1b5aa95dfb8e5.sql @@ -0,0 +1,17 @@ +CREATE TABLE post_state +( + `ts` DateTime, + `id` Int64, + `state` Nullable(UInt8) TTL ts + INTERVAL 1 MONTH, + PROJECTION p_digest_posts_state + ( + SELECT + id, + argMax(state, ts) AS state + GROUP BY id + ) +) +ENGINE = MergeTree() +ORDER BY id +TTL ts + toIntervalSecond(0) WHERE state IS NULL +SETTINGS index_granularity = 8192, deduplicate_merge_projection_mode='rebuild' diff --git a/tests/ast_json_fixtures/shapes/7be40c098ea04d30.json b/tests/ast_json_fixtures/shapes/7be40c098ea04d30.json new file mode 100644 index 000000000000..db948d8c0e50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7be40c098ea04d30.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "arr", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "arr.size0", + "name_parts": ["arr", "size0"] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7be40c098ea04d30.sql b/tests/ast_json_fixtures/shapes/7be40c098ea04d30.sql new file mode 100644 index 000000000000..7788608605b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7be40c098ea04d30.sql @@ -0,0 +1 @@ +WITH materialize([1, 2, 3]) AS arr SELECT arr.size0 diff --git a/tests/ast_json_fixtures/shapes/7bf82acb70b9f59f.json b/tests/ast_json_fixtures/shapes/7bf82acb70b9f59f.json new file mode 100644 index 000000000000..7f6701b1d215 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7bf82acb70b9f59f.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "dummy" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.{1,2}" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + } + ] + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "dummy" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7bf82acb70b9f59f.sql b/tests/ast_json_fixtures/shapes/7bf82acb70b9f59f.sql new file mode 100644 index 000000000000..f689046960d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7bf82acb70b9f59f.sql @@ -0,0 +1,4 @@ +SELECT dummy +FROM remote('127.{1,2}', system.one) +WHERE dummy IN (SELECT 0) +LIMIT 1 BY dummy diff --git a/tests/ast_json_fixtures/shapes/7c50cb71e570bcb8.json b/tests/ast_json_fixtures/shapes/7c50cb71e570bcb8.json new file mode 100644 index 000000000000..0e1ff949d444 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7c50cb71e570bcb8.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "clusterAllReplicas", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "distributed_01099_c" + } + ] + }, + "columns": [ + { + "type": "Identifier", + "name": "n" + } + ], + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "tx", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "localhost" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7c50cb71e570bcb8.sql b/tests/ast_json_fixtures/shapes/7c50cb71e570bcb8.sql new file mode 100644 index 000000000000..ae1054068743 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7c50cb71e570bcb8.sql @@ -0,0 +1 @@ +INSERT INTO TABLE FUNCTION clusterAllReplicas('test_shard_localhost', currentDatabase(), 'distributed_01099_c') (n) SELECT number FROM remote('localhost', numbers(5)) tx diff --git a/tests/ast_json_fixtures/shapes/7c6435f0606f7599.json b/tests/ast_json_fixtures/shapes/7c6435f0606f7599.json new file mode 100644 index 000000000000..055a36d1e694 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7c6435f0606f7599.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "attach_from_path": "01188_attach\/file", + "table": { + "type": "Identifier", + "name": "file" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "File", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "TSV" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7c6435f0606f7599.sql b/tests/ast_json_fixtures/shapes/7c6435f0606f7599.sql new file mode 100644 index 000000000000..7c0f6d2b63e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7c6435f0606f7599.sql @@ -0,0 +1 @@ +attach table file from '01188_attach/file' (s String, n UInt8) engine=File(TSV) diff --git a/tests/ast_json_fixtures/shapes/7cab152e137bcac7.json b/tests/ast_json_fixtures/shapes/7cab152e137bcac7.json new file mode 100644 index 000000000000..83a85fb6bd43 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cab152e137bcac7.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "offset": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "LENGTH", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "NNN" + } + ] + }, + { + "type": "Function", + "name": "COS", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + "limit": { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0000-00-02" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7cab152e137bcac7.sql b/tests/ast_json_fixtures/shapes/7cab152e137bcac7.sql new file mode 100644 index 000000000000..253072ffb4ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cab152e137bcac7.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) LIMIT LENGTH('NNN') + COS(0), toDate('0000-00-02') diff --git a/tests/ast_json_fixtures/shapes/7cacc49b332f3567.json b/tests/ast_json_fixtures/shapes/7cacc49b332f3567.json new file mode 100644 index 000000000000..d0e6607960e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cacc49b332f3567.json @@ -0,0 +1,154 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "dt_m", + "name": "toStartOfMinute", + "arguments": [ + { + "type": "Identifier", + "name": "datetime" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "first_time" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "kbytes" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "projection_test" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "domain_alias" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "domain" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "dt_m" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "dt_m" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7cacc49b332f3567.sql b/tests/ast_json_fixtures/shapes/7cacc49b332f3567.sql new file mode 100644 index 000000000000..5fcbcb98f767 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cacc49b332f3567.sql @@ -0,0 +1 @@ +select toStartOfMinute(datetime) dt_m, countIf(first_time = 0) / count(), avg((kbytes * 8) / duration) from projection_test prewhere domain_alias = 1 where domain = '1' group by dt_m order by dt_m diff --git a/tests/ast_json_fixtures/shapes/7cb1adf339201d2c.json b/tests/ast_json_fixtures/shapes/7cb1adf339201d2c.json new file mode 100644 index 000000000000..8008395e06a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cb1adf339201d2c.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "database": { + "type": "Identifier", + "name": "test1601_detach_permanently_ordinary" + }, + "table": { + "type": "Identifier", + "name": "test_name_reuse" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "number", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7cb1adf339201d2c.sql b/tests/ast_json_fixtures/shapes/7cb1adf339201d2c.sql new file mode 100644 index 000000000000..4033cf1f88d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cb1adf339201d2c.sql @@ -0,0 +1 @@ +ATTACH TABLE test1601_detach_permanently_ordinary.test_name_reuse (`number` UInt64 ) ENGINE = MergeTree ORDER BY tuple() SETTINGS index_granularity = 8192 diff --git a/tests/ast_json_fixtures/shapes/7cc3cae1030ef8a7.json b/tests/ast_json_fixtures/shapes/7cc3cae1030ef8a7.json new file mode 100644 index 000000000000..160b2201e71b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cc3cae1030ef8a7.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "d0" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "c1", + "data_type": { + "type": "DataType", + "name": "Nested", + "arguments": [ + { + "type": "NameTypePair", + "name": "c2", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + } + } + ], + "dictionary": { + "type": "Dictionary", + "range": { + "type": "DictionaryRange", + "min_attr_name": "c1", + "max_attr_name": "c1.c2" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7cc3cae1030ef8a7.sql b/tests/ast_json_fixtures/shapes/7cc3cae1030ef8a7.sql new file mode 100644 index 000000000000..3e3e7cf7688d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cc3cae1030ef8a7.sql @@ -0,0 +1 @@ +CREATE DICTIONARY d0 (c1 Nested(c2 Int)) RANGE(MIN c1 MAX `c1.c2`) diff --git a/tests/ast_json_fixtures/shapes/7cc6d1cfabdbfc86.json b/tests/ast_json_fixtures/shapes/7cc6d1cfabdbfc86.json new file mode 100644 index 000000000000..67f540d47467 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cc6d1cfabdbfc86.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": true + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7cc6d1cfabdbfc86.sql b/tests/ast_json_fixtures/shapes/7cc6d1cfabdbfc86.sql new file mode 100644 index 000000000000..aa2ac633dcf6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cc6d1cfabdbfc86.sql @@ -0,0 +1 @@ +SELECT tuple(), 0 FROM numbers(1) SETTINGS use_query_cache = true diff --git a/tests/ast_json_fixtures/shapes/7cc740d0f8a8bffa.json b/tests/ast_json_fixtures/shapes/7cc740d0f8a8bffa.json new file mode 100644 index 000000000000..94575a70d206 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cc740d0f8a8bffa.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR MARK CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/7cc740d0f8a8bffa.sql b/tests/ast_json_fixtures/shapes/7cc740d0f8a8bffa.sql new file mode 100644 index 000000000000..301741b9fdae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cc740d0f8a8bffa.sql @@ -0,0 +1 @@ +SYSTEM CLEAR MARK CACHE diff --git a/tests/ast_json_fixtures/shapes/7ce0ad9d3a15f919.json b/tests/ast_json_fixtures/shapes/7ce0ad9d3a15f919.json new file mode 100644 index 000000000000..7cae7ce4714d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ce0ad9d3a15f919.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "t0", + "to_table": "t1", + "if_exists": true + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7ce0ad9d3a15f919.sql b/tests/ast_json_fixtures/shapes/7ce0ad9d3a15f919.sql new file mode 100644 index 000000000000..f2553d227c43 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ce0ad9d3a15f919.sql @@ -0,0 +1 @@ +RENAME TABLE if exists t0 TO t1 diff --git a/tests/ast_json_fixtures/shapes/7cebe8b0a2f1c904.json b/tests/ast_json_fixtures/shapes/7cebe8b0a2f1c904.json new file mode 100644 index 000000000000..8772f64a7d64 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cebe8b0a2f1c904.json @@ -0,0 +1,115 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "q1", + "value_type": "UInt64", + "value": "5" + }, + { + "type": "WithElement", + "name": "x", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "b", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Identifier", + "alias": "a", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "q1" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7cebe8b0a2f1c904.sql b/tests/ast_json_fixtures/shapes/7cebe8b0a2f1c904.sql new file mode 100644 index 000000000000..24861ecd063d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cebe8b0a2f1c904.sql @@ -0,0 +1 @@ +with 5 as q1, x as (select number+100 as b, number as a from numbers(10) where number > q1) select * from x diff --git a/tests/ast_json_fixtures/shapes/7cece023677ae824.json b/tests/ast_json_fixtures/shapes/7cece023677ae824.json new file mode 100644 index 000000000000..87327bdc0c76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cece023677ae824.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "primary_key_bytes_in_memory" + }, + { + "type": "Identifier", + "name": "primary_key_bytes_in_memory_allocated" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parts", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test" + } + ] + } + ] + } + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/7cece023677ae824.sql b/tests/ast_json_fixtures/shapes/7cece023677ae824.sql new file mode 100644 index 000000000000..253b369f3345 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cece023677ae824.sql @@ -0,0 +1 @@ +SELECT primary_key_bytes_in_memory, primary_key_bytes_in_memory_allocated FROM system.parts WHERE database = currentDatabase() AND table = 'test' FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/7cf2789e7e9227a4.json b/tests/ast_json_fixtures/shapes/7cf2789e7e9227a4.json new file mode 100644 index 000000000000..b889c764ef49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cf2789e7e9227a4.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "i" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/7cf2789e7e9227a4.sql b/tests/ast_json_fixtures/shapes/7cf2789e7e9227a4.sql new file mode 100644 index 000000000000..0f0a69a9bd9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cf2789e7e9227a4.sql @@ -0,0 +1 @@ +select * from test where i < 10 group by i order by i limit 1 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/7cf7d4d6594c1a84.json b/tests/ast_json_fixtures/shapes/7cf7d4d6594c1a84.json new file mode 100644 index 000000000000..dbf46f19ecce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cf7d4d6594c1a84.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + }, + { + "type": "Literal", + "alias": "key", + "value_type": "String", + "value": "a" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7cf7d4d6594c1a84.sql b/tests/ast_json_fixtures/shapes/7cf7d4d6594c1a84.sql new file mode 100644 index 000000000000..c77956d39115 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7cf7d4d6594c1a84.sql @@ -0,0 +1 @@ +SELECT materialize('a'), 'a' AS key GROUP BY key WITH CUBE WITH TOTALS SETTINGS group_by_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/7d14b278103c3ffd.json b/tests/ast_json_fixtures/shapes/7d14b278103c3ffd.json new file mode 100644 index 000000000000..2be4b6f7e3e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d14b278103c3ffd.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "String", + "value": "default" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7d14b278103c3ffd.sql b/tests/ast_json_fixtures/shapes/7d14b278103c3ffd.sql new file mode 100644 index 000000000000..f708a2fec098 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d14b278103c3ffd.sql @@ -0,0 +1 @@ +INSERT INTO FUNCTION remote('127.0.0.{1,2}', currentDatabase(), y, 'default', rand()) SELECT * FROM numbers(10) diff --git a/tests/ast_json_fixtures/shapes/7d165da3b6f49ea6.json b/tests/ast_json_fixtures/shapes/7d165da3b6f49ea6.json new file mode 100644 index 000000000000..74379b8d6a71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d165da3b6f49ea6.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "in_01277" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Null", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "out_01277" + } +} diff --git a/tests/ast_json_fixtures/shapes/7d165da3b6f49ea6.sql b/tests/ast_json_fixtures/shapes/7d165da3b6f49ea6.sql new file mode 100644 index 000000000000..7f8d6b71aa82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d165da3b6f49ea6.sql @@ -0,0 +1 @@ +create table in_01277 as out_01277 Engine=Null() diff --git a/tests/ast_json_fixtures/shapes/7d1959c61cf50733.json b/tests/ast_json_fixtures/shapes/7d1959c61cf50733.json new file mode 100644 index 000000000000..c9f57d82a33f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d1959c61cf50733.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "long_string" + }, + "settings_changes": { + "type": "Settings", + "changes": { + "min_compress_block_size": "8192" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7d1959c61cf50733.sql b/tests/ast_json_fixtures/shapes/7d1959c61cf50733.sql new file mode 100644 index 000000000000..2c4d207130ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d1959c61cf50733.sql @@ -0,0 +1 @@ +ALTER TABLE tab MODIFY COLUMN long_string MODIFY SETTING min_compress_block_size = 8192 diff --git a/tests/ast_json_fixtures/shapes/7d339eca202eccfa.json b/tests/ast_json_fixtures/shapes/7d339eca202eccfa.json new file mode 100644 index 000000000000..0364f2824cee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d339eca202eccfa.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Function", + "alias": "s", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "c2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_validation" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "c1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7d339eca202eccfa.sql b/tests/ast_json_fixtures/shapes/7d339eca202eccfa.sql new file mode 100644 index 000000000000..b5efc1e0b453 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d339eca202eccfa.sql @@ -0,0 +1 @@ +SELECT c0, sum(c2) as s FROM test_limit_by_validation GROUP BY c0 LIMIT 1 BY c1 diff --git a/tests/ast_json_fixtures/shapes/7d563ea9427454de.json b/tests/ast_json_fixtures/shapes/7d563ea9427454de.json new file mode 100644 index 000000000000..29c56c41e206 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d563ea9427454de.json @@ -0,0 +1,149 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Identifier", + "name": "uints8" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "uints8" + } + ] + }, + { + "type": "Identifier", + "name": "ints8" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "ints8" + } + ] + }, + { + "type": "Identifier", + "name": "ints32" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "ints32" + } + ] + }, + { + "type": "Identifier", + "name": "floats32" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "floats32" + } + ] + }, + { + "type": "Identifier", + "name": "decs32" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "decs32" + } + ] + }, + { + "type": "Identifier", + "name": "dates" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "dates" + } + ] + }, + { + "type": "Identifier", + "name": "uuids" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "uuids" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_byte_size_array" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7d563ea9427454de.sql b/tests/ast_json_fixtures/shapes/7d563ea9427454de.sql new file mode 100644 index 000000000000..2b05059f4753 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d563ea9427454de.sql @@ -0,0 +1 @@ +select key, byteSize(*), uints8, byteSize(uints8), ints8, byteSize(ints8), ints32, byteSize(ints32), floats32, byteSize(floats32), decs32, byteSize(decs32), dates, byteSize(dates), uuids, byteSize(uuids) from test_byte_size_array order by key diff --git a/tests/ast_json_fixtures/shapes/7d5fde272a5dec88.json b/tests/ast_json_fixtures/shapes/7d5fde272a5dec88.json new file mode 100644 index 000000000000..ffc96984345a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d5fde272a5dec88.json @@ -0,0 +1,297 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "row", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775808" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 3.4028234663852886e38 + } + ] + }, + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483647" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + } + ] + }, + { + "type": "Identifier", + "name": "k2" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "k2" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + }, + { + "type": "Identifier", + "name": "k2" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775807" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + }, + { + "type": "Function", + "alias": "k", + "name": "tupleElement", + "arguments": [ + { + "type": "Identifier", + "name": "row" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048576" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t__fuzz_282" + }, + "final": true + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "655.36" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0.2147483648" + } + ] + }, + { + "type": "Identifier", + "name": "k2" + } + ] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "102.3" + } + ] + }, + "direction": "DESC", + "nulls_first": true + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "String", + "value": "10.25" + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC", + "nulls_first": true + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/7d5fde272a5dec88.sql b/tests/ast_json_fixtures/shapes/7d5fde272a5dec88.sql new file mode 100644 index 000000000000..fe366e0cfbdc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d5fde272a5dec88.sql @@ -0,0 +1 @@ +SELECT arrayJoin([tuple([(toNullable(NULL), -9223372036854775808, toNullable(3.4028234663852886e38), arrayJoin([tuple([(toNullable(NULL), 2147483647, toNullable(0.5), k2)])]), k2)])]) AS row, arrayJoin([(1024, k2)]), -9223372036854775807, 256, tupleElement(row, 1048576, 1024) AS k FROM t__fuzz_282 FINAL ORDER BY (toNullable('655.36'), 2, toNullable('0.2147483648'), k2) ASC, toNullable('102.3') DESC NULLS FIRST, '10.25' DESC, k ASC NULLS FIRST format Null diff --git a/tests/ast_json_fixtures/shapes/7d63d7fc30a9c857.json b/tests/ast_json_fixtures/shapes/7d63d7fc30a9c857.json new file mode 100644 index 000000000000..68794d43a6d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d63d7fc30a9c857.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_shard_localhost", + "table": { + "type": "Identifier", + "name": "t02006" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "Date" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "d" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/7d63d7fc30a9c857.sql b/tests/ast_json_fixtures/shapes/7d63d7fc30a9c857.sql new file mode 100644 index 000000000000..0ac0e953c2a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d63d7fc30a9c857.sql @@ -0,0 +1,3 @@ +CREATE TABLE t02006 on cluster test_shard_localhost (d Date) +ENGINE = MergeTree ORDER BY d +format Null diff --git a/tests/ast_json_fixtures/shapes/7d94f422bc272b7b.json b/tests/ast_json_fixtures/shapes/7d94f422bc272b7b.json new file mode 100644 index 000000000000..48ab8a1fa736 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d94f422bc272b7b.json @@ -0,0 +1,140 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "cluster": "test_shard_localhost", + "table": { + "type": "Identifier", + "name": "mview" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "day", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "card_id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "card_view", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "day", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + { + "type": "Identifier", + "name": "card_id" + }, + { + "type": "Function", + "alias": "card_view", + "name": "count", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "source" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day" + }, + { + "type": "Identifier", + "name": "card_id" + } + ] + } + ] + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "SummingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day" + }, + { + "type": "Identifier", + "name": "card_id" + } + ] + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7d94f422bc272b7b.sql b/tests/ast_json_fixtures/shapes/7d94f422bc272b7b.sql new file mode 100644 index 000000000000..752983acae2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7d94f422bc272b7b.sql @@ -0,0 +1,12 @@ +CREATE MATERIALIZED VIEW mview on cluster test_shard_localhost +( + day Date, + card_id UInt64, + card_view Int64 +) +ENGINE = SummingMergeTree ORDER BY (day, card_id) +as SELECT + toDate(timestamp) AS day, + card_id, + count(*) AS card_view +FROM source GROUP BY (day, card_id) diff --git a/tests/ast_json_fixtures/shapes/7dbcbb815230abe5.json b/tests/ast_json_fixtures/shapes/7dbcbb815230abe5.json new file mode 100644 index 000000000000..00e37640a787 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7dbcbb815230abe5.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "log_proxy_02572" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "receiver_02572" + } + ] + } + }, + "as_database": "system", + "as_table": "query_log" + } +} diff --git a/tests/ast_json_fixtures/shapes/7dbcbb815230abe5.sql b/tests/ast_json_fixtures/shapes/7dbcbb815230abe5.sql new file mode 100644 index 000000000000..4d55f870bdbb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7dbcbb815230abe5.sql @@ -0,0 +1 @@ +create table log_proxy_02572 as system.query_log engine=Distributed('test_shard_localhost', currentDatabase(), 'receiver_02572') diff --git a/tests/ast_json_fixtures/shapes/7dee5e0c4a6ef477.json b/tests/ast_json_fixtures/shapes/7dee5e0c4a6ef477.json new file mode 100644 index 000000000000..01e5cf44f273 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7dee5e0c4a6ef477.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "or_replace": true, + "names": ["test_01605"] + } +} diff --git a/tests/ast_json_fixtures/shapes/7dee5e0c4a6ef477.sql b/tests/ast_json_fixtures/shapes/7dee5e0c4a6ef477.sql new file mode 100644 index 000000000000..07bcdc339851 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7dee5e0c4a6ef477.sql @@ -0,0 +1 @@ +CREATE SETTINGS PROFILE OR REPLACE 'test_01605' diff --git a/tests/ast_json_fixtures/shapes/7df568db62a1634f.json b/tests/ast_json_fixtures/shapes/7df568db62a1634f.json new file mode 100644 index 000000000000..d91ced668f51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7df568db62a1634f.json @@ -0,0 +1,245 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "FirstKey" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Literal", + "value_type": "String", + "value": "FirstKey" + }, + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + } + ] + }, + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "a", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tb__fuzz_0" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "strictness": "ALL", + "locality": "GLOBAL", + "using": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tabc__fuzz_21" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "DESC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1", + "max_block_size": "900", + "max_threads": "20", + "receive_timeout": 10, + "receive_data_timeout_ms": "10000", + "allow_suspicious_low_cardinality_types": true, + "merge_tree_min_rows_for_concurrent_read": "1000", + "log_queries": true, + "table_function_remote_max_addresses": "200", + "join_use_nulls": true, + "max_execution_time": 10, + "read_in_order_use_virtual_row": true, + "allow_introspection_functions": true, + "mutations_sync": "2", + "optimize_trivial_insert_select": true, + "aggregate_functions_null_for_empty": true, + "enable_filesystem_cache": false, + "allow_prefetched_read_pool_for_remote_filesystem": false, + "parallel_replicas_for_cluster_engines": false, + "allow_experimental_analyzer": true, + "analyzer_compatibility_join_using_top_level_identifier": true + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7df568db62a1634f.sql b/tests/ast_json_fixtures/shapes/7df568db62a1634f.sql new file mode 100644 index 000000000000..9b16d6be069c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7df568db62a1634f.sql @@ -0,0 +1 @@ +SELECT (*, 8, 8, 8, toFixedString('FirstKey', 8), 8, 8, (toNullable(8) IS NOT NULL) IS NULL, 8, toNullable(toNullable(toNullable(8))), 8, 8, 'FirstKey', (8 IS NOT NULL) IS NOT NULL), *, b + 1 AS a FROM tb__fuzz_0 GLOBAL ALL INNER JOIN tabc__fuzz_21 USING (a) ORDER BY `ALL` DESC SETTINGS enable_analyzer = 1, max_block_size = 900, max_threads = 20, receive_timeout = 10., receive_data_timeout_ms = 10000, allow_suspicious_low_cardinality_types = true, merge_tree_min_rows_for_concurrent_read = 1000, log_queries = true, table_function_remote_max_addresses = 200, join_use_nulls = true, max_execution_time = 10., read_in_order_use_virtual_row = true, allow_introspection_functions = true, mutations_sync = 2, optimize_trivial_insert_select = true, aggregate_functions_null_for_empty = true, enable_filesystem_cache = false, allow_prefetched_read_pool_for_remote_filesystem = false, parallel_replicas_for_cluster_engines = false, allow_experimental_analyzer = true, analyzer_compatibility_join_using_top_level_identifier = true diff --git a/tests/ast_json_fixtures/shapes/7e05f6cb81733c52.json b/tests/ast_json_fixtures/shapes/7e05f6cb81733c52.json new file mode 100644 index 000000000000..68636e3301e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7e05f6cb81733c52.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Literal", + "alias": "z", + "value_type": "UInt64", + "value": "11" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "43" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "44" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7e05f6cb81733c52.sql b/tests/ast_json_fixtures/shapes/7e05f6cb81733c52.sql new file mode 100644 index 000000000000..832cc8ddc504 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7e05f6cb81733c52.sql @@ -0,0 +1 @@ +select 11 AS z from (SELECT 1 UNION ALL SELECT 2) group by 42, 43, 44 WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/7e245bc6abd8104b.json b/tests/ast_json_fixtures/shapes/7e245bc6abd8104b.json new file mode 100644 index 000000000000..673290649316 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7e245bc6abd8104b.json @@ -0,0 +1,93 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "value", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Identifier", + "alias": "time", + "name": "number" + } + ], + "select": [ + { + "type": "Function", + "alias": "exp_smooth", + "name": "exponentialMovingAverage", + "arguments": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Identifier", + "name": "time" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7e245bc6abd8104b.sql b/tests/ast_json_fixtures/shapes/7e245bc6abd8104b.sql new file mode 100644 index 000000000000..43bd470b151d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7e245bc6abd8104b.sql @@ -0,0 +1 @@ +WITH number % 10 = 0 AS value, number AS time SELECT exponentialMovingAverage(1)(value, time) AS exp_smooth FROM numbers_mt(10) diff --git a/tests/ast_json_fixtures/shapes/7e689c0c6a1bb643.json b/tests/ast_json_fixtures/shapes/7e689c0c6a1bb643.json new file mode 100644 index 000000000000..297b2f70513f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7e689c0c6a1bb643.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "result" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "c", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7e689c0c6a1bb643.sql b/tests/ast_json_fixtures/shapes/7e689c0c6a1bb643.sql new file mode 100644 index 000000000000..aa9034a5641a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7e689c0c6a1bb643.sql @@ -0,0 +1 @@ +select 1, result from c(a=0) diff --git a/tests/ast_json_fixtures/shapes/7e7f8b1351c3554f.json b/tests/ast_json_fixtures/shapes/7e7f8b1351c3554f.json new file mode 100644 index 000000000000..b53ead65c133 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7e7f8b1351c3554f.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q15_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "QUERY_SELECTS": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7e7f8b1351c3554f.sql b/tests/ast_json_fixtures/shapes/7e7f8b1351c3554f.sql new file mode 100644 index 000000000000..1fecf4c1094d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7e7f8b1351c3554f.sql @@ -0,0 +1 @@ +CREATE QUOTA q15_01297 FOR INTERVAL 1 MINUTE MAX query_selects = 1.5 diff --git a/tests/ast_json_fixtures/shapes/7e9ad4c90fd08b4e.json b/tests/ast_json_fixtures/shapes/7e9ad4c90fd08b4e.json new file mode 100644 index 000000000000..4240f9b90e6e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7e9ad4c90fd08b4e.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "current_database", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "03626_parquet_bool.parquet" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "Bool", + "value": true + } + ], + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7e9ad4c90fd08b4e.sql b/tests/ast_json_fixtures/shapes/7e9ad4c90fd08b4e.sql new file mode 100644 index 000000000000..7965080e069a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7e9ad4c90fd08b4e.sql @@ -0,0 +1 @@ +insert into function file(current_database() ||'03626_parquet_bool.parquet') select true as x settings engine_file_truncate_on_insert=1 diff --git a/tests/ast_json_fixtures/shapes/7ed17a631940eb3b.json b/tests/ast_json_fixtures/shapes/7ed17a631940eb3b.json new file mode 100644 index 000000000000..a4597c8302ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ed17a631940eb3b.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t1" + }, + "as_table": "test_view" + } +} diff --git a/tests/ast_json_fixtures/shapes/7ed17a631940eb3b.sql b/tests/ast_json_fixtures/shapes/7ed17a631940eb3b.sql new file mode 100644 index 000000000000..a3964e362bef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ed17a631940eb3b.sql @@ -0,0 +1 @@ +CREATE TABLE t1 AS test_view diff --git a/tests/ast_json_fixtures/shapes/7ef4d7acc06680b8.json b/tests/ast_json_fixtures/shapes/7ef4d7acc06680b8.json new file mode 100644 index 000000000000..613675c06226 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ef4d7acc06680b8.json @@ -0,0 +1,259 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "IF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.00009999999747378752 + } + ] + }, + { + "type": "Function", + "name": "IF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "104" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048576" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "c1.key", + "name_parts": ["c1", "key"] + }, + { + "type": "Function", + "name": "IF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "c2.key", + "name_parts": ["c2", "key"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "c1", + "name": "codecTest" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "c2", + "name": "codecTest" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "name": "IF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "255" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-2" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "65537" + } + ] + } + ] + }, + { + "type": "Function", + "name": "IF", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775807" + } + ] + } + ] + }, + { + "type": "Function", + "name": "IF", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "IF", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "1048576" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c1.key", + "name_parts": ["c1", "key"] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "65535" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7ef4d7acc06680b8.sql b/tests/ast_json_fixtures/shapes/7ef4d7acc06680b8.sql new file mode 100644 index 000000000000..5eca8385c387 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ef4d7acc06680b8.sql @@ -0,0 +1 @@ +SELECT IF(2, NULL, 0.00009999999747378752), IF(104, 1048576, NULL), c1.key, IF(1, NULL, NULL), c2.key FROM codecTest AS c1 , codecTest AS c2 WHERE ignore(IF(255, -2, NULL), arrayJoin([65537]), IF(3, 1024, 9223372036854775807)) AND IF(NULL, 256, NULL) AND (IF(NULL, '1048576', NULL) = (c1.key - NULL)) LIMIT 65535 diff --git a/tests/ast_json_fixtures/shapes/7f03597ed926e951.json b/tests/ast_json_fixtures/shapes/7f03597ed926e951.json new file mode 100644 index 000000000000..62c25019c5af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f03597ed926e951.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t1" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PARTITION", + "detach": true, + "part": true, + "partition": { + "type": "Literal", + "value_type": "String", + "value": "all_0_0_0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7f03597ed926e951.sql b/tests/ast_json_fixtures/shapes/7f03597ed926e951.sql new file mode 100644 index 000000000000..73c02ab63c25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f03597ed926e951.sql @@ -0,0 +1 @@ +ALTER TABLE t1 DETACH PART 'all_0_0_0' diff --git a/tests/ast_json_fixtures/shapes/7f3765ecf2e7741e.json b/tests/ast_json_fixtures/shapes/7f3765ecf2e7741e.json new file mode 100644 index 000000000000..a2615f6e7524 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f3765ecf2e7741e.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "testing" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "c", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "proj_1", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "d" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "a" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192", + "index_granularity_bytes": "0", + "min_bytes_for_wide_part": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7f3765ecf2e7741e.sql b/tests/ast_json_fixtures/shapes/7f3765ecf2e7741e.sql new file mode 100644 index 000000000000..7171fd1f7044 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f3765ecf2e7741e.sql @@ -0,0 +1,16 @@ +CREATE TABLE testing +( + a String, + b String, + c String, + d String, + PROJECTION proj_1 + ( + SELECT b, c + ORDER BY d + ) +) +ENGINE = MergeTree() +PRIMARY KEY (a) +ORDER BY (a, b) +SETTINGS index_granularity = 8192, index_granularity_bytes = 0, min_bytes_for_wide_part = 0 diff --git a/tests/ast_json_fixtures/shapes/7f517a0f83768fbc.json b/tests/ast_json_fixtures/shapes/7f517a0f83768fbc.json new file mode 100644 index 000000000000..cb780bb40ba6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f517a0f83768fbc.json @@ -0,0 +1,152 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "REGEXP_REPLACE", + "arguments": [ + { + "type": "Identifier", + "name": "Referer" + }, + { + "type": "Literal", + "value_type": "String", + "value": "^https?:\/\/(?:www\\.)?([^\/]+)\/.*$" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\\1" + } + ] + }, + { + "type": "Function", + "alias": "l", + "name": "AVG", + "arguments": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "Referer" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "c", + "name": "COUNT", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "Referer" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Referer" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "COUNT", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "l" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "25" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "query_28" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/7f517a0f83768fbc.sql b/tests/ast_json_fixtures/shapes/7f517a0f83768fbc.sql new file mode 100644 index 000000000000..503e88eda856 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f517a0f83768fbc.sql @@ -0,0 +1 @@ +SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k, AVG(length(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM test.hits WHERE Referer <> '' GROUP BY k HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25 FORMAT Null SETTINGS log_comment='query_28' diff --git a/tests/ast_json_fixtures/shapes/7f53cfd9cb1b1188.json b/tests/ast_json_fixtures/shapes/7f53cfd9cb1b1188.json new file mode 100644 index 000000000000..0fe3359270e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f53cfd9cb1b1188.json @@ -0,0 +1,203 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "o_orderpriority" + }, + { + "type": "Function", + "alias": "order_count", + "name": "count", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "orders" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "o_orderdate" + }, + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1993-07-01" + } + ] + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "o_orderdate" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1993-07-01" + } + ] + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "3" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "exists", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lineitem" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l_orderkey" + }, + { + "type": "Identifier", + "name": "o_orderkey" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l_commitdate" + }, + { + "type": "Identifier", + "name": "l_receiptdate" + } + ] + } + ] + } + } + ] + } + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "o_orderpriority" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "o_orderpriority" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/7f53cfd9cb1b1188.sql b/tests/ast_json_fixtures/shapes/7f53cfd9cb1b1188.sql new file mode 100644 index 000000000000..baecae4ccb35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f53cfd9cb1b1188.sql @@ -0,0 +1,22 @@ +SELECT + o_orderpriority, + count(*) AS order_count +FROM + orders +WHERE + o_orderdate >= DATE '1993-07-01' + AND o_orderdate < DATE '1993-07-01' + INTERVAL '3' MONTH + AND EXISTS ( + SELECT + * + FROM + lineitem + WHERE + l_orderkey = o_orderkey + AND l_commitdate < l_receiptdate + ) +GROUP BY + o_orderpriority +ORDER BY + o_orderpriority +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/7f83c626d5284585.json b/tests/ast_json_fixtures/shapes/7f83c626d5284585.json new file mode 100644 index 000000000000..c45736000332 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f83c626d5284585.json @@ -0,0 +1,176 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "5" + }, + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7f83c626d5284585.sql b/tests/ast_json_fixtures/shapes/7f83c626d5284585.sql new file mode 100644 index 000000000000..ece48513f95e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f83c626d5284585.sql @@ -0,0 +1,22 @@ +WITH t AS + ( + SELECT number + a AS x + FROM numbers(5) + ) +SELECT * +FROM +( + SELECT + 0 AS a, + x + FROM t + UNION ALL + SELECT + 5 AS a, + x + FROM t +) +ORDER BY + a ASC, + x ASC +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/7f90f48ad26c59a0.json b/tests/ast_json_fixtures/shapes/7f90f48ad26c59a0.json new file mode 100644 index 000000000000..d6edca46e328 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f90f48ad26c59a0.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "alter": true, + "names": ["s1_01294"], + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["u1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7f90f48ad26c59a0.sql b/tests/ast_json_fixtures/shapes/7f90f48ad26c59a0.sql new file mode 100644 index 000000000000..ed03e20315c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7f90f48ad26c59a0.sql @@ -0,0 +1 @@ +ALTER PROFILE s1_01294 TO u1_01294 diff --git a/tests/ast_json_fixtures/shapes/7fd060d4d47f3588.json b/tests/ast_json_fixtures/shapes/7fd060d4d47f3588.json new file mode 100644 index 000000000000..ad0d69c805b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7fd060d4d47f3588.json @@ -0,0 +1,94 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "123" + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "555" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7fd060d4d47f3588.sql b/tests/ast_json_fixtures/shapes/7fd060d4d47f3588.sql new file mode 100644 index 000000000000..4eabec563b45 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7fd060d4d47f3588.sql @@ -0,0 +1 @@ +WITH 123 AS x SELECT 555 FROM (SELECT a, x FROM (SELECT 1 AS a, 2 AS b)) diff --git a/tests/ast_json_fixtures/shapes/7fd79a5ea2829083.json b/tests/ast_json_fixtures/shapes/7fd79a5ea2829083.json new file mode 100644 index 000000000000..f02cdd9bae9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7fd79a5ea2829083.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettyCompactNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/7fd79a5ea2829083.sql b/tests/ast_json_fixtures/shapes/7fd79a5ea2829083.sql new file mode 100644 index 000000000000..4f6ff519f080 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7fd79a5ea2829083.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettyCompactNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/7fd7fcdc402b6306.json b/tests/ast_json_fixtures/shapes/7fd7fcdc402b6306.json new file mode 100644 index 000000000000..c507c56207e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7fd7fcdc402b6306.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_create_empty": true, + "table": { + "type": "Identifier", + "name": "b" + }, + "as_table": "a" + } +} diff --git a/tests/ast_json_fixtures/shapes/7fd7fcdc402b6306.sql b/tests/ast_json_fixtures/shapes/7fd7fcdc402b6306.sql new file mode 100644 index 000000000000..721460bc97f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7fd7fcdc402b6306.sql @@ -0,0 +1 @@ +create table b empty as a diff --git a/tests/ast_json_fixtures/shapes/7fd81705f907e584.json b/tests/ast_json_fixtures/shapes/7fd81705f907e584.json new file mode 100644 index 000000000000..a988a8ac2696 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7fd81705f907e584.json @@ -0,0 +1,117 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "a", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "aaa" + }, + { + "value_type": "String", + "value": "bbb" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "b", + "value_type": "String", + "value": "aaa\u0000bbb" + } + ], + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/7fd81705f907e584.sql b/tests/ast_json_fixtures/shapes/7fd81705f907e584.sql new file mode 100644 index 000000000000..683e26d8ea74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7fd81705f907e584.sql @@ -0,0 +1 @@ +WITH arrayJoin(['aaa', 'bbb']) AS a, 'aaa\0bbb' AS b SELECT a = b, a < b, a > b, a <= b, a >= b diff --git a/tests/ast_json_fixtures/shapes/7feb6c0ecbef6da4.json b/tests/ast_json_fixtures/shapes/7feb6c0ecbef6da4.json new file mode 100644 index 000000000000..af8dfe406f48 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7feb6c0ecbef6da4.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "copy_with_comment" + }, + "as_table": "base", + "comment": { + "type": "Literal", + "value_type": "String", + "value": "new comment" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7feb6c0ecbef6da4.sql b/tests/ast_json_fixtures/shapes/7feb6c0ecbef6da4.sql new file mode 100644 index 000000000000..fc28151b2cfd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7feb6c0ecbef6da4.sql @@ -0,0 +1 @@ +CREATE TABLE copy_with_comment AS base COMMENT 'new comment' diff --git a/tests/ast_json_fixtures/shapes/7ff226905f5087c9.json b/tests/ast_json_fixtures/shapes/7ff226905f5087c9.json new file mode 100644 index 000000000000..e640980a0a76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ff226905f5087c9.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "src", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "123" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + }, + { + "type": "Identifier", + "name": "theAlias" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "alias_bug_dist" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/7ff226905f5087c9.sql b/tests/ast_json_fixtures/shapes/7ff226905f5087c9.sql new file mode 100644 index 000000000000..dcaf0479c04d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ff226905f5087c9.sql @@ -0,0 +1 @@ +SELECT CAST(123, 'String') AS src,theAlias FROM alias_bug_dist LIMIT 1 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/7ff69eded83c902d.json b/tests/ast_json_fixtures/shapes/7ff69eded83c902d.json new file mode 100644 index 000000000000..302aa256c613 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ff69eded83c902d.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateWorkloadQuery", + "if_not_exists": true, + "workload_name": { + "type": "Identifier", + "name": "production" + }, + "workload_parent": { + "type": "Identifier", + "name": "all" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/7ff69eded83c902d.sql b/tests/ast_json_fixtures/shapes/7ff69eded83c902d.sql new file mode 100644 index 000000000000..58fb28ff1b75 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/7ff69eded83c902d.sql @@ -0,0 +1 @@ +CREATE WORKLOAD IF NOT EXISTS production IN all diff --git a/tests/ast_json_fixtures/shapes/80041a862534e61f.json b/tests/ast_json_fixtures/shapes/80041a862534e61f.json new file mode 100644 index 000000000000..796d64e7346f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/80041a862534e61f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "DROP REPLICA", + "replica": "r1" + } +} diff --git a/tests/ast_json_fixtures/shapes/80041a862534e61f.sql b/tests/ast_json_fixtures/shapes/80041a862534e61f.sql new file mode 100644 index 000000000000..5a437f4da2b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/80041a862534e61f.sql @@ -0,0 +1 @@ +SYSTEM DROP REPLICA 'r1' FROM ZKPATH '' diff --git a/tests/ast_json_fixtures/shapes/8019b54a0ec9dba7.json b/tests/ast_json_fixtures/shapes/8019b54a0ec9dba7.json new file mode 100644 index 000000000000..88bf74526865 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8019b54a0ec9dba7.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pk_order" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8019b54a0ec9dba7.sql b/tests/ast_json_fixtures/shapes/8019b54a0ec9dba7.sql new file mode 100644 index 000000000000..55a1a98f33c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8019b54a0ec9dba7.sql @@ -0,0 +1 @@ +SELECT d, max(b) FROM pk_order GROUP BY d, a ORDER BY d, a LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/8033275526e8cbbe.json b/tests/ast_json_fixtures/shapes/8033275526e8cbbe.json new file mode 100644 index 000000000000..a081197146ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8033275526e8cbbe.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": [" "] + } +} diff --git a/tests/ast_json_fixtures/shapes/8033275526e8cbbe.sql b/tests/ast_json_fixtures/shapes/8033275526e8cbbe.sql new file mode 100644 index 000000000000..b779fb7dd442 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8033275526e8cbbe.sql @@ -0,0 +1 @@ +drop user " " diff --git a/tests/ast_json_fixtures/shapes/8066fe025fc22819.json b/tests/ast_json_fixtures/shapes/8066fe025fc22819.json new file mode 100644 index 000000000000..fee538278e21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8066fe025fc22819.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "replicated_merge_tree_commit_zk_fail_when_recovering_from_hw_fault" + } +} diff --git a/tests/ast_json_fixtures/shapes/8066fe025fc22819.sql b/tests/ast_json_fixtures/shapes/8066fe025fc22819.sql new file mode 100644 index 000000000000..bcfd981732f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8066fe025fc22819.sql @@ -0,0 +1 @@ +system enable failpoint replicated_merge_tree_commit_zk_fail_when_recovering_from_hw_fault diff --git a/tests/ast_json_fixtures/shapes/80777797a12b1096.json b/tests/ast_json_fixtures/shapes/80777797a12b1096.json new file mode 100644 index 000000000000..06c3218dbbbc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/80777797a12b1096.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tmp" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_COLUMN", + "column": { + "type": "Identifier", + "name": "s" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/80777797a12b1096.sql b/tests/ast_json_fixtures/shapes/80777797a12b1096.sql new file mode 100644 index 000000000000..f9380b59bd62 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/80777797a12b1096.sql @@ -0,0 +1 @@ +ALTER TABLE tmp MATERIALIZE COLUMN s diff --git a/tests/ast_json_fixtures/shapes/808f3b54c04243e1.json b/tests/ast_json_fixtures/shapes/808f3b54c04243e1.json new file mode 100644 index 000000000000..b7e9817e4a76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/808f3b54c04243e1.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02125_function_1" + } +} diff --git a/tests/ast_json_fixtures/shapes/808f3b54c04243e1.sql b/tests/ast_json_fixtures/shapes/808f3b54c04243e1.sql new file mode 100644 index 000000000000..de8184d7ec6d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/808f3b54c04243e1.sql @@ -0,0 +1 @@ +DROP FUNCTION 02125_function_1 diff --git a/tests/ast_json_fixtures/shapes/80c765340bdc7b97.json b/tests/ast_json_fixtures/shapes/80c765340bdc7b97.json new file mode 100644 index 000000000000..f119f871e95f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/80c765340bdc7b97.json @@ -0,0 +1,115 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "p" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Identifier", + "name": "p" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/80c765340bdc7b97.sql b/tests/ast_json_fixtures/shapes/80c765340bdc7b97.sql new file mode 100644 index 000000000000..5da25482e4b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/80c765340bdc7b97.sql @@ -0,0 +1 @@ +select 1 from tab where d > toDateTime(toDate('2000-01-01')) and p in ('a') and 1 = 1 group by d, t, p diff --git a/tests/ast_json_fixtures/shapes/80eb296feb094851.json b/tests/ast_json_fixtures/shapes/80eb296feb094851.json new file mode 100644 index 000000000000..efc2150ff743 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/80eb296feb094851.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "any", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "1", + "query_plan_aggregation_in_order": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/80eb296feb094851.sql b/tests/ast_json_fixtures/shapes/80eb296feb094851.sql new file mode 100644 index 000000000000..12e30927d618 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/80eb296feb094851.sql @@ -0,0 +1 @@ +select a, any(b), c, d from tab where b = 1 group by a, c, d order by c, d settings optimize_aggregation_in_order=1, query_plan_aggregation_in_order=1 diff --git a/tests/ast_json_fixtures/shapes/80ec022f7ed26800.json b/tests/ast_json_fixtures/shapes/80ec022f7ed26800.json new file mode 100644 index 000000000000..a813b19417cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/80ec022f7ed26800.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Identifier", + "name": "system" + }, + { + "type": "Identifier", + "name": "one" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "String", + "value": "hi" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1", + "group_by_two_level_threshold": "1", + "group_by_two_level_threshold_bytes": "33950592" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/80ec022f7ed26800.sql b/tests/ast_json_fixtures/shapes/80ec022f7ed26800.sql new file mode 100644 index 000000000000..465936c0a500 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/80ec022f7ed26800.sql @@ -0,0 +1,7 @@ +SELECT count() +FROM remote(test_cluster_two_shards, system, one) +GROUP BY 'hi' +SETTINGS + enable_analyzer = 1, + group_by_two_level_threshold = 1, + group_by_two_level_threshold_bytes = 33950592 diff --git a/tests/ast_json_fixtures/shapes/8102dd24dc35853b.json b/tests/ast_json_fixtures/shapes/8102dd24dc35853b.json new file mode 100644 index 000000000000..6515e70b90f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8102dd24dc35853b.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectIntersectExceptQuery", + "operator": "INTERSECT ALL", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8102dd24dc35853b.sql b/tests/ast_json_fixtures/shapes/8102dd24dc35853b.sql new file mode 100644 index 000000000000..d4755d5ecbca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8102dd24dc35853b.sql @@ -0,0 +1 @@ +select 1 union all select 1 intersect select 1 diff --git a/tests/ast_json_fixtures/shapes/811e2496f32eb5d5.json b/tests/ast_json_fixtures/shapes/811e2496f32eb5d5.json new file mode 100644 index 000000000000..48106b5fcd3e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/811e2496f32eb5d5.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + ], + "format": "PrettyCompactNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/811e2496f32eb5d5.sql b/tests/ast_json_fixtures/shapes/811e2496f32eb5d5.sql new file mode 100644 index 000000000000..a2b4b1d5267d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/811e2496f32eb5d5.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a FORMAT PrettyCompactNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/8136511ad2811cfd.json b/tests/ast_json_fixtures/shapes/8136511ad2811cfd.json new file mode 100644 index 000000000000..f99ac216d82c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8136511ad2811cfd.json @@ -0,0 +1,127 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + ] + } + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/8136511ad2811cfd.sql b/tests/ast_json_fixtures/shapes/8136511ad2811cfd.sql new file mode 100644 index 000000000000..490641e219a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8136511ad2811cfd.sql @@ -0,0 +1,13 @@ +SELECT * +FROM +( + SELECT * + FROM system.numbers + WHERE number = 100 + UNION ALL + SELECT * + FROM system.numbers + WHERE number = 100 +) +LIMIT 2 +SETTINGS max_threads = 1 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/813b713142d1897f.json b/tests/ast_json_fixtures/shapes/813b713142d1897f.json new file mode 100644 index 000000000000..68df5f9c3642 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/813b713142d1897f.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "assert_exists", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "events", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "String", + "value": "FilterTransformPassedRows" + }, + { + "value_type": "String", + "value": "FilterTransformPassedBytes" + } + ] + } + ] + }, + "having": { + "type": "Identifier", + "name": "assert_exists" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/813b713142d1897f.sql b/tests/ast_json_fixtures/shapes/813b713142d1897f.sql new file mode 100644 index 000000000000..180384b1c2f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/813b713142d1897f.sql @@ -0,0 +1 @@ +SELECT count() = 2 AS assert_exists FROM system.events WHERE name IN ('FilterTransformPassedRows', 'FilterTransformPassedBytes') HAVING assert_exists diff --git a/tests/ast_json_fixtures/shapes/814890c1bd83f1d7.json b/tests/ast_json_fixtures/shapes/814890c1bd83f1d7.json new file mode 100644 index 000000000000..da229b155a5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/814890c1bd83f1d7.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02483_plusthree", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/814890c1bd83f1d7.sql b/tests/ast_json_fixtures/shapes/814890c1bd83f1d7.sql new file mode 100644 index 000000000000..a7779faa0b41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/814890c1bd83f1d7.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02483_plusthree diff --git a/tests/ast_json_fixtures/shapes/81573ddcd8c32083.json b/tests/ast_json_fixtures/shapes/81573ddcd8c32083.json new file mode 100644 index 000000000000..5040e9ecba51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81573ddcd8c32083.json @@ -0,0 +1,272 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "uuid", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "uuid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tables", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "t_ind_merge_1" + } + ] + } + ] + } + } + ] + } + }, + { + "type": "Function", + "alias": "groups", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "extractAllGroupsVertical", + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "containing (\\d+) columns \\((\\d+) merged, (\\d+) gathered\\)" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "total", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "groups" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "merged", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "groups" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "alias": "gathered", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "groups" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "text_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "uuid" + }, + { + "type": "Literal", + "value_type": "String", + "value": "::all_1_2_1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".t_ind_merge_1::all_1_2_1" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "notEmpty", + "arguments": [ + { + "type": "Identifier", + "name": "groups" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time_microseconds" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/81573ddcd8c32083.sql b/tests/ast_json_fixtures/shapes/81573ddcd8c32083.sql new file mode 100644 index 000000000000..9309682eccd7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81573ddcd8c32083.sql @@ -0,0 +1,10 @@ +WITH + (SELECT uuid FROM system.tables WHERE database = currentDatabase() AND table = 't_ind_merge_1') AS uuid, + extractAllGroupsVertical(message, 'containing (\\d+) columns \((\\d+) merged, (\\d+) gathered\)')[1] AS groups +SELECT + groups[1] AS total, + groups[2] AS merged, + groups[3] AS gathered +FROM system.text_log +WHERE ((query_id = uuid || '::all_1_2_1') OR (query_id = currentDatabase() || '.t_ind_merge_1::all_1_2_1')) AND notEmpty(groups) +ORDER BY event_time_microseconds diff --git a/tests/ast_json_fixtures/shapes/8194bf43d71f3de8.json b/tests/ast_json_fixtures/shapes/8194bf43d71f3de8.json new file mode 100644 index 000000000000..3a7336647c5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8194bf43d71f3de8.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "test_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "key_column", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "data_column_1", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "data_column_2", + "data_type": { + "type": "DataType", + "name": "UInt8" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "key_column" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "test_table" + } + } + ] + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "direct", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8194bf43d71f3de8.sql b/tests/ast_json_fixtures/shapes/8194bf43d71f3de8.sql new file mode 100644 index 000000000000..de3955aa5779 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8194bf43d71f3de8.sql @@ -0,0 +1,9 @@ +CREATE DICTIONARY test_dictionary +( + key_column UInt64 DEFAULT 0, + data_column_1 UInt64 DEFAULT 1, + data_column_2 UInt8 DEFAULT 1 +) +PRIMARY KEY key_column +LAYOUT(DIRECT()) +SOURCE(CLICKHOUSE(TABLE 'test_table')) diff --git a/tests/ast_json_fixtures/shapes/819801ad7930dfbd.json b/tests/ast_json_fixtures/shapes/819801ad7930dfbd.json new file mode 100644 index 000000000000..eebb522810f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/819801ad7930dfbd.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "c", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "having": { + "type": "Identifier", + "name": "c" + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/819801ad7930dfbd.sql b/tests/ast_json_fixtures/shapes/819801ad7930dfbd.sql new file mode 100644 index 000000000000..8ee03efb0e9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/819801ad7930dfbd.sql @@ -0,0 +1 @@ +SELECT a, sum(b) FROM (SELECT 1 AS a, 1 AS b, 0 AS c) GROUP BY a HAVING c SETTINGS enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/81b005749aae7ad1.json b/tests/ast_json_fixtures/shapes/81b005749aae7ad1.json new file mode 100644 index 000000000000..df428753589c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81b005749aae7ad1.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettyNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/81b005749aae7ad1.sql b/tests/ast_json_fixtures/shapes/81b005749aae7ad1.sql new file mode 100644 index 000000000000..cf11561c05ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81b005749aae7ad1.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettyNoEscapes diff --git a/tests/ast_json_fixtures/shapes/81bc204e9ba8f22e.json b/tests/ast_json_fixtures/shapes/81bc204e9ba8f22e.json new file mode 100644 index 000000000000..a0c4533ca730 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81bc204e9ba8f22e.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "col", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx", + "expression": { + "type": "Identifier", + "name": "col" + }, + "index_type": { + "type": "Function", + "name": "text", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tokenizer" + }, + { + "type": "Identifier", + "name": "array" + } + ] + } + ] + }, + "granularity": 100000000 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/81bc204e9ba8f22e.sql b/tests/ast_json_fixtures/shapes/81bc204e9ba8f22e.sql new file mode 100644 index 000000000000..cc4a326ea42d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81bc204e9ba8f22e.sql @@ -0,0 +1,7 @@ +CREATE TABLE tab +( + col Array(String), + INDEX idx col TYPE text(tokenizer=array) +) +ENGINE=MergeTree() ORDER BY tuple() +AS SELECT [] diff --git a/tests/ast_json_fixtures/shapes/81c01a8f94317acf.json b/tests/ast_json_fixtures/shapes/81c01a8f94317acf.json new file mode 100644 index 000000000000..de4d0f0417a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81c01a8f94317acf.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "dictionary": true, + "elements": [ + { + "from_database": "test_01155_ordinary", + "from_table": "dict", + "to_database": "test_01155_atomic", + "to_table": "dict" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/81c01a8f94317acf.sql b/tests/ast_json_fixtures/shapes/81c01a8f94317acf.sql new file mode 100644 index 000000000000..a798b0c06a7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81c01a8f94317acf.sql @@ -0,0 +1 @@ +RENAME DICTIONARY test_01155_ordinary.dict TO test_01155_atomic.dict diff --git a/tests/ast_json_fixtures/shapes/81cac15d28f640aa.json b/tests/ast_json_fixtures/shapes/81cac15d28f640aa.json new file mode 100644 index 000000000000..61f42863a58f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81cac15d28f640aa.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettySpaceNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/81cac15d28f640aa.sql b/tests/ast_json_fixtures/shapes/81cac15d28f640aa.sql new file mode 100644 index 000000000000..597835fc5131 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81cac15d28f640aa.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettySpaceNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/81d8032cbcff40d2.json b/tests/ast_json_fixtures/shapes/81d8032cbcff40d2.json new file mode 100644 index 000000000000..9d208025b35c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81d8032cbcff40d2.json @@ -0,0 +1,214 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "rowNr" + }, + { + "type": "Identifier", + "name": "val_string" + }, + { + "type": "Function", + "alias": "str_m1", + "name": "neighbor", + "arguments": [ + { + "type": "Identifier", + "name": "val_string" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + }, + { + "type": "Function", + "alias": "str_p1", + "name": "neighbor", + "arguments": [ + { + "type": "Identifier", + "name": "val_string" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "val_low" + }, + { + "type": "Function", + "alias": "low_m1", + "name": "neighbor", + "arguments": [ + { + "type": "Identifier", + "name": "val_low" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + }, + { + "type": "Function", + "alias": "low_p1", + "name": "neighbor", + "arguments": [ + { + "type": "Identifier", + "name": "val_low" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "neighbor_test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "val_string" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "rowNr" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "rowNr" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "val_string" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "str_m1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "str_p1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "val_low" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "low_m1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "low_p1" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_color": "1" + } + } + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/81d8032cbcff40d2.sql b/tests/ast_json_fixtures/shapes/81d8032cbcff40d2.sql new file mode 100644 index 000000000000..22797574c21e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81d8032cbcff40d2.sql @@ -0,0 +1,17 @@ +SELECT + rowNr, + val_string, + neighbor(val_string, -1) AS str_m1, + neighbor(val_string, 1) AS str_p1, + val_low, + neighbor(val_low, -1) AS low_m1, + neighbor(val_low, 1) AS low_p1 +FROM +( + SELECT * + FROM neighbor_test + ORDER BY val_string, rowNr +) +ORDER BY rowNr, val_string, str_m1, str_p1, val_low, low_m1, low_p1 +SETTINGS output_format_pretty_color=1 +format PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/81d96e793d00d087.json b/tests/ast_json_fixtures/shapes/81d96e793d00d087.json new file mode 100644 index 000000000000..285c446bf15e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81d96e793d00d087.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "replace_table": true, + "table": { + "type": "Identifier", + "name": "tmp" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/81d96e793d00d087.sql b/tests/ast_json_fixtures/shapes/81d96e793d00d087.sql new file mode 100644 index 000000000000..6fe2640d3206 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/81d96e793d00d087.sql @@ -0,0 +1 @@ +REPLACE TEMPORARY TABLE tmp (s String) AS SELECT 'a' FROM numbers(10) diff --git a/tests/ast_json_fixtures/shapes/8200ebd40bab454d.json b/tests/ast_json_fixtures/shapes/8200ebd40bab454d.json new file mode 100644 index 000000000000..e3b2a6bc7064 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8200ebd40bab454d.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "t_lwu_defaults" + }, + "assignments": [ + { + "type": "Assignment", + "column": "z", + "expression": { + "type": "Identifier", + "name": "y" + } + } + ], + "predicate": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8200ebd40bab454d.sql b/tests/ast_json_fixtures/shapes/8200ebd40bab454d.sql new file mode 100644 index 000000000000..61ce6efd6ed2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8200ebd40bab454d.sql @@ -0,0 +1 @@ +UPDATE t_lwu_defaults SET z = y WHERE x > 0 diff --git a/tests/ast_json_fixtures/shapes/82140dcf349c147e.json b/tests/ast_json_fixtures/shapes/82140dcf349c147e.json new file mode 100644 index 000000000000..17f20aa24ea5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82140dcf349c147e.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "s3", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "http:\/\/localhost:11111\/test\/data_*_{_partition_id}.csv" + } + ] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/82140dcf349c147e.sql b/tests/ast_json_fixtures/shapes/82140dcf349c147e.sql new file mode 100644 index 000000000000..660830df144d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82140dcf349c147e.sql @@ -0,0 +1 @@ +insert into function s3('http://localhost:11111/test/data_*_{_partition_id}.csv') partition by number % 3 select * from numbers(10) diff --git a/tests/ast_json_fixtures/shapes/82267aceab9418f3.json b/tests/ast_json_fixtures/shapes/82267aceab9418f3.json new file mode 100644 index 000000000000..9eefdadca4dc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82267aceab9418f3.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q15_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/82267aceab9418f3.sql b/tests/ast_json_fixtures/shapes/82267aceab9418f3.sql new file mode 100644 index 000000000000..18137ea66cb1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82267aceab9418f3.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q15_01297 diff --git a/tests/ast_json_fixtures/shapes/823876f5cd61ee28.json b/tests/ast_json_fixtures/shapes/823876f5cd61ee28.json new file mode 100644 index 000000000000..1253ddb0f7b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/823876f5cd61ee28.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["无名氏 "] + } +} diff --git a/tests/ast_json_fixtures/shapes/823876f5cd61ee28.sql b/tests/ast_json_fixtures/shapes/823876f5cd61ee28.sql new file mode 100644 index 000000000000..6253a33dcfc4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/823876f5cd61ee28.sql @@ -0,0 +1 @@ +drop user if exists "无名氏 " diff --git a/tests/ast_json_fixtures/shapes/825c290574d6a2fc.json b/tests/ast_json_fixtures/shapes/825c290574d6a2fc.json new file mode 100644 index 000000000000..1735c712037a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/825c290574d6a2fc.json @@ -0,0 +1,121 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_grouping_sets_predicate" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "day_" + }, + { + "type": "Identifier", + "name": "type_1" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "day_" + } + ] + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day_" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2023-01-05" + } + ] + }, + "group_by": [ + { + "type": "Asterisk" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/825c290574d6a2fc.sql b/tests/ast_json_fixtures/shapes/825c290574d6a2fc.sql new file mode 100644 index 000000000000..b8543574f78b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/825c290574d6a2fc.sql @@ -0,0 +1,6 @@ +SELECT * +FROM ( SELECT * FROM test_grouping_sets_predicate GROUP BY GROUPING SETS ( (day_, type_1), (day_) ) ) +WHERE day_ = '2023-01-05' +GROUP BY * +ORDER BY ALL +SETTINGS enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/826f91bcf7ab471c.json b/tests/ast_json_fixtures/shapes/826f91bcf7ab471c.json new file mode 100644 index 000000000000..f4b0ba35fa6d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/826f91bcf7ab471c.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "summing" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_ORDER_BY", + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "val" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/826f91bcf7ab471c.sql b/tests/ast_json_fixtures/shapes/826f91bcf7ab471c.sql new file mode 100644 index 000000000000..6ccd313101b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/826f91bcf7ab471c.sql @@ -0,0 +1 @@ +ALTER TABLE summing MODIFY ORDER BY (x, y, -val) diff --git a/tests/ast_json_fixtures/shapes/82a00f60f9cc9b77.json b/tests/ast_json_fixtures/shapes/82a00f60f9cc9b77.json new file mode 100644 index 000000000000..03510bb2b58e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82a00f60f9cc9b77.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u2_01292", "u3_01292", "u4_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/82a00f60f9cc9b77.sql b/tests/ast_json_fixtures/shapes/82a00f60f9cc9b77.sql new file mode 100644 index 000000000000..e8c1a807d46c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82a00f60f9cc9b77.sql @@ -0,0 +1 @@ +SHOW CREATE USER u1_01292, u2_01292, u3_01292, u4_01292 diff --git a/tests/ast_json_fixtures/shapes/82a06a461beaba8c.json b/tests/ast_json_fixtures/shapes/82a06a461beaba8c.json new file mode 100644 index 000000000000..0d766f1c42bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82a06a461beaba8c.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "pol2", + "table": "tab2" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/82a06a461beaba8c.sql b/tests/ast_json_fixtures/shapes/82a06a461beaba8c.sql new file mode 100644 index 000000000000..2339b91b3626 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82a06a461beaba8c.sql @@ -0,0 +1 @@ +CREATE ROW POLICY pol2 ON tab2 USING x != 1 TO ALL diff --git a/tests/ast_json_fixtures/shapes/82a1fedd5d5cf5b8.json b/tests/ast_json_fixtures/shapes/82a1fedd5d5cf5b8.json new file mode 100644 index 000000000000..cedac23a83ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82a1fedd5d5cf5b8.json @@ -0,0 +1,113 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "database": { + "type": "Identifier", + "name": "database_dictionary_test_key_expression" + }, + "table": { + "type": "Identifier", + "name": "test_query_log_dictionary_simple" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "value_id", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "expression": { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "value_id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "user", + "value": { + "type": "Literal", + "value_type": "String", + "value": "default" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "test_for_dictionary" + } + }, + { + "type": "pair", + "key": "db", + "value": { + "type": "Literal", + "value_type": "String", + "value": "database_dictionary_test_key_expression" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 1, + "max_sec": 10 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "hashed", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/82a1fedd5d5cf5b8.sql b/tests/ast_json_fixtures/shapes/82a1fedd5d5cf5b8.sql new file mode 100644 index 000000000000..1365b8637d87 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82a1fedd5d5cf5b8.sql @@ -0,0 +1,9 @@ +CREATE DICTIONARY database_dictionary_test_key_expression.test_query_log_dictionary_simple +( + `value_id` UInt64 EXPRESSION cityHash64(value), + `value` String +) +PRIMARY KEY value_id +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'test_for_dictionary' DB 'database_dictionary_test_key_expression')) +LIFETIME(MIN 1 MAX 10) +LAYOUT(HASHED()) diff --git a/tests/ast_json_fixtures/shapes/82b1f228a4e217bc.json b/tests/ast_json_fixtures/shapes/82b1f228a4e217bc.json new file mode 100644 index 000000000000..754c878113e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82b1f228a4e217bc.json @@ -0,0 +1,252 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "2147483647" + }, + { + "value_type": "Float64", + "value": 0 + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 10.0001 + }, + { + "value_type": "UInt64", + "value": "65535" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "255" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1023" + }, + { + "value_type": "UInt64", + "value": "2147483646" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "polygonsSymDifferenceCartesian", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "2147483647" + }, + { + "value_type": "Float64", + "value": 0 + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 10.0001 + }, + { + "value_type": "UInt64", + "value": "65535" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1023" + }, + { + "value_type": "UInt64", + "value": "2147483646" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 1000.0001 + }, + { + "value_type": "Float64", + "value": 10.0001 + } + ] + } + ] + } + ] + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "2147483647" + }, + { + "value_type": "Float64", + "value": 0 + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 10.0001 + }, + { + "value_type": "UInt64", + "value": "65535" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1023" + }, + { + "value_type": "UInt64", + "value": "2147483646" + } + ] + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/82b1f228a4e217bc.sql b/tests/ast_json_fixtures/shapes/82b1f228a4e217bc.sql new file mode 100644 index 000000000000..818eaa5886b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82b1f228a4e217bc.sql @@ -0,0 +1 @@ +SELECT [[(2147483647, 0.), (10.0001, 65535), (1, 255), (1023, 2147483646)]], polygonsSymDifferenceCartesian([[[(2147483647, 0.), (10.0001, 65535), (1023, 2147483646)]]], [[[(1000.0001, 10.0001)]]]) GROUP BY [[(2147483647, 0.), (10.0001, 65535), (1023, 2147483646)]] WITH ROLLUP SETTINGS enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/82b22641482ee0eb.json b/tests/ast_json_fixtures/shapes/82b22641482ee0eb.json new file mode 100644 index 000000000000..a9e32bf1cb82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82b22641482ee0eb.json @@ -0,0 +1,98 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "alias": "amount", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test02315" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "amount" + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_grouping_standard_compatibility": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/82b22641482ee0eb.sql b/tests/ast_json_fixtures/shapes/82b22641482ee0eb.sql new file mode 100644 index 000000000000..3f889b1688fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82b22641482ee0eb.sql @@ -0,0 +1 @@ +SELECT count() AS amount, a, b, GROUPING(a, b) FROM test02315 GROUP BY ROLLUP(a, b) ORDER BY (amount, a, b) SETTINGS force_grouping_standard_compatibility=0 diff --git a/tests/ast_json_fixtures/shapes/82b9cd1285f4df57.json b/tests/ast_json_fixtures/shapes/82b9cd1285f4df57.json new file mode 100644 index 000000000000..2ba4fbddb335 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82b9cd1285f4df57.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_shared" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "APPLY_PATCHES" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/82b9cd1285f4df57.sql b/tests/ast_json_fixtures/shapes/82b9cd1285f4df57.sql new file mode 100644 index 000000000000..9ddf72f33813 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82b9cd1285f4df57.sql @@ -0,0 +1 @@ +ALTER TABLE t_shared APPLY PATCHES SETTINGS mutations_sync = 2 diff --git a/tests/ast_json_fixtures/shapes/82ba119205f0c273.json b/tests/ast_json_fixtures/shapes/82ba119205f0c273.json new file mode 100644 index 000000000000..6b86cc6ed9d8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82ba119205f0c273.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "str" + } + }, + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "column": { + "type": "Identifier", + "name": "x" + }, + "rename_to": { + "type": "Identifier", + "name": "str" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/82ba119205f0c273.sql b/tests/ast_json_fixtures/shapes/82ba119205f0c273.sql new file mode 100644 index 000000000000..14b2fb6a3e3d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82ba119205f0c273.sql @@ -0,0 +1 @@ +ALTER TABLE test DROP COLUMN str, RENAME COLUMN x TO str diff --git a/tests/ast_json_fixtures/shapes/82c3d8fb40466f06.json b/tests/ast_json_fixtures/shapes/82c3d8fb40466f06.json new file mode 100644 index 000000000000..3eca93be4557 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82c3d8fb40466f06.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Hello, world" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/82c3d8fb40466f06.sql b/tests/ast_json_fixtures/shapes/82c3d8fb40466f06.sql new file mode 100644 index 000000000000..a64d3a3881b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82c3d8fb40466f06.sql @@ -0,0 +1,2 @@ +SELECT 'Hello, world' FROM (SELECT number FROM system.numbers LIMIT 10) WHERE number < 0 +FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/82c41cd8cd51448f.json b/tests/ast_json_fixtures/shapes/82c41cd8cd51448f.json new file mode 100644 index 000000000000..09c2a0bbb614 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82c41cd8cd51448f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02125_function_2", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/82c41cd8cd51448f.sql b/tests/ast_json_fixtures/shapes/82c41cd8cd51448f.sql new file mode 100644 index 000000000000..47af2f028f1f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82c41cd8cd51448f.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02125_function_2 diff --git a/tests/ast_json_fixtures/shapes/82de3c96df922892.json b/tests/ast_json_fixtures/shapes/82de3c96df922892.json new file mode 100644 index 000000000000..bb49c31205a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82de3c96df922892.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "6" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + } + ] + } + ], + "format": "BSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/82de3c96df922892.sql b/tests/ast_json_fixtures/shapes/82de3c96df922892.sql new file mode 100644 index 000000000000..592e51d96ccd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82de3c96df922892.sql @@ -0,0 +1 @@ +select tuple(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) as x format BSONEachRow diff --git a/tests/ast_json_fixtures/shapes/82e453e059ca05ac.json b/tests/ast_json_fixtures/shapes/82e453e059ca05ac.json new file mode 100644 index 000000000000..ceb98d883962 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82e453e059ca05ac.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "ShowIndexes", + "table": "tbl", + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "index_type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%minmax%" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/82e453e059ca05ac.sql b/tests/ast_json_fixtures/shapes/82e453e059ca05ac.sql new file mode 100644 index 000000000000..4a3135eede6e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82e453e059ca05ac.sql @@ -0,0 +1 @@ +SHOW INDEX FROM tbl WHERE index_type LIKE '%minmax%' diff --git a/tests/ast_json_fixtures/shapes/82e680bb1533ff4c.json b/tests/ast_json_fixtures/shapes/82e680bb1533ff4c.json new file mode 100644 index 000000000000..35ec305a6f00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82e680bb1533ff4c.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "key", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "alias": "value", + "value_type": "String", + "value": "b" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/82e680bb1533ff4c.sql b/tests/ast_json_fixtures/shapes/82e680bb1533ff4c.sql new file mode 100644 index 000000000000..98ece0b57018 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82e680bb1533ff4c.sql @@ -0,0 +1 @@ +SELECT 'a' AS key, 'b' as value GROUP BY key diff --git a/tests/ast_json_fixtures/shapes/82fe03ebb5129a9e.json b/tests/ast_json_fixtures/shapes/82fe03ebb5129a9e.json new file mode 100644 index 000000000000..9b83912decde --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82fe03ebb5129a9e.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "RawWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/82fe03ebb5129a9e.sql b/tests/ast_json_fixtures/shapes/82fe03ebb5129a9e.sql new file mode 100644 index 000000000000..78e1257c6f81 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/82fe03ebb5129a9e.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT RawWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/831776bfb7c76cdc.json b/tests/ast_json_fixtures/shapes/831776bfb7c76cdc.json new file mode 100644 index 000000000000..55445e31e65a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/831776bfb7c76cdc.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROW POLICY", + "short_name": "sqllt_policy", + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/831776bfb7c76cdc.sql b/tests/ast_json_fixtures/shapes/831776bfb7c76cdc.sql new file mode 100644 index 000000000000..a779b01fe0fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/831776bfb7c76cdc.sql @@ -0,0 +1 @@ +SHOW CREATE POLICY sqllt_policy FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/8325c02aab8a1ebc.json b/tests/ast_json_fixtures/shapes/8325c02aab8a1ebc.json new file mode 100644 index 000000000000..020d8eb3fa9c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8325c02aab8a1ebc.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "add_table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "if_not_exists": true, + "column_declaration": { + "type": "ColumnDeclaration", + "name": "value1", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8325c02aab8a1ebc.sql b/tests/ast_json_fixtures/shapes/8325c02aab8a1ebc.sql new file mode 100644 index 000000000000..4cf6bc9e8ec2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8325c02aab8a1ebc.sql @@ -0,0 +1 @@ +ALTER TABLE add_table ADD COLUMN IF NOT EXISTS value1 UInt64 diff --git a/tests/ast_json_fixtures/shapes/832828d33656fa89.json b/tests/ast_json_fixtures/shapes/832828d33656fa89.json new file mode 100644 index 000000000000..4c0e9e33a8d8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/832828d33656fa89.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["INSERT"], + "default_database": true, + "table": "foo", + "wildcard": true + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["user_03141"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/832828d33656fa89.sql b/tests/ast_json_fixtures/shapes/832828d33656fa89.sql new file mode 100644 index 000000000000..3376a8410ead --- /dev/null +++ b/tests/ast_json_fixtures/shapes/832828d33656fa89.sql @@ -0,0 +1 @@ +GRANT INSERT ON foo* TO user_03141 diff --git a/tests/ast_json_fixtures/shapes/83385a4a72df79c5.json b/tests/ast_json_fixtures/shapes/83385a4a72df79c5.json new file mode 100644 index 000000000000..f9dfa381cec3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83385a4a72df79c5.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["Вася Пупкин"] + } +} diff --git a/tests/ast_json_fixtures/shapes/83385a4a72df79c5.sql b/tests/ast_json_fixtures/shapes/83385a4a72df79c5.sql new file mode 100644 index 000000000000..dfd17ff35ba0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83385a4a72df79c5.sql @@ -0,0 +1 @@ +drop user if exists "Вася Пупкин" diff --git a/tests/ast_json_fixtures/shapes/835ed1c4cf399b72.json b/tests/ast_json_fixtures/shapes/835ed1c4cf399b72.json new file mode 100644 index 000000000000..ed8603f755cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/835ed1c4cf399b72.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p3_01295", + "database": "db", + "table": "table" + } + ] + }, + "is_restrictive": false, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/835ed1c4cf399b72.sql b/tests/ast_json_fixtures/shapes/835ed1c4cf399b72.sql new file mode 100644 index 000000000000..ca240688331e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/835ed1c4cf399b72.sql @@ -0,0 +1 @@ +CREATE ROW POLICY p3_01295 ON db.table USING 1 AS PERMISSIVE diff --git a/tests/ast_json_fixtures/shapes/83bd3ac1aaf63edc.json b/tests/ast_json_fixtures/shapes/83bd3ac1aaf63edc.json new file mode 100644 index 000000000000..068b1577b7b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83bd3ac1aaf63edc.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowIndexes", + "table": "tab.with.dots" + } +} diff --git a/tests/ast_json_fixtures/shapes/83bd3ac1aaf63edc.sql b/tests/ast_json_fixtures/shapes/83bd3ac1aaf63edc.sql new file mode 100644 index 000000000000..d7a4356dd749 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83bd3ac1aaf63edc.sql @@ -0,0 +1 @@ +SHOW INDEX FROM `tab.with.dots` diff --git a/tests/ast_json_fixtures/shapes/83bfb04ebf9955db.json b/tests/ast_json_fixtures/shapes/83bfb04ebf9955db.json new file mode 100644 index 000000000000..472e569e529d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83bfb04ebf9955db.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "03717_mv_table_all" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03717_mv_table_all" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/83bfb04ebf9955db.sql b/tests/ast_json_fixtures/shapes/83bfb04ebf9955db.sql new file mode 100644 index 000000000000..ecd0bada2742 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83bfb04ebf9955db.sql @@ -0,0 +1 @@ +select '03717_mv_table_all', sum(value) from 03717_mv_table_all order by all diff --git a/tests/ast_json_fixtures/shapes/83d55153ab16949c.json b/tests/ast_json_fixtures/shapes/83d55153ab16949c.json new file mode 100644 index 000000000000..af906eb7eecc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83d55153ab16949c.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_atomic", + "from_table": "dist", + "to_database": "test_01155_ordinary", + "to_table": "dist" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/83d55153ab16949c.sql b/tests/ast_json_fixtures/shapes/83d55153ab16949c.sql new file mode 100644 index 000000000000..faac3060e619 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83d55153ab16949c.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_atomic.dist TO test_01155_ordinary.dist diff --git a/tests/ast_json_fixtures/shapes/83d82c3e5f5fac6c.json b/tests/ast_json_fixtures/shapes/83d82c3e5f5fac6c.json new file mode 100644 index 000000000000..3bdda384b934 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83d82c3e5f5fac6c.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t1" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "APPLY_DELETED_MASK" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/83d82c3e5f5fac6c.sql b/tests/ast_json_fixtures/shapes/83d82c3e5f5fac6c.sql new file mode 100644 index 000000000000..389cef6006af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83d82c3e5f5fac6c.sql @@ -0,0 +1 @@ +ALTER TABLE t1 APPLY DELETED MASK diff --git a/tests/ast_json_fixtures/shapes/83f7e1dfe074888f.json b/tests/ast_json_fixtures/shapes/83f7e1dfe074888f.json new file mode 100644 index 000000000000..1f986634f79d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83f7e1dfe074888f.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "RIGHT", + "strictness": "ALL", + "using": [ + { + "type": "Identifier", + "name": "key1" + }, + { + "type": "Identifier", + "name": "key2" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tj" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key1" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/83f7e1dfe074888f.sql b/tests/ast_json_fixtures/shapes/83f7e1dfe074888f.sql new file mode 100644 index 000000000000..b2f922d29717 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/83f7e1dfe074888f.sql @@ -0,0 +1 @@ +SELECT a FROM t ALL RIGHT JOIN tj USING (key1, key2) ORDER BY key1 FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/840074a0ccef31d1.json b/tests/ast_json_fixtures/shapes/840074a0ccef31d1.json new file mode 100644 index 000000000000..88bdd66a8275 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/840074a0ccef31d1.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "alias": "x", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2015-01-02" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Hello" + } + ] + } + ] + } + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "identity", + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "identity", + "arguments": [ + { + "type": "Subquery", + "alias": "y", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/840074a0ccef31d1.sql b/tests/ast_json_fixtures/shapes/840074a0ccef31d1.sql new file mode 100644 index 000000000000..1fff5a323670 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/840074a0ccef31d1.sql @@ -0,0 +1 @@ +SELECT (SELECT toDate('2015-01-02'), 'Hello') AS x, x, identity((SELECT 1)), identity((SELECT 1) AS y) diff --git a/tests/ast_json_fixtures/shapes/842ce74505202e59.json b/tests/ast_json_fixtures/shapes/842ce74505202e59.json new file mode 100644 index 000000000000..11d289f9d2b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/842ce74505202e59.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_clone_as": true, + "table": { + "type": "Identifier", + "name": "clone_as_foo_file" + }, + "as_table": "foo_file" + } +} diff --git a/tests/ast_json_fixtures/shapes/842ce74505202e59.sql b/tests/ast_json_fixtures/shapes/842ce74505202e59.sql new file mode 100644 index 000000000000..40ad62ead16e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/842ce74505202e59.sql @@ -0,0 +1 @@ +CREATE TABLE clone_as_foo_file CLONE AS foo_file diff --git a/tests/ast_json_fixtures/shapes/843087641336d50b.json b/tests/ast_json_fixtures/shapes/843087641336d50b.json new file mode 100644 index 000000000000..22975f293512 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/843087641336d50b.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t3" + }, + "as_table": "v" + } +} diff --git a/tests/ast_json_fixtures/shapes/843087641336d50b.sql b/tests/ast_json_fixtures/shapes/843087641336d50b.sql new file mode 100644 index 000000000000..d570f216a53b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/843087641336d50b.sql @@ -0,0 +1 @@ +CREATE TABLE t3 AS v diff --git a/tests/ast_json_fixtures/shapes/84364a4c71478289.json b/tests/ast_json_fixtures/shapes/84364a4c71478289.json new file mode 100644 index 000000000000..01d271b0a85b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84364a4c71478289.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_COLUMN", + "column": { + "type": "Identifier", + "name": "s1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/84364a4c71478289.sql b/tests/ast_json_fixtures/shapes/84364a4c71478289.sql new file mode 100644 index 000000000000..b285dfd0ce36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84364a4c71478289.sql @@ -0,0 +1 @@ +alter table test materialize column s1 settings mutations_sync=1 diff --git a/tests/ast_json_fixtures/shapes/843812633e29bc17.json b/tests/ast_json_fixtures/shapes/843812633e29bc17.json new file mode 100644 index 000000000000..18402e27ec7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/843812633e29bc17.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Identifier", + "name": "changed" + }, + { + "type": "Identifier", + "name": "default" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "settings", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "force_index_by_date" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "force_index_by_date": true + } + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/843812633e29bc17.sql b/tests/ast_json_fixtures/shapes/843812633e29bc17.sql new file mode 100644 index 000000000000..4d05212bbe38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/843812633e29bc17.sql @@ -0,0 +1 @@ +SELECT name, value, changed, default FROM system.settings WHERE name = 'force_index_by_date' SETTINGS force_index_by_date FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/843e2aad8b905c76.json b/tests/ast_json_fixtures/shapes/843e2aad8b905c76.json new file mode 100644 index 000000000000..571337f413c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/843e2aad8b905c76.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "d55" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "SimpleAggregateFunction", + "arguments": [ + { + "type": "Identifier", + "name": "anyLast" + }, + { + "type": "DataType", + "name": "Date" + } + ] + }, + "default_value": { + "type": "Literal", + "value_type": "String", + "value": "75942d37-37c4-8ea0-4175-1a4e0cb18c3b" + }, + "injective": true + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "db", + "value": { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "t13" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 2 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "hashed", + "parameters": [ + { + "type": "pair", + "key": "shard_load_queue_backlog", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483648" + } + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/843e2aad8b905c76.sql b/tests/ast_json_fixtures/shapes/843e2aad8b905c76.sql new file mode 100644 index 000000000000..b67de5389f47 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/843e2aad8b905c76.sql @@ -0,0 +1,6 @@ +CREATE DICTIONARY `d55` (`c0` SimpleAggregateFunction(anyLast, Date) +DEFAULT '75942d37-37c4-8ea0-4175-1a4e0cb18c3b' INJECTIVE) +PRIMARY KEY (`c0`) +SOURCE(CLICKHOUSE(DB currentDatabase() TABLE 't13')) +LAYOUT(HASHED(SHARD_LOAD_QUEUE_BACKLOG 2147483648)) +LIFETIME(2) diff --git a/tests/ast_json_fixtures/shapes/84426eb565e4d283.json b/tests/ast_json_fixtures/shapes/84426eb565e4d283.json new file mode 100644 index 000000000000..c9c9fe4a79ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84426eb565e4d283.json @@ -0,0 +1,212 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "i" + } + ] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "i" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "d" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_partition_value" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "name": "bitTest", + "arguments": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_partition_value" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "10.25" + }, + { + "type": "Function", + "name": "bitTest", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-2147483647" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + } + ] + }, + { + "type": "Identifier", + "name": "_partition_id" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "_partition_id" + }, + "direction": "ASC", + "nulls_first": true + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/84426eb565e4d283.sql b/tests/ast_json_fixtures/shapes/84426eb565e4d283.sql new file mode 100644 index 000000000000..06807b1f3ad1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84426eb565e4d283.sql @@ -0,0 +1 @@ +SELECT min(i), max(i), count() FROM d WHERE (_partition_value.1) = 0 GROUP BY ignore(bitTest(ignore(NULL), 0), NULL, (_partition_value.1) = 7, '10.25', bitTest(NULL, 0), NULL, ignore(ignore(-2147483647, NULL)), 1024), _partition_id ORDER BY _partition_id ASC NULLS FIRST diff --git a/tests/ast_json_fixtures/shapes/846f0ef5a3d433a6.json b/tests/ast_json_fixtures/shapes/846f0ef5a3d433a6.json new file mode 100644 index 000000000000..10800e6cc427 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/846f0ef5a3d433a6.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "constF32" + } +} diff --git a/tests/ast_json_fixtures/shapes/846f0ef5a3d433a6.sql b/tests/ast_json_fixtures/shapes/846f0ef5a3d433a6.sql new file mode 100644 index 000000000000..817ff23ae3ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/846f0ef5a3d433a6.sql @@ -0,0 +1 @@ +DROP FUNCTION constF32 diff --git a/tests/ast_json_fixtures/shapes/847b310788a60e52.json b/tests/ast_json_fixtures/shapes/847b310788a60e52.json new file mode 100644 index 000000000000..f7890f062333 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/847b310788a60e52.json @@ -0,0 +1,113 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "s", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "alias": "key", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC", + "with_fill": true + } + ], + "interpolate": [ + { + "type": "InterpolateElement", + "column": "s", + "expr": { + "type": "Literal", + "value_type": "UInt64", + "value": "100500" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/847b310788a60e52.sql b/tests/ast_json_fixtures/shapes/847b310788a60e52.sql new file mode 100644 index 000000000000..0da778f56ed5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/847b310788a60e52.sql @@ -0,0 +1 @@ +select sum(number) as s from remote('127.0.0.{1,2}', numbers(10)) where (intDiv(number, 2) as key) != 1 group by key order by key with fill interpolate (s as 100500) diff --git a/tests/ast_json_fixtures/shapes/847efad38532d931.json b/tests/ast_json_fixtures/shapes/847efad38532d931.json new file mode 100644 index 000000000000..c7a4c65f82ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/847efad38532d931.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "test_func_1", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/847efad38532d931.sql b/tests/ast_json_fixtures/shapes/847efad38532d931.sql new file mode 100644 index 000000000000..28289d4f0391 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/847efad38532d931.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS test_func_1 diff --git a/tests/ast_json_fixtures/shapes/8481d38d0aa690ba.json b/tests/ast_json_fixtures/shapes/8481d38d0aa690ba.json new file mode 100644 index 000000000000..fa559bfd1722 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8481d38d0aa690ba.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "replace_access": true, + "access_rights": [ + { + "access_types": [] + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8481d38d0aa690ba.sql b/tests/ast_json_fixtures/shapes/8481d38d0aa690ba.sql new file mode 100644 index 000000000000..8379afeaa871 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8481d38d0aa690ba.sql @@ -0,0 +1 @@ +GRANT NONE ON *.* TO test_user_01999 WITH REPLACE OPTION diff --git a/tests/ast_json_fixtures/shapes/84a73d2cec9bfbc9.json b/tests/ast_json_fixtures/shapes/84a73d2cec9bfbc9.json new file mode 100644 index 000000000000..cd707c552fd9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84a73d2cec9bfbc9.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pk_func" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ui" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/84a73d2cec9bfbc9.sql b/tests/ast_json_fixtures/shapes/84a73d2cec9bfbc9.sql new file mode 100644 index 000000000000..e584bce96f97 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84a73d2cec9bfbc9.sql @@ -0,0 +1 @@ +SELECT 1, * FROM pk_func ORDER BY toDate(d) ASC, ui ASC LIMIT 3 diff --git a/tests/ast_json_fixtures/shapes/84be22c751c685ca.json b/tests/ast_json_fixtures/shapes/84be22c751c685ca.json new file mode 100644 index 000000000000..abde97ff48b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84be22c751c685ca.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "alias": "a", + "name": "number" + }, + { + "type": "Function", + "alias": "b", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 100000 + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/84be22c751c685ca.sql b/tests/ast_json_fixtures/shapes/84be22c751c685ca.sql new file mode 100644 index 000000000000..195ef107464c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84be22c751c685ca.sql @@ -0,0 +1 @@ +select number as a, number+1 as b from remote('127.0.0.{1,2}', numbers_mt(1e5)) group by grouping sets ((a), (b)) format Null diff --git a/tests/ast_json_fixtures/shapes/84d7ae204d0a9160.json b/tests/ast_json_fixtures/shapes/84d7ae204d0a9160.json new file mode 100644 index 000000000000..a42940303bc5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84d7ae204d0a9160.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "replace_table": true, + "table": { + "type": "Identifier", + "name": "t1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "n" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/84d7ae204d0a9160.sql b/tests/ast_json_fixtures/shapes/84d7ae204d0a9160.sql new file mode 100644 index 000000000000..cb8ec4952672 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84d7ae204d0a9160.sql @@ -0,0 +1 @@ +replace table t1 (n UInt64) engine=MergeTree order by n diff --git a/tests/ast_json_fixtures/shapes/84fb62e90c2dbe1e.json b/tests/ast_json_fixtures/shapes/84fb62e90c2dbe1e.json new file mode 100644 index 000000000000..0dd4ffa8d8ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84fb62e90c2dbe1e.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_move_partition_throttling" + }, + "settings": { + "type": "Settings", + "changes": { + "max_remote_write_network_bandwidth": "1600000" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "move_destination_type": "VOLUME", + "move_destination_name": "remote" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/84fb62e90c2dbe1e.sql b/tests/ast_json_fixtures/shapes/84fb62e90c2dbe1e.sql new file mode 100644 index 000000000000..f5167bc6c64b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/84fb62e90c2dbe1e.sql @@ -0,0 +1 @@ +ALTER TABLE test_move_partition_throttling MOVE PARTITION tuple() TO VOLUME 'remote' SETTINGS max_remote_write_network_bandwidth=1600000 diff --git a/tests/ast_json_fixtures/shapes/850919f5cedd604f.json b/tests/ast_json_fixtures/shapes/850919f5cedd604f.json new file mode 100644 index 000000000000..272086c97029 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/850919f5cedd604f.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "ttl" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_TTL", + "ttl": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Identifier", + "name": "a" + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/850919f5cedd604f.sql b/tests/ast_json_fixtures/shapes/850919f5cedd604f.sql new file mode 100644 index 000000000000..c3289f1a7499 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/850919f5cedd604f.sql @@ -0,0 +1 @@ +alter table ttl modify ttl a diff --git a/tests/ast_json_fixtures/shapes/853f3751a73e7fb1.json b/tests/ast_json_fixtures/shapes/853f3751a73e7fb1.json new file mode 100644 index 000000000000..a43d669755dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/853f3751a73e7fb1.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "CheckQuery", + "table": { + "type": "Identifier", + "name": "partition_all2" + }, + "partition": { + "type": "Partition_ID", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/853f3751a73e7fb1.sql b/tests/ast_json_fixtures/shapes/853f3751a73e7fb1.sql new file mode 100644 index 000000000000..f5f27239f502 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/853f3751a73e7fb1.sql @@ -0,0 +1 @@ +CHECK TABLE partition_all2 PARTITION ALL diff --git a/tests/ast_json_fixtures/shapes/8559f39fd538127a.json b/tests/ast_json_fixtures/shapes/8559f39fd538127a.json new file mode 100644 index 000000000000..71371110565a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8559f39fd538127a.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ], + "format": "JSONCompactEachRowWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/8559f39fd538127a.sql b/tests/ast_json_fixtures/shapes/8559f39fd538127a.sql new file mode 100644 index 000000000000..f31205fcd8fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8559f39fd538127a.sql @@ -0,0 +1 @@ +SELECT * FROM test_table FORMAT JSONCompactEachRowWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/8564c7369fa235b9.json b/tests/ast_json_fixtures/shapes/8564c7369fa235b9.json new file mode 100644 index 000000000000..3b2c954fe8b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8564c7369fa235b9.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_1603_rename_bug_atomic", + "from_table": "bar", + "to_database": "test_1603_rename_bug_atomic", + "to_table": "foo" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8564c7369fa235b9.sql b/tests/ast_json_fixtures/shapes/8564c7369fa235b9.sql new file mode 100644 index 000000000000..b4563800b876 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8564c7369fa235b9.sql @@ -0,0 +1 @@ +rename table test_1603_rename_bug_atomic.bar to test_1603_rename_bug_atomic.foo diff --git a/tests/ast_json_fixtures/shapes/857837aa561cf3ed.json b/tests/ast_json_fixtures/shapes/857837aa561cf3ed.json new file mode 100644 index 000000000000..54c88764f43b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/857837aa561cf3ed.json @@ -0,0 +1,493 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "ifNull", + "arguments": [ + { + "type": "Identifier", + "name": "fun_res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "alias": "fun_res", + "name": "windowFunnel", + "arguments": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "22" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "6" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "6" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "9" + } + ] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "9" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "91" + } + ] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "99" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "99" + } + ] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "74" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "74" + } + ] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "55" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "55" + } + ] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "13" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "13" + } + ] + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "69" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "String", + "value": "69" + } + ] + } + ] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "86400000" + }, + { + "type": "Literal", + "value_type": "String", + "value": "strict_increase" + }, + { + "type": "Literal", + "value_type": "String", + "value": "strict_once" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "fun_res" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_queries": "1", + "max_memory_usage": "800Mi" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/857837aa561cf3ed.sql b/tests/ast_json_fixtures/shapes/857837aa561cf3ed.sql new file mode 100644 index 000000000000..603f4790d6d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/857837aa561cf3ed.sql @@ -0,0 +1,16 @@ +SELECT + ifNull(fun_res, 0), + count(*) +FROM +( + + + SELECT + a, + windowFunnel(86400000, 'strict_increase', 'strict_once')((b = '10') OR (c = '10') OR (b = '22') OR (c = '3') OR (b = '6') OR (c = '5') OR (b = '6') OR (c = '9'), (b = '9') OR (c = '91'), (b = '99') OR (c = '99'), (b = '74') OR (c = '74'), (b = '55') OR (c = '55'), (b = '13') OR (c = '13'), (b = '69') OR (c = '69')) AS fun_res + FROM test + GROUP BY a +) +GROUP BY fun_res +FORMAT Null +SETTINGS log_queries = 1, max_memory_usage = '800Mi' diff --git a/tests/ast_json_fixtures/shapes/85a4cdf00f0d5a6e.json b/tests/ast_json_fixtures/shapes/85a4cdf00f0d5a6e.json new file mode 100644 index 000000000000..324cfe57cd07 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85a4cdf00f0d5a6e.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "64" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/85a4cdf00f0d5a6e.sql b/tests/ast_json_fixtures/shapes/85a4cdf00f0d5a6e.sql new file mode 100644 index 000000000000..92226433d0d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85a4cdf00f0d5a6e.sql @@ -0,0 +1 @@ +SELECT count() FROM test WHERE x = 10 SETTINGS max_rows_to_read = 64 diff --git a/tests/ast_json_fixtures/shapes/85b7fdb8d746173c.json b/tests/ast_json_fixtures/shapes/85b7fdb8d746173c.json new file mode 100644 index 000000000000..dbfb57f51d40 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85b7fdb8d746173c.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "db_hang", + "from_table": "test_mv", + "to_database": "db_hang_temp", + "to_table": "test_mv" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/85b7fdb8d746173c.sql b/tests/ast_json_fixtures/shapes/85b7fdb8d746173c.sql new file mode 100644 index 000000000000..70f09cd18ef6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85b7fdb8d746173c.sql @@ -0,0 +1 @@ +rename table db_hang.test_mv to db_hang_temp.test_mv diff --git a/tests/ast_json_fixtures/shapes/85b81062bc710dab.json b/tests/ast_json_fixtures/shapes/85b81062bc710dab.json new file mode 100644 index 000000000000..55457fbe9df6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85b81062bc710dab.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/85b81062bc710dab.sql b/tests/ast_json_fixtures/shapes/85b81062bc710dab.sql new file mode 100644 index 000000000000..c3cd3fc4700d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85b81062bc710dab.sql @@ -0,0 +1 @@ +select 1 settings enable_analyzer='1' diff --git a/tests/ast_json_fixtures/shapes/85bb3111fd089076.json b/tests/ast_json_fixtures/shapes/85bb3111fd089076.json new file mode 100644 index 000000000000..f783cbc4925f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85bb3111fd089076.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "t1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "c" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "INTERSECT ALL", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/85bb3111fd089076.sql b/tests/ast_json_fixtures/shapes/85bb3111fd089076.sql new file mode 100644 index 000000000000..204e3f22f784 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85bb3111fd089076.sql @@ -0,0 +1 @@ +create temporary table t1 engine=MergeTree() order by c as ( select 1 as c intersect (select 1 as c union all select 2 as c ) ) diff --git a/tests/ast_json_fixtures/shapes/85c3056a6449f9aa.json b/tests/ast_json_fixtures/shapes/85c3056a6449f9aa.json new file mode 100644 index 000000000000..14ec8c3f77cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85c3056a6449f9aa.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01292"] + }, + "grantees": { + "type": "RolesOrUsersSet", + "names": ["u1_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/85c3056a6449f9aa.sql b/tests/ast_json_fixtures/shapes/85c3056a6449f9aa.sql new file mode 100644 index 000000000000..6cf58c8f7056 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85c3056a6449f9aa.sql @@ -0,0 +1 @@ +GRANT r1_01292 TO u1_01292 diff --git a/tests/ast_json_fixtures/shapes/85ca91a8a38c09ad.json b/tests/ast_json_fixtures/shapes/85ca91a8a38c09ad.json new file mode 100644 index 000000000000..f8e6ea4a596f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85ca91a8a38c09ad.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "A_M" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^A1$" + } + ] + } + }, + "as_table": "A1" + } +} diff --git a/tests/ast_json_fixtures/shapes/85ca91a8a38c09ad.sql b/tests/ast_json_fixtures/shapes/85ca91a8a38c09ad.sql new file mode 100644 index 000000000000..51483f87d79d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85ca91a8a38c09ad.sql @@ -0,0 +1 @@ +CREATE TABLE A_M as A1 ENGINE = Merge(currentDatabase(), '^A1$') diff --git a/tests/ast_json_fixtures/shapes/85ccef424cf156e3.json b/tests/ast_json_fixtures/shapes/85ccef424cf156e3.json new file mode 100644 index 000000000000..1ea7d54214ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85ccef424cf156e3.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "alias": "a1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "alias": "a1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/85ccef424cf156e3.sql b/tests/ast_json_fixtures/shapes/85ccef424cf156e3.sql new file mode 100644 index 000000000000..9a98acb5f4fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85ccef424cf156e3.sql @@ -0,0 +1 @@ +SELECT ((SELECT 1) AS a1), NOT ((SELECT 1) AS a1) diff --git a/tests/ast_json_fixtures/shapes/85cf8f6ff9af10c9.json b/tests/ast_json_fixtures/shapes/85cf8f6ff9af10c9.json new file mode 100644 index 000000000000..a5ae6ad1ab9f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85cf8f6ff9af10c9.json @@ -0,0 +1,158 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "gr", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "having": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "gr" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_grouping_standard_compatibility": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/85cf8f6ff9af10c9.sql b/tests/ast_json_fixtures/shapes/85cf8f6ff9af10c9.sql new file mode 100644 index 000000000000..d579c62ba902 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85cf8f6ff9af10c9.sql @@ -0,0 +1,10 @@ +SELECT + number, + grouping(number, number % 2) + 3 as gr +FROM remote('127.0.0.{2,3}', numbers(10)) +GROUP BY + CUBE(number, number % 2) +HAVING grouping(number) != 0 +ORDER BY + number, gr +SETTINGS force_grouping_standard_compatibility=0 diff --git a/tests/ast_json_fixtures/shapes/85d262486612cc45.json b/tests/ast_json_fixtures/shapes/85d262486612cc45.json new file mode 100644 index 000000000000..22f96a5746df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85d262486612cc45.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "01721_file\/test\/data.TSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "TSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "id UInt32" + } + ] + }, + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/85d262486612cc45.sql b/tests/ast_json_fixtures/shapes/85d262486612cc45.sql new file mode 100644 index 000000000000..66bce28d751b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85d262486612cc45.sql @@ -0,0 +1 @@ +INSERT INTO TABLE FUNCTION file('01721_file/test/data.TSV', 'TSV', 'id UInt32') VALUES (1) diff --git a/tests/ast_json_fixtures/shapes/85e9a11f4354a51c.json b/tests/ast_json_fixtures/shapes/85e9a11f4354a51c.json new file mode 100644 index 000000000000..c94979356808 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85e9a11f4354a51c.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "if_exists": true, + "names": ["r1_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/85e9a11f4354a51c.sql b/tests/ast_json_fixtures/shapes/85e9a11f4354a51c.sql new file mode 100644 index 000000000000..8ec5be14a3ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85e9a11f4354a51c.sql @@ -0,0 +1 @@ +DROP ROLE IF EXISTS r1_01297 diff --git a/tests/ast_json_fixtures/shapes/85fca11aa9f3b4e8.json b/tests/ast_json_fixtures/shapes/85fca11aa9f3b4e8.json new file mode 100644 index 000000000000..f8c512b395d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85fca11aa9f3b4e8.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["test 01119"] + } +} diff --git a/tests/ast_json_fixtures/shapes/85fca11aa9f3b4e8.sql b/tests/ast_json_fixtures/shapes/85fca11aa9f3b4e8.sql new file mode 100644 index 000000000000..d43686469487 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85fca11aa9f3b4e8.sql @@ -0,0 +1 @@ +drop user if exists "test 01119" diff --git a/tests/ast_json_fixtures/shapes/85fec65b08f91fea.json b/tests/ast_json_fixtures/shapes/85fec65b08f91fea.json new file mode 100644 index 000000000000..c663bd5a00d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85fec65b08f91fea.json @@ -0,0 +1,109 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "v0", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c0", + "value_type": "UInt64", + "value": "1" + } + ], + "where": { + "type": "Function", + "name": "exists", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "v0.c0", + "name_parts": ["v0", "c0"] + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v0.c0", + "name_parts": ["v0", "c0"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "exact_rows_before_limit": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/85fec65b08f91fea.sql b/tests/ast_json_fixtures/shapes/85fec65b08f91fea.sql new file mode 100644 index 000000000000..94a30323dffe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/85fec65b08f91fea.sql @@ -0,0 +1 @@ +SELECT 1 FROM (SELECT 1 AS c0 WHERE EXISTS (SELECT 1) LIMIT 1) v0 GROUP BY v0.c0 HAVING v0.c0 = 1 SETTINGS exact_rows_before_limit = 1 diff --git a/tests/ast_json_fixtures/shapes/8603e9cbb502eca7.json b/tests/ast_json_fixtures/shapes/8603e9cbb502eca7.json new file mode 100644 index 000000000000..112ee4fcee92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8603e9cbb502eca7.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "loop", + "arguments": [ + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8603e9cbb502eca7.sql b/tests/ast_json_fixtures/shapes/8603e9cbb502eca7.sql new file mode 100644 index 000000000000..e660cbaf1f49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8603e9cbb502eca7.sql @@ -0,0 +1 @@ +SELECT * FROM loop (numbers(3)) LIMIT 10 settings max_block_size = 1 diff --git a/tests/ast_json_fixtures/shapes/86502f4ab9e853b9.json b/tests/ast_json_fixtures/shapes/86502f4ab9e853b9.json new file mode 100644 index 000000000000..4fd5768b2a75 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86502f4ab9e853b9.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "table": { + "type": "Identifier", + "name": "t" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/86502f4ab9e853b9.sql b/tests/ast_json_fixtures/shapes/86502f4ab9e853b9.sql new file mode 100644 index 000000000000..e5105001cb17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86502f4ab9e853b9.sql @@ -0,0 +1 @@ +ATTACH TABLE t diff --git a/tests/ast_json_fixtures/shapes/86532dcaf048bc5f.json b/tests/ast_json_fixtures/shapes/86532dcaf048bc5f.json new file mode 100644 index 000000000000..db443217333c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86532dcaf048bc5f.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "k", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "110000" + }, + "settings": { + "type": "Settings", + "changes": { + "max_result_rows": "0" + } + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_result_rows": "100000", + "result_overflow_mode": "break" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/86532dcaf048bc5f.sql b/tests/ast_json_fixtures/shapes/86532dcaf048bc5f.sql new file mode 100644 index 000000000000..9160492f151a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86532dcaf048bc5f.sql @@ -0,0 +1 @@ +SELECT number AS k FROM (SELECT number FROM system.numbers LIMIT 110000 SETTINGS max_result_rows = 0) GROUP BY k ORDER BY k LIMIT 10 SETTINGS max_result_rows = 100000, result_overflow_mode = 'break' diff --git a/tests/ast_json_fixtures/shapes/86a4f46d59ec5c68.json b/tests/ast_json_fixtures/shapes/86a4f46d59ec5c68.json new file mode 100644 index 000000000000..51cc99d364fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86a4f46d59ec5c68.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "KillQueryQuery", + "kill_type": "MUTATION", + "sync": true, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "command" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%throwIf%" + } + ] + } + ] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/86a4f46d59ec5c68.sql b/tests/ast_json_fixtures/shapes/86a4f46d59ec5c68.sql new file mode 100644 index 000000000000..96f671fd12f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86a4f46d59ec5c68.sql @@ -0,0 +1 @@ +KILL MUTATION WHERE database = currentDatabase() AND command LIKE '%throwIf%' SYNC FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/86cb6b0367799cf2.json b/tests/ast_json_fixtures/shapes/86cb6b0367799cf2.json new file mode 100644 index 000000000000..cb8814f255d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86cb6b0367799cf2.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u_03174_multiple_auth_show_create" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + { + "type": "AuthenticationData", + "auth_type": "PLAINTEXT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2" + } + ] + }, + { + "type": "AuthenticationData", + "auth_type": "BCRYPT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "3" + } + ] + }, + { + "type": "AuthenticationData", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "4" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/86cb6b0367799cf2.sql b/tests/ast_json_fixtures/shapes/86cb6b0367799cf2.sql new file mode 100644 index 000000000000..aecdf8433dd5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86cb6b0367799cf2.sql @@ -0,0 +1 @@ +CREATE USER u_03174_multiple_auth_show_create IDENTIFIED by '1', plaintext_password by '2', bcrypt_password by '3', by '4' diff --git a/tests/ast_json_fixtures/shapes/86e1ced1582609d2.json b/tests/ast_json_fixtures/shapes/86e1ced1582609d2.json new file mode 100644 index 000000000000..d340d462a921 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86e1ced1582609d2.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/86e1ced1582609d2.sql b/tests/ast_json_fixtures/shapes/86e1ced1582609d2.sql new file mode 100644 index 000000000000..d0f96c4371d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86e1ced1582609d2.sql @@ -0,0 +1 @@ +desc (select 1) diff --git a/tests/ast_json_fixtures/shapes/86e303b0f19e47d5.json b/tests/ast_json_fixtures/shapes/86e303b0f19e47d5.json new file mode 100644 index 000000000000..0566fcab20ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86e303b0f19e47d5.json @@ -0,0 +1,188 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "2147483648" + }, + { + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": -0 + }, + { + "value_type": "Float64", + "value": 1.1754943508222875e-38 + }, + { + "value_type": "UInt64", + "value": "2147483646" + }, + { + "value_type": "String", + "value": "-9223372036854775808" + }, + { + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "toInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.0001 + } + ] + } + ], + "group_by": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + }, + { + "type": "Function", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1.1754943508222875e-38 + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Float64", + "value": -0 + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "65535" + }, + { + "value_type": "String", + "value": "-92233720368547758.07" + } + ] + }, + { + "value_type": "Float64", + "value": 0.9999 + } + ] + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 1 + }, + { + "value_type": "Float64", + "value": 3.4028234663852886e38 + }, + { + "value_type": "String", + "value": "1" + }, + { + "value_type": "Float64", + "value": 0.5 + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0.1" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/86e303b0f19e47d5.sql b/tests/ast_json_fixtures/shapes/86e303b0f19e47d5.sql new file mode 100644 index 000000000000..038b77e0c8a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/86e303b0f19e47d5.sql @@ -0,0 +1 @@ +SELECT tuple((2147483648, (-0., 1.1754943508222875e-38, 2147483646, '-9223372036854775808', NULL))), toInt128(0.0001) GROUP BY ((256, toInt64(1.1754943508222875e-38), NULL), NULL, -0., ((65535, '-92233720368547758.07'), 0.9999), tuple(((1., 3.4028234663852886e38, '1', 0.5), NULL, tuple('0.1')))) WITH CUBE WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/870f4d50f49e3e55.json b/tests/ast_json_fixtures/shapes/870f4d50f49e3e55.json new file mode 100644 index 000000000000..a3072852486e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/870f4d50f49e3e55.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "ParallelWithQuery", + "children": [ + { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "table1" + }, + "if_exists": true + }, + { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "table2" + }, + "if_exists": true + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/870f4d50f49e3e55.sql b/tests/ast_json_fixtures/shapes/870f4d50f49e3e55.sql new file mode 100644 index 000000000000..0837e7371e09 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/870f4d50f49e3e55.sql @@ -0,0 +1,3 @@ +DROP TABLE IF EXISTS table1 +PARALLEL WITH +DROP TABLE IF EXISTS table2 diff --git a/tests/ast_json_fixtures/shapes/87266df3e23000af.json b/tests/ast_json_fixtures/shapes/87266df3e23000af.json new file mode 100644 index 000000000000..9c4429573dcc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87266df3e23000af.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "cnt", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cnt" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/87266df3e23000af.sql b/tests/ast_json_fixtures/shapes/87266df3e23000af.sql new file mode 100644 index 000000000000..9c395d187cbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87266df3e23000af.sql @@ -0,0 +1 @@ +select count() cnt, * from dist_01247 group by number having cnt == 2 diff --git a/tests/ast_json_fixtures/shapes/8728942732e3b9b2.json b/tests/ast_json_fixtures/shapes/8728942732e3b9b2.json new file mode 100644 index 000000000000..36d3fb6487be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8728942732e3b9b2.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "number" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "set" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8728942732e3b9b2.sql b/tests/ast_json_fixtures/shapes/8728942732e3b9b2.sql new file mode 100644 index 000000000000..0608414fbc3e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8728942732e3b9b2.sql @@ -0,0 +1 @@ +SELECT number FROM number WHERE number IN set LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/873e4b5c3c3f71ae.json b/tests/ast_json_fixtures/shapes/873e4b5c3c3f71ae.json new file mode 100644 index 000000000000..951eae483de3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/873e4b5c3c3f71ae.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "first" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "inn" + }, + { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "received" + } + ] + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "inn" + }, + { + "type": "Identifier", + "name": "sessionId" + } + ] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "received", + "name": "now", + "arguments": [] + }, + { + "type": "Literal", + "alias": "inn", + "value_type": "String", + "value": "123456789" + }, + { + "type": "Literal", + "alias": "sessionId", + "value_type": "String", + "value": "42" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/873e4b5c3c3f71ae.sql b/tests/ast_json_fixtures/shapes/873e4b5c3c3f71ae.sql new file mode 100644 index 000000000000..7aa9a659fe59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/873e4b5c3c3f71ae.sql @@ -0,0 +1,2 @@ +CREATE TABLE IF NOT EXISTS first engine = MergeTree PARTITION BY (inn, toYYYYMM(received)) ORDER BY (inn, sessionId) +AS SELECT now() AS received, '123456789' AS inn, '42' AS sessionId diff --git a/tests/ast_json_fixtures/shapes/875c8b6fdc9369a8.json b/tests/ast_json_fixtures/shapes/875c8b6fdc9369a8.json new file mode 100644 index 000000000000..b12bb6810f62 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/875c8b6fdc9369a8.json @@ -0,0 +1,153 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Literal", + "alias": "constant", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "user_id" + }, + { + "type": "Identifier", + "name": "job_id" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "metric" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "my_first_table" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "constant" + }, + { + "type": "Identifier", + "name": "user_id" + }, + { + "type": "Identifier", + "name": "job_id" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "constant" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "user_id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "job_id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "constant" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "user_id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "job_id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/875c8b6fdc9369a8.sql b/tests/ast_json_fixtures/shapes/875c8b6fdc9369a8.sql new file mode 100644 index 000000000000..fe371445b9ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/875c8b6fdc9369a8.sql @@ -0,0 +1,4 @@ +SELECT 1 AS constant, user_id, job_id, sum(metric) +FROM my_first_table +GROUP BY constant, user_id, job_id WITH ROLLUP +ORDER BY constant = 0, user_id = 0, job_id = 0, constant, user_id, job_id diff --git a/tests/ast_json_fixtures/shapes/878aec2323019141.json b/tests/ast_json_fixtures/shapes/878aec2323019141.json new file mode 100644 index 000000000000..3b0b7509ff09 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/878aec2323019141.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "rename_table_multiple" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "column": { + "type": "Identifier", + "name": "value1" + }, + "rename_to": { + "type": "Identifier", + "name": "value1_string" + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "value1_string", + "data_type": { + "type": "DataType", + "name": "String" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/878aec2323019141.sql b/tests/ast_json_fixtures/shapes/878aec2323019141.sql new file mode 100644 index 000000000000..f66c85af689e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/878aec2323019141.sql @@ -0,0 +1 @@ +ALTER TABLE rename_table_multiple RENAME COLUMN value1 TO value1_string, MODIFY COLUMN value1_string String diff --git a/tests/ast_json_fixtures/shapes/878d71d8ee501b1f.json b/tests/ast_json_fixtures/shapes/878d71d8ee501b1f.json new file mode 100644 index 000000000000..eb5bb29a76ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/878d71d8ee501b1f.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s4_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "parent_profile": "readonly" + }, + { + "type": "SettingsProfileElement", + "parent_profile": "readonly" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/878d71d8ee501b1f.sql b/tests/ast_json_fixtures/shapes/878d71d8ee501b1f.sql new file mode 100644 index 000000000000..26ccc8b64fe4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/878d71d8ee501b1f.sql @@ -0,0 +1 @@ +CREATE PROFILE s4_01294 SETTINGS profile readonly, readonly diff --git a/tests/ast_json_fixtures/shapes/87902d3729fd3c51.json b/tests/ast_json_fixtures/shapes/87902d3729fd3c51.json new file mode 100644 index 000000000000..9f1ef1343932 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87902d3729fd3c51.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/87902d3729fd3c51.sql b/tests/ast_json_fixtures/shapes/87902d3729fd3c51.sql new file mode 100644 index 000000000000..a3e0d2c6bb2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87902d3729fd3c51.sql @@ -0,0 +1 @@ +SELECT x FROM t ORDER BY x diff --git a/tests/ast_json_fixtures/shapes/8791a3cce9d5637f.json b/tests/ast_json_fixtures/shapes/8791a3cce9d5637f.json new file mode 100644 index 000000000000..46e6351e591a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8791a3cce9d5637f.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "untuple", + "arguments": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "col1.n", + "name_parts": ["col1", "n"] + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "nested" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8791a3cce9d5637f.sql b/tests/ast_json_fixtures/shapes/8791a3cce9d5637f.sql new file mode 100644 index 000000000000..6bc2987805b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8791a3cce9d5637f.sql @@ -0,0 +1 @@ +SELECT untuple(arrayJoin(arrayJoin(col1.n))) FROM nested ORDER BY id LIMIT 10 OFFSET 10 diff --git a/tests/ast_json_fixtures/shapes/87986460111f9b99.json b/tests/ast_json_fixtures/shapes/87986460111f9b99.json new file mode 100644 index 000000000000..a60754c84565 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87986460111f9b99.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q1_01297", "q2_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/87986460111f9b99.sql b/tests/ast_json_fixtures/shapes/87986460111f9b99.sql new file mode 100644 index 000000000000..1a6ed81ae4ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87986460111f9b99.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q1_01297, q2_01297 diff --git a/tests/ast_json_fixtures/shapes/87a14569f3989617.json b/tests/ast_json_fixtures/shapes/87a14569f3989617.json new file mode 100644 index 000000000000..ea70c66d4a3d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87a14569f3989617.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distributed_01099_b" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "local_01099_b" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "local_01099_b" + } +} diff --git a/tests/ast_json_fixtures/shapes/87a14569f3989617.sql b/tests/ast_json_fixtures/shapes/87a14569f3989617.sql new file mode 100644 index 000000000000..2c08d4e0f07c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87a14569f3989617.sql @@ -0,0 +1 @@ +CREATE TABLE distributed_01099_b AS local_01099_b ENGINE = Distributed('test_shard_localhost', currentDatabase(), local_01099_b, rand()) diff --git a/tests/ast_json_fixtures/shapes/87adf1bcae93d0c1.json b/tests/ast_json_fixtures/shapes/87adf1bcae93d0c1.json new file mode 100644 index 000000000000..1a625b8e33c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87adf1bcae93d0c1.json @@ -0,0 +1,392 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "byte", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reinterpretAsUInt8", + "arguments": [ + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Function", + "name": "randomString", + "arguments": [ + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Function", + "name": "randomString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048577" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reinterpretAsUInt8", + "arguments": [ + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Function", + "name": "randomString", + "arguments": [ + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65537" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "255" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Function", + "name": "randomString", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "257" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1025" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reinterpretAsUInt8", + "arguments": [ + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Function", + "name": "randomString", + "arguments": [ + { + "type": "Function", + "name": "randomString", + "arguments": [ + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Function", + "name": "randomString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "255" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Function", + "name": "randomString", + "arguments": [ + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Function", + "name": "randomString", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048577" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "byte" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "byte" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/87adf1bcae93d0c1.sql b/tests/ast_json_fixtures/shapes/87adf1bcae93d0c1.sql new file mode 100644 index 000000000000..61308887c00d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87adf1bcae93d0c1.sql @@ -0,0 +1,9 @@ +SELECT + arrayJoin(arrayMap(x -> reinterpretAsUInt8(substring(randomString(range(randomString(1048577), NULL), arrayJoin(arrayMap(x -> reinterpretAsUInt8(substring(randomString(range(NULL), 65537), 255)), range(1))), substring(randomString(NULL), x + 7), '257'), 1025)), range(7))) AS byte, + count() AS c + FROM numbers(10) + GROUP BY + arrayMap(x -> reinterpretAsUInt8(substring(randomString(randomString(range(randomString(255), NULL)), NULL), NULL)), range(3)), + randomString(range(randomString(1048577), NULL), NULL), + byte + ORDER BY byte ASC diff --git a/tests/ast_json_fixtures/shapes/87b6315b5b7768ff.json b/tests/ast_json_fixtures/shapes/87b6315b5b7768ff.json new file mode 100644 index 000000000000..9532b524de3b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87b6315b5b7768ff.json @@ -0,0 +1,223 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Function", + "name": "greatest", + "arguments": [ + { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test1_00395" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "col1" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "27" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + "direction": "ASC", + "nulls_first": false + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/87b6315b5b7768ff.sql b/tests/ast_json_fixtures/shapes/87b6315b5b7768ff.sql new file mode 100644 index 000000000000..3807549bcc28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87b6315b5b7768ff.sql @@ -0,0 +1 @@ +SELECT multiIf(1, 2, NULL, 3, 4), count(greatest(multiIf(1, 2, NULL, toUInt256(3), 4), multiIf(1, 2, NULL, 3, 4))) FROM test1_00395 GROUP BY col1 WITH CUBE WITH TOTALS ORDER BY multiIf(27, 1, multiIf(materialize(1), toLowCardinality(2), 3, 1, 4), NULL, 4) ASC NULLS LAST diff --git a/tests/ast_json_fixtures/shapes/87bcdf5ff570f31c.json b/tests/ast_json_fixtures/shapes/87bcdf5ff570f31c.json new file mode 100644 index 000000000000..e26de0005118 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87bcdf5ff570f31c.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "u", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_00184" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "u" + }, + "direction": "DESC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "distributed_group_by_no_merge": "2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/87bcdf5ff570f31c.sql b/tests/ast_json_fixtures/shapes/87bcdf5ff570f31c.sql new file mode 100644 index 000000000000..e64f6229f931 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87bcdf5ff570f31c.sql @@ -0,0 +1 @@ +SELECT uniq(number) u FROM remote('127.0.0.{2,3}', currentDatabase(), data_00184) GROUP BY number ORDER BY u DESC SETTINGS distributed_group_by_no_merge=2 diff --git a/tests/ast_json_fixtures/shapes/87c48f6a8b879291.json b/tests/ast_json_fixtures/shapes/87c48f6a8b879291.json new file mode 100644 index 000000000000..315510ea4912 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87c48f6a8b879291.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "search_engine", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "SearchEngineID" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "URL" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "SearchEngineID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "search_engine" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/87c48f6a8b879291.sql b/tests/ast_json_fixtures/shapes/87c48f6a8b879291.sql new file mode 100644 index 000000000000..faa222c328df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87c48f6a8b879291.sql @@ -0,0 +1 @@ +SELECT arrayJoin([SearchEngineID]) AS search_engine, URL FROM test.hits WHERE SearchEngineID != 0 AND search_engine != 0 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/87d1b69339add10e.json b/tests/ast_json_fixtures/shapes/87d1b69339add10e.json new file mode 100644 index 000000000000..dbcdff89c559 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87d1b69339add10e.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "test1", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "with_test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/87d1b69339add10e.sql b/tests/ast_json_fixtures/shapes/87d1b69339add10e.sql new file mode 100644 index 000000000000..1a4525623ec2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87d1b69339add10e.sql @@ -0,0 +1,2 @@ +WITH test1 AS (SELECT n FROM with_test order by n limit 100) +SELECT max(n) FROM test1 where n=42 diff --git a/tests/ast_json_fixtures/shapes/87d2fb98e782bcbf.json b/tests/ast_json_fixtures/shapes/87d2fb98e782bcbf.json new file mode 100644 index 000000000000..36e860e9f10a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87d2fb98e782bcbf.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/87d2fb98e782bcbf.sql b/tests/ast_json_fixtures/shapes/87d2fb98e782bcbf.sql new file mode 100644 index 000000000000..da4dc9d30cd0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87d2fb98e782bcbf.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number limit 1 offset 1 diff --git a/tests/ast_json_fixtures/shapes/87e347dd45d14b71.json b/tests/ast_json_fixtures/shapes/87e347dd45d14b71.json new file mode 100644 index 000000000000..ce984c6c2505 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87e347dd45d14b71.json @@ -0,0 +1,138 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "EXCEPT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "v" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "k" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + }, + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "v" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "k" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_parallel_replicas": "0" + } + } + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/87e347dd45d14b71.sql b/tests/ast_json_fixtures/shapes/87e347dd45d14b71.sql new file mode 100644 index 000000000000..273da7d92002 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87e347dd45d14b71.sql @@ -0,0 +1,3 @@ +(select * from v join t1 using k order by all) +except +(select * from v join t1 using k order by all settings enable_parallel_replicas=0) diff --git a/tests/ast_json_fixtures/shapes/87fed4cd54faf0f3.json b/tests/ast_json_fixtures/shapes/87fed4cd54faf0f3.json new file mode 100644 index 000000000000..6ac412cdf61c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87fed4cd54faf0f3.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["sqllt_settings_profile"], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/87fed4cd54faf0f3.sql b/tests/ast_json_fixtures/shapes/87fed4cd54faf0f3.sql new file mode 100644 index 000000000000..6908cdf0424b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/87fed4cd54faf0f3.sql @@ -0,0 +1 @@ +SHOW CREATE SETTINGS PROFILE sqllt_settings_profile FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/8801d8576312bc04.json b/tests/ast_json_fixtures/shapes/8801d8576312bc04.json new file mode 100644 index 000000000000..d404cbb3492d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8801d8576312bc04.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "str", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "str" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8801d8576312bc04.sql b/tests/ast_json_fixtures/shapes/8801d8576312bc04.sql new file mode 100644 index 000000000000..a5d68502f5b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8801d8576312bc04.sql @@ -0,0 +1,7 @@ +WITH + toString(number) as str +SELECT + *, + count() OVER () AS c +FROM numbers(10) +ORDER BY str diff --git a/tests/ast_json_fixtures/shapes/8806db136fead644.json b/tests/ast_json_fixtures/shapes/8806db136fead644.json new file mode 100644 index 000000000000..24601a8a9207 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8806db136fead644.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s6_01294"], + "to_roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["u1_01294", "r1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8806db136fead644.sql b/tests/ast_json_fixtures/shapes/8806db136fead644.sql new file mode 100644 index 000000000000..8a7e7d03f0e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8806db136fead644.sql @@ -0,0 +1 @@ +CREATE PROFILE s6_01294 TO ALL EXCEPT u1_01294, r1_01294 diff --git a/tests/ast_json_fixtures/shapes/8807786a67049356.json b/tests/ast_json_fixtures/shapes/8807786a67049356.json new file mode 100644 index 000000000000..8896e437822a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8807786a67049356.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8807786a67049356.sql b/tests/ast_json_fixtures/shapes/8807786a67049356.sql new file mode 100644 index 000000000000..19ae8e5b4503 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8807786a67049356.sql @@ -0,0 +1 @@ +SELECT number % 3 + 1 AS n, min(n), max(n) FROM numbers(100) GROUP BY n WITH CUBE diff --git a/tests/ast_json_fixtures/shapes/8834c1f51cdb711b.json b/tests/ast_json_fixtures/shapes/8834c1f51cdb711b.json new file mode 100644 index 000000000000..ecd9c4d0fe5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8834c1f51cdb711b.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "alias_bug_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "alias_bug" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "alias_bug" + } +} diff --git a/tests/ast_json_fixtures/shapes/8834c1f51cdb711b.sql b/tests/ast_json_fixtures/shapes/8834c1f51cdb711b.sql new file mode 100644 index 000000000000..d5a63405b7a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8834c1f51cdb711b.sql @@ -0,0 +1,3 @@ +CREATE TABLE alias_bug_dist +AS alias_bug +ENGINE = Distributed('test_shard_localhost', currentDatabase(), 'alias_bug', rand()) diff --git a/tests/ast_json_fixtures/shapes/8845507cddb2f184.json b/tests/ast_json_fixtures/shapes/8845507cddb2f184.json new file mode 100644 index 000000000000..0170483e354e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8845507cddb2f184.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "tp" + }, + "deduplicate": true + } +} diff --git a/tests/ast_json_fixtures/shapes/8845507cddb2f184.sql b/tests/ast_json_fixtures/shapes/8845507cddb2f184.sql new file mode 100644 index 000000000000..d1afc6f232ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8845507cddb2f184.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE tp DEDUPLICATE diff --git a/tests/ast_json_fixtures/shapes/885eb706cded10a0.json b/tests/ast_json_fixtures/shapes/885eb706cded10a0.json new file mode 100644 index 000000000000..b533f146a7a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/885eb706cded10a0.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toDateTime64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.1" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "prefer_localhost_replica": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/885eb706cded10a0.sql b/tests/ast_json_fixtures/shapes/885eb706cded10a0.sql new file mode 100644 index 000000000000..e640adda194b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/885eb706cded10a0.sql @@ -0,0 +1 @@ +select *, (select toDateTime64(0, 3)) from remote('127.0.0.1', system.one) settings prefer_localhost_replica=0 diff --git a/tests/ast_json_fixtures/shapes/88664a6e7e375a94.json b/tests/ast_json_fixtures/shapes/88664a6e7e375a94.json new file mode 100644 index 000000000000..d5ed11135e37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/88664a6e7e375a94.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "json.^`b`", + "name_parts": ["json", "^`b`"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/88664a6e7e375a94.sql b/tests/ast_json_fixtures/shapes/88664a6e7e375a94.sql new file mode 100644 index 000000000000..08ce6ca8a760 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/88664a6e7e375a94.sql @@ -0,0 +1 @@ +select json.^b from test order by id format Null diff --git a/tests/ast_json_fixtures/shapes/8867af1a8910ec00.json b/tests/ast_json_fixtures/shapes/8867af1a8910ec00.json new file mode 100644 index 000000000000..28d5b89b3bdd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8867af1a8910ec00.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8867af1a8910ec00.sql b/tests/ast_json_fixtures/shapes/8867af1a8910ec00.sql new file mode 100644 index 000000000000..7a95a4a65d2b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8867af1a8910ec00.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) LIMIT a + b diff --git a/tests/ast_json_fixtures/shapes/887391b2b60a14fa.json b/tests/ast_json_fixtures/shapes/887391b2b60a14fa.json new file mode 100644 index 000000000000..ba5f66f7abff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/887391b2b60a14fa.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q8_01297"], + "limits": [ + { + "duration_sec": "15778476", + "max": { + "QUERIES": "100", + "ERRORS": "11" + } + }, + { + "duration_sec": "5259492", + "max": { + "RESULT_ROWS": "1002" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/887391b2b60a14fa.sql b/tests/ast_json_fixtures/shapes/887391b2b60a14fa.sql new file mode 100644 index 000000000000..606f32a0a11b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/887391b2b60a14fa.sql @@ -0,0 +1 @@ +CREATE QUOTA q8_01297 FOR 0.5 year ERRORS MAX 11, QUERIES MAX 100, FOR 2 MONTH RESULT ROWS MAX 1002 diff --git a/tests/ast_json_fixtures/shapes/88757ae167fc60c1.json b/tests/ast_json_fixtures/shapes/88757ae167fc60c1.json new file mode 100644 index 000000000000..c22a0eebd50c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/88757ae167fc60c1.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Identifier", + "name": "new_part_name" + }, + { + "type": "Function", + "alias": "has_postpones", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "num_postponed" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Identifier", + "name": "postpone_reason" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "replication_queue", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "execute\\_on\\_single\\_replica\\_r%" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "table" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/88757ae167fc60c1.sql b/tests/ast_json_fixtures/shapes/88757ae167fc60c1.sql new file mode 100644 index 000000000000..a8cde137eeda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/88757ae167fc60c1.sql @@ -0,0 +1,11 @@ +SELECT + table, + type, + new_part_name, + num_postponed > 0 AS has_postpones, + postpone_reason +FROM system.replication_queue +WHERE table LIKE 'execute\\_on\\_single\\_replica\\_r%' +AND database = currentDatabase() +ORDER BY table +FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/8875ae1688577400.json b/tests/ast_json_fixtures/shapes/8875ae1688577400.json new file mode 100644 index 000000000000..ffa6b6bf2d28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8875ae1688577400.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_vertical_json" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/8875ae1688577400.sql b/tests/ast_json_fixtures/shapes/8875ae1688577400.sql new file mode 100644 index 000000000000..401cdb015c15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8875ae1688577400.sql @@ -0,0 +1 @@ +SELECT * FROM test_vertical_json ORDER BY id FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/887a4371570bdd08.json b/tests/ast_json_fixtures/shapes/887a4371570bdd08.json new file mode 100644 index 000000000000..0b4006aec190 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/887a4371570bdd08.json @@ -0,0 +1,122 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_having" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_optimize_predicate_expression": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/887a4371570bdd08.sql b/tests/ast_json_fixtures/shapes/887a4371570bdd08.sql new file mode 100644 index 000000000000..ad664bf43985 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/887a4371570bdd08.sql @@ -0,0 +1,3 @@ +SELECT sum(c0 = 0), min(c0 + 1), sum(c0 + 2) FROM t_having +GROUP BY c0 HAVING c0 = 0 +SETTINGS enable_optimize_predicate_expression=0 diff --git a/tests/ast_json_fixtures/shapes/889bb8a45ed141ca.json b/tests/ast_json_fixtures/shapes/889bb8a45ed141ca.json new file mode 100644 index 000000000000..f744d3e700b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/889bb8a45ed141ca.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t2_distr" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards_localhost" + }, + { + "type": "Identifier", + "name": "test_01103" + }, + { + "type": "Identifier", + "name": "t2_shard" + }, + { + "type": "Identifier", + "name": "id" + } + ] + } + }, + "as_table": "t2_shard" + } +} diff --git a/tests/ast_json_fixtures/shapes/889bb8a45ed141ca.sql b/tests/ast_json_fixtures/shapes/889bb8a45ed141ca.sql new file mode 100644 index 000000000000..4d1609d475bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/889bb8a45ed141ca.sql @@ -0,0 +1 @@ +create table t2_distr as t2_shard engine Distributed(test_cluster_two_shards_localhost, test_01103, t2_shard, id) diff --git a/tests/ast_json_fixtures/shapes/88b8665d835250ad.json b/tests/ast_json_fixtures/shapes/88b8665d835250ad.json new file mode 100644 index 000000000000..79ce2f5125cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/88b8665d835250ad.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q12_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/88b8665d835250ad.sql b/tests/ast_json_fixtures/shapes/88b8665d835250ad.sql new file mode 100644 index 000000000000..599db593beda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/88b8665d835250ad.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q12_01297 diff --git a/tests/ast_json_fixtures/shapes/88d6e5a228ac0459.json b/tests/ast_json_fixtures/shapes/88d6e5a228ac0459.json new file mode 100644 index 000000000000..7829a835645e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/88d6e5a228ac0459.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Identifier", + "name": "_table" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "d1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "d1" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "_table" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/88d6e5a228ac0459.sql b/tests/ast_json_fixtures/shapes/88d6e5a228ac0459.sql new file mode 100644 index 000000000000..792f2676eb97 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/88d6e5a228ac0459.sql @@ -0,0 +1 @@ +SELECT count(_table) FROM d1 WHERE _table = 'd1' GROUP BY _table diff --git a/tests/ast_json_fixtures/shapes/8913dda08c818574.json b/tests/ast_json_fixtures/shapes/8913dda08c818574.json new file mode 100644 index 000000000000..b58562b26eaf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8913dda08c818574.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "TransactionControl", + "action": "BEGIN" + } +} diff --git a/tests/ast_json_fixtures/shapes/8913dda08c818574.sql b/tests/ast_json_fixtures/shapes/8913dda08c818574.sql new file mode 100644 index 000000000000..8ccb6cda374e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8913dda08c818574.sql @@ -0,0 +1 @@ +BEGIN TRANSACTION diff --git a/tests/ast_json_fixtures/shapes/8919bd4eb31ad57c.json b/tests/ast_json_fixtures/shapes/8919bd4eb31ad57c.json new file mode 100644 index 000000000000..7b904035c846 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8919bd4eb31ad57c.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "STOP CLEANUP", + "table": { + "type": "Identifier", + "name": "rmt" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8919bd4eb31ad57c.sql b/tests/ast_json_fixtures/shapes/8919bd4eb31ad57c.sql new file mode 100644 index 000000000000..fd6aae28b0d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8919bd4eb31ad57c.sql @@ -0,0 +1 @@ +system stop cleanup rmt diff --git a/tests/ast_json_fixtures/shapes/893941463b260f49.json b/tests/ast_json_fixtures/shapes/893941463b260f49.json new file mode 100644 index 000000000000..590cd0fc379c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/893941463b260f49.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + } + ], + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/893941463b260f49.sql b/tests/ast_json_fixtures/shapes/893941463b260f49.sql new file mode 100644 index 000000000000..3bfa47262699 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/893941463b260f49.sql @@ -0,0 +1 @@ +SELECT 1 AS id WHERE id = 1 diff --git a/tests/ast_json_fixtures/shapes/8957107710155d14.json b/tests/ast_json_fixtures/shapes/8957107710155d14.json new file mode 100644 index 000000000000..fae4280276a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8957107710155d14.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "mt_select_parts_to_mutate_no_free_threads" + } +} diff --git a/tests/ast_json_fixtures/shapes/8957107710155d14.sql b/tests/ast_json_fixtures/shapes/8957107710155d14.sql new file mode 100644 index 000000000000..e161cc117ef4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8957107710155d14.sql @@ -0,0 +1 @@ +SYSTEM ENABLE FAILPOINT mt_select_parts_to_mutate_no_free_threads diff --git a/tests/ast_json_fixtures/shapes/89652eaaab3b4dd3.json b/tests/ast_json_fixtures/shapes/89652eaaab3b4dd3.json new file mode 100644 index 000000000000..487f79bdaa4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/89652eaaab3b4dd3.json @@ -0,0 +1,368 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "alias": "dummy", + "name": "firstNonDefault", + "arguments": [ + { + "type": "Identifier", + "name": "__table3.dummy", + "name_parts": ["__table3", "dummy"] + }, + { + "type": "Identifier", + "name": "__table4.dummy", + "name_parts": ["__table4", "dummy"] + } + ] + }, + { + "type": "Identifier", + "alias": "isNotNull(map(assumeNotNull(isNull(3)), NULL))", + "name": "__table4.isNotNull(map(assumeNotNull(isNull(3)), NULL))", + "name_parts": ["__table4", "isNotNull(map(assumeNotNull(isNull(3)), NULL))"] + }, + { + "type": "Identifier", + "alias": "isNotDistinctFrom(3, isZeroOrNull(isNotNull(3)))", + "name": "__table4.isNotDistinctFrom(3, isZeroOrNull(isNotNull(3)))", + "name_parts": ["__table4", "isNotDistinctFrom(3, isZeroOrNull(isNotNull(3)))"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "__table3", + "name": "one", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "strictness": "ALL", + "using": [ + { + "type": "Identifier", + "name": "dummy" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "__table4", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "alias": "dummy", + "name": "__table5.dummy", + "name_parts": ["__table5", "dummy"] + }, + { + "type": "Identifier", + "alias": "isNotNull(map(assumeNotNull(isNull(3)), NULL))", + "name": "__table5.isNotNull(map(assumeNotNull(isNull(3)), NULL))", + "name_parts": ["__table5", "isNotNull(map(assumeNotNull(isNull(3)), NULL))"] + }, + { + "type": "Function", + "alias": "isNotDistinctFrom(3, isZeroOrNull(isNotNull(3)))", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt8" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "__table5", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "dummy", + "name": "__table6.dummy", + "name_parts": ["__table6", "dummy"] + }, + { + "type": "Function", + "alias": "isNotNull(map(assumeNotNull(isNull(3)), NULL))", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt8" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "__table6", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.3" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "LEFT", + "expressions": [ + { + "type": "Function", + "alias": "__array_join_exp_2", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt8" + } + ] + } + ] + } + ] + } + ] + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "LEFT", + "expressions": [ + { + "type": "Function", + "alias": "__array_join_exp_1", + "name": "map", + "arguments": [ + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt8" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt8" + } + ] + }, + { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt128" + } + ] + } + ] + } + ] + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "__table4.isNotNull(map(assumeNotNull(isNull(3)), NULL))", + "name_parts": ["__table4", "isNotNull(map(assumeNotNull(isNull(3)), NULL))"] + }, + { + "type": "Function", + "name": "firstNonDefault", + "arguments": [ + { + "type": "Identifier", + "name": "__table3.dummy", + "name_parts": ["__table3", "dummy"] + }, + { + "type": "Identifier", + "name": "__table4.dummy", + "name_parts": ["__table4", "dummy"] + } + ] + }, + { + "type": "Identifier", + "name": "__table4.isNotDistinctFrom(3, isZeroOrNull(isNotNull(3)))", + "name_parts": ["__table4", "isNotDistinctFrom(3, isZeroOrNull(isNotNull(3)))"] + }, + { + "type": "Identifier", + "name": "__table4.isNotNull(map(assumeNotNull(isNull(3)), NULL))", + "name_parts": ["__table4", "isNotNull(map(assumeNotNull(isNull(3)), NULL))"] + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_lazy_columns_replication": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/89652eaaab3b4dd3.sql b/tests/ast_json_fixtures/shapes/89652eaaab3b4dd3.sql new file mode 100644 index 000000000000..bc74c5c0d8d9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/89652eaaab3b4dd3.sql @@ -0,0 +1,29 @@ +SELECT DISTINCT + firstNonDefault(__table3.dummy, __table4.dummy) AS dummy, + __table4.`isNotNull(map(assumeNotNull(isNull(3)), NULL))` AS `isNotNull(map(assumeNotNull(isNull(3)), NULL))`, + __table4.`isNotDistinctFrom(3, isZeroOrNull(isNotNull(3)))` AS `isNotDistinctFrom(3, isZeroOrNull(isNotNull(3)))` +FROM system.one AS __table3 +ALL FULL OUTER JOIN +( + SELECT DISTINCT + __table5.dummy AS dummy, + __table5.`isNotNull(map(assumeNotNull(isNull(3)), NULL))` AS `isNotNull(map(assumeNotNull(isNull(3)), NULL))`, + _CAST(0, 'UInt8') AS `isNotDistinctFrom(3, isZeroOrNull(isNotNull(3)))` + FROM + ( + SELECT + __table6.dummy AS dummy, + _CAST(1, 'UInt8') AS `isNotNull(map(assumeNotNull(isNull(3)), NULL))` + FROM remote('127.0.0.3') AS __table6 + ) AS __table5 +) AS __table4 USING (dummy) +LEFT ARRAY JOIN [equals(materialize(3), _CAST(1, 'UInt8'))] AS __array_join_exp_2 +LEFT ARRAY JOIN map(_CAST(0, 'UInt8'), materialize(2), _CAST(0, 'UInt8'), _CAST('1', 'UInt128')) AS __array_join_exp_1 +GROUP BY + materialize(1), + __table4.`isNotNull(map(assumeNotNull(isNull(3)), NULL))`, + firstNonDefault(__table3.dummy, __table4.dummy), + __table4.`isNotDistinctFrom(3, isZeroOrNull(isNotNull(3)))`, + __table4.`isNotNull(map(assumeNotNull(isNull(3)), NULL))` + WITH CUBE +SETTINGS enable_lazy_columns_replication = 1 diff --git a/tests/ast_json_fixtures/shapes/897b98d91f49e426.json b/tests/ast_json_fixtures/shapes/897b98d91f49e426.json new file mode 100644 index 000000000000..ead3c402168f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/897b98d91f49e426.json @@ -0,0 +1,157 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "ClientIP" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits_s3", + "database": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/897b98d91f49e426.sql b/tests/ast_json_fixtures/shapes/897b98d91f49e426.sql new file mode 100644 index 000000000000..fc64c8060434 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/897b98d91f49e426.sql @@ -0,0 +1 @@ +SELECT ClientIP AS x, x - 1, x - 2, x - 3, count() AS c FROM test.hits_s3 GROUP BY x, x - 1, x - 2, x - 3 ORDER BY c DESC LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/897cb96ad34ce355.json b/tests/ast_json_fixtures/shapes/897cb96ad34ce355.json new file mode 100644 index 000000000000..b3864290e5af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/897cb96ad34ce355.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_all": true, + "select": [ + { + "type": "Function", + "alias": "val", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "val" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/897cb96ad34ce355.sql b/tests/ast_json_fixtures/shapes/897cb96ad34ce355.sql new file mode 100644 index 000000000000..35776e96b052 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/897cb96ad34ce355.sql @@ -0,0 +1,4 @@ +SELECT toString(toString(number + 1)) as val, count() +FROM numbers(2) +GROUP BY ALL +ORDER BY val diff --git a/tests/ast_json_fixtures/shapes/898c1303a0025ef2.json b/tests/ast_json_fixtures/shapes/898c1303a0025ef2.json new file mode 100644 index 000000000000..b860fc7cf23c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/898c1303a0025ef2.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02125_function" + } +} diff --git a/tests/ast_json_fixtures/shapes/898c1303a0025ef2.sql b/tests/ast_json_fixtures/shapes/898c1303a0025ef2.sql new file mode 100644 index 000000000000..0bd8a99d51cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/898c1303a0025ef2.sql @@ -0,0 +1 @@ +DROP FUNCTION 02125_function diff --git a/tests/ast_json_fixtures/shapes/898ef8fd3a51bbf3.json b/tests/ast_json_fixtures/shapes/898ef8fd3a51bbf3.json new file mode 100644 index 000000000000..788391677e0a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/898ef8fd3a51bbf3.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_part" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/898ef8fd3a51bbf3.sql b/tests/ast_json_fixtures/shapes/898ef8fd3a51bbf3.sql new file mode 100644 index 000000000000..598e9e7fbe0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/898ef8fd3a51bbf3.sql @@ -0,0 +1 @@ +SELECT _part, * FROM t1 diff --git a/tests/ast_json_fixtures/shapes/89a61130f5d41ce2.json b/tests/ast_json_fixtures/shapes/89a61130f5d41ce2.json new file mode 100644 index 000000000000..96d9b48ef127 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/89a61130f5d41ce2.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "format", + "arguments": [ + { + "type": "Identifier", + "name": "TSVRaw" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Function", + "name": "arrayStringConcat", + "arguments": [ + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "some long string" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "\n" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "LowCardinality(String)" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + } + ] + } + } + } + ] + } + } + ] + } + } + ] + } + } + } + ] + } + } + ], + "format": "TSVRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/89a61130f5d41ce2.sql b/tests/ast_json_fixtures/shapes/89a61130f5d41ce2.sql new file mode 100644 index 000000000000..1e8f4639b76f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/89a61130f5d41ce2.sql @@ -0,0 +1 @@ +SELECT count() FROM format(TSVRaw, (SELECT cast(arrayStringConcat(groupArray('some long string'), '\n'), 'LowCardinality(String)') FROM numbers(10000))) FORMAT TSVRaw diff --git a/tests/ast_json_fixtures/shapes/89b03bf9334a61f8.json b/tests/ast_json_fixtures/shapes/89b03bf9334a61f8.json new file mode 100644 index 000000000000..b9e01ae36b77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/89b03bf9334a61f8.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "is_populate": true, + "uuid": "00000609-1000-4000-8000-000000000001", + "table": { + "type": "Identifier", + "name": "test_mv_00609" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "alias": "date", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_00609" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "date" + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8192" + } + ] + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/89b03bf9334a61f8.sql b/tests/ast_json_fixtures/shapes/89b03bf9334a61f8.sql new file mode 100644 index 000000000000..85946e274d5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/89b03bf9334a61f8.sql @@ -0,0 +1 @@ +create materialized view test_mv_00609 uuid '00000609-1000-4000-8000-000000000001' Engine=MergeTree(date, (a), 8192) populate as select a, toDate('2000-01-01') date from test_00609 diff --git a/tests/ast_json_fixtures/shapes/89e9f0cedf213cda.json b/tests/ast_json_fixtures/shapes/89e9f0cedf213cda.json new file mode 100644 index 000000000000..5c2ce4172422 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/89e9f0cedf213cda.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "normal" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/89e9f0cedf213cda.sql b/tests/ast_json_fixtures/shapes/89e9f0cedf213cda.sql new file mode 100644 index 000000000000..384d7759521a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/89e9f0cedf213cda.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS normal +( + `key` UInt32, + `value` UInt32, +) +ENGINE = MergeTree +ORDER BY tuple() settings index_granularity=1 diff --git a/tests/ast_json_fixtures/shapes/89f56f9c9a64c41e.json b/tests/ast_json_fixtures/shapes/89f56f9c9a64c41e.json new file mode 100644 index 000000000000..0bdcfa601f74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/89f56f9c9a64c41e.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tp" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PROJECTION", + "if_exists": true, + "projection": { + "type": "Identifier", + "name": "p" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/89f56f9c9a64c41e.sql b/tests/ast_json_fixtures/shapes/89f56f9c9a64c41e.sql new file mode 100644 index 000000000000..68a406f38653 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/89f56f9c9a64c41e.sql @@ -0,0 +1 @@ +alter table tp drop projection if exists p diff --git a/tests/ast_json_fixtures/shapes/8a0145df8e820727.json b/tests/ast_json_fixtures/shapes/8a0145df8e820727.json new file mode 100644 index 000000000000..3eb70d79d214 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a0145df8e820727.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "fIrSt_VaLue", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "w" + }, + { + "type": "Function", + "name": "lAsT_vAlUe", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "w" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "frame_type": "RANGE", + "frame_begin": { + "type": "Offset", + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "preceding": true + }, + "frame_end": { + "type": "Offset", + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + } + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8a0145df8e820727.sql b/tests/ast_json_fixtures/shapes/8a0145df8e820727.sql new file mode 100644 index 000000000000..7faff659a80a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a0145df8e820727.sql @@ -0,0 +1,7 @@ +select + number, + fIrSt_VaLue(number) over w, + lAsT_vAlUe(number) over w +from numbers(10) +window w as (order by number range between 1 preceding and 1 following) +order by number diff --git a/tests/ast_json_fixtures/shapes/8a116e6c5ea4a19b.json b/tests/ast_json_fixtures/shapes/8a116e6c5ea4a19b.json new file mode 100644 index 000000000000..45078be79416 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a116e6c5ea4a19b.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "test_02184" + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Identifier", + "name": "kek" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8a116e6c5ea4a19b.sql b/tests/ast_json_fixtures/shapes/8a116e6c5ea4a19b.sql new file mode 100644 index 000000000000..b73cae1c6992 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a116e6c5ea4a19b.sql @@ -0,0 +1 @@ +CREATE DATABASE test_02184 ORDER BY kek diff --git a/tests/ast_json_fixtures/shapes/8a22ba8d5c1c4eff.json b/tests/ast_json_fixtures/shapes/8a22ba8d5c1c4eff.json new file mode 100644 index 000000000000..6096023c50a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a22ba8d5c1c4eff.json @@ -0,0 +1,111 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "filtered", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "tup" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tuple_test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tup" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "tup.u", + "name_parts": ["tup", "u"] + }, + { + "type": "Identifier", + "name": "tup.s", + "name_parts": ["tup", "s"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "filtered" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8a22ba8d5c1c4eff.sql b/tests/ast_json_fixtures/shapes/8a22ba8d5c1c4eff.sql new file mode 100644 index 000000000000..6c544c11d7e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a22ba8d5c1c4eff.sql @@ -0,0 +1,9 @@ +WITH filtered AS ( + SELECT id, tup + FROM tuple_test + WHERE tup IS NOT NULL +) +SELECT id, tup.u, tup.s +FROM filtered +ORDER BY id +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/8a3a2a01c2207d32.json b/tests/ast_json_fixtures/shapes/8a3a2a01c2207d32.json new file mode 100644 index 000000000000..9d9ad33e6813 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a3a2a01c2207d32.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_engines", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "String", + "value": "MergeTree" + }, + { + "value_type": "String", + "value": "ReplicatedCollapsingMergeTree" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/8a3a2a01c2207d32.sql b/tests/ast_json_fixtures/shapes/8a3a2a01c2207d32.sql new file mode 100644 index 000000000000..7930139b4651 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a3a2a01c2207d32.sql @@ -0,0 +1 @@ +SELECT * FROM system.table_engines WHERE name in ('MergeTree', 'ReplicatedCollapsingMergeTree') ORDER BY name FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/8a3b4d18c4b39c39.json b/tests/ast_json_fixtures/shapes/8a3b4d18c4b39c39.json new file mode 100644 index 000000000000..dd07e8619c79 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a3b4d18c4b39c39.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "dictionaries": true, + "from": { + "type": "Identifier", + "name": "memory_db" + }, + "like": "dict2" + } +} diff --git a/tests/ast_json_fixtures/shapes/8a3b4d18c4b39c39.sql b/tests/ast_json_fixtures/shapes/8a3b4d18c4b39c39.sql new file mode 100644 index 000000000000..3b6db141eeb8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a3b4d18c4b39c39.sql @@ -0,0 +1 @@ +SHOW DICTIONARIES FROM memory_db LIKE 'dict2' diff --git a/tests/ast_json_fixtures/shapes/8a582df13e24792a.json b/tests/ast_json_fixtures/shapes/8a582df13e24792a.json new file mode 100644 index 000000000000..4d7af2c8bb30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a582df13e24792a.json @@ -0,0 +1,235 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "owner_id", + "name": "tb1.owner_id", + "name_parts": ["tb1", "owner_id"] + }, + { + "type": "Identifier", + "name": "type" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "tb1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "owner_id", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "CROSS" + }, + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "pt", + "name": "values", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "type varchar" + }, + { + "type": "Literal", + "value_type": "String", + "value": "type1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "type2" + }, + { + "type": "Literal", + "value_type": "String", + "value": "type3" + } + ] + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "using": [ + { + "type": "Identifier", + "name": "owner_id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "merged", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "owner_id", + "name": "tb2.owner_id", + "name_parts": ["tb2", "owner_id"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "tb2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "owner_id", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "owner_id" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tb1.owner_id", + "name_parts": ["tb1", "owner_id"] + }, + { + "type": "Identifier", + "name": "merged.owner_id", + "name_parts": ["merged", "owner_id"] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "tb1.owner_id", + "name_parts": ["tb1", "owner_id"] + }, + { + "type": "Identifier", + "name": "type" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/8a582df13e24792a.sql b/tests/ast_json_fixtures/shapes/8a582df13e24792a.sql new file mode 100644 index 000000000000..6f57b041db03 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a582df13e24792a.sql @@ -0,0 +1,24 @@ +SELECT + tb1.owner_id AS owner_id, + type +FROM +( + SELECT number AS owner_id + FROM numbers(100) +) AS tb1 +CROSS JOIN values('type varchar', 'type1', 'type2', 'type3') AS pt +LEFT JOIN +( + SELECT tb2.owner_id AS owner_id + FROM + ( + SELECT number AS owner_id + FROM numbers(100) + GROUP BY owner_id + ) AS tb2 +) AS merged USING (owner_id) +WHERE tb1.owner_id = merged.owner_id +GROUP BY + tb1.owner_id, + type +FORMAT `Null` diff --git a/tests/ast_json_fixtures/shapes/8a7a752b8b8d115b.json b/tests/ast_json_fixtures/shapes/8a7a752b8b8d115b.json new file mode 100644 index 000000000000..d8920b734a75 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a7a752b8b8d115b.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "mixed_final_mark" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + "replace": false, + "from_table": "has_final_mark" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8a7a752b8b8d115b.sql b/tests/ast_json_fixtures/shapes/8a7a752b8b8d115b.sql new file mode 100644 index 000000000000..c63f954e15cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a7a752b8b8d115b.sql @@ -0,0 +1 @@ +alter table mixed_final_mark attach partition 1 from has_final_mark diff --git a/tests/ast_json_fixtures/shapes/8a7d61902bf50b46.json b/tests/ast_json_fixtures/shapes/8a7d61902bf50b46.json new file mode 100644 index 000000000000..23fb1ce267b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a7d61902bf50b46.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tmp_mv2" + }, + "as_table": "tmp_mv" + } +} diff --git a/tests/ast_json_fixtures/shapes/8a7d61902bf50b46.sql b/tests/ast_json_fixtures/shapes/8a7d61902bf50b46.sql new file mode 100644 index 000000000000..64ae359082fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a7d61902bf50b46.sql @@ -0,0 +1 @@ +CREATE TABLE tmp_mv2 AS tmp_mv diff --git a/tests/ast_json_fixtures/shapes/8a8cd9e395292670.json b/tests/ast_json_fixtures/shapes/8a8cd9e395292670.json new file mode 100644 index 000000000000..d8bbfabe6ed0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a8cd9e395292670.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "pool" + }, + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Function", + "alias": "has_uuid", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table_uuid" + }, + { + "type": "Function", + "name": "toUUIDOrDefault", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "log_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "background_schedule_pool", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8a8cd9e395292670.sql b/tests/ast_json_fixtures/shapes/8a8cd9e395292670.sql new file mode 100644 index 000000000000..ea3b6ebe70e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8a8cd9e395292670.sql @@ -0,0 +1 @@ +SELECT pool, database, table, table_uuid != toUUIDOrDefault(0) AS has_uuid, log_name FROM system.background_schedule_pool WHERE database = currentDatabase() diff --git a/tests/ast_json_fixtures/shapes/8abfe191bf01ad8c.json b/tests/ast_json_fixtures/shapes/8abfe191bf01ad8c.json new file mode 100644 index 000000000000..c8dee29aa7b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8abfe191bf01ad8c.json @@ -0,0 +1,1046 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "digits", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "digit", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "digit" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "digits" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "digit" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "alias": "S", + "name": "s.digit", + "name_parts": ["s", "digit"] + }, + { + "type": "Identifier", + "alias": "E", + "name": "e.digit", + "name_parts": ["e", "digit"] + }, + { + "type": "Identifier", + "alias": "N", + "name": "n.digit", + "name_parts": ["n", "digit"] + }, + { + "type": "Identifier", + "alias": "D", + "name": "d.digit", + "name_parts": ["d", "digit"] + }, + { + "type": "Identifier", + "alias": "M", + "name": "m.digit", + "name_parts": ["m", "digit"] + }, + { + "type": "Identifier", + "alias": "O", + "name": "o.digit", + "name_parts": ["o", "digit"] + }, + { + "type": "Identifier", + "alias": "R", + "name": "r.digit", + "name_parts": ["r", "digit"] + }, + { + "type": "Identifier", + "alias": "Y", + "name": "y.digit", + "name_parts": ["y", "digit"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "s", + "name": "digits" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "e", + "name": "digits" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "n", + "name": "digits" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "d", + "name": "digits" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "m", + "name": "digits" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "o", + "name": "digits" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "r", + "name": "digits" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "y", + "name": "digits" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.digit", + "name_parts": ["s", "digit"] + }, + { + "type": "Identifier", + "name": "e.digit", + "name_parts": ["e", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.digit", + "name_parts": ["s", "digit"] + }, + { + "type": "Identifier", + "name": "n.digit", + "name_parts": ["n", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.digit", + "name_parts": ["s", "digit"] + }, + { + "type": "Identifier", + "name": "d.digit", + "name_parts": ["d", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.digit", + "name_parts": ["s", "digit"] + }, + { + "type": "Identifier", + "name": "m.digit", + "name_parts": ["m", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.digit", + "name_parts": ["s", "digit"] + }, + { + "type": "Identifier", + "name": "o.digit", + "name_parts": ["o", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.digit", + "name_parts": ["s", "digit"] + }, + { + "type": "Identifier", + "name": "r.digit", + "name_parts": ["r", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.digit", + "name_parts": ["s", "digit"] + }, + { + "type": "Identifier", + "name": "y.digit", + "name_parts": ["y", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e.digit", + "name_parts": ["e", "digit"] + }, + { + "type": "Identifier", + "name": "n.digit", + "name_parts": ["n", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e.digit", + "name_parts": ["e", "digit"] + }, + { + "type": "Identifier", + "name": "d.digit", + "name_parts": ["d", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e.digit", + "name_parts": ["e", "digit"] + }, + { + "type": "Identifier", + "name": "m.digit", + "name_parts": ["m", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e.digit", + "name_parts": ["e", "digit"] + }, + { + "type": "Identifier", + "name": "o.digit", + "name_parts": ["o", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e.digit", + "name_parts": ["e", "digit"] + }, + { + "type": "Identifier", + "name": "r.digit", + "name_parts": ["r", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e.digit", + "name_parts": ["e", "digit"] + }, + { + "type": "Identifier", + "name": "y.digit", + "name_parts": ["y", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n.digit", + "name_parts": ["n", "digit"] + }, + { + "type": "Identifier", + "name": "d.digit", + "name_parts": ["d", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n.digit", + "name_parts": ["n", "digit"] + }, + { + "type": "Identifier", + "name": "m.digit", + "name_parts": ["m", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n.digit", + "name_parts": ["n", "digit"] + }, + { + "type": "Identifier", + "name": "o.digit", + "name_parts": ["o", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n.digit", + "name_parts": ["n", "digit"] + }, + { + "type": "Identifier", + "name": "r.digit", + "name_parts": ["r", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n.digit", + "name_parts": ["n", "digit"] + }, + { + "type": "Identifier", + "name": "y.digit", + "name_parts": ["y", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d.digit", + "name_parts": ["d", "digit"] + }, + { + "type": "Identifier", + "name": "m.digit", + "name_parts": ["m", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d.digit", + "name_parts": ["d", "digit"] + }, + { + "type": "Identifier", + "name": "o.digit", + "name_parts": ["o", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d.digit", + "name_parts": ["d", "digit"] + }, + { + "type": "Identifier", + "name": "r.digit", + "name_parts": ["r", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d.digit", + "name_parts": ["d", "digit"] + }, + { + "type": "Identifier", + "name": "y.digit", + "name_parts": ["y", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "m.digit", + "name_parts": ["m", "digit"] + }, + { + "type": "Identifier", + "name": "o.digit", + "name_parts": ["o", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "m.digit", + "name_parts": ["m", "digit"] + }, + { + "type": "Identifier", + "name": "r.digit", + "name_parts": ["r", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "m.digit", + "name_parts": ["m", "digit"] + }, + { + "type": "Identifier", + "name": "y.digit", + "name_parts": ["y", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "o.digit", + "name_parts": ["o", "digit"] + }, + { + "type": "Identifier", + "name": "r.digit", + "name_parts": ["r", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "o.digit", + "name_parts": ["o", "digit"] + }, + { + "type": "Identifier", + "name": "y.digit", + "name_parts": ["y", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "r.digit", + "name_parts": ["r", "digit"] + }, + { + "type": "Identifier", + "name": "y.digit", + "name_parts": ["y", "digit"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.digit", + "name_parts": ["s", "digit"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "m.digit", + "name_parts": ["m", "digit"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + }, + { + "type": "Identifier", + "name": "s.digit", + "name_parts": ["s", "digit"] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Identifier", + "name": "e.digit", + "name_parts": ["e", "digit"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Identifier", + "name": "n.digit", + "name_parts": ["n", "digit"] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "d.digit", + "name_parts": ["d", "digit"] + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + }, + { + "type": "Identifier", + "name": "m.digit", + "name_parts": ["m", "digit"] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Identifier", + "name": "o.digit", + "name_parts": ["o", "digit"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Identifier", + "name": "r.digit", + "name_parts": ["r", "digit"] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "e.digit", + "name_parts": ["e", "digit"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + }, + { + "type": "Identifier", + "name": "m.digit", + "name_parts": ["m", "digit"] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + }, + { + "type": "Identifier", + "name": "o.digit", + "name_parts": ["o", "digit"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Identifier", + "name": "n.digit", + "name_parts": ["n", "digit"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Identifier", + "name": "e.digit", + "name_parts": ["e", "digit"] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "y.digit", + "name_parts": ["y", "digit"] + } + ] + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8abfe191bf01ad8c.sql b/tests/ast_json_fixtures/shapes/8abfe191bf01ad8c.sql new file mode 100644 index 000000000000..1aee45d2170c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8abfe191bf01ad8c.sql @@ -0,0 +1,25 @@ +WITH RECURSIVE digits AS ( + SELECT 0 AS digit + UNION ALL + SELECT digit + 1 + FROM digits + WHERE digit < 9 +) +SELECT s.digit AS S, e.digit AS E, n.digit AS N, d.digit AS D, + m.digit AS M, o.digit AS O, r.digit AS R, y.digit AS Y +FROM digits s, digits e, digits n, digits d, digits m, digits o, digits r, digits y +WHERE s.digit <> e.digit AND s.digit <> n.digit AND s.digit <> d.digit AND s.digit <> m.digit AND + s.digit <> o.digit AND s.digit <> r.digit AND s.digit <> y.digit AND + e.digit <> n.digit AND e.digit <> d.digit AND e.digit <> m.digit AND + e.digit <> o.digit AND e.digit <> r.digit AND e.digit <> y.digit AND + n.digit <> d.digit AND n.digit <> m.digit AND n.digit <> o.digit AND + n.digit <> r.digit AND n.digit <> y.digit AND + d.digit <> m.digit AND d.digit <> o.digit AND d.digit <> r.digit AND + d.digit <> y.digit AND + m.digit <> o.digit AND m.digit <> r.digit AND m.digit <> y.digit AND + o.digit <> r.digit AND o.digit <> y.digit AND + r.digit <> y.digit AND + s.digit <> 0 AND m.digit <> 0 AND + (1000 * s.digit + 100 * e.digit + 10 * n.digit + d.digit) + + (1000 * m.digit + 100 * o.digit + 10 * r.digit + e.digit) = + (10000 * m.digit + 1000 * o.digit + 100 * n.digit + 10 * e.digit + y.digit) diff --git a/tests/ast_json_fixtures/shapes/8ad1a0d7a82b976a.json b/tests/ast_json_fixtures/shapes/8ad1a0d7a82b976a.json new file mode 100644 index 000000000000..22c29fdcda8e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8ad1a0d7a82b976a.json @@ -0,0 +1,122 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "val1" + }, + { + "type": "Identifier", + "name": "val2" + }, + { + "type": "Function", + "alias": "x1", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "assumeNotNull", + "arguments": [ + { + "type": "Identifier", + "name": "val1" + } + ] + }, + { + "type": "Identifier", + "name": "val2" + } + ] + }, + { + "type": "Function", + "alias": "x2", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "val1" + }, + { + "type": "Identifier", + "name": "val2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + }, + "final": true + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "assumeNotNull", + "arguments": [ + { + "type": "Identifier", + "name": "val1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x1" + }, + { + "type": "Identifier", + "name": "x2" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8ad1a0d7a82b976a.sql b/tests/ast_json_fixtures/shapes/8ad1a0d7a82b976a.sql new file mode 100644 index 000000000000..6286d1b20f40 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8ad1a0d7a82b976a.sql @@ -0,0 +1 @@ +select key, val1, val2, assumeNotNull(val1) > val2 x1, val1 > val2 x2 from data final prewhere assumeNotNull(val1) > 0 where x1 != x2 settings max_threads=1 diff --git a/tests/ast_json_fixtures/shapes/8adefbc33641e07c.json b/tests/ast_json_fixtures/shapes/8adefbc33641e07c.json new file mode 100644 index 000000000000..597a7820b91d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8adefbc33641e07c.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/8adefbc33641e07c.sql b/tests/ast_json_fixtures/shapes/8adefbc33641e07c.sql new file mode 100644 index 000000000000..99b1f8886a69 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8adefbc33641e07c.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/8aef72bbc52e5042.json b/tests/ast_json_fixtures/shapes/8aef72bbc52e5042.json new file mode 100644 index 000000000000..5f7e256e102b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8aef72bbc52e5042.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_result_rows": "1" + } + }, + "format": "XML" + } +} diff --git a/tests/ast_json_fixtures/shapes/8aef72bbc52e5042.sql b/tests/ast_json_fixtures/shapes/8aef72bbc52e5042.sql new file mode 100644 index 000000000000..571ea0e3a7a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8aef72bbc52e5042.sql @@ -0,0 +1 @@ +select * from numbers(100) FORMAT XML settings max_result_rows = 1 diff --git a/tests/ast_json_fixtures/shapes/8afeb03003a3a041.json b/tests/ast_json_fixtures/shapes/8afeb03003a3a041.json new file mode 100644 index 000000000000..1cd5258a18b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8afeb03003a3a041.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["test_user_02867"] + } +} diff --git a/tests/ast_json_fixtures/shapes/8afeb03003a3a041.sql b/tests/ast_json_fixtures/shapes/8afeb03003a3a041.sql new file mode 100644 index 000000000000..fab0537308c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8afeb03003a3a041.sql @@ -0,0 +1 @@ +DROP USER test_user_02867 diff --git a/tests/ast_json_fixtures/shapes/8b0520f1590734d6.json b/tests/ast_json_fixtures/shapes/8b0520f1590734d6.json new file mode 100644 index 000000000000..b546437630d9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b0520f1590734d6.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "ColumnsRegexpMatcher", + "pattern": "^c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8b0520f1590734d6.sql b/tests/ast_json_fixtures/shapes/8b0520f1590734d6.sql new file mode 100644 index 000000000000..1287849a7333 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b0520f1590734d6.sql @@ -0,0 +1 @@ +SELECT COLUMNS('^c') FROM t diff --git a/tests/ast_json_fixtures/shapes/8b0a71f4edecee38.json b/tests/ast_json_fixtures/shapes/8b0a71f4edecee38.json new file mode 100644 index 000000000000..73c54a6da1be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b0a71f4edecee38.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q2_01297_renamed"] + } +} diff --git a/tests/ast_json_fixtures/shapes/8b0a71f4edecee38.sql b/tests/ast_json_fixtures/shapes/8b0a71f4edecee38.sql new file mode 100644 index 000000000000..cf692eb75108 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b0a71f4edecee38.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q2_01297_renamed diff --git a/tests/ast_json_fixtures/shapes/8b314649f10efc0c.json b/tests/ast_json_fixtures/shapes/8b314649f10efc0c.json new file mode 100644 index 000000000000..9a90840944fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b314649f10efc0c.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "temporary_table" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "column", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8b314649f10efc0c.sql b/tests/ast_json_fixtures/shapes/8b314649f10efc0c.sql new file mode 100644 index 000000000000..c38273f74652 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b314649f10efc0c.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE IF NOT EXISTS temporary_table (column UInt32) ENGINE = Memory diff --git a/tests/ast_json_fixtures/shapes/8b34cc5a73c51d45.json b/tests/ast_json_fixtures/shapes/8b34cc5a73c51d45.json new file mode 100644 index 000000000000..0b0b5a28a34b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b34cc5a73c51d45.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "view1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8b34cc5a73c51d45.sql b/tests/ast_json_fixtures/shapes/8b34cc5a73c51d45.sql new file mode 100644 index 000000000000..81cfe3bd70ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b34cc5a73c51d45.sql @@ -0,0 +1 @@ +SELECT * FROM view1 WHERE id = 1 ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/8b34f74afd874a37.json b/tests/ast_json_fixtures/shapes/8b34f74afd874a37.json new file mode 100644 index 000000000000..e87f1ed8f29a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b34f74afd874a37.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "col" + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%a" + } + ] + }, + { + "type": "Function", + "name": "ilike", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "col" + }, + { + "type": "Literal", + "value_type": "String", + "value": "AA" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8b34f74afd874a37.sql b/tests/ast_json_fixtures/shapes/8b34f74afd874a37.sql new file mode 100644 index 000000000000..80612e287f7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b34f74afd874a37.sql @@ -0,0 +1 @@ +SELECT col, col LIKE '%a', col ILIKE '%a' FROM tab WHERE col = 'AA' diff --git a/tests/ast_json_fixtures/shapes/8b4d190aac155bf5.json b/tests/ast_json_fixtures/shapes/8b4d190aac155bf5.json new file mode 100644 index 000000000000..3744aae1ddde --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b4d190aac155bf5.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "out_02231" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Null", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "buffer_02231" + } +} diff --git a/tests/ast_json_fixtures/shapes/8b4d190aac155bf5.sql b/tests/ast_json_fixtures/shapes/8b4d190aac155bf5.sql new file mode 100644 index 000000000000..76c987b1ed30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b4d190aac155bf5.sql @@ -0,0 +1 @@ +create table out_02231 as buffer_02231 engine=Null() diff --git a/tests/ast_json_fixtures/shapes/8b4e8a8b4b83d8c5.json b/tests/ast_json_fixtures/shapes/8b4e8a8b4b83d8c5.json new file mode 100644 index 000000000000..73acd9f3391b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b4e8a8b4b83d8c5.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "replaceRegexpAll", + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\\(\\d+\\)" + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + } + ] + }, + { + "type": "Identifier", + "name": "message_format_string" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "warnings", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "The number of%" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "message" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8b4e8a8b4b83d8c5.sql b/tests/ast_json_fixtures/shapes/8b4e8a8b4b83d8c5.sql new file mode 100644 index 000000000000..8c1a94b324f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b4e8a8b4b83d8c5.sql @@ -0,0 +1 @@ +SELECT replaceRegexpAll(message, '\(\d+\)', '_'), message_format_string FROM system.warnings WHERE message LIKE 'The number of%' ORDER BY message diff --git a/tests/ast_json_fixtures/shapes/8b55c3dc9a1ab4f3.json b/tests/ast_json_fixtures/shapes/8b55c3dc9a1ab4f3.json new file mode 100644 index 000000000000..9563a88a9974 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b55c3dc9a1ab4f3.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "m" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "f" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8b55c3dc9a1ab4f3.sql b/tests/ast_json_fixtures/shapes/8b55c3dc9a1ab4f3.sql new file mode 100644 index 000000000000..6888247ea16a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b55c3dc9a1ab4f3.sql @@ -0,0 +1 @@ +SELECT * FROM m PREWHERE f = 1 ORDER BY a diff --git a/tests/ast_json_fixtures/shapes/8b60de296cf84150.json b/tests/ast_json_fixtures/shapes/8b60de296cf84150.json new file mode 100644 index 000000000000..760f34876984 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b60de296cf84150.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "move_destination_type": "TABLE", + "to_table": "t2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8b60de296cf84150.sql b/tests/ast_json_fixtures/shapes/8b60de296cf84150.sql new file mode 100644 index 000000000000..86a978042130 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b60de296cf84150.sql @@ -0,0 +1 @@ +ALTER TABLE t MOVE PARTITION tuple() TO TABLE t2 diff --git a/tests/ast_json_fixtures/shapes/8b812dccc5d9486d.json b/tests/ast_json_fixtures/shapes/8b812dccc5d9486d.json new file mode 100644 index 000000000000..2ad3cd480318 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b812dccc5d9486d.json @@ -0,0 +1,168 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "compound_value", + "name": "CAST", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple (value UInt64)" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "test_table" + }, + "transformers": [ + { + "type": "ColumnsApplyTransformer", + "lambda": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "compound_value" + } + } + ] + }, + "lambda_arg": "x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "alias": "lambda", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "UInt64", + "value": "256" + }, + { + "value_type": "UInt64", + "value": "257" + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "convert_query_to_cnf": true, + "optimize_using_constraints": true, + "optimize_substitute_columns": true + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8b812dccc5d9486d.sql b/tests/ast_json_fixtures/shapes/8b812dccc5d9486d.sql new file mode 100644 index 000000000000..0bc87790e941 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b812dccc5d9486d.sql @@ -0,0 +1,5 @@ +WITH CAST(tuple(1), 'Tuple (value UInt64)') AS compound_value +SELECT id, test_table.* APPLY x -> compound_value.* +FROM test_table +WHERE arrayMap(x -> toString(x) AS lambda, [NULL, 256, 257, NULL, NULL]) +SETTINGS convert_query_to_cnf = true, optimize_using_constraints = true, optimize_substitute_columns = true diff --git a/tests/ast_json_fixtures/shapes/8b993875e582e784.json b/tests/ast_json_fixtures/shapes/8b993875e582e784.json new file mode 100644 index 000000000000..a9b90554b323 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b993875e582e784.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "udf", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": true, + "query_cache_nondeterministic_function_handling": "save" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/8b993875e582e784.sql b/tests/ast_json_fixtures/shapes/8b993875e582e784.sql new file mode 100644 index 000000000000..8f7b3e7f9bee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b993875e582e784.sql @@ -0,0 +1 @@ +SELECT udf(1) FORMAT Null SETTINGS use_query_cache = true, query_cache_nondeterministic_function_handling = 'save' diff --git a/tests/ast_json_fixtures/shapes/8b9f265c9ea6add4.json b/tests/ast_json_fixtures/shapes/8b9f265c9ea6add4.json new file mode 100644 index 000000000000..ce9adfa8c996 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b9f265c9ea6add4.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tbl" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "read_in_order_use_virtual_row": "1" + } + } + } + ], + "format": "Hash" + } +} diff --git a/tests/ast_json_fixtures/shapes/8b9f265c9ea6add4.sql b/tests/ast_json_fixtures/shapes/8b9f265c9ea6add4.sql new file mode 100644 index 000000000000..13030328081d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8b9f265c9ea6add4.sql @@ -0,0 +1,7 @@ +SELECT + a, + b +FROM tbl +ORDER BY (a, b) +SETTINGS read_in_order_use_virtual_row = 1 +FORMAT Hash diff --git a/tests/ast_json_fixtures/shapes/8baf46cf535df8d1.json b/tests/ast_json_fixtures/shapes/8baf46cf535df8d1.json new file mode 100644 index 000000000000..9eda39525ac5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8baf46cf535df8d1.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01223" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8baf46cf535df8d1.sql b/tests/ast_json_fixtures/shapes/8baf46cf535df8d1.sql new file mode 100644 index 000000000000..f654f3f0cc09 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8baf46cf535df8d1.sql @@ -0,0 +1 @@ +select * from dist_01223 group by key order by key limit 1 diff --git a/tests/ast_json_fixtures/shapes/8bb9b7e56d5ab38b.json b/tests/ast_json_fixtures/shapes/8bb9b7e56d5ab38b.json new file mode 100644 index 000000000000..f5654e54ca24 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8bb9b7e56d5ab38b.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "_state" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parts", + "database": "system" + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/8bb9b7e56d5ab38b.sql b/tests/ast_json_fixtures/shapes/8bb9b7e56d5ab38b.sql new file mode 100644 index 000000000000..64d77814fb5d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8bb9b7e56d5ab38b.sql @@ -0,0 +1 @@ +SELECT *, _state FROM system.parts FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/8bcfb2833afa094f.json b/tests/ast_json_fixtures/shapes/8bcfb2833afa094f.json new file mode 100644 index 000000000000..f3a935fbc89e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8bcfb2833afa094f.json @@ -0,0 +1,129 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "alias": "mA", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "A" + } + ] + }, + { + "type": "Function", + "alias": "mB", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "B" + } + ] + }, + { + "type": "Function", + "alias": "mC", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "C" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ], + "having": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "mA" + }, + { + "type": "Identifier", + "name": "mB" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "mA" + }, + { + "type": "Identifier", + "name": "mC" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_extract_common_expressions": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8bcfb2833afa094f.sql b/tests/ast_json_fixtures/shapes/8bcfb2833afa094f.sql new file mode 100644 index 000000000000..0bc007bf5b7a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8bcfb2833afa094f.sql @@ -0,0 +1 @@ +SELECT x, max(A) AS mA, max(B) AS mB, max(C) AS mC FROM x GROUP BY x HAVING (mA AND mB) OR (mA AND mC) ORDER BY x LIMIT 10 SETTINGS optimize_extract_common_expressions = 0 diff --git a/tests/ast_json_fixtures/shapes/8c05a11146563837.json b/tests/ast_json_fixtures/shapes/8c05a11146563837.json new file mode 100644 index 000000000000..6da749c8d948 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c05a11146563837.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "markdown" + } + } + } + ] + } + } + ], + "format": "Markdown" + } +} diff --git a/tests/ast_json_fixtures/shapes/8c05a11146563837.sql b/tests/ast_json_fixtures/shapes/8c05a11146563837.sql new file mode 100644 index 000000000000..17758d050985 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c05a11146563837.sql @@ -0,0 +1 @@ +SELECT * FROM markdown FORMAT Markdown diff --git a/tests/ast_json_fixtures/shapes/8c226e37382d6d7b.json b/tests/ast_json_fixtures/shapes/8c226e37382d6d7b.json new file mode 100644 index 000000000000..733d66a5d240 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c226e37382d6d7b.json @@ -0,0 +1,119 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "alias": "a0", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a0" + } + ] + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t0", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c0", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_correlated_subqueries": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8c226e37382d6d7b.sql b/tests/ast_json_fixtures/shapes/8c226e37382d6d7b.sql new file mode 100644 index 000000000000..fa162b11c9d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c226e37382d6d7b.sql @@ -0,0 +1 @@ +SELECT (SELECT min(*) FROM (SELECT t0.c0)) AS a0, (SELECT a0) FROM (SELECT 1 c0) AS t0 SETTINGS allow_experimental_correlated_subqueries = 1 diff --git a/tests/ast_json_fixtures/shapes/8c2610079c5f14bd.json b/tests/ast_json_fixtures/shapes/8c2610079c5f14bd.json new file mode 100644 index 000000000000..db2e65a639e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c2610079c5f14bd.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "limit" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.1" + }, + { + "type": "Function", + "name": "view", + "arguments": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + ] + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "limit": "5" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8c2610079c5f14bd.sql b/tests/ast_json_fixtures/shapes/8c2610079c5f14bd.sql new file mode 100644 index 000000000000..2023df8b8602 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c2610079c5f14bd.sql @@ -0,0 +1 @@ +SELECT 'limit', * FROM remote('127.1', view(SELECT * FROM numbers(10))) SETTINGS limit=5 diff --git a/tests/ast_json_fixtures/shapes/8c304e67c57cc2b0.json b/tests/ast_json_fixtures/shapes/8c304e67c57cc2b0.json new file mode 100644 index 000000000000..1795050da02d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c304e67c57cc2b0.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "foo_distributed" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "foo_local" + } + ] + } + }, + "as_table": "foo_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/8c304e67c57cc2b0.sql b/tests/ast_json_fixtures/shapes/8c304e67c57cc2b0.sql new file mode 100644 index 000000000000..958a821603cf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c304e67c57cc2b0.sql @@ -0,0 +1,2 @@ +CREATE TABLE foo_distributed AS foo_local +ENGINE = Distributed('test_cluster_two_shards_localhost', currentDatabase(), foo_local) diff --git a/tests/ast_json_fixtures/shapes/8c3a43914029da3b.json b/tests/ast_json_fixtures/shapes/8c3a43914029da3b.json new file mode 100644 index 000000000000..33b154cab786 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c3a43914029da3b.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "i" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ] + } + ], + "format": "XML" + } +} diff --git a/tests/ast_json_fixtures/shapes/8c3a43914029da3b.sql b/tests/ast_json_fixtures/shapes/8c3a43914029da3b.sql new file mode 100644 index 000000000000..26b86a305bd3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c3a43914029da3b.sql @@ -0,0 +1 @@ +select * from test where i < 10 group by i order by i FORMAT XML diff --git a/tests/ast_json_fixtures/shapes/8c479758f0c8aee7.json b/tests/ast_json_fixtures/shapes/8c479758f0c8aee7.json new file mode 100644 index 000000000000..b37a06f20f39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c479758f0c8aee7.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_file" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_02302" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_file" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8c479758f0c8aee7.sql b/tests/ast_json_fixtures/shapes/8c479758f0c8aee7.sql new file mode 100644 index 000000000000..30a12c9da219 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c479758f0c8aee7.sql @@ -0,0 +1 @@ +select _file, * from test_02302 where _file like '%1' diff --git a/tests/ast_json_fixtures/shapes/8c8b0976999f1523.json b/tests/ast_json_fixtures/shapes/8c8b0976999f1523.json new file mode 100644 index 000000000000..6066634c2fd4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c8b0976999f1523.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "local_t" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "having": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8c8b0976999f1523.sql b/tests/ast_json_fixtures/shapes/8c8b0976999f1523.sql new file mode 100644 index 000000000000..32253ae6a2e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8c8b0976999f1523.sql @@ -0,0 +1,10 @@ +SELECT + a, + count() +FROM remote('127.0.0.{1,2}', currentDatabase(), local_t) +GROUP BY a + WITH TOTALS +HAVING a IN +( + SELECT 1 +) diff --git a/tests/ast_json_fixtures/shapes/8cac41d4b02ed918.json b/tests/ast_json_fixtures/shapes/8cac41d4b02ed918.json new file mode 100644 index 000000000000..3b2222a39561 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8cac41d4b02ed918.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Identifier", + "name": "system" + }, + { + "type": "Identifier", + "name": "one" + } + ] + } + }, + "as_database": "system", + "as_table": "one" + } +} diff --git a/tests/ast_json_fixtures/shapes/8cac41d4b02ed918.sql b/tests/ast_json_fixtures/shapes/8cac41d4b02ed918.sql new file mode 100644 index 000000000000..e2a80ed529bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8cac41d4b02ed918.sql @@ -0,0 +1 @@ +create table dist as system.one engine=Distributed(test_shard_localhost, system, one) diff --git a/tests/ast_json_fixtures/shapes/8cba860359044902.json b/tests/ast_json_fixtures/shapes/8cba860359044902.json new file mode 100644 index 000000000000..dab0e9d8fc16 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8cba860359044902.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8cba860359044902.sql b/tests/ast_json_fixtures/shapes/8cba860359044902.sql new file mode 100644 index 000000000000..f9d083a1be3e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8cba860359044902.sql @@ -0,0 +1 @@ +SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 WHERE 1 IN (SELECT 1 WHERE 0) diff --git a/tests/ast_json_fixtures/shapes/8ccdd473f4ebb8b4.json b/tests/ast_json_fixtures/shapes/8ccdd473f4ebb8b4.json new file mode 100644 index 000000000000..2c6e4cd35f38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8ccdd473f4ebb8b4.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "assignments": [ + { + "type": "Assignment", + "column": "c0", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "predicate": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8ccdd473f4ebb8b4.sql b/tests/ast_json_fixtures/shapes/8ccdd473f4ebb8b4.sql new file mode 100644 index 000000000000..5cea87bf49e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8ccdd473f4ebb8b4.sql @@ -0,0 +1 @@ +UPDATE t0 SET c0 = 1 WHERE 1 diff --git a/tests/ast_json_fixtures/shapes/8cfc3f851b384074.json b/tests/ast_json_fixtures/shapes/8cfc3f851b384074.json new file mode 100644 index 000000000000..6227e0678e17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8cfc3f851b384074.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "maxArgMax", + "arguments": [ + { + "type": "Identifier", + "name": "agg_time" + }, + { + "type": "Identifier", + "name": "value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "combinator_argMin_table_r1__fuzz_791" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/8cfc3f851b384074.sql b/tests/ast_json_fixtures/shapes/8cfc3f851b384074.sql new file mode 100644 index 000000000000..eeafab925764 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8cfc3f851b384074.sql @@ -0,0 +1,3 @@ +SELECT maxArgMax(agg_time, value) +FROM combinator_argMin_table_r1__fuzz_791 +GROUP BY id WITH CUBE WITH TOTALS FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/8d14eb7a512462d5.json b/tests/ast_json_fixtures/shapes/8d14eb7a512462d5.json new file mode 100644 index 000000000000..3e776ee598b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d14eb7a512462d5.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Identifier", + "name": "ui" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pk_func" + }, + "final": true + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8d14eb7a512462d5.sql b/tests/ast_json_fixtures/shapes/8d14eb7a512462d5.sql new file mode 100644 index 000000000000..5d2a4009cfce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d14eb7a512462d5.sql @@ -0,0 +1 @@ +SELECT toDate(d), ui FROM pk_func FINAL order by d diff --git a/tests/ast_json_fixtures/shapes/8d29b5dda2feabef.json b/tests/ast_json_fixtures/shapes/8d29b5dda2feabef.json new file mode 100644 index 000000000000..75f50e34f8da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d29b5dda2feabef.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "uuid": "aaaaaaaa-1111-2222-3333-aaaaaaaaaaaa", + "table": { + "type": "Identifier", + "name": "x" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/tables\/{database}\/{uuid}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "r1" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8d29b5dda2feabef.sql b/tests/ast_json_fixtures/shapes/8d29b5dda2feabef.sql new file mode 100644 index 000000000000..c00b9471b8ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d29b5dda2feabef.sql @@ -0,0 +1 @@ +CREATE TABLE x UUID 'aaaaaaaa-1111-2222-3333-aaaaaaaaaaaa' (key Int) ENGINE = ReplicatedMergeTree('/tables/{database}/{uuid}', 'r1') ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/8d566e7bdfc330c2.json b/tests/ast_json_fixtures/shapes/8d566e7bdfc330c2.json new file mode 100644 index 000000000000..1d66d5d4a41e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d566e7bdfc330c2.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test", + "from_table": "hits", + "to_database": "test", + "to_table": "visits_tmp" + }, + { + "from_database": "test", + "from_table": "visits", + "to_database": "test", + "to_table": "hits" + }, + { + "from_database": "test", + "from_table": "visits_tmp", + "to_database": "test", + "to_table": "visits" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8d566e7bdfc330c2.sql b/tests/ast_json_fixtures/shapes/8d566e7bdfc330c2.sql new file mode 100644 index 000000000000..722aa4e219d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d566e7bdfc330c2.sql @@ -0,0 +1 @@ +RENAME TABLE test.hits TO test.visits_tmp, test.visits TO test.hits, test.visits_tmp TO test.visits diff --git a/tests/ast_json_fixtures/shapes/8d8a2befe3cc54e0.json b/tests/ast_json_fixtures/shapes/8d8a2befe3cc54e0.json new file mode 100644 index 000000000000..5ea81c4bf358 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d8a2befe3cc54e0.json @@ -0,0 +1,525 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "topKExact", + "name": "arraySlice", + "arguments": [ + { + "type": "Function", + "name": "arrayReverseSort", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayZip", + "arguments": [ + { + "type": "Function", + "name": "untuple", + "arguments": [ + { + "type": "Function", + "name": "sumMap", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "alias": "topKWeightedExact", + "name": "arraySlice", + "arguments": [ + { + "type": "Function", + "name": "arrayReverseSort", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayZip", + "arguments": [ + { + "type": "Function", + "name": "untuple", + "arguments": [ + { + "type": "Function", + "name": "sumMap", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "w" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "topKExact" + }, + { + "type": "Identifier", + "name": "topKWeightedExact" + }, + { + "type": "Function", + "alias": "topK_counts", + "name": "topK", + "arguments": [ + { + "type": "Identifier", + "name": "k" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "counts" + } + ] + }, + { + "type": "Function", + "alias": "topKWeighted_counts", + "name": "topKWeighted", + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Identifier", + "name": "w" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "counts" + } + ] + }, + { + "type": "Function", + "alias": "approx_top_count", + "name": "approx_top_count", + "arguments": [ + { + "type": "Identifier", + "name": "k" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "6" + } + ] + }, + { + "type": "Function", + "alias": "approx_top_k", + "name": "approx_top_k", + "arguments": [ + { + "type": "Identifier", + "name": "k" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Function", + "alias": "approx_top_sum", + "name": "approx_top_sum", + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Identifier", + "name": "w" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "countDigits", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + }, + { + "type": "Function", + "name": "intDiv", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + } + ] + }, + { + "type": "Identifier", + "alias": "w", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/8d8a2befe3cc54e0.sql b/tests/ast_json_fixtures/shapes/8d8a2befe3cc54e0.sql new file mode 100644 index 000000000000..be2ed0830eb2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d8a2befe3cc54e0.sql @@ -0,0 +1,19 @@ +WITH + arraySlice(arrayReverseSort(x -> (x.2, x.1), arrayZip(untuple(sumMap(([k], [1]))))), 1, 5) AS topKExact, + arraySlice(arrayReverseSort(x -> (x.2, x.1), arrayZip(untuple(sumMap(([k], [w]))))), 1, 5) AS topKWeightedExact +SELECT + topKExact, + topKWeightedExact, + topK(3, 1, 'counts')(k) AS topK_counts, + topKWeighted(3, 1, 'counts')(k, w) AS topKWeighted_counts, + approx_top_count(3, 6)(k) AS approx_top_count, + approx_top_k(3, 4)(k) AS approx_top_k, + approx_top_sum(3, 4)(k, w) AS approx_top_sum +FROM +( + SELECT + concat(countDigits(number * number), '_', intDiv((number % 10), 7)) AS k, + number AS w + FROM numbers(1000) +) +FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/8d9889cadb39561c.json b/tests/ast_json_fixtures/shapes/8d9889cadb39561c.json new file mode 100644 index 000000000000..17c2669b2c49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d9889cadb39561c.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "limit": { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8d9889cadb39561c.sql b/tests/ast_json_fixtures/shapes/8d9889cadb39561c.sql new file mode 100644 index 000000000000..035e38274601 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d9889cadb39561c.sql @@ -0,0 +1 @@ +SELECT * FROM test ORDER BY i LIMIT 4*5 OFFSET 10*10 diff --git a/tests/ast_json_fixtures/shapes/8d9e3599b3fd3cf8.json b/tests/ast_json_fixtures/shapes/8d9e3599b3fd3cf8.json new file mode 100644 index 000000000000..641750bc1eca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d9e3599b3fd3cf8.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "left_joined_view" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1_a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2000" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "log_comment": "left_join_view" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/8d9e3599b3fd3cf8.sql b/tests/ast_json_fixtures/shapes/8d9e3599b3fd3cf8.sql new file mode 100644 index 000000000000..c2eeb8131697 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d9e3599b3fd3cf8.sql @@ -0,0 +1,4 @@ +SELECT * FROM left_joined_view +WHERE t1_a < 2000 +SETTINGS log_comment = 'left_join_view' +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/8d9fc46647d1d28d.json b/tests/ast_json_fixtures/shapes/8d9fc46647d1d28d.json new file mode 100644 index 000000000000..29c0e09d8373 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d9fc46647d1d28d.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "RestoreQuery", + "kind": "RESTORE", + "elements": [ + { + "element_type": "TABLE", + "table": "t0", + "new_table": "t1" + } + ], + "backup_name": { + "type": "Function", + "name": "Disk", + "kind": "BACKUP_NAME", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "backups" + }, + { + "type": "Literal", + "value_type": "String", + "value": "03760_backup_tar_archive.tar" + } + ] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/8d9fc46647d1d28d.sql b/tests/ast_json_fixtures/shapes/8d9fc46647d1d28d.sql new file mode 100644 index 000000000000..686ba7b06257 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8d9fc46647d1d28d.sql @@ -0,0 +1 @@ +RESTORE TABLE t0 AS t1 FROM Disk('backups', '03760_backup_tar_archive.tar') FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/8db70316ee6119a1.json b/tests/ast_json_fixtures/shapes/8db70316ee6119a1.json new file mode 100644 index 000000000000..1bced2fe8445 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8db70316ee6119a1.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "check_constraint" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_CONSTRAINT", + "constraint_declaration": { + "type": "Constraint", + "name": "c0", + "constraint_type": "CHECK", + "expression": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8db70316ee6119a1.sql b/tests/ast_json_fixtures/shapes/8db70316ee6119a1.sql new file mode 100644 index 000000000000..6fee496956b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8db70316ee6119a1.sql @@ -0,0 +1 @@ +ALTER TABLE check_constraint ADD CONSTRAINT c0 CHECK (SELECT 1) diff --git a/tests/ast_json_fixtures/shapes/8de27575db92cac2.json b/tests/ast_json_fixtures/shapes/8de27575db92cac2.json new file mode 100644 index 000000000000..de3b5ff3c6d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8de27575db92cac2.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8de27575db92cac2.sql b/tests/ast_json_fixtures/shapes/8de27575db92cac2.sql new file mode 100644 index 000000000000..2aa829d5e26e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8de27575db92cac2.sql @@ -0,0 +1 @@ +SELECT 1 LIMIT 0 diff --git a/tests/ast_json_fixtures/shapes/8de3f9f970384bfd.json b/tests/ast_json_fixtures/shapes/8de3f9f970384bfd.json new file mode 100644 index 000000000000..55d7cdcff968 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8de3f9f970384bfd.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "partial_duplicates" + }, + "final": true, + "deduplicate": true, + "deduplicate_by_columns": { + "type": "ExpressionList", + "children": [ + { + "type": "ColumnsRegexpMatcher", + "pattern": ".*k" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8de3f9f970384bfd.sql b/tests/ast_json_fixtures/shapes/8de3f9f970384bfd.sql new file mode 100644 index 000000000000..c7362c056641 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8de3f9f970384bfd.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE partial_duplicates FINAL DEDUPLICATE BY COLUMNS('.*k') diff --git a/tests/ast_json_fixtures/shapes/8dec72ebc056f745.json b/tests/ast_json_fixtures/shapes/8dec72ebc056f745.json new file mode 100644 index 000000000000..0dd53fcc1217 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8dec72ebc056f745.json @@ -0,0 +1,164 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-128" + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "realtimebuff__fuzz_19" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-127" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "intDivOrZero", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "DESC", + "nulls_first": true + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/8dec72ebc056f745.sql b/tests/ast_json_fixtures/shapes/8dec72ebc056f745.sql new file mode 100644 index 000000000000..4569c6f1d18a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8dec72ebc056f745.sql @@ -0,0 +1,4 @@ +SELECT intDivOrZero(intDivOrZero(toLowCardinality(-128), toLowCardinality(-1)) = 0, materialize(toLowCardinality(4))) +FROM realtimebuff__fuzz_19 GROUP BY materialize(toLowCardinality(-127)), intDivOrZero(0, 0) = toLowCardinality(toLowCardinality(0)) +WITH TOTALS ORDER BY ALL DESC NULLS FIRST +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/8df308a976f9b876.json b/tests/ast_json_fixtures/shapes/8df308a976f9b876.json new file mode 100644 index 000000000000..a8df5dd425fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8df308a976f9b876.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_1" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "additional_table_filters": { + "table_1": { + "value_type": "String", + "value": "x != 2" + } + } + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8df308a976f9b876.sql b/tests/ast_json_fixtures/shapes/8df308a976f9b876.sql new file mode 100644 index 000000000000..c0a6b6f25e74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8df308a976f9b876.sql @@ -0,0 +1 @@ +select x from table_1 prewhere x != 2 where x != 2 settings additional_table_filters={'table_1' : 'x != 2'} diff --git a/tests/ast_json_fixtures/shapes/8df45590e5aaf439.json b/tests/ast_json_fixtures/shapes/8df45590e5aaf439.json new file mode 100644 index 000000000000..cd7d4de7b64d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8df45590e5aaf439.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + }, + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/8df45590e5aaf439.sql b/tests/ast_json_fixtures/shapes/8df45590e5aaf439.sql new file mode 100644 index 000000000000..c0b5e2c24d56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8df45590e5aaf439.sql @@ -0,0 +1 @@ +DESCRIBE SELECT 1 FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/8e30e4920f6692d4.json b/tests/ast_json_fixtures/shapes/8e30e4920f6692d4.json new file mode 100644 index 000000000000..e14a0f8ddb49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e30e4920f6692d4.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "function_name": { + "type": "Identifier", + "name": "02126_function" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8e30e4920f6692d4.sql b/tests/ast_json_fixtures/shapes/8e30e4920f6692d4.sql new file mode 100644 index 000000000000..267627dea386 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e30e4920f6692d4.sql @@ -0,0 +1 @@ +CREATE FUNCTION 02126_function AS () -> 5 diff --git a/tests/ast_json_fixtures/shapes/8e502314c86bf342.json b/tests/ast_json_fixtures/shapes/8e502314c86bf342.json new file mode 100644 index 000000000000..8c9645fc0424 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e502314c86bf342.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "m02006" + }, + "format": "Null", + "cluster": "test_shard_localhost", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/8e502314c86bf342.sql b/tests/ast_json_fixtures/shapes/8e502314c86bf342.sql new file mode 100644 index 000000000000..d642fc5b7f4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e502314c86bf342.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS m02006 on cluster test_shard_localhost format Null diff --git a/tests/ast_json_fixtures/shapes/8e55995e0858240a.json b/tests/ast_json_fixtures/shapes/8e55995e0858240a.json new file mode 100644 index 000000000000..aef36ab7e5e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e55995e0858240a.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "X" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "foo_merge" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "Val" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Val" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "X" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8e55995e0858240a.sql b/tests/ast_json_fixtures/shapes/8e55995e0858240a.sql new file mode 100644 index 000000000000..319e3567bb18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e55995e0858240a.sql @@ -0,0 +1 @@ +SELECT count(), X FROM foo_merge JOIN t2 USING Val WHERE Val = 3 AND Id = 3 GROUP BY X diff --git a/tests/ast_json_fixtures/shapes/8e5ab18911593b01.json b/tests/ast_json_fixtures/shapes/8e5ab18911593b01.json new file mode 100644 index 000000000000..f63391d2d383 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e5ab18911593b01.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Identifier", + "name": "zookeeper_name" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "replicas", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Identifier", + "name": "table" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parts", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Identifier", + "name": "zookeeper_name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "table" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "zookeeper_name" + }, + "direction": "ASC" + } + ] + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/8e5ab18911593b01.sql b/tests/ast_json_fixtures/shapes/8e5ab18911593b01.sql new file mode 100644 index 000000000000..1eef97d3682c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e5ab18911593b01.sql @@ -0,0 +1,8 @@ +SELECT + table, zookeeper_name, count() +FROM system.replicas +INNER JOIN system.parts USING (database, table) +WHERE database = currentDatabase() +GROUP BY table, zookeeper_name +ORDER BY table, zookeeper_name +FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/8e76919b7cf2101d.json b/tests/ast_json_fixtures/shapes/8e76919b7cf2101d.json new file mode 100644 index 000000000000..257bf4f0fe50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e76919b7cf2101d.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_ordinary_view": true, + "table": { + "type": "Identifier", + "name": "v" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "v", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "v" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8e76919b7cf2101d.sql b/tests/ast_json_fixtures/shapes/8e76919b7cf2101d.sql new file mode 100644 index 000000000000..1ed88370b4e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e76919b7cf2101d.sql @@ -0,0 +1 @@ +create view v (x UInt32, v String) as select x, v from test diff --git a/tests/ast_json_fixtures/shapes/8e7c01dd5559d959.json b/tests/ast_json_fixtures/shapes/8e7c01dd5559d959.json new file mode 100644 index 000000000000..368f3a2f3e32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e7c01dd5559d959.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8e7c01dd5559d959.sql b/tests/ast_json_fixtures/shapes/8e7c01dd5559d959.sql new file mode 100644 index 000000000000..ca2468cb9164 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e7c01dd5559d959.sql @@ -0,0 +1 @@ +SELECT number FROM numbers(10) LIMIT 0 + 1 diff --git a/tests/ast_json_fixtures/shapes/8e8854dcba19e11c.json b/tests/ast_json_fixtures/shapes/8e8854dcba19e11c.json new file mode 100644 index 000000000000..924ce0f7af83 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e8854dcba19e11c.json @@ -0,0 +1,143 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "X", + "name": "arraySort", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ttt01746" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2021-03-03" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8e8854dcba19e11c.sql b/tests/ast_json_fixtures/shapes/8e8854dcba19e11c.sql new file mode 100644 index 000000000000..adcecf0873c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e8854dcba19e11c.sql @@ -0,0 +1 @@ +SELECT arraySort(x -> x.2, [tuple('a', 10)]) AS X FROM ttt01746 WHERE d >= toDate('2021-03-03') - 2 ORDER BY n LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/8e8bb9388f654345.json b/tests/ast_json_fixtures/shapes/8e8bb9388f654345.json new file mode 100644 index 000000000000..f28adca2325b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e8bb9388f654345.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "REFRESH VIEW", + "table": { + "type": "Identifier", + "name": "03789_rmv_mv" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8e8bb9388f654345.sql b/tests/ast_json_fixtures/shapes/8e8bb9388f654345.sql new file mode 100644 index 000000000000..f4d3b17ed0ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8e8bb9388f654345.sql @@ -0,0 +1 @@ +SYSTEM REFRESH VIEW 03789_rmv_mv diff --git a/tests/ast_json_fixtures/shapes/8eaf255620a98826.json b/tests/ast_json_fixtures/shapes/8eaf255620a98826.json new file mode 100644 index 000000000000..32983e54a640 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8eaf255620a98826.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "substr", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "aaaaaaaaaaaaaa" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ], + "group_by": [ + { + "type": "Function", + "name": "substr", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "aaaaaaaaaaaaaa" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8eaf255620a98826.sql b/tests/ast_json_fixtures/shapes/8eaf255620a98826.sql new file mode 100644 index 000000000000..68494e9a4b01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8eaf255620a98826.sql @@ -0,0 +1 @@ +select substr('aaaaaaaaaaaaaa', 8) as a group by substr('aaaaaaaaaaaaaa', 8) order by a diff --git a/tests/ast_json_fixtures/shapes/8eb21146e88122e7.json b/tests/ast_json_fixtures/shapes/8eb21146e88122e7.json new file mode 100644 index 000000000000..518789b636dc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8eb21146e88122e7.json @@ -0,0 +1,141 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "recursive_cte", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toUInt8", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toUInt8", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recursive_cte" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "n" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recursive_cte" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_recursive_cte_evaluation_depth": "5" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/8eb21146e88122e7.sql b/tests/ast_json_fixtures/shapes/8eb21146e88122e7.sql new file mode 100644 index 000000000000..9b851af043c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8eb21146e88122e7.sql @@ -0,0 +1,2 @@ +WITH RECURSIVE recursive_cte AS (SELECT materialize(toUInt8(1)) AS n UNION ALL SELECT materialize(toUInt8(n + 1)) FROM recursive_cte WHERE n < 10) +SELECT n FROM recursive_cte FORMAT Null SETTINGS max_recursive_cte_evaluation_depth = 5 diff --git a/tests/ast_json_fixtures/shapes/8ed160081a30a4eb.json b/tests/ast_json_fixtures/shapes/8ed160081a30a4eb.json new file mode 100644 index 000000000000..932f6dd9c5f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8ed160081a30a4eb.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t0" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "column": { + "type": "Identifier", + "name": "c0.c1" + }, + "rename_to": { + "type": "Identifier", + "name": "c0.c2" + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "c0.c1" + }, + "settings_changes": { + "type": "Settings", + "changes": { + "max_compress_block_size": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8ed160081a30a4eb.sql b/tests/ast_json_fixtures/shapes/8ed160081a30a4eb.sql new file mode 100644 index 000000000000..f42f1fd01f28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8ed160081a30a4eb.sql @@ -0,0 +1 @@ +ALTER TABLE t0 (RENAME COLUMN `c0.c1` TO `c0.c2`), (MODIFY COLUMN `c0.c1` MODIFY SETTING max_compress_block_size = 1) diff --git a/tests/ast_json_fixtures/shapes/8edf5ee983595d1e.json b/tests/ast_json_fixtures/shapes/8edf5ee983595d1e.json new file mode 100644 index 000000000000..fdda3cb623c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8edf5ee983595d1e.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Identifier", + "name": "str1" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "str1" + } + ] + }, + { + "type": "Identifier", + "name": "str2" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "str2" + } + ] + }, + { + "type": "Identifier", + "name": "fstr1" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "fstr1" + } + ] + }, + { + "type": "Identifier", + "name": "fstr2" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "fstr2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_byte_size_string" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8edf5ee983595d1e.sql b/tests/ast_json_fixtures/shapes/8edf5ee983595d1e.sql new file mode 100644 index 000000000000..ba839c091a80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8edf5ee983595d1e.sql @@ -0,0 +1 @@ +select key, byteSize(*), str1, byteSize(str1), str2, byteSize(str2), fstr1, byteSize(fstr1), fstr2, byteSize(fstr2) from test_byte_size_string order by key diff --git a/tests/ast_json_fixtures/shapes/8f593a32ab2460c0.json b/tests/ast_json_fixtures/shapes/8f593a32ab2460c0.json new file mode 100644 index 000000000000..b15caa23a809 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8f593a32ab2460c0.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Identifier", + "name": "remote1" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + }, + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/8f593a32ab2460c0.sql b/tests/ast_json_fixtures/shapes/8f593a32ab2460c0.sql new file mode 100644 index 000000000000..6c4aa180e08b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8f593a32ab2460c0.sql @@ -0,0 +1 @@ +INSERT INTO FUNCTION remote(remote1, database=currentDatabase()) VALUES(1) diff --git a/tests/ast_json_fixtures/shapes/8f76ace64a65cfe6.json b/tests/ast_json_fixtures/shapes/8f76ace64a65cfe6.json new file mode 100644 index 000000000000..5766f3c0fdd0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8f76ace64a65cfe6.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "02884_1.csv" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8f76ace64a65cfe6.sql b/tests/ast_json_fixtures/shapes/8f76ace64a65cfe6.sql new file mode 100644 index 000000000000..15cba5afdc38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8f76ace64a65cfe6.sql @@ -0,0 +1 @@ +insert into function file('02884_1.csv') select 1 as x settings engine_file_truncate_on_insert=1 diff --git a/tests/ast_json_fixtures/shapes/8f7901608fccfc48.json b/tests/ast_json_fixtures/shapes/8f7901608fccfc48.json new file mode 100644 index 000000000000..7919229e2c7a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8f7901608fccfc48.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t_light" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "c", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "i_c", + "expression": { + "type": "Identifier", + "name": "b" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 4 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "a" + }, + "settings": { + "type": "Settings", + "changes": { + "min_bytes_for_wide_part": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8f7901608fccfc48.sql b/tests/ast_json_fixtures/shapes/8f7901608fccfc48.sql new file mode 100644 index 000000000000..781c820e1e52 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8f7901608fccfc48.sql @@ -0,0 +1 @@ +create table t_light(a int, b int, c int, index i_c(b) type minmax granularity 4) engine = MergeTree order by a partition by c % 5 settings min_bytes_for_wide_part=0 diff --git a/tests/ast_json_fixtures/shapes/8f7c7bff530ccf65.json b/tests/ast_json_fixtures/shapes/8f7c7bff530ccf65.json new file mode 100644 index 000000000000..45eaf99d21ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8f7c7bff530ccf65.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/8f7c7bff530ccf65.sql b/tests/ast_json_fixtures/shapes/8f7c7bff530ccf65.sql new file mode 100644 index 000000000000..8c3f5aa645bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8f7c7bff530ccf65.sql @@ -0,0 +1 @@ +SELECT x, y, x+y FROM a diff --git a/tests/ast_json_fixtures/shapes/8f7f2c290fb12e42.json b/tests/ast_json_fixtures/shapes/8f7f2c290fb12e42.json new file mode 100644 index 000000000000..cac97520a855 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8f7f2c290fb12e42.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_ordinary_view": true, + "replace_view": true, + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "number", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/8f7f2c290fb12e42.sql b/tests/ast_json_fixtures/shapes/8f7f2c290fb12e42.sql new file mode 100644 index 000000000000..42e78dbf961d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8f7f2c290fb12e42.sql @@ -0,0 +1 @@ +CREATE OR REPLACE VIEW t (number UInt64) AS SELECT number FROM system.numbers diff --git a/tests/ast_json_fixtures/shapes/8fe0d0b01d6a847a.json b/tests/ast_json_fixtures/shapes/8fe0d0b01d6a847a.json new file mode 100644 index 000000000000..e31054ec330a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8fe0d0b01d6a847a.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropWorkloadQuery", + "workload_name": "development", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/8fe0d0b01d6a847a.sql b/tests/ast_json_fixtures/shapes/8fe0d0b01d6a847a.sql new file mode 100644 index 000000000000..e95d81d804ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/8fe0d0b01d6a847a.sql @@ -0,0 +1 @@ +drop workload if exists development diff --git a/tests/ast_json_fixtures/shapes/901dd1f5cc7934fd.json b/tests/ast_json_fixtures/shapes/901dd1f5cc7934fd.json new file mode 100644 index 000000000000..efd74e9b03a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/901dd1f5cc7934fd.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "xy" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "intHash64", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "y" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/901dd1f5cc7934fd.sql b/tests/ast_json_fixtures/shapes/901dd1f5cc7934fd.sql new file mode 100644 index 000000000000..7bbc02a80258 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/901dd1f5cc7934fd.sql @@ -0,0 +1 @@ +create table xy(x int, y int) engine MergeTree partition by intHash64(x) % 2 order by y settings index_granularity = 1 diff --git a/tests/ast_json_fixtures/shapes/904d3d2771fd1ba4.json b/tests/ast_json_fixtures/shapes/904d3d2771fd1ba4.json new file mode 100644 index 000000000000..04b4215afe60 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/904d3d2771fd1ba4.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["sqllt_settings_profile"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "interactive_delay", + "value": "200000" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/904d3d2771fd1ba4.sql b/tests/ast_json_fixtures/shapes/904d3d2771fd1ba4.sql new file mode 100644 index 000000000000..1edb356b0dd1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/904d3d2771fd1ba4.sql @@ -0,0 +1 @@ +CREATE SETTINGS PROFILE sqllt_settings_profile SETTINGS interactive_delay = 200000 diff --git a/tests/ast_json_fixtures/shapes/906e36a943997a8b.json b/tests/ast_json_fixtures/shapes/906e36a943997a8b.json new file mode 100644 index 000000000000..5bb21a5d2c7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/906e36a943997a8b.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettySpaceNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/906e36a943997a8b.sql b/tests/ast_json_fixtures/shapes/906e36a943997a8b.sql new file mode 100644 index 000000000000..dea11de4e21e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/906e36a943997a8b.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettySpaceNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/907c917fab0e7ce1.json b/tests/ast_json_fixtures/shapes/907c917fab0e7ce1.json new file mode 100644 index 000000000000..3a0316b2ac8b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/907c917fab0e7ce1.json @@ -0,0 +1,187 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "number", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "cos", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "min2", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "having": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sign", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-233841197" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "sin", + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "lcm", + "arguments": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "372497213" + } + ] + } + ] + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "aggregate_functions_null_for_empty": "1", + "enable_optimize_predicate_expression": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/907c917fab0e7ce1.sql b/tests/ast_json_fixtures/shapes/907c917fab0e7ce1.sql new file mode 100644 index 000000000000..8adc28a07953 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/907c917fab0e7ce1.sql @@ -0,0 +1,8 @@ +SELECT SUM(number) +FROM +( + SELECT 10 AS number +) +GROUP BY cos(min2(number, number) % number) - number +HAVING ((-sign(-233841197)) IS NOT NULL) AND sin(lcm(SUM(number), SUM(number)) >= ('372497213' IS NOT NULL)) +SETTINGS aggregate_functions_null_for_empty = 1, enable_optimize_predicate_expression = 0 diff --git a/tests/ast_json_fixtures/shapes/908743237780ed94.json b/tests/ast_json_fixtures/shapes/908743237780ed94.json new file mode 100644 index 000000000000..1ec6f6283a4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/908743237780ed94.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "full": true, + "table": "tab" + } +} diff --git a/tests/ast_json_fixtures/shapes/908743237780ed94.sql b/tests/ast_json_fixtures/shapes/908743237780ed94.sql new file mode 100644 index 000000000000..9e0540d58d6d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/908743237780ed94.sql @@ -0,0 +1 @@ +SHOW FULL COLUMNS FROM tab diff --git a/tests/ast_json_fixtures/shapes/90b2b05c875e073c.json b/tests/ast_json_fixtures/shapes/90b2b05c875e073c.json new file mode 100644 index 000000000000..e2fd9d40e269 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90b2b05c875e073c.json @@ -0,0 +1,123 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "pr_1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "a" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Function", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/90b2b05c875e073c.sql b/tests/ast_json_fixtures/shapes/90b2b05c875e073c.sql new file mode 100644 index 000000000000..c659b0f4931c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90b2b05c875e073c.sql @@ -0,0 +1,2 @@ +CREATE TABLE pr_1 (`a` UInt32) ENGINE = MergeTree ORDER BY a PARTITION BY a % 10 AS +SELECT 10 * intDiv(number, 10) + 1 FROM numbers(1_000) diff --git a/tests/ast_json_fixtures/shapes/90b96dc44c35b6d1.json b/tests/ast_json_fixtures/shapes/90b96dc44c35b6d1.json new file mode 100644 index 000000000000..e33fa0f15120 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90b96dc44c35b6d1.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/90b96dc44c35b6d1.sql b/tests/ast_json_fixtures/shapes/90b96dc44c35b6d1.sql new file mode 100644 index 000000000000..9e0b862d3665 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90b96dc44c35b6d1.sql @@ -0,0 +1 @@ +SELECT number % 3 + 1 AS n, min(n), max(n) FROM numbers(100) GROUP BY n WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/90ba49016324280e.json b/tests/ast_json_fixtures/shapes/90ba49016324280e.json new file mode 100644 index 000000000000..9c21a7393e28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90ba49016324280e.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "name": "fact_1_id" + }, + { + "type": "Identifier", + "name": "fact_3_id" + }, + { + "type": "Function", + "alias": "sales_value", + "name": "SUM", + "arguments": [ + { + "type": "Identifier", + "name": "sales_value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "grouping_sets" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "fact_1_id" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "fact_1_id" + }, + { + "type": "Identifier", + "name": "fact_3_id" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "fact_1_id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "fact_3_id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/90ba49016324280e.sql b/tests/ast_json_fixtures/shapes/90ba49016324280e.sql new file mode 100644 index 000000000000..d5fb19001d28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90ba49016324280e.sql @@ -0,0 +1,7 @@ +SELECT + fact_1_id, + fact_3_id, + SUM(sales_value) AS sales_value +FROM grouping_sets +GROUP BY grouping sets (fact_1_id, (fact_1_id, fact_3_id)) WITH TOTALS +ORDER BY fact_1_id, fact_3_id diff --git a/tests/ast_json_fixtures/shapes/90d83b09fdcd0151.json b/tests/ast_json_fixtures/shapes/90d83b09fdcd0151.json new file mode 100644 index 000000000000..421014cc7543 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90d83b09fdcd0151.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_display_footer_column_names": "0" + } + }, + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/90d83b09fdcd0151.sql b/tests/ast_json_fixtures/shapes/90d83b09fdcd0151.sql new file mode 100644 index 000000000000..f8e99bbd4b81 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90d83b09fdcd0151.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettySpace SETTINGS output_format_pretty_display_footer_column_names=0 diff --git a/tests/ast_json_fixtures/shapes/90e232a87e7ab30c.json b/tests/ast_json_fixtures/shapes/90e232a87e7ab30c.json new file mode 100644 index 000000000000..85a91fade502 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90e232a87e7ab30c.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + } + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/90e232a87e7ab30c.sql b/tests/ast_json_fixtures/shapes/90e232a87e7ab30c.sql new file mode 100644 index 000000000000..cb2c04981e32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90e232a87e7ab30c.sql @@ -0,0 +1 @@ +SELECT count() FROM numbers(10) WHERE number = -1 WITH TOTALS FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/90f83d59bbea5aad.json b/tests/ast_json_fixtures/shapes/90f83d59bbea5aad.json new file mode 100644 index 000000000000..ef01bbae84db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90f83d59bbea5aad.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "group_by_null_key" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "c1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/90f83d59bbea5aad.sql b/tests/ast_json_fixtures/shapes/90f83d59bbea5aad.sql new file mode 100644 index 000000000000..8bef3cf5ea6b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90f83d59bbea5aad.sql @@ -0,0 +1 @@ +select c1, count(*) from group_by_null_key group by c1 WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/90fd15117a9b0675.json b/tests/ast_json_fixtures/shapes/90fd15117a9b0675.json new file mode 100644 index 000000000000..ed9c9a9d37e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90fd15117a9b0675.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_for_rename" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/90fd15117a9b0675.sql b/tests/ast_json_fixtures/shapes/90fd15117a9b0675.sql new file mode 100644 index 000000000000..420b0904b375 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/90fd15117a9b0675.sql @@ -0,0 +1 @@ +SELECT * FROM table_for_rename WHERE key = 1 FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/91023ad3d73b1044.json b/tests/ast_json_fixtures/shapes/91023ad3d73b1044.json new file mode 100644 index 000000000000..50d266838fc2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91023ad3d73b1044.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02483_plustwo", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/91023ad3d73b1044.sql b/tests/ast_json_fixtures/shapes/91023ad3d73b1044.sql new file mode 100644 index 000000000000..5f54496c04cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91023ad3d73b1044.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02483_plustwo diff --git a/tests/ast_json_fixtures/shapes/910e362a782c2a4f.json b/tests/ast_json_fixtures/shapes/910e362a782c2a4f.json new file mode 100644 index 000000000000..b5c07e0faf59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/910e362a782c2a4f.json @@ -0,0 +1,269 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "lineWithInlines", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "alias": "lineWithInlines", + "name": "addressToLineWithInlines", + "arguments": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "trace" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "trace_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "query_id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "log_comment" + }, + { + "type": "Literal", + "value_type": "String", + "value": "02161_test_case" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "has inlines:" + }, + { + "type": "Function", + "name": "or", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "lineWithInlines" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Function", + "name": "locate", + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "lineWithInlines" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": ":" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lineWithInlines" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "short_circuit_function_evaluation": "enable" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/910e362a782c2a4f.sql b/tests/ast_json_fixtures/shapes/910e362a782c2a4f.sql new file mode 100644 index 000000000000..ecc2900527fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/910e362a782c2a4f.sql @@ -0,0 +1,9 @@ +WITH + lineWithInlines AS + ( + SELECT DISTINCT addressToLineWithInlines(arrayJoin(trace)) AS lineWithInlines FROM system.trace_log WHERE query_id = + ( + SELECT query_id FROM system.query_log WHERE current_database = currentDatabase() AND log_comment='02161_test_case' ORDER BY event_time DESC LIMIT 1 + ) + ) +SELECT 'has inlines:', or(max(length(lineWithInlines)) > 1, max(locate(lineWithInlines[1], ':')) = 0) FROM lineWithInlines SETTINGS short_circuit_function_evaluation='enable' diff --git a/tests/ast_json_fixtures/shapes/9138b8c186412e17.json b/tests/ast_json_fixtures/shapes/9138b8c186412e17.json new file mode 100644 index 000000000000..2b59e0e5df3c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9138b8c186412e17.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers_mt", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + }, + "limit": { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9138b8c186412e17.sql b/tests/ast_json_fixtures/shapes/9138b8c186412e17.sql new file mode 100644 index 000000000000..dcc6bd6012b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9138b8c186412e17.sql @@ -0,0 +1 @@ +SELECT * FROM system.numbers_mt WHERE number = 1000000 LIMIT -1 OFFSET -1 diff --git a/tests/ast_json_fixtures/shapes/9141415632a102c0.json b/tests/ast_json_fixtures/shapes/9141415632a102c0.json new file mode 100644 index 000000000000..e287863cbdc4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9141415632a102c0.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9141415632a102c0.sql b/tests/ast_json_fixtures/shapes/9141415632a102c0.sql new file mode 100644 index 000000000000..cc8b8597863b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9141415632a102c0.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number with totals limit 1 diff --git a/tests/ast_json_fixtures/shapes/91455521349857f1.json b/tests/ast_json_fixtures/shapes/91455521349857f1.json new file mode 100644 index 000000000000..317695b93556 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91455521349857f1.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "hosts": { + "local_host": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/91455521349857f1.sql b/tests/ast_json_fixtures/shapes/91455521349857f1.sql new file mode 100644 index 000000000000..0eb14043a863 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91455521349857f1.sql @@ -0,0 +1 @@ +ALTER USER u1_01292@'%' HOST LOCAL diff --git a/tests/ast_json_fixtures/shapes/915bc25fdee6ae06.json b/tests/ast_json_fixtures/shapes/915bc25fdee6ae06.json new file mode 100644 index 000000000000..e8f5689c1595 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/915bc25fdee6ae06.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1" + } + }, + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/915bc25fdee6ae06.sql b/tests/ast_json_fixtures/shapes/915bc25fdee6ae06.sql new file mode 100644 index 000000000000..7482de23e048 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/915bc25fdee6ae06.sql @@ -0,0 +1 @@ +SELECT c FROM tab FORMAT Vertical SETTINGS use_query_cache = 1 diff --git a/tests/ast_json_fixtures/shapes/916f17401900d487.json b/tests/ast_json_fixtures/shapes/916f17401900d487.json new file mode 100644 index 000000000000..ea98fd0c8869 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/916f17401900d487.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2022-12-12 23:23:23" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Europe\/Zurich" + } + ] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2022-12-12 23:23:23" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Europe\/Zurich" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "session_timezone": "Europe\/Helsinki" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "session_timezone": "America\/Denver" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/916f17401900d487.sql b/tests/ast_json_fixtures/shapes/916f17401900d487.sql new file mode 100644 index 000000000000..f127bc6fd7ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/916f17401900d487.sql @@ -0,0 +1 @@ +SELECT toDateTime(toDateTime('2022-12-12 23:23:23'), 'Europe/Zurich'), (SELECT toDateTime(toDateTime('2022-12-12 23:23:23'), 'Europe/Zurich') SETTINGS session_timezone = 'Europe/Helsinki') SETTINGS session_timezone = 'America/Denver' diff --git a/tests/ast_json_fixtures/shapes/917d1feef878a604.json b/tests/ast_json_fixtures/shapes/917d1feef878a604.json new file mode 100644 index 000000000000..5db80b0e9e6a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/917d1feef878a604.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "alias": "create_time", + "value_type": "String", + "value": "1997-02-01" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "test.create_time", + "name_parts": ["test", "create_time"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "1970-02-01 00:00:00" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/917d1feef878a604.sql b/tests/ast_json_fixtures/shapes/917d1feef878a604.sql new file mode 100644 index 000000000000..725ece0e6dea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/917d1feef878a604.sql @@ -0,0 +1 @@ +select id,'1997-02-01' as create_time from test where test.create_time='1970-02-01 00:00:00' ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/918d22223fc84bc5.json b/tests/ast_json_fixtures/shapes/918d22223fc84bc5.json new file mode 100644 index 000000000000..f4ccdb4ef1f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/918d22223fc84bc5.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "CounterID" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/918d22223fc84bc5.sql b/tests/ast_json_fixtures/shapes/918d22223fc84bc5.sql new file mode 100644 index 000000000000..870ddb98d783 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/918d22223fc84bc5.sql @@ -0,0 +1 @@ +SELECT CounterID FROM test.hits WHERE CounterID > 0 LIMIT 1 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/919e906560fc16c8.json b/tests/ast_json_fixtures/shapes/919e906560fc16c8.json new file mode 100644 index 000000000000..ccb67c21d6ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/919e906560fc16c8.json @@ -0,0 +1,199 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Identifier", + "name": "exp_smooth" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "bar", + "name": "bar", + "arguments": [ + { + "type": "Identifier", + "name": "exp_smooth" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775807" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048575" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "value", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Identifier", + "alias": "time", + "name": "number" + }, + { + "type": "Function", + "alias": "exp_smooth", + "name": "exponentialTimeDecayedSum", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Identifier", + "name": "time" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483646" + } + ], + "window_definition": { + "type": "WindowDefinition", + "frame_type": "RANGE", + "frame_begin": { + "type": "Current", + "preceding": true + }, + "frame_end": { + "type": "Current" + } + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "25" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/919e906560fc16c8.sql b/tests/ast_json_fixtures/shapes/919e906560fc16c8.sql new file mode 100644 index 000000000000..ec0a14800d54 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/919e906560fc16c8.sql @@ -0,0 +1 @@ +SELECT time, round(exp_smooth, 10), bar(exp_smooth, -9223372036854775807, 1048575, 50) AS bar FROM (SELECT 2 OR (number = 0) OR (number >= 1) AS value, number AS time, exponentialTimeDecayedSum(2147483646)(value, time) OVER (RANGE BETWEEN CURRENT ROW AND CURRENT ROW) AS exp_smooth FROM numbers(1) WHERE 10) WHERE 25 diff --git a/tests/ast_json_fixtures/shapes/91b2111845a53279.json b/tests/ast_json_fixtures/shapes/91b2111845a53279.json new file mode 100644 index 000000000000..f6874036fa23 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91b2111845a53279.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t3" + }, + "as_table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/91b2111845a53279.sql b/tests/ast_json_fixtures/shapes/91b2111845a53279.sql new file mode 100644 index 000000000000..85da8381af45 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91b2111845a53279.sql @@ -0,0 +1 @@ +CREATE TABLE t3 AS numbers(10) diff --git a/tests/ast_json_fixtures/shapes/91b522da954c2759.json b/tests/ast_json_fixtures/shapes/91b522da954c2759.json new file mode 100644 index 000000000000..fe19a40d2045 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91b522da954c2759.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "dynamicType", + "arguments": [ + { + "type": "Identifier", + "name": "n2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "to_table" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/91b522da954c2759.sql b/tests/ast_json_fixtures/shapes/91b522da954c2759.sql new file mode 100644 index 000000000000..9ee8fc88813b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91b522da954c2759.sql @@ -0,0 +1 @@ +SELECT *, dynamicType(n2) FROM to_table ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/91c70d4381b53cba.json b/tests/ast_json_fixtures/shapes/91c70d4381b53cba.json new file mode 100644 index 000000000000..2e0bec25b7d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91c70d4381b53cba.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "l", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "alias": "r", + "value_type": "UInt64", + "value": "10" + } + ], + "select": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC", + "with_fill": true, + "fill_from": { + "type": "Identifier", + "name": "l" + }, + "fill_to": { + "type": "Identifier", + "name": "r" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/91c70d4381b53cba.sql b/tests/ast_json_fixtures/shapes/91c70d4381b53cba.sql new file mode 100644 index 000000000000..24310dbbd26c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91c70d4381b53cba.sql @@ -0,0 +1 @@ +WITH 0 AS l, 10 AS r SELECT number * 2 FROM numbers(5) ORDER BY 1 WITH FILL FROM l TO r diff --git a/tests/ast_json_fixtures/shapes/91d050b907c2e6c9.json b/tests/ast_json_fixtures/shapes/91d050b907c2e6c9.json new file mode 100644 index 000000000000..b23f657f0589 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91d050b907c2e6c9.json @@ -0,0 +1,137 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "03443_data" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "name", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx_name", + "expression": { + "type": "Identifier", + "name": "name" + }, + "index_type": { + "type": "Function", + "name": "ngrambf_v1", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "id" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "John" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Ksenia" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Alice" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/91d050b907c2e6c9.sql b/tests/ast_json_fixtures/shapes/91d050b907c2e6c9.sql new file mode 100644 index 000000000000..1f7ed8fcc9cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91d050b907c2e6c9.sql @@ -0,0 +1,11 @@ +CREATE TABLE 03443_data +( + id Int32, + name String, + INDEX idx_name name TYPE ngrambf_v1(1, 1024, 3, 0) GRANULARITY 1 +) +ENGINE = MergeTree ORDER BY id SETTINGS index_granularity = 1 +AS +SELECT 1, 'John' UNION ALL +SELECT 2, 'Ksenia' UNION ALL +SELECT 3, 'Alice' diff --git a/tests/ast_json_fixtures/shapes/91de960f16f2bc00.json b/tests/ast_json_fixtures/shapes/91de960f16f2bc00.json new file mode 100644 index 000000000000..c4aea48a80c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91de960f16f2bc00.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Literal", + "alias": "orig", + "value_type": "String", + "value": "original" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test2" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC", + "with_fill": true + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/91de960f16f2bc00.sql b/tests/ast_json_fixtures/shapes/91de960f16f2bc00.sql new file mode 100644 index 000000000000..9fc9a144c5fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91de960f16f2bc00.sql @@ -0,0 +1 @@ +SELECT *, 'original' AS orig FROM test2 ORDER BY a, b WITH FILL diff --git a/tests/ast_json_fixtures/shapes/91f3bb3b8be7e7f7.json b/tests/ast_json_fixtures/shapes/91f3bb3b8be7e7f7.json new file mode 100644 index 000000000000..e3fcad65791e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91f3bb3b8be7e7f7.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s2_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/91f3bb3b8be7e7f7.sql b/tests/ast_json_fixtures/shapes/91f3bb3b8be7e7f7.sql new file mode 100644 index 000000000000..4014106ba786 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/91f3bb3b8be7e7f7.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s2_01294 diff --git a/tests/ast_json_fixtures/shapes/921de91c79402e57.json b/tests/ast_json_fixtures/shapes/921de91c79402e57.json new file mode 100644 index 000000000000..cb1782e5d7b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/921de91c79402e57.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "attach_partition_t4" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "replace": false, + "from_table": "attach_partition_t3" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/921de91c79402e57.sql b/tests/ast_json_fixtures/shapes/921de91c79402e57.sql new file mode 100644 index 000000000000..bbfd5f3492f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/921de91c79402e57.sql @@ -0,0 +1 @@ +ALTER TABLE attach_partition_t4 ATTACH PARTITION tuple() FROM attach_partition_t3 diff --git a/tests/ast_json_fixtures/shapes/9223e69a2cb7acab.json b/tests/ast_json_fixtures/shapes/9223e69a2cb7acab.json new file mode 100644 index 000000000000..c7f1566e1e2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9223e69a2cb7acab.json @@ -0,0 +1,203 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Function", + "name": "topKDistinctState", + "nulls_action": "IGNORE NULLS", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "parameters": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "map", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "3" + }, + { + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Function", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "3" + }, + { + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/9223e69a2cb7acab.sql b/tests/ast_json_fixtures/shapes/9223e69a2cb7acab.sql new file mode 100644 index 000000000000..4a066be50860 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9223e69a2cb7acab.sql @@ -0,0 +1 @@ +SELECT toTypeName(topKDistinctState(toNullable(10))(toString(number)) IGNORE NULLS) FROM numbers(100) GROUP BY tuple((map((materialize(toNullable(1)), 2), 4, (3, 4), 5), 3)), map((1, 2), 4, (3, 4), toNullable(5)) WITH CUBE WITH TOTALS FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/922b3cda1431ca91.json b/tests/ast_json_fixtures/shapes/922b3cda1431ca91.json new file mode 100644 index 000000000000..90ad560451c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/922b3cda1431ca91.json @@ -0,0 +1,173 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t1" + } + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t2" + } + }, + { + "type": "Literal", + "alias": "constant", + "value_type": "UInt64", + "value": "123" + }, + { + "type": "Function", + "name": "isConstant", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "world" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "321" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.k", + "name_parts": ["t1", "k"] + }, + { + "type": "Identifier", + "name": "t2.k", + "name_parts": ["t2", "k"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "123" + } + ] + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.k", + "name_parts": ["t1", "k"] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/922b3cda1431ca91.sql b/tests/ast_json_fixtures/shapes/922b3cda1431ca91.sql new file mode 100644 index 000000000000..e6b6d5502bf9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/922b3cda1431ca91.sql @@ -0,0 +1,17 @@ +SELECT + t1.*, + t2.*, + 123 AS constant, + isConstant('world') +FROM +( + SELECT + arrayJoin([1, 2]) AS k, + 321 +) AS t1 +LEFT JOIN +( + SELECT + arrayJoin([1, 3]) AS k, + 123 +) AS t2 ON t1.k = t2.k ORDER BY t1.k diff --git a/tests/ast_json_fixtures/shapes/922f9cc3935768fb.json b/tests/ast_json_fixtures/shapes/922f9cc3935768fb.json new file mode 100644 index 000000000000..a58bc165e70e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/922f9cc3935768fb.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "shift_right_bit", + "value_type": "UInt64", + "value": "7" + }, + { + "type": "Identifier", + "alias": "arg", + "name": "str" + }, + { + "type": "Function", + "alias": "string_res", + "name": "bin", + "arguments": [ + { + "type": "Function", + "name": "bitShiftLeft", + "arguments": [ + { + "type": "Identifier", + "name": "str" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_bit_shift_left_string_integer" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/922f9cc3935768fb.sql b/tests/ast_json_fixtures/shapes/922f9cc3935768fb.sql new file mode 100644 index 000000000000..2c2a4eb5fef3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/922f9cc3935768fb.sql @@ -0,0 +1 @@ +SELECT 7 as shift_right_bit,str as arg,bin(bitShiftLeft(str, 7)) as string_res FROM test_bit_shift_left_string_integer diff --git a/tests/ast_json_fixtures/shapes/92332161c5d571a5.json b/tests/ast_json_fixtures/shapes/92332161c5d571a5.json new file mode 100644 index 000000000000..e711acc7fd98 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/92332161c5d571a5.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u4_01292@::1"] + } +} diff --git a/tests/ast_json_fixtures/shapes/92332161c5d571a5.sql b/tests/ast_json_fixtures/shapes/92332161c5d571a5.sql new file mode 100644 index 000000000000..3785c9103d07 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/92332161c5d571a5.sql @@ -0,0 +1 @@ +SHOW CREATE USER 'u4_01292@::1' diff --git a/tests/ast_json_fixtures/shapes/92416311e4ff86b8.json b/tests/ast_json_fixtures/shapes/92416311e4ff86b8.json new file mode 100644 index 000000000000..d2555ca22c73 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/92416311e4ff86b8.json @@ -0,0 +1,141 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "gr", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "having": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "gr" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/92416311e4ff86b8.sql b/tests/ast_json_fixtures/shapes/92416311e4ff86b8.sql new file mode 100644 index 000000000000..0c7d088418fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/92416311e4ff86b8.sql @@ -0,0 +1,9 @@ +SELECT + number, + grouping(number, number % 2) as gr +FROM remote('127.0.0.{2,3}', numbers(10)) +GROUP BY + CUBE(number, number % 2) WITH TOTALS +HAVING grouping(number) != 0 +ORDER BY + number, gr diff --git a/tests/ast_json_fixtures/shapes/925826890fb8986b.json b/tests/ast_json_fixtures/shapes/925826890fb8986b.json new file mode 100644 index 000000000000..14ce45c9cb4e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/925826890fb8986b.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r1_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/925826890fb8986b.sql b/tests/ast_json_fixtures/shapes/925826890fb8986b.sql new file mode 100644 index 000000000000..e7a88688a0c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/925826890fb8986b.sql @@ -0,0 +1 @@ +CREATE ROLE r1_01294 diff --git a/tests/ast_json_fixtures/shapes/925b05fc5be9a55c.json b/tests/ast_json_fixtures/shapes/925b05fc5be9a55c.json new file mode 100644 index 000000000000..2c50abee8784 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/925b05fc5be9a55c.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "direct_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "v1", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "v2", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + }, + "default_value": { + "type": "Literal", + "value_type": "Null", + "value": null + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "v3", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "UInt64" + } + ] + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "dictionary_source_table" + } + } + ] + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "direct", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/925b05fc5be9a55c.sql b/tests/ast_json_fixtures/shapes/925b05fc5be9a55c.sql new file mode 100644 index 000000000000..2db69bd3ea44 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/925b05fc5be9a55c.sql @@ -0,0 +1,10 @@ +CREATE DICTIONARY direct_dictionary +( + id UInt64, + v1 String, + v2 Nullable(String) DEFAULT NULL, + v3 Nullable(UInt64) +) +PRIMARY KEY id +SOURCE(CLICKHOUSE(TABLE 'dictionary_source_table')) +LAYOUT(DIRECT()) diff --git a/tests/ast_json_fixtures/shapes/926f3c8b3108a241.json b/tests/ast_json_fixtures/shapes/926f3c8b3108a241.json new file mode 100644 index 000000000000..87d90dea62dc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/926f3c8b3108a241.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/926f3c8b3108a241.sql b/tests/ast_json_fixtures/shapes/926f3c8b3108a241.sql new file mode 100644 index 000000000000..13964c4aeb7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/926f3c8b3108a241.sql @@ -0,0 +1 @@ +EXPLAIN SYNTAX SELECT number FROM numbers_mt(1000) GROUP BY number FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/9274cf4b14d07752.json b/tests/ast_json_fixtures/shapes/9274cf4b14d07752.json new file mode 100644 index 000000000000..83b22aa96734 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9274cf4b14d07752.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tbl" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "assignments": [ + { + "type": "Assignment", + "column": "a", + "expression": { + "type": "Identifier", + "name": "xi" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9274cf4b14d07752.sql b/tests/ast_json_fixtures/shapes/9274cf4b14d07752.sql new file mode 100644 index 000000000000..407c5d0de9cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9274cf4b14d07752.sql @@ -0,0 +1 @@ +ALTER TABLE tbl UPDATE a = xi WHERE 1 diff --git a/tests/ast_json_fixtures/shapes/927867ae156e9bc0.json b/tests/ast_json_fixtures/shapes/927867ae156e9bc0.json new file mode 100644 index 000000000000..e8ee32d7fdf3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/927867ae156e9bc0.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_03176" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "settings": { + "type": "Settings", + "changes": { + "log_comment": "03176_q1" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "indexes": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/927867ae156e9bc0.sql b/tests/ast_json_fixtures/shapes/927867ae156e9bc0.sql new file mode 100644 index 000000000000..02aced9f6787 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/927867ae156e9bc0.sql @@ -0,0 +1 @@ +EXPLAIN indexes = 1 SELECT * FROM t_03176 ORDER BY k LIMIT 5 SETTINGS log_comment = '03176_q1' FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/929025a27cc86c0f.json b/tests/ast_json_fixtures/shapes/929025a27cc86c0f.json new file mode 100644 index 000000000000..036e88d67bf0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/929025a27cc86c0f.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "JSONDynamicPaths", + "arguments": [ + { + "type": "Identifier", + "name": "json" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_updates" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/929025a27cc86c0f.sql b/tests/ast_json_fixtures/shapes/929025a27cc86c0f.sql new file mode 100644 index 000000000000..ef3ddbe9c833 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/929025a27cc86c0f.sql @@ -0,0 +1 @@ +select distinct arrayJoin(JSONDynamicPaths(json)) from test_updates order by all diff --git a/tests/ast_json_fixtures/shapes/92aa2a439e500ee8.json b/tests/ast_json_fixtures/shapes/92aa2a439e500ee8.json new file mode 100644 index 000000000000..2e57cf8fea0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/92aa2a439e500ee8.json @@ -0,0 +1,212 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "known_tables", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "asynchronous_metric_log" + }, + { + "value_type": "String", + "value": "asynchronous_insert_log" + }, + { + "value_type": "String", + "value": "opentelemetry_span_log" + }, + { + "value_type": "String", + "value": "coverage_log" + } + ] + }, + { + "type": "Literal", + "alias": "default_sorting_key", + "value_type": "String", + "value": "event_date, event_time" + } + ], + "select": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Table " + }, + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": " has non-default sorting key: " + }, + { + "type": "Identifier", + "name": "sorting_key" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tables", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Literal", + "value_type": "String", + "value": "system" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "engine" + }, + { + "type": "Literal", + "value_type": "String", + "value": "MergeTree" + } + ] + }, + { + "type": "Function", + "name": "notLike", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "minio%" + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arraySum", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "position", + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "known_tables" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "sorting_key" + }, + { + "type": "Identifier", + "name": "default_sorting_key" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/92aa2a439e500ee8.sql b/tests/ast_json_fixtures/shapes/92aa2a439e500ee8.sql new file mode 100644 index 000000000000..4f120f343c7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/92aa2a439e500ee8.sql @@ -0,0 +1,7 @@ +WITH + ['asynchronous_metric_log', 'asynchronous_insert_log', 'opentelemetry_span_log', 'coverage_log'] AS known_tables, + 'event_date, event_time' as default_sorting_key +SELECT + 'Table ' || name || ' has non-default sorting key: ' || sorting_key +FROM system.tables +WHERE (database = 'system') AND (engine = 'MergeTree') AND name not like 'minio%' AND (NOT arraySum(arrayMap(x -> position(name, x), known_tables))) AND (sorting_key != default_sorting_key) diff --git a/tests/ast_json_fixtures/shapes/92e3059d134eac9d.json b/tests/ast_json_fixtures/shapes/92e3059d134eac9d.json new file mode 100644 index 000000000000..6930ea254b9a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/92e3059d134eac9d.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "primary_key": { + "type": "Identifier", + "name": "key" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/92e3059d134eac9d.sql b/tests/ast_json_fixtures/shapes/92e3059d134eac9d.sql new file mode 100644 index 000000000000..740bcc4941c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/92e3059d134eac9d.sql @@ -0,0 +1,7 @@ +CREATE TABLE t0 ( + key Int32, + value Int32 +) +ENGINE=MergeTree() +PRIMARY KEY key +PARTITION BY key % 2 diff --git a/tests/ast_json_fixtures/shapes/92f8794a5de9fc0f.json b/tests/ast_json_fixtures/shapes/92f8794a5de9fc0f.json new file mode 100644 index 000000000000..8b5fa31a2f73 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/92f8794a5de9fc0f.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "t_shared" + }, + "assignments": [ + { + "type": "Assignment", + "column": "c1", + "expression": { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + ], + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/92f8794a5de9fc0f.sql b/tests/ast_json_fixtures/shapes/92f8794a5de9fc0f.sql new file mode 100644 index 000000000000..7592245ae2ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/92f8794a5de9fc0f.sql @@ -0,0 +1 @@ +UPDATE t_shared SET c1 = c1 * 10 WHERE id % 2 = 0 diff --git a/tests/ast_json_fixtures/shapes/93291e8657acdf9f.json b/tests/ast_json_fixtures/shapes/93291e8657acdf9f.json new file mode 100644 index 000000000000..b99c70251649 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/93291e8657acdf9f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r9_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/93291e8657acdf9f.sql b/tests/ast_json_fixtures/shapes/93291e8657acdf9f.sql new file mode 100644 index 000000000000..c0558782fb46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/93291e8657acdf9f.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r9_01293 diff --git a/tests/ast_json_fixtures/shapes/933748b92998e66c.json b/tests/ast_json_fixtures/shapes/933748b92998e66c.json new file mode 100644 index 000000000000..bc0bbf1c65fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/933748b92998e66c.json @@ -0,0 +1,187 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "test1", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "alias": "b", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "alias": "m", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "with_test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "alias": "m", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "test1.m", + "name_parts": ["test1", "m"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "43" + } + ] + } + ] + }, + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "m" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/933748b92998e66c.sql b/tests/ast_json_fixtures/shapes/933748b92998e66c.sql new file mode 100644 index 000000000000..0edd32af655a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/933748b92998e66c.sql @@ -0,0 +1,2 @@ +WITH test1 AS (SELECT n, null b, n+1 m FROM with_test where n = 42 order by n limit 4) +SELECT max(n) m FROM test1 where b is null and test1.m=43 having m=42 limit 4 diff --git a/tests/ast_json_fixtures/shapes/93431fab3f0374ad.json b/tests/ast_json_fixtures/shapes/93431fab3f0374ad.json new file mode 100644 index 000000000000..534b76aa25e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/93431fab3f0374ad.json @@ -0,0 +1,138 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "database": { + "type": "Identifier", + "name": "db_01268" + }, + "table": { + "type": "Identifier", + "name": "dict2" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "region_id", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "parent_region", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "hierarchical": true + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "region_name", + "data_type": { + "type": "DataType", + "name": "String" + }, + "default_value": { + "type": "Literal", + "value_type": "String", + "value": "" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "region_id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "user", + "value": { + "type": "Literal", + "value_type": "String", + "value": "default" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "table_for_dict2" + } + }, + { + "type": "pair", + "key": "password", + "value": { + "type": "Literal", + "value_type": "String", + "value": "" + } + }, + { + "type": "pair", + "key": "db", + "value": { + "type": "Literal", + "value_type": "String", + "value": "database_for_dict_01268" + } + } + ] + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "direct", + "parameters": [] + }, + "settings": { + "type": "DictionarySettings", + "changes": { + "dictionary_use_async_executor": "1", + "max_threads": "8" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/93431fab3f0374ad.sql b/tests/ast_json_fixtures/shapes/93431fab3f0374ad.sql new file mode 100644 index 000000000000..dd26bb8f6176 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/93431fab3f0374ad.sql @@ -0,0 +1,9 @@ +CREATE DICTIONARY db_01268.dict2 +( + region_id UInt64 DEFAULT 0, + parent_region UInt64 DEFAULT 0 HIERARCHICAL, + region_name String DEFAULT '' +) +PRIMARY KEY region_id +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict2' PASSWORD '' DB 'database_for_dict_01268')) +LAYOUT(DIRECT()) SETTINGS(dictionary_use_async_executor=1, max_threads=8) diff --git a/tests/ast_json_fixtures/shapes/9349b8e9acfeb2a3.json b/tests/ast_json_fixtures/shapes/9349b8e9acfeb2a3.json new file mode 100644 index 000000000000..8370f4e1bed9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9349b8e9acfeb2a3.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "RELOAD DICTIONARIES" + } +} diff --git a/tests/ast_json_fixtures/shapes/9349b8e9acfeb2a3.sql b/tests/ast_json_fixtures/shapes/9349b8e9acfeb2a3.sql new file mode 100644 index 000000000000..cb4d074be252 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9349b8e9acfeb2a3.sql @@ -0,0 +1 @@ +SYSTEM RELOAD DICTIONARIES diff --git a/tests/ast_json_fixtures/shapes/9359ad25358cda88.json b/tests/ast_json_fixtures/shapes/9359ad25358cda88.json new file mode 100644 index 000000000000..ccc56fc91a57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9359ad25358cda88.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "dictionary": true, + "elements": [ + { + "from_database": "test_01191", + "from_table": "t", + "to_database": "test_01191", + "to_table": "dict1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9359ad25358cda88.sql b/tests/ast_json_fixtures/shapes/9359ad25358cda88.sql new file mode 100644 index 000000000000..cebe63d97443 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9359ad25358cda88.sql @@ -0,0 +1 @@ +RENAME DICTIONARY test_01191.t TO test_01191.dict1 diff --git a/tests/ast_json_fixtures/shapes/936a21c45ebdaa4f.json b/tests/ast_json_fixtures/shapes/936a21c45ebdaa4f.json new file mode 100644 index 000000000000..ba7f04db811b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/936a21c45ebdaa4f.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "limit_with_ties": true, + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "wt" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/936a21c45ebdaa4f.sql b/tests/ast_json_fixtures/shapes/936a21c45ebdaa4f.sql new file mode 100644 index 000000000000..ccee16577a71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/936a21c45ebdaa4f.sql @@ -0,0 +1 @@ +select 1 from wt order by a limit 3 with ties diff --git a/tests/ast_json_fixtures/shapes/937464b27459a458.json b/tests/ast_json_fixtures/shapes/937464b27459a458.json new file mode 100644 index 000000000000..c491fdb9f8d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/937464b27459a458.json @@ -0,0 +1,113 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "isConstant", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "a", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "b", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "alias": "y", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/937464b27459a458.sql b/tests/ast_json_fixtures/shapes/937464b27459a458.sql new file mode 100644 index 000000000000..90b867063fd8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/937464b27459a458.sql @@ -0,0 +1 @@ +select null, isConstant(null), * from (select 2 x) a left join (select null, 3 y) b on y = x diff --git a/tests/ast_json_fixtures/shapes/939f11116f7ef292.json b/tests/ast_json_fixtures/shapes/939f11116f7ef292.json new file mode 100644 index 000000000000..fdaadf77f38e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/939f11116f7ef292.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["READ"], + "parameter": "URL" + }, + { + "access_types": ["WRITE"], + "parameter": "URL" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_03593"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/939f11116f7ef292.sql b/tests/ast_json_fixtures/shapes/939f11116f7ef292.sql new file mode 100644 index 000000000000..96c465d5ebd3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/939f11116f7ef292.sql @@ -0,0 +1 @@ +GRANT READ,WRITE ON URL TO test_user_03593 diff --git a/tests/ast_json_fixtures/shapes/93aee82f20db92e6.json b/tests/ast_json_fixtures/shapes/93aee82f20db92e6.json new file mode 100644 index 000000000000..bc36a34a74ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/93aee82f20db92e6.json @@ -0,0 +1,128 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "alias": "k", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "." + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "k" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/93aee82f20db92e6.sql b/tests/ast_json_fixtures/shapes/93aee82f20db92e6.sql new file mode 100644 index 000000000000..c00ea5fa6f25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/93aee82f20db92e6.sql @@ -0,0 +1 @@ +SELECT arrayMap(x -> '.', range(number % 10)) AS k FROM remote('127.0.0.{2,3}', numbers(10)) GROUP BY GROUPING SETS ((k)) ORDER BY k settings group_by_use_nulls=1 diff --git a/tests/ast_json_fixtures/shapes/93e1c14aae9024e6.json b/tests/ast_json_fixtures/shapes/93e1c14aae9024e6.json new file mode 100644 index 000000000000..659e1b4dcd9a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/93e1c14aae9024e6.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "03717_table" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03717_table" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/93e1c14aae9024e6.sql b/tests/ast_json_fixtures/shapes/93e1c14aae9024e6.sql new file mode 100644 index 000000000000..6790c0b03ba8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/93e1c14aae9024e6.sql @@ -0,0 +1 @@ +select '03717_table', * from 03717_table order by all diff --git a/tests/ast_json_fixtures/shapes/9403cf1876551b63.json b/tests/ast_json_fixtures/shapes/9403cf1876551b63.json new file mode 100644 index 000000000000..c4b12718aa5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9403cf1876551b63.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "mutations", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "is_done" + } + ] + } + ] + } + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/9403cf1876551b63.sql b/tests/ast_json_fixtures/shapes/9403cf1876551b63.sql new file mode 100644 index 000000000000..98789394534f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9403cf1876551b63.sql @@ -0,0 +1 @@ +select * from system.mutations where database = currentDatabase() and not is_done format Vertical diff --git a/tests/ast_json_fixtures/shapes/94131d7a28859a5f.json b/tests/ast_json_fixtures/shapes/94131d7a28859a5f.json new file mode 100644 index 000000000000..3b15d72bf826 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94131d7a28859a5f.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "mode", + "value_type": "String", + "value": "aes-256-ecb" + }, + { + "type": "Function", + "alias": "ciphertext", + "name": "unhex", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "D1B43643E1D0E9390E39BA4EAE150851" + } + ] + }, + { + "type": "Literal", + "alias": "key", + "value_type": "String", + "value": "test_key________________________" + } + ], + "select": [ + { + "type": "Function", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "aes_decrypt_mysql", + "arguments": [ + { + "type": "Identifier", + "name": "mode" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Identifier", + "name": "ciphertext" + } + ] + }, + { + "type": "Identifier", + "name": "key" + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/94131d7a28859a5f.sql b/tests/ast_json_fixtures/shapes/94131d7a28859a5f.sql new file mode 100644 index 000000000000..7f4c0ef2dd71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94131d7a28859a5f.sql @@ -0,0 +1,2 @@ +WITH 'aes-256-ecb' as mode, unhex('D1B43643E1D0E9390E39BA4EAE150851') as ciphertext, 'test_key________________________' as key +SELECT hex(aes_decrypt_mysql(mode, toNullable(ciphertext), key)) diff --git a/tests/ast_json_fixtures/shapes/94146db795d69da9.json b/tests/ast_json_fixtures/shapes/94146db795d69da9.json new file mode 100644 index 000000000000..d619750ceb0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94146db795d69da9.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02484_plusthreedays" + } +} diff --git a/tests/ast_json_fixtures/shapes/94146db795d69da9.sql b/tests/ast_json_fixtures/shapes/94146db795d69da9.sql new file mode 100644 index 000000000000..23b8649201ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94146db795d69da9.sql @@ -0,0 +1 @@ +DROP FUNCTION 02484_plusthreedays diff --git a/tests/ast_json_fixtures/shapes/9426455b6778c634.json b/tests/ast_json_fixtures/shapes/9426455b6778c634.json new file mode 100644 index 000000000000..19df5e5ac4b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9426455b6778c634.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "lambda", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Literal", + "alias": "lambda", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9426455b6778c634.sql b/tests/ast_json_fixtures/shapes/9426455b6778c634.sql new file mode 100644 index 000000000000..a3b8091faa4f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9426455b6778c634.sql @@ -0,0 +1 @@ +WITH x -> x + 1 AS lambda SELECT 1 AS lambda diff --git a/tests/ast_json_fixtures/shapes/942bf50356c4bb1a.json b/tests/ast_json_fixtures/shapes/942bf50356c4bb1a.json new file mode 100644 index 000000000000..ea1d2dde64bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/942bf50356c4bb1a.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u4_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "PLAINTEXT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "123qwe" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/942bf50356c4bb1a.sql b/tests/ast_json_fixtures/shapes/942bf50356c4bb1a.sql new file mode 100644 index 000000000000..eb35a8fd78a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/942bf50356c4bb1a.sql @@ -0,0 +1 @@ +ALTER USER u4_01292 IDENTIFIED WITH plaintext_password BY '123qwe' diff --git a/tests/ast_json_fixtures/shapes/9436b8eacc29afeb.json b/tests/ast_json_fixtures/shapes/9436b8eacc29afeb.json new file mode 100644 index 000000000000..ed1a1ccef6d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9436b8eacc29afeb.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distributed_01099_a" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "local_01099_a" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "local_01099_a" + } +} diff --git a/tests/ast_json_fixtures/shapes/9436b8eacc29afeb.sql b/tests/ast_json_fixtures/shapes/9436b8eacc29afeb.sql new file mode 100644 index 000000000000..f22d03fb0b76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9436b8eacc29afeb.sql @@ -0,0 +1 @@ +CREATE TABLE distributed_01099_a AS local_01099_a ENGINE = Distributed('test_shard_localhost', currentDatabase(), local_01099_a, rand()) diff --git a/tests/ast_json_fixtures/shapes/943d9b57c97a4e77.json b/tests/ast_json_fixtures/shapes/943d9b57c97a4e77.json new file mode 100644 index 000000000000..79b99d63d04b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/943d9b57c97a4e77.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DetachQuery", + "kind": "DETACH", + "temporary": true, + "table": { + "type": "Identifier", + "name": "tmp" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/943d9b57c97a4e77.sql b/tests/ast_json_fixtures/shapes/943d9b57c97a4e77.sql new file mode 100644 index 000000000000..6574fe96274a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/943d9b57c97a4e77.sql @@ -0,0 +1 @@ +DETACH TEMPORARY TABLE tmp diff --git a/tests/ast_json_fixtures/shapes/94598e81da69d4af.json b/tests/ast_json_fixtures/shapes/94598e81da69d4af.json new file mode 100644 index 000000000000..fcc280843fb5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94598e81da69d4af.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "SYNC REPLICA", + "table": { + "type": "Identifier", + "name": "rmt1" + }, + "sync_replica_mode": "LIGHTWEIGHT" + } +} diff --git a/tests/ast_json_fixtures/shapes/94598e81da69d4af.sql b/tests/ast_json_fixtures/shapes/94598e81da69d4af.sql new file mode 100644 index 000000000000..dbda881900ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94598e81da69d4af.sql @@ -0,0 +1 @@ +system sync replica rmt1 lightweight diff --git a/tests/ast_json_fixtures/shapes/945dd96bfadf190a.json b/tests/ast_json_fixtures/shapes/945dd96bfadf190a.json new file mode 100644 index 000000000000..e408e0d78c89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/945dd96bfadf190a.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s7_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "writability": "WRITABLE" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/945dd96bfadf190a.sql b/tests/ast_json_fixtures/shapes/945dd96bfadf190a.sql new file mode 100644 index 000000000000..59aa62e7d398 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/945dd96bfadf190a.sql @@ -0,0 +1 @@ +CREATE PROFILE s7_01294 SETTINGS max_memory_usage WRITABLE diff --git a/tests/ast_json_fixtures/shapes/94b0a41d53e82ca8.json b/tests/ast_json_fixtures/shapes/94b0a41d53e82ca8.json new file mode 100644 index 000000000000..c6b03cdf87ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94b0a41d53e82ca8.json @@ -0,0 +1,128 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "A.k", + "name_parts": ["A", "k"] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "A.t", + "name_parts": ["A", "t"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + }, + { + "type": "Identifier", + "name": "A.a", + "name_parts": ["A", "a"] + }, + { + "type": "Identifier", + "name": "B.b", + "name_parts": ["B", "b"] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "B.t", + "name_parts": ["B", "t"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + }, + { + "type": "Identifier", + "name": "B.k", + "name_parts": ["B", "k"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "A" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "strictness": "ASOF", + "using": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Identifier", + "name": "t" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "B" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "A.k", + "name_parts": ["A", "k"] + }, + { + "type": "Identifier", + "name": "A.t", + "name_parts": ["A", "t"] + } + ] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/94b0a41d53e82ca8.sql b/tests/ast_json_fixtures/shapes/94b0a41d53e82ca8.sql new file mode 100644 index 000000000000..58ebf794479e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94b0a41d53e82ca8.sql @@ -0,0 +1 @@ +SELECT A.k, toString(A.t, 'UTC'), A.a, B.b, toString(B.t, 'UTC'), B.k FROM A ASOF JOIN B USING(k,t) ORDER BY (A.k, A.t) diff --git a/tests/ast_json_fixtures/shapes/94b360f1e49739f4.json b/tests/ast_json_fixtures/shapes/94b360f1e49739f4.json new file mode 100644 index 000000000000..e9dd99c158ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94b360f1e49739f4.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "full_duplicates" + }, + "deduplicate": true, + "deduplicate_by_columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "sk" + }, + { + "type": "Identifier", + "name": "val" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/94b360f1e49739f4.sql b/tests/ast_json_fixtures/shapes/94b360f1e49739f4.sql new file mode 100644 index 000000000000..0f5b022cb687 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94b360f1e49739f4.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE full_duplicates DEDUPLICATE BY sk, val diff --git a/tests/ast_json_fixtures/shapes/94c2d6d8fb762ff9.json b/tests/ast_json_fixtures/shapes/94c2d6d8fb762ff9.json new file mode 100644 index 000000000000..933c30e1db65 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94c2d6d8fb762ff9.json @@ -0,0 +1,136 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "g" + }, + { + "type": "Identifier", + "name": "s" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "g" + }, + { + "type": "Function", + "alias": "s", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "alias": "g", + "name": "bitAnd", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "g" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "INNER", + "expressions": [ + { + "type": "Literal", + "alias": "a", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + ] + } + } + ], + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/94c2d6d8fb762ff9.sql b/tests/ast_json_fixtures/shapes/94c2d6d8fb762ff9.sql new file mode 100644 index 000000000000..3e9f7e47ab4c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94c2d6d8fb762ff9.sql @@ -0,0 +1 @@ +select g, s from (select g, sum(number) as s from numbers(4) group by bitAnd(number, 1) as g with totals order by g) array join [1, 2] as a format JSON diff --git a/tests/ast_json_fixtures/shapes/94c4698ff6d12afd.json b/tests/ast_json_fixtures/shapes/94c4698ff6d12afd.json new file mode 100644 index 000000000000..d0c61bcd3db6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94c4698ff6d12afd.json @@ -0,0 +1,193 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000000" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + ], + "having": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/94c4698ff6d12afd.sql b/tests/ast_json_fixtures/shapes/94c4698ff6d12afd.sql new file mode 100644 index 000000000000..d8a887f5371e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94c4698ff6d12afd.sql @@ -0,0 +1 @@ +SELECT (number % 5) * (number % 5) AS k FROM numbers(10000000) GROUP BY number % 5, ((number % 5) * (number % 5)) HAVING ((number % 5) * (number % 5)) < 5 ORDER BY k diff --git a/tests/ast_json_fixtures/shapes/94de775ee3ec31be.json b/tests/ast_json_fixtures/shapes/94de775ee3ec31be.json new file mode 100644 index 000000000000..a120373343e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94de775ee3ec31be.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "m" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "f" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_move_to_prewhere": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/94de775ee3ec31be.sql b/tests/ast_json_fixtures/shapes/94de775ee3ec31be.sql new file mode 100644 index 000000000000..e614387a3fa1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94de775ee3ec31be.sql @@ -0,0 +1 @@ +SELECT * FROM m WHERE f = 0 SETTINGS optimize_move_to_prewhere=0 diff --git a/tests/ast_json_fixtures/shapes/94f49301e8877919.json b/tests/ast_json_fixtures/shapes/94f49301e8877919.json new file mode 100644 index 000000000000..151651edc720 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94f49301e8877919.json @@ -0,0 +1,161 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "246" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "arrayStringConcat", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reinterpretAsString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "TabSeparatedRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/94f49301e8877919.sql b/tests/ast_json_fixtures/shapes/94f49301e8877919.sql new file mode 100644 index 000000000000..0b47bd13f268 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/94f49301e8877919.sql @@ -0,0 +1 @@ +SELECT number * 246 + 10 AS n, toDate('2000-01-01') + n AS d, range(n) AS arr, arrayStringConcat(arrayMap(x -> reinterpretAsString(x), arr)) AS s, (n, d) AS tuple FROM system.numbers LIMIT 2 FORMAT TabSeparatedRaw diff --git a/tests/ast_json_fixtures/shapes/953f01e251cfc99e.json b/tests/ast_json_fixtures/shapes/953f01e251cfc99e.json new file mode 100644 index 000000000000..1b2b2fa93829 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/953f01e251cfc99e.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "s3", + "arguments": [ + { + "type": "Identifier", + "name": "s3_conn" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "filename" + }, + { + "type": "Literal", + "value_type": "String", + "value": "t_03363_parquet" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "format" + }, + { + "type": "Identifier", + "name": "Parquet" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "partition_strategy" + }, + { + "type": "Literal", + "value_type": "String", + "value": "hive" + } + ] + } + ] + }, + "partition_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "year" + }, + { + "type": "Identifier", + "name": "country" + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "year", + "value_type": "UInt64", + "value": "2020" + }, + { + "type": "Literal", + "alias": "country", + "value_type": "String", + "value": "Brazil" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/953f01e251cfc99e.sql b/tests/ast_json_fixtures/shapes/953f01e251cfc99e.sql new file mode 100644 index 000000000000..5172040f6dcd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/953f01e251cfc99e.sql @@ -0,0 +1 @@ +INSERT INTO FUNCTION s3(s3_conn, filename='t_03363_parquet', format=Parquet, partition_strategy='hive') PARTITION BY (year, country) SELECT 2020 as year, 'Brazil' as country diff --git a/tests/ast_json_fixtures/shapes/95450e4648990d8e.json b/tests/ast_json_fixtures/shapes/95450e4648990d8e.json new file mode 100644 index 000000000000..ac8351b2791f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/95450e4648990d8e.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "if_exists": true, + "database_and_tables": { + "type": "ExpressionList", + "children": [ + { + "type": "TableIdentifier", + "name": "test" + }, + { + "type": "TableIdentifier", + "name": "src" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/95450e4648990d8e.sql b/tests/ast_json_fixtures/shapes/95450e4648990d8e.sql new file mode 100644 index 000000000000..26c1469fd95d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/95450e4648990d8e.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS test, src diff --git a/tests/ast_json_fixtures/shapes/9584dc43a565ee49.json b/tests/ast_json_fixtures/shapes/9584dc43a565ee49.json new file mode 100644 index 000000000000..854ebcb03a28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9584dc43a565ee49.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r3_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/9584dc43a565ee49.sql b/tests/ast_json_fixtures/shapes/9584dc43a565ee49.sql new file mode 100644 index 000000000000..86515b71ecf1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9584dc43a565ee49.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r3_01293 diff --git a/tests/ast_json_fixtures/shapes/95a599b148fe7fea.json b/tests/ast_json_fixtures/shapes/95a599b148fe7fea.json new file mode 100644 index 000000000000..b939c153d11e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/95a599b148fe7fea.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Identifier", + "name": "c0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0__fuzz_41" + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/95a599b148fe7fea.sql b/tests/ast_json_fixtures/shapes/95a599b148fe7fea.sql new file mode 100644 index 000000000000..28a920487d9a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/95a599b148fe7fea.sql @@ -0,0 +1 @@ +SELECT multiIf(0, 2, 1, materialize(3), 4), c0 FROM t0__fuzz_41 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/95ce6a72fd6d4f31.json b/tests/ast_json_fixtures/shapes/95ce6a72fd6d4f31.json new file mode 100644 index 000000000000..6bd38f094dc9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/95ce6a72fd6d4f31.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/95ce6a72fd6d4f31.sql b/tests/ast_json_fixtures/shapes/95ce6a72fd6d4f31.sql new file mode 100644 index 000000000000..36d27d09c435 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/95ce6a72fd6d4f31.sql @@ -0,0 +1 @@ +select * from test where i < 20 order by i limit 1 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/9605d7305a84108d.json b/tests/ast_json_fixtures/shapes/9605d7305a84108d.json new file mode 100644 index 000000000000..8051d9923adb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9605d7305a84108d.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "hello" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "hello" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9605d7305a84108d.sql b/tests/ast_json_fixtures/shapes/9605d7305a84108d.sql new file mode 100644 index 000000000000..ba5a9275752f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9605d7305a84108d.sql @@ -0,0 +1 @@ +SELECT 'hello' UNION ALL SELECT toLowCardinality('hello') diff --git a/tests/ast_json_fixtures/shapes/9609bc7114316bc0.json b/tests/ast_json_fixtures/shapes/9609bc7114316bc0.json new file mode 100644 index 000000000000..ac024150fc0a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9609bc7114316bc0.json @@ -0,0 +1,138 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_shard_num" + }, + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "b.host_name", + "name_parts": ["b", "host_name"] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b.host_address", + "name_parts": ["b", "host_address"] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "String", + "value": "::1" + }, + { + "value_type": "String", + "value": "127.0.0.1" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "b.port", + "name_parts": ["b", "port"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "a", + "name": "dist_1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_shard_num" + }, + { + "type": "Identifier", + "name": "b.shard_num", + "name_parts": ["b", "shard_num"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "b", + "name": "clusters", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b.cluster", + "name_parts": ["b", "cluster"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards_localhost" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9609bc7114316bc0.sql b/tests/ast_json_fixtures/shapes/9609bc7114316bc0.sql new file mode 100644 index 000000000000..0c1740348c2d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9609bc7114316bc0.sql @@ -0,0 +1,7 @@ +SELECT _shard_num, key, b.host_name, b.host_address IN ('::1', '127.0.0.1'), b.port +FROM dist_1 a +JOIN system.clusters b +ON _shard_num = b.shard_num +WHERE b.cluster = 'test_cluster_two_shards_localhost' +ORDER BY key +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/961159f79046c88b.json b/tests/ast_json_fixtures/shapes/961159f79046c88b.json new file mode 100644 index 000000000000..10b75156f920 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/961159f79046c88b.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "a" + }, + "order_by": { + "type": "Identifier", + "name": "a" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/961159f79046c88b.sql b/tests/ast_json_fixtures/shapes/961159f79046c88b.sql new file mode 100644 index 000000000000..a3775b0f531f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/961159f79046c88b.sql @@ -0,0 +1 @@ +create table test (a String) Engine MergeTree order by a partition by a diff --git a/tests/ast_json_fixtures/shapes/9624f684f0616999.json b/tests/ast_json_fixtures/shapes/9624f684f0616999.json new file mode 100644 index 000000000000..6f9460bc120e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9624f684f0616999.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "table_with_complex_default" + }, + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/9624f684f0616999.sql b/tests/ast_json_fixtures/shapes/9624f684f0616999.sql new file mode 100644 index 000000000000..f6d61ba268c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9624f684f0616999.sql @@ -0,0 +1,3 @@ +INSERT INTO table_with_complex_default FORMAT JSONEachRow {"i":0, "n": 0} + +SELECT * FROM table_with_complex_default diff --git a/tests/ast_json_fixtures/shapes/96639807969b49ad.json b/tests/ast_json_fixtures/shapes/96639807969b49ad.json new file mode 100644 index 000000000000..e32698c2d5d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96639807969b49ad.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "l", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "arr" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "prewhere_column_missing" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/96639807969b49ad.sql b/tests/ast_json_fixtures/shapes/96639807969b49ad.sql new file mode 100644 index 000000000000..f1105d7336ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96639807969b49ad.sql @@ -0,0 +1 @@ +select *, length(arr) as l from prewhere_column_missing prewhere l = 0 diff --git a/tests/ast_json_fixtures/shapes/966beb492754cc26.json b/tests/ast_json_fixtures/shapes/966beb492754cc26.json new file mode 100644 index 000000000000..0251d04acb7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/966beb492754cc26.json @@ -0,0 +1,104 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "xx" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "date", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "clicks", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "price", + "data_type": { + "type": "DataType", + "name": "Float64" + } + }, + { + "type": "ColumnDeclaration", + "name": "spend", + "data_type": { + "type": "DataType", + "name": "Float64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "SummingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "price" + }, + { + "type": "Identifier", + "name": "spend" + } + ] + } + ] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "id" + }, + "sample_by": { + "type": "Identifier", + "name": "id" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/966beb492754cc26.sql b/tests/ast_json_fixtures/shapes/966beb492754cc26.sql new file mode 100644 index 000000000000..6bd9051fdf6d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/966beb492754cc26.sql @@ -0,0 +1,13 @@ +CREATE TABLE xx +( + `date` Date, + `id` Int64, + `clicks` Int64, + `price` Float64, + `spend` Float64 +) +ENGINE = SummingMergeTree([price, spend]) +PARTITION BY toYYYYMM(date) +ORDER BY id +SAMPLE BY id +SETTINGS index_granularity = 8192 diff --git a/tests/ast_json_fixtures/shapes/968eefae852031a9.json b/tests/ast_json_fixtures/shapes/968eefae852031a9.json new file mode 100644 index 000000000000..51852f1f1221 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/968eefae852031a9.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "dictionary": true, + "elements": [ + { + "from_database": "test_01155_atomic", + "from_table": "dict", + "to_database": "test_01155_ordinary", + "to_table": "dict" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/968eefae852031a9.sql b/tests/ast_json_fixtures/shapes/968eefae852031a9.sql new file mode 100644 index 000000000000..5b24ca7db229 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/968eefae852031a9.sql @@ -0,0 +1 @@ +RENAME DICTIONARY test_01155_atomic.dict TO test_01155_ordinary.dict diff --git a/tests/ast_json_fixtures/shapes/96b9f88af3d9c2fa.json b/tests/ast_json_fixtures/shapes/96b9f88af3d9c2fa.json new file mode 100644 index 000000000000..7bf6345f27e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96b9f88af3d9c2fa.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "primary_key_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "v", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "v" + }, + "order_by": { + "type": "Identifier", + "name": "v" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/96b9f88af3d9c2fa.sql b/tests/ast_json_fixtures/shapes/96b9f88af3d9c2fa.sql new file mode 100644 index 000000000000..eaca37037613 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96b9f88af3d9c2fa.sql @@ -0,0 +1 @@ +CREATE TABLE primary_key_test(v Int32) ENGINE=ReplacingMergeTree ORDER BY v PRIMARY KEY(v) diff --git a/tests/ast_json_fixtures/shapes/96c6ba8a2c5559aa.json b/tests/ast_json_fixtures/shapes/96c6ba8a2c5559aa.json new file mode 100644 index 000000000000..afad30d617d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96c6ba8a2c5559aa.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "distributed_push_down_limit": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/96c6ba8a2c5559aa.sql b/tests/ast_json_fixtures/shapes/96c6ba8a2c5559aa.sql new file mode 100644 index 000000000000..7e46b6758185 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96c6ba8a2c5559aa.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number offset 1 settings distributed_push_down_limit=0 diff --git a/tests/ast_json_fixtures/shapes/96d2f263bdfb763d.json b/tests/ast_json_fixtures/shapes/96d2f263bdfb763d.json new file mode 100644 index 000000000000..a90b633cdeb1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96d2f263bdfb763d.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "ORDERS" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "ORDERS_shard" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "ORDERS_shard" + } +} diff --git a/tests/ast_json_fixtures/shapes/96d2f263bdfb763d.sql b/tests/ast_json_fixtures/shapes/96d2f263bdfb763d.sql new file mode 100644 index 000000000000..4851ba911f89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96d2f263bdfb763d.sql @@ -0,0 +1,2 @@ +CREATE TABLE ORDERS AS ORDERS_shard +ENGINE = Distributed('test_shard_localhost', currentDatabase(), ORDERS_shard, rand()) diff --git a/tests/ast_json_fixtures/shapes/96d7a5f36efeef7e.json b/tests/ast_json_fixtures/shapes/96d7a5f36efeef7e.json new file mode 100644 index 000000000000..fcd5e3cd0cf7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96d7a5f36efeef7e.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "qualify": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/96d7a5f36efeef7e.sql b/tests/ast_json_fixtures/shapes/96d7a5f36efeef7e.sql new file mode 100644 index 000000000000..8f6a927d6ed8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96d7a5f36efeef7e.sql @@ -0,0 +1 @@ +SELECT number FROM numbers(10) QUALIFY number > 5 ORDER BY number diff --git a/tests/ast_json_fixtures/shapes/96df5e0d4a90c745.json b/tests/ast_json_fixtures/shapes/96df5e0d4a90c745.json new file mode 100644 index 000000000000..d79b244fe115 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96df5e0d4a90c745.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "attach_partition_t8" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "1" + } + }, + "replace": false, + "from_table": "attach_partition_t7" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/96df5e0d4a90c745.sql b/tests/ast_json_fixtures/shapes/96df5e0d4a90c745.sql new file mode 100644 index 000000000000..52d1ec3d8796 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96df5e0d4a90c745.sql @@ -0,0 +1 @@ +ALTER TABLE attach_partition_t8 ATTACH PARTITION ID '1' FROM attach_partition_t7 diff --git a/tests/ast_json_fixtures/shapes/96e9fdfc4c4ec086.json b/tests/ast_json_fixtures/shapes/96e9fdfc4c4ec086.json new file mode 100644 index 000000000000..0fe8465a3700 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96e9fdfc4c4ec086.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "DISABLE FAILPOINT", + "fail_point_name": "slowdown_parallel_replicas_local_plan_read" + } +} diff --git a/tests/ast_json_fixtures/shapes/96e9fdfc4c4ec086.sql b/tests/ast_json_fixtures/shapes/96e9fdfc4c4ec086.sql new file mode 100644 index 000000000000..9061ccd4d770 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/96e9fdfc4c4ec086.sql @@ -0,0 +1 @@ +SYSTEM DISABLE FAILPOINT slowdown_parallel_replicas_local_plan_read diff --git a/tests/ast_json_fixtures/shapes/97049c960a62ad00.json b/tests/ast_json_fixtures/shapes/97049c960a62ad00.json new file mode 100644 index 000000000000..6796da15cbbd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/97049c960a62ad00.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "attach_from_path": "..\/..\/..\/..\/..\/..\/..\/..\/..\/etc\/passwd", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "File", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "TSVRaw" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/97049c960a62ad00.sql b/tests/ast_json_fixtures/shapes/97049c960a62ad00.sql new file mode 100644 index 000000000000..5f099aa581fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/97049c960a62ad00.sql @@ -0,0 +1 @@ +attach table test from '../../../../../../../../../etc/passwd' (s String) engine=File(TSVRaw) diff --git a/tests/ast_json_fixtures/shapes/971bbc499e5e6cf2.json b/tests/ast_json_fixtures/shapes/971bbc499e5e6cf2.json new file mode 100644 index 000000000000..6ef3271191b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/971bbc499e5e6cf2.json @@ -0,0 +1,134 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "p", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "alias": "o", + "name": "mod", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ], + "window_name": "w" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "31" + } + ] + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "p" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "o" + }, + "direction": "ASC" + } + ], + "frame_type": "RANGE", + "frame_begin": { + "type": "Unbounded", + "preceding": true + }, + "frame_end": { + "type": "Current" + } + } + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "5" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/971bbc499e5e6cf2.sql b/tests/ast_json_fixtures/shapes/971bbc499e5e6cf2.sql new file mode 100644 index 000000000000..06289433b472 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/971bbc499e5e6cf2.sql @@ -0,0 +1,5 @@ +select number, intDiv(number, 2) p, mod(number, 3) o, count(number) over w as c +from numbers(31) +window w as (partition by p order by o range unbounded preceding) +order by number +settings max_block_size = 5 diff --git a/tests/ast_json_fixtures/shapes/9728efb2860b5fba.json b/tests/ast_json_fixtures/shapes/9728efb2860b5fba.json new file mode 100644 index 000000000000..1859ac70fee1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9728efb2860b5fba.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u2_01292", + "host_pattern": "%.myhost.com" + } + ] + }, + "hosts": { + "like_patterns": ["%.myhost.com"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9728efb2860b5fba.sql b/tests/ast_json_fixtures/shapes/9728efb2860b5fba.sql new file mode 100644 index 000000000000..e08d85c3af96 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9728efb2860b5fba.sql @@ -0,0 +1 @@ +CREATE USER u2_01292@'%.myhost.com' diff --git a/tests/ast_json_fixtures/shapes/9755d5a2fe26a1ce.json b/tests/ast_json_fixtures/shapes/9755d5a2fe26a1ce.json new file mode 100644 index 000000000000..d4415c7c42a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9755d5a2fe26a1ce.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "grp_aggreg" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data_02295" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "grp_aggreg" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "0" + } + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/9755d5a2fe26a1ce.sql b/tests/ast_json_fixtures/shapes/9755d5a2fe26a1ce.sql new file mode 100644 index 000000000000..70d47ae4180e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9755d5a2fe26a1ce.sql @@ -0,0 +1 @@ +SELECT grp_aggreg FROM data_02295 GROUP BY a, grp_aggreg WITH TOTALS ORDER BY a SETTINGS optimize_aggregation_in_order = 0 FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/97706efd966524f7.json b/tests/ast_json_fixtures/shapes/97706efd966524f7.json new file mode 100644 index 000000000000..ad570da2f9a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/97706efd966524f7.json @@ -0,0 +1,94 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "Int" + } + }, + { + "type": "ColumnDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "number" + }, + { + "type": "Function", + "alias": "y", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/97706efd966524f7.sql b/tests/ast_json_fixtures/shapes/97706efd966524f7.sql new file mode 100644 index 000000000000..131c4383ee4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/97706efd966524f7.sql @@ -0,0 +1,2 @@ +CREATE TABLE t(x Int, y Int) ORDER BY () +AS SELECT number as x, number % 2 as y FROM numbers(100) diff --git a/tests/ast_json_fixtures/shapes/9779cdfebecaaf02.json b/tests/ast_json_fixtures/shapes/9779cdfebecaaf02.json new file mode 100644 index 000000000000..1c97740af418 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9779cdfebecaaf02.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "clear_column": true, + "column": { + "type": "Identifier", + "name": "x" + }, + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9779cdfebecaaf02.sql b/tests/ast_json_fixtures/shapes/9779cdfebecaaf02.sql new file mode 100644 index 000000000000..246e7312bef8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9779cdfebecaaf02.sql @@ -0,0 +1 @@ +ALTER TABLE test CLEAR COLUMN x IN PARTITION '' diff --git a/tests/ast_json_fixtures/shapes/9794dbde9ce6f864.json b/tests/ast_json_fixtures/shapes/9794dbde9ce6f864.json new file mode 100644 index 000000000000..4caf75f9432a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9794dbde9ce6f864.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "value", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "censor.net" + }, + { + "type": "Literal", + "value_type": "String", + "value": "google" + } + ] + }, + { + "type": "Identifier", + "name": "value" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9794dbde9ce6f864.sql b/tests/ast_json_fixtures/shapes/9794dbde9ce6f864.sql new file mode 100644 index 000000000000..88c02e9a92de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9794dbde9ce6f864.sql @@ -0,0 +1 @@ +SELECT number > 5 ? 'censor.net' : 'google' as value, value FROM system.numbers LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/97adf058c8a0c322.json b/tests/ast_json_fixtures/shapes/97adf058c8a0c322.json new file mode 100644 index 000000000000..6ab8002861f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/97adf058c8a0c322.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["test_03727"] + } +} diff --git a/tests/ast_json_fixtures/shapes/97adf058c8a0c322.sql b/tests/ast_json_fixtures/shapes/97adf058c8a0c322.sql new file mode 100644 index 000000000000..88759e75c548 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/97adf058c8a0c322.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS test_03727 diff --git a/tests/ast_json_fixtures/shapes/97c723751efbc57c.json b/tests/ast_json_fixtures/shapes/97c723751efbc57c.json new file mode 100644 index 000000000000..845775b718fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/97c723751efbc57c.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "k", + "name": "CounterID" + }, + { + "type": "Function", + "name": "quantileBFloat16", + "arguments": [ + { + "type": "Identifier", + "name": "ResolutionWidth" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [] + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "CounterID" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/97c723751efbc57c.sql b/tests/ast_json_fixtures/shapes/97c723751efbc57c.sql new file mode 100644 index 000000000000..a4b346d51fe9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/97c723751efbc57c.sql @@ -0,0 +1,10 @@ +SELECT + CounterID AS k, + quantileBFloat16(0.5)(ResolutionWidth) +FROM test.hits +GROUP BY k +ORDER BY + count() DESC, + CounterID ASC +LIMIT 10 +SETTINGS group_by_use_nulls = 1 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/97ff0f686a54847f.json b/tests/ast_json_fixtures/shapes/97ff0f686a54847f.json new file mode 100644 index 000000000000..a33b22b5abc4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/97ff0f686a54847f.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "json", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "{\"a\" : [{\"b\" : 42}]}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "JSON(a Array(JSON))" + } + ] + }, + { + "type": "Identifier", + "name": "json.a.b", + "name_parts": ["json", "a", "b"] + }, + { + "type": "Function", + "alias": "json2", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "json" + }, + { + "type": "Literal", + "value_type": "String", + "value": "JSON" + } + ] + }, + { + "type": "Function", + "name": "dynamicType", + "arguments": [ + { + "type": "Identifier", + "name": "json2.a", + "name_parts": ["json2", "a"] + } + ] + }, + { + "type": "Identifier", + "name": "json2.a.:`Array(JSON)`.b", + "name_parts": ["json2", "a", ":`Array(JSON)`", "b"] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/97ff0f686a54847f.sql b/tests/ast_json_fixtures/shapes/97ff0f686a54847f.sql new file mode 100644 index 000000000000..36538c8320f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/97ff0f686a54847f.sql @@ -0,0 +1 @@ +select '{"a" : [{"b" : 42}]}'::JSON(a Array(JSON)) as json, json.a.b, json::JSON as json2, dynamicType(json2.a), json2.a[].b diff --git a/tests/ast_json_fixtures/shapes/9803ab5511e949b5.json b/tests/ast_json_fixtures/shapes/9803ab5511e949b5.json new file mode 100644 index 000000000000..44394fa42999 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9803ab5511e949b5.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r1_01293", "r2_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/9803ab5511e949b5.sql b/tests/ast_json_fixtures/shapes/9803ab5511e949b5.sql new file mode 100644 index 000000000000..490ebc53ef6f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9803ab5511e949b5.sql @@ -0,0 +1 @@ +CREATE ROLE r1_01293, r2_01293 diff --git a/tests/ast_json_fixtures/shapes/980f76e4ee120b0a.json b/tests/ast_json_fixtures/shapes/980f76e4ee120b0a.json new file mode 100644 index 000000000000..8be486d67ace --- /dev/null +++ b/tests/ast_json_fixtures/shapes/980f76e4ee120b0a.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "RegionID" + }, + { + "type": "Function", + "alias": "u", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "800784" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "RegionID" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "u" + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "RegionID" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/980f76e4ee120b0a.sql b/tests/ast_json_fixtures/shapes/980f76e4ee120b0a.sql new file mode 100644 index 000000000000..bc36a2b69e6e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/980f76e4ee120b0a.sql @@ -0,0 +1 @@ +SELECT RegionID, uniq(UserID) AS u FROM test.hits WHERE CounterID = 800784 GROUP BY RegionID ORDER BY u DESC, RegionID LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/981c97b35b44cb94.json b/tests/ast_json_fixtures/shapes/981c97b35b44cb94.json new file mode 100644 index 000000000000..b2101f9bd813 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/981c97b35b44cb94.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "part_log_bytes_uncompressed" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PARTITION", + "part": true, + "partition": { + "type": "Literal", + "value_type": "String", + "value": "all_4_4_0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/981c97b35b44cb94.sql b/tests/ast_json_fixtures/shapes/981c97b35b44cb94.sql new file mode 100644 index 000000000000..474a238f291b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/981c97b35b44cb94.sql @@ -0,0 +1 @@ +ALTER TABLE part_log_bytes_uncompressed DROP PART 'all_4_4_0' SETTINGS mutations_sync=2 diff --git a/tests/ast_json_fixtures/shapes/98261f664ee1d89d.json b/tests/ast_json_fixtures/shapes/98261f664ee1d89d.json new file mode 100644 index 000000000000..81a7bf5a6997 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98261f664ee1d89d.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "left.x", + "name_parts": ["left", "x"] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "right.x", + "name_parts": ["right", "x"] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Boolean" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "left" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "left.x", + "name_parts": ["left", "x"] + }, + { + "type": "Identifier", + "name": "right.x", + "name_parts": ["right", "x"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "right" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/98261f664ee1d89d.sql b/tests/ast_json_fixtures/shapes/98261f664ee1d89d.sql new file mode 100644 index 000000000000..896b7ecc706b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98261f664ee1d89d.sql @@ -0,0 +1 @@ +SELECT left.x, (right.x IS NULL)::Boolean FROM left LEFT OUTER JOIN right ON left.x = right.x GROUP BY ALL diff --git a/tests/ast_json_fixtures/shapes/9842df30694ae8c5.json b/tests/ast_json_fixtures/shapes/9842df30694ae8c5.json new file mode 100644 index 000000000000..c7307c404419 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9842df30694ae8c5.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q11_01297"], + "key_type": "CLIENT_KEY_OR_USER_NAME" + } +} diff --git a/tests/ast_json_fixtures/shapes/9842df30694ae8c5.sql b/tests/ast_json_fixtures/shapes/9842df30694ae8c5.sql new file mode 100644 index 000000000000..b053881529f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9842df30694ae8c5.sql @@ -0,0 +1 @@ +CREATE QUOTA q11_01297 KEYED BY 'client key or user name' diff --git a/tests/ast_json_fixtures/shapes/9864844f2a792d53.json b/tests/ast_json_fixtures/shapes/9864844f2a792d53.json new file mode 100644 index 000000000000..8c73056db0c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9864844f2a792d53.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02126_function", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/9864844f2a792d53.sql b/tests/ast_json_fixtures/shapes/9864844f2a792d53.sql new file mode 100644 index 000000000000..b317d64506f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9864844f2a792d53.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02126_function diff --git a/tests/ast_json_fixtures/shapes/98754668ca48518e.json b/tests/ast_json_fixtures/shapes/98754668ca48518e.json new file mode 100644 index 000000000000..acb67dc2d7af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98754668ca48518e.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "02179_test_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + }, + "default_value": { + "type": "Literal", + "value_type": "String", + "value": "DefaultValue" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "start", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "end", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "02179_test_table" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 0 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "range_hashed", + "parameters": [] + }, + "range": { + "type": "DictionaryRange", + "min_attr_name": "start", + "max_attr_name": "end" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/98754668ca48518e.sql b/tests/ast_json_fixtures/shapes/98754668ca48518e.sql new file mode 100644 index 000000000000..991fc8979e51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98754668ca48518e.sql @@ -0,0 +1,11 @@ +CREATE DICTIONARY 02179_test_dictionary +( + id UInt64, + value String DEFAULT 'DefaultValue', + start Int64, + end Int64 +) PRIMARY KEY id +LAYOUT(RANGE_HASHED()) +SOURCE(CLICKHOUSE(TABLE '02179_test_table')) +RANGE(MIN start MAX end) +LIFETIME(0) diff --git a/tests/ast_json_fixtures/shapes/9876c2600cb0bff1.json b/tests/ast_json_fixtures/shapes/9876c2600cb0bff1.json new file mode 100644 index 000000000000..75d23a99f088 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9876c2600cb0bff1.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/9876c2600cb0bff1.sql b/tests/ast_json_fixtures/shapes/9876c2600cb0bff1.sql new file mode 100644 index 000000000000..1754d22c269a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9876c2600cb0bff1.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/98781241de765950.json b/tests/ast_json_fixtures/shapes/98781241de765950.json new file mode 100644 index 000000000000..2ce5c5119bdc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98781241de765950.json @@ -0,0 +1,150 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x.A", + "name_parts": ["x", "A"] + }, + { + "type": "Identifier", + "name": "y.A", + "name_parts": ["y", "A"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x.B", + "name_parts": ["x", "B"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x.A", + "name_parts": ["x", "A"] + }, + { + "type": "Identifier", + "name": "y.A", + "name_parts": ["y", "A"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y.C", + "name_parts": ["y", "C"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "y" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/98781241de765950.sql b/tests/ast_json_fixtures/shapes/98781241de765950.sql new file mode 100644 index 000000000000..90509e0f9476 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98781241de765950.sql @@ -0,0 +1 @@ +SELECT * FROM x INNER JOIN y ON ((x.A = y.A ) AND x.B = 1) OR ((x.A = y.A) AND y.C = 1) ORDER BY ALL LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/98879c5dc54906f1.json b/tests/ast_json_fixtures/shapes/98879c5dc54906f1.json new file mode 100644 index 000000000000..cd8480bd62be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98879c5dc54906f1.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "log_for_alter" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_SETTING", + "settings_changes": { + "type": "Settings", + "changes": { + "aaa": "123" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/98879c5dc54906f1.sql b/tests/ast_json_fixtures/shapes/98879c5dc54906f1.sql new file mode 100644 index 000000000000..0819209ab63c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98879c5dc54906f1.sql @@ -0,0 +1 @@ +ALTER TABLE log_for_alter MODIFY SETTING aaa=123 diff --git a/tests/ast_json_fixtures/shapes/98a16ba2e4f0133c.json b/tests/ast_json_fixtures/shapes/98a16ba2e4f0133c.json new file mode 100644 index 000000000000..18982f85209d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98a16ba2e4f0133c.json @@ -0,0 +1,93 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "name": "dim1" + }, + { + "type": "Identifier", + "name": "dim2" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "dim1" + }, + { + "type": "Identifier", + "name": "dim2" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "dim1" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "dim1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "dim2" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/98a16ba2e4f0133c.sql b/tests/ast_json_fixtures/shapes/98a16ba2e4f0133c.sql new file mode 100644 index 000000000000..117e66e54022 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98a16ba2e4f0133c.sql @@ -0,0 +1 @@ +select dim1, dim2, count() from test group by grouping sets ((dim1, dim2), dim1) order by dim1, dim2, count() diff --git a/tests/ast_json_fixtures/shapes/98c1d157387ca1a5.json b/tests/ast_json_fixtures/shapes/98c1d157387ca1a5.json new file mode 100644 index 000000000000..f70d1d778b8b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98c1d157387ca1a5.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "dictionaries": true, + "from": { + "type": "Identifier", + "name": "db_01018" + }, + "like": "dict1" + } +} diff --git a/tests/ast_json_fixtures/shapes/98c1d157387ca1a5.sql b/tests/ast_json_fixtures/shapes/98c1d157387ca1a5.sql new file mode 100644 index 000000000000..a39500dbb6e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98c1d157387ca1a5.sql @@ -0,0 +1 @@ +SHOW DICTIONARIES FROM db_01018 LIKE 'dict1' diff --git a/tests/ast_json_fixtures/shapes/98c7099efb8d8667.json b/tests/ast_json_fixtures/shapes/98c7099efb8d8667.json new file mode 100644 index 000000000000..8cb9759b8ab5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98c7099efb8d8667.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_clone_as": true, + "table": { + "type": "Identifier", + "name": "clone_as_foo_replacing_merge_tree_p_x" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "x" + } + }, + "as_table": "foo_replacing_merge_tree" + } +} diff --git a/tests/ast_json_fixtures/shapes/98c7099efb8d8667.sql b/tests/ast_json_fixtures/shapes/98c7099efb8d8667.sql new file mode 100644 index 000000000000..0a24a725b7e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/98c7099efb8d8667.sql @@ -0,0 +1 @@ +CREATE TABLE clone_as_foo_replacing_merge_tree_p_x CLONE AS foo_replacing_merge_tree ENGINE=ReplacingMergeTree PRIMARY KEY x diff --git a/tests/ast_json_fixtures/shapes/990deb7cc8a9a18d.json b/tests/ast_json_fixtures/shapes/990deb7cc8a9a18d.json new file mode 100644 index 000000000000..7db3c8bf7551 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/990deb7cc8a9a18d.json @@ -0,0 +1,128 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "k", + "name": "intDiv", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + }, + { + "type": "Function", + "alias": "value", + "name": "toUInt32", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "name": "sparkbar", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "value" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "99" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/990deb7cc8a9a18d.sql b/tests/ast_json_fixtures/shapes/990deb7cc8a9a18d.sql new file mode 100644 index 000000000000..8d880731466d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/990deb7cc8a9a18d.sql @@ -0,0 +1 @@ +WITH number DIV 50 AS k, toUInt32(number % 50) AS value SELECT k, sparkbar(50, 0, 99)(number, value) FROM numbers(100) GROUP BY k ORDER BY k diff --git a/tests/ast_json_fixtures/shapes/991bc1ec5d980ee4.json b/tests/ast_json_fixtures/shapes/991bc1ec5d980ee4.json new file mode 100644 index 000000000000..6282d108a1f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/991bc1ec5d980ee4.json @@ -0,0 +1,118 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "testing" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "c", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "e", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "proj_1", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "d" + } + ] + } + }, + { + "type": "Projection", + "name": "proj_2", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "e" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "a" + }, + "settings": { + "type": "Settings", + "changes": { + "min_bytes_for_wide_part": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/991bc1ec5d980ee4.sql b/tests/ast_json_fixtures/shapes/991bc1ec5d980ee4.sql new file mode 100644 index 000000000000..8144d1625a2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/991bc1ec5d980ee4.sql @@ -0,0 +1,17 @@ +CREATE TABLE testing +( + a String, + b String, + c Int32, + d Int32, + e Int32, + PROJECTION proj_1 + ( + SELECT c ORDER BY d + ), + PROJECTION proj_2 + ( + SELECT c ORDER BY e, d + ) +) +ENGINE = MergeTree() PRIMARY KEY (a) SETTINGS min_bytes_for_wide_part = 0 diff --git a/tests/ast_json_fixtures/shapes/991d274cd0297efd.json b/tests/ast_json_fixtures/shapes/991d274cd0297efd.json new file mode 100644 index 000000000000..918fb58d2dda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/991d274cd0297efd.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t" + } + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "s" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.a", + "name_parts": ["s", "a"] + }, + { + "type": "Identifier", + "name": "t.a", + "name_parts": ["t", "a"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "s" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t.a", + "name_parts": ["t", "a"] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/991d274cd0297efd.sql b/tests/ast_json_fixtures/shapes/991d274cd0297efd.sql new file mode 100644 index 000000000000..d7dade135397 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/991d274cd0297efd.sql @@ -0,0 +1 @@ +select t.*, s.* from t left join s on (s.a=t.a) order by t.a diff --git a/tests/ast_json_fixtures/shapes/9930a314342d7718.json b/tests/ast_json_fixtures/shapes/9930a314342d7718.json new file mode 100644 index 000000000000..ed8eb861e72a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9930a314342d7718.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q6_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/9930a314342d7718.sql b/tests/ast_json_fixtures/shapes/9930a314342d7718.sql new file mode 100644 index 000000000000..33369ba8b05d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9930a314342d7718.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q6_01297 diff --git a/tests/ast_json_fixtures/shapes/9935c331568bf315.json b/tests/ast_json_fixtures/shapes/9935c331568bf315.json new file mode 100644 index 000000000000..092bd2129d5a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9935c331568bf315.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9935c331568bf315.sql b/tests/ast_json_fixtures/shapes/9935c331568bf315.sql new file mode 100644 index 000000000000..07b50d026f17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9935c331568bf315.sql @@ -0,0 +1 @@ +SELECT 1 as a, a diff --git a/tests/ast_json_fixtures/shapes/9985377361e36fc7.json b/tests/ast_json_fixtures/shapes/9985377361e36fc7.json new file mode 100644 index 000000000000..211df08cec8e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9985377361e36fc7.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sipHash64Keyed", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt64" + } + ] + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ], + "group_by": [ + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9985377361e36fc7.sql b/tests/ast_json_fixtures/shapes/9985377361e36fc7.sql new file mode 100644 index 000000000000..83d379139369 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9985377361e36fc7.sql @@ -0,0 +1 @@ +SELECT sipHash64Keyed((2::UInt64, toUInt64(2)), 4) GROUP BY toUInt64(2) diff --git a/tests/ast_json_fixtures/shapes/999d67a2c6e248f2.json b/tests/ast_json_fixtures/shapes/999d67a2c6e248f2.json new file mode 100644 index 000000000000..5f20969c2e10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/999d67a2c6e248f2.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "databases": true, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/999d67a2c6e248f2.sql b/tests/ast_json_fixtures/shapes/999d67a2c6e248f2.sql new file mode 100644 index 000000000000..df6795479cf6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/999d67a2c6e248f2.sql @@ -0,0 +1 @@ +SHOW DATABASES LIMIT 0 diff --git a/tests/ast_json_fixtures/shapes/999e233620a11a87.json b/tests/ast_json_fixtures/shapes/999e233620a11a87.json new file mode 100644 index 000000000000..7ff77a6d2536 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/999e233620a11a87.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u7_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/999e233620a11a87.sql b/tests/ast_json_fixtures/shapes/999e233620a11a87.sql new file mode 100644 index 000000000000..779fcac95e8d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/999e233620a11a87.sql @@ -0,0 +1 @@ +SHOW CREATE USER u7_01292 diff --git a/tests/ast_json_fixtures/shapes/99a4c772b9ce63b1.json b/tests/ast_json_fixtures/shapes/99a4c772b9ce63b1.json new file mode 100644 index 000000000000..2c8585aa2d31 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/99a4c772b9ce63b1.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "lightweight_test" + }, + "assignments": [ + { + "type": "Assignment", + "column": "value", + "expression": { + "type": "Literal", + "value_type": "String", + "value": "UPDATED-1" + } + } + ], + "predicate": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "keys" + } + } + } + ] + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/99a4c772b9ce63b1.sql b/tests/ast_json_fixtures/shapes/99a4c772b9ce63b1.sql new file mode 100644 index 000000000000..608bc4185a5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/99a4c772b9ce63b1.sql @@ -0,0 +1,3 @@ +UPDATE lightweight_test +SET value = 'UPDATED-1' +WHERE key IN (SELECT key FROM keys) diff --git a/tests/ast_json_fixtures/shapes/99b14db993c1868c.json b/tests/ast_json_fixtures/shapes/99b14db993c1868c.json new file mode 100644 index 000000000000..cb7426cf37f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/99b14db993c1868c.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Function", + "alias": "c8", + "name": "row_number", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "d" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c8" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "2", + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/99b14db993c1868c.sql b/tests/ast_json_fixtures/shapes/99b14db993c1868c.sql new file mode 100644 index 000000000000..51ea3f13365c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/99b14db993c1868c.sql @@ -0,0 +1 @@ +SELECT d, c, row_number() over (partition by d order by c) as c8 FROM t qualify c8=1 order by d settings max_threads=2, enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/99ec4b90728b6d62.json b/tests/ast_json_fixtures/shapes/99ec4b90728b6d62.json new file mode 100644 index 000000000000..7ba3bd36b8d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/99ec4b90728b6d62.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_STATISTICS", + "clear_statistics": true, + "statistics_declaration": { + "type": "Stat", + "columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "s" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/99ec4b90728b6d62.sql b/tests/ast_json_fixtures/shapes/99ec4b90728b6d62.sql new file mode 100644 index 000000000000..61c480f1ad5a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/99ec4b90728b6d62.sql @@ -0,0 +1 @@ +ALTER TABLE tab CLEAR STATISTICS s diff --git a/tests/ast_json_fixtures/shapes/9a00789fa4c5098e.json b/tests/ast_json_fixtures/shapes/9a00789fa4c5098e.json new file mode 100644 index 000000000000..8e41247ac43b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a00789fa4c5098e.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u9_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "BCRYPT_PASSWORD", + "contains_hash": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "$2a$12$rz5iy2LhuwBezsM88ZzWiemOVUeJ94xHTzwAlLMDhTzwUxOHaY64q" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/9a00789fa4c5098e.sql b/tests/ast_json_fixtures/shapes/9a00789fa4c5098e.sql new file mode 100644 index 000000000000..0c2edeb8e481 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a00789fa4c5098e.sql @@ -0,0 +1 @@ +CREATE USER u9_01292 IDENTIFIED WITH bcrypt_hash BY '$2a$12$rz5iy2LhuwBezsM88ZzWiemOVUeJ94xHTzwAlLMDhTzwUxOHaY64q' diff --git a/tests/ast_json_fixtures/shapes/9a069582ec86f813.json b/tests/ast_json_fixtures/shapes/9a069582ec86f813.json new file mode 100644 index 000000000000..958f9202d6ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a069582ec86f813.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q8_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "QUERY_SELECTS": "13194139533312" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9a069582ec86f813.sql b/tests/ast_json_fixtures/shapes/9a069582ec86f813.sql new file mode 100644 index 000000000000..0191945877d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a069582ec86f813.sql @@ -0,0 +1 @@ +CREATE QUOTA q8_01297 FOR INTERVAL 1 MINUTE MAX query_selects = '12Ti' diff --git a/tests/ast_json_fixtures/shapes/9a2d4b124f970f0b.json b/tests/ast_json_fixtures/shapes/9a2d4b124f970f0b.json new file mode 100644 index 000000000000..7e88ccec8066 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a2d4b124f970f0b.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "j" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "i" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "j" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9a2d4b124f970f0b.sql b/tests/ast_json_fixtures/shapes/9a2d4b124f970f0b.sql new file mode 100644 index 000000000000..fb4b0c0f7186 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a2d4b124f970f0b.sql @@ -0,0 +1 @@ +SELECT j = 2, i FROM t PREWHERE j = 2 diff --git a/tests/ast_json_fixtures/shapes/9a38515c332f0e51.json b/tests/ast_json_fixtures/shapes/9a38515c332f0e51.json new file mode 100644 index 000000000000..630069bb790c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a38515c332f0e51.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "having": { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [] + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9a38515c332f0e51.sql b/tests/ast_json_fixtures/shapes/9a38515c332f0e51.sql new file mode 100644 index 000000000000..43a5e68e68e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a38515c332f0e51.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(4) GROUP BY number WITH TOTALS HAVING sum(number) <= arrayJoin([]) diff --git a/tests/ast_json_fixtures/shapes/9a3af33bb026d3c2.json b/tests/ast_json_fixtures/shapes/9a3af33bb026d3c2.json new file mode 100644 index 000000000000..c70e57cc30ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a3af33bb026d3c2.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "36" + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + }, + "format": "RowBinaryWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/9a3af33bb026d3c2.sql b/tests/ast_json_fixtures/shapes/9a3af33bb026d3c2.sql new file mode 100644 index 000000000000..396192b8df63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a3af33bb026d3c2.sql @@ -0,0 +1 @@ +SELECT 36 AS n, toDate('2000-01-01') + n AS d, (n, d) AS tuple FROM system.numbers LIMIT 1 FORMAT RowBinaryWithNamesAndTypes SETTINGS enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/9a4bd914b0086f50.json b/tests/ast_json_fixtures/shapes/9a4bd914b0086f50.json new file mode 100644 index 000000000000..9ee71d2afae0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a4bd914b0086f50.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "key", + "name": "a" + } + ], + "select": [ + { + "type": "Identifier", + "alias": "k1", + "name": "a" + }, + { + "type": "Function", + "alias": "k2", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k2" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9a4bd914b0086f50.sql b/tests/ast_json_fixtures/shapes/9a4bd914b0086f50.sql new file mode 100644 index 000000000000..d120d1532c10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a4bd914b0086f50.sql @@ -0,0 +1,10 @@ +WITH + a as key +SELECT + a as k1, + sum(b) as k2 +FROM + test +GROUP BY + key +ORDER BY k1, k2 diff --git a/tests/ast_json_fixtures/shapes/9a596124d0a04c8a.json b/tests/ast_json_fixtures/shapes/9a596124d0a04c8a.json new file mode 100644 index 000000000000..3bd34bca15e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a596124d0a04c8a.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "t1", + "to_table": "t1tmp" + }, + { + "from_table": "t2", + "to_table": "t2tmp" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9a596124d0a04c8a.sql b/tests/ast_json_fixtures/shapes/9a596124d0a04c8a.sql new file mode 100644 index 000000000000..c2449c2ba546 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a596124d0a04c8a.sql @@ -0,0 +1 @@ +RENAME TABLE t1 TO t1tmp, t2 TO t2tmp diff --git a/tests/ast_json_fixtures/shapes/9a78fe9f581b4aca.json b/tests/ast_json_fixtures/shapes/9a78fe9f581b4aca.json new file mode 100644 index 000000000000..21989bd48f00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a78fe9f581b4aca.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9a78fe9f581b4aca.sql b/tests/ast_json_fixtures/shapes/9a78fe9f581b4aca.sql new file mode 100644 index 000000000000..a5c82a2a6838 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a78fe9f581b4aca.sql @@ -0,0 +1 @@ +SELECT *, (SELECT 1) diff --git a/tests/ast_json_fixtures/shapes/9a8c2c5f17119925.json b/tests/ast_json_fixtures/shapes/9a8c2c5f17119925.json new file mode 100644 index 000000000000..d9cc8dd273c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a8c2c5f17119925.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02096_test_function" + } +} diff --git a/tests/ast_json_fixtures/shapes/9a8c2c5f17119925.sql b/tests/ast_json_fixtures/shapes/9a8c2c5f17119925.sql new file mode 100644 index 000000000000..d8eb2a599329 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a8c2c5f17119925.sql @@ -0,0 +1 @@ +DROP FUNCTION 02096_test_function diff --git a/tests/ast_json_fixtures/shapes/9a92af396178b3da.json b/tests/ast_json_fixtures/shapes/9a92af396178b3da.json new file mode 100644 index 000000000000..46c2c9825c08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a92af396178b3da.json @@ -0,0 +1,166 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "db.name", + "name_parts": ["db", "name"] + }, + { + "type": "Identifier", + "name": "t.name", + "name_parts": ["t", "name"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Identifier", + "name": "database" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tables", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "one" + } + ] + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t.database", + "name_parts": ["t", "database"] + }, + { + "type": "Identifier", + "name": "db.name", + "name_parts": ["db", "name"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "db", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "databases", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "system" + } + ] + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/9a92af396178b3da.sql b/tests/ast_json_fixtures/shapes/9a92af396178b3da.sql new file mode 100644 index 000000000000..feebac90f9a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a92af396178b3da.sql @@ -0,0 +1,4 @@ +SELECT db.name, t.name + FROM (SELECT name, database FROM system.tables WHERE name = 'one') AS t + JOIN (SELECT name FROM system.databases WHERE name = 'system') AS db ON t.database = db.name + FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/9a985953c2399c4c.json b/tests/ast_json_fixtures/shapes/9a985953c2399c4c.json new file mode 100644 index 000000000000..17ee4a3249fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a985953c2399c4c.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "final_bug" + }, + "final": true + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "2", + "max_final_threads": "2", + "max_block_size": "8" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/9a985953c2399c4c.sql b/tests/ast_json_fixtures/shapes/9a985953c2399c4c.sql new file mode 100644 index 000000000000..22ee73972fe7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a985953c2399c4c.sql @@ -0,0 +1 @@ +select x from final_bug final order by x settings max_threads=2, max_final_threads=2, max_block_size=8 format Null diff --git a/tests/ast_json_fixtures/shapes/9a9f2d1726645bd1.json b/tests/ast_json_fixtures/shapes/9a9f2d1726645bd1.json new file mode 100644 index 000000000000..669ea02eb366 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a9f2d1726645bd1.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02484_plusthreemonths", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/9a9f2d1726645bd1.sql b/tests/ast_json_fixtures/shapes/9a9f2d1726645bd1.sql new file mode 100644 index 000000000000..17ed5d0281dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9a9f2d1726645bd1.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02484_plusthreemonths diff --git a/tests/ast_json_fixtures/shapes/9aa81e69bc25c936.json b/tests/ast_json_fixtures/shapes/9aa81e69bc25c936.json new file mode 100644 index 000000000000..d2b4e0d3b9cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9aa81e69bc25c936.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "uuid": "00000510-1000-4000-8000-000000000001", + "table": { + "type": "Identifier", + "name": "with_deduplication_mv" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "dummy", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Function", + "alias": "cnt", + "name": "countState", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "with_deduplication" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedAggregatingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/clickhouse\/tables\/{database}\/test_00510\/with_deduplication_mv" + }, + { + "type": "Literal", + "value_type": "String", + "value": "r1" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "dummy" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9aa81e69bc25c936.sql b/tests/ast_json_fixtures/shapes/9aa81e69bc25c936.sql new file mode 100644 index 000000000000..deac436ca077 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9aa81e69bc25c936.sql @@ -0,0 +1,3 @@ +CREATE MATERIALIZED VIEW with_deduplication_mv UUID '00000510-1000-4000-8000-000000000001' + ENGINE = ReplicatedAggregatingMergeTree('/clickhouse/tables/{database}/test_00510/with_deduplication_mv', 'r1') ORDER BY dummy + AS SELECT 0 AS dummy, countState(x) AS cnt FROM with_deduplication diff --git a/tests/ast_json_fixtures/shapes/9ab0ed2ac2069045.json b/tests/ast_json_fixtures/shapes/9ab0ed2ac2069045.json new file mode 100644 index 000000000000..9fd25d7d6b07 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ab0ed2ac2069045.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_merge", + "database": "01902_db_repr" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "n" + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "_table" + }, + "direction": "DESC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9ab0ed2ac2069045.sql b/tests/ast_json_fixtures/shapes/9ab0ed2ac2069045.sql new file mode 100644 index 000000000000..f420478c674d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ab0ed2ac2069045.sql @@ -0,0 +1 @@ +SELECT NULL FROM 01902_db_repr.t_merge WHERE n ORDER BY _table DESC diff --git a/tests/ast_json_fixtures/shapes/9ac7d62bbe8268e1.json b/tests/ast_json_fixtures/shapes/9ac7d62bbe8268e1.json new file mode 100644 index 000000000000..3f84cefc908b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ac7d62bbe8268e1.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "02681_undrop_no_uuid_on_cluster" + }, + "format": "Null", + "cluster": "test_shard_localhost", + "sync": true + } +} diff --git a/tests/ast_json_fixtures/shapes/9ac7d62bbe8268e1.sql b/tests/ast_json_fixtures/shapes/9ac7d62bbe8268e1.sql new file mode 100644 index 000000000000..fcb2a25548cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ac7d62bbe8268e1.sql @@ -0,0 +1 @@ +drop table 02681_undrop_no_uuid_on_cluster on cluster test_shard_localhost sync format Null diff --git a/tests/ast_json_fixtures/shapes/9ac8b30d64561942.json b/tests/ast_json_fixtures/shapes/9ac8b30d64561942.json new file mode 100644 index 000000000000..2aaf4b3e3b4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ac8b30d64561942.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "default_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9ac8b30d64561942.sql b/tests/ast_json_fixtures/shapes/9ac8b30d64561942.sql new file mode 100644 index 000000000000..a76ef53d628f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ac8b30d64561942.sql @@ -0,0 +1 @@ +ALTER USER u1_01292 DEFAULT ROLE r1_01292 diff --git a/tests/ast_json_fixtures/shapes/9aca48154c3fc878.json b/tests/ast_json_fixtures/shapes/9aca48154c3fc878.json new file mode 100644 index 000000000000..a3b22359e460 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9aca48154c3fc878.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_PROJECTION", + "projection": { + "type": "Identifier", + "name": "p1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9aca48154c3fc878.sql b/tests/ast_json_fixtures/shapes/9aca48154c3fc878.sql new file mode 100644 index 000000000000..02b8dc5f6fe8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9aca48154c3fc878.sql @@ -0,0 +1 @@ +ALTER TABLE test MATERIALIZE PROJECTION p1 diff --git a/tests/ast_json_fixtures/shapes/9ad6362e4f8469b8.json b/tests/ast_json_fixtures/shapes/9ad6362e4f8469b8.json new file mode 100644 index 000000000000..a7bdb1cea584 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ad6362e4f8469b8.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "long_string" + }, + "settings_resets": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "min_compress_block_size" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9ad6362e4f8469b8.sql b/tests/ast_json_fixtures/shapes/9ad6362e4f8469b8.sql new file mode 100644 index 000000000000..33b9e7107a3c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ad6362e4f8469b8.sql @@ -0,0 +1 @@ +ALTER TABLE tab MODIFY COLUMN long_string RESET SETTING min_compress_block_size diff --git a/tests/ast_json_fixtures/shapes/9ad6bc85341d0975.json b/tests/ast_json_fixtures/shapes/9ad6bc85341d0975.json new file mode 100644 index 000000000000..c44b975ba3b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ad6bc85341d0975.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_in_tuple" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^test_in_tuple_[0-9]+$" + } + ] + } + }, + "as_table": "test_in_tuple_1" + } +} diff --git a/tests/ast_json_fixtures/shapes/9ad6bc85341d0975.sql b/tests/ast_json_fixtures/shapes/9ad6bc85341d0975.sql new file mode 100644 index 000000000000..1d09dd71999c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ad6bc85341d0975.sql @@ -0,0 +1 @@ +create table test_in_tuple as test_in_tuple_1 engine = Merge(currentDatabase(), '^test_in_tuple_[0-9]+$') diff --git a/tests/ast_json_fixtures/shapes/9af037bed71bbc64.json b/tests/ast_json_fixtures/shapes/9af037bed71bbc64.json new file mode 100644 index 000000000000..7d5311f0b44e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9af037bed71bbc64.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROW POLICY", + "if_exists": true, + "cluster": "test_shard_localhost", + "row_policy_names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "02911_rowpolicy", + "database": "default" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9af037bed71bbc64.sql b/tests/ast_json_fixtures/shapes/9af037bed71bbc64.sql new file mode 100644 index 000000000000..43c8b6b1b2af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9af037bed71bbc64.sql @@ -0,0 +1 @@ +DROP ROW POLICY IF EXISTS 02911_rowpolicy ON default.* ON CLUSTER test_shard_localhost diff --git a/tests/ast_json_fixtures/shapes/9afa066778cbe02f.json b/tests/ast_json_fixtures/shapes/9afa066778cbe02f.json new file mode 100644 index 000000000000..27e9b2545a11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9afa066778cbe02f.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_filter" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "f" + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "u" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9afa066778cbe02f.sql b/tests/ast_json_fixtures/shapes/9afa066778cbe02f.sql new file mode 100644 index 000000000000..dd16cb572d0a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9afa066778cbe02f.sql @@ -0,0 +1 @@ +SELECT * FROM t_filter WHERE f ORDER BY u LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/9b3224037b7af415.json b/tests/ast_json_fixtures/shapes/9b3224037b7af415.json new file mode 100644 index 000000000000..a8ed2a861cb9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b3224037b7af415.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "Null" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Null", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "Example" + } +} diff --git a/tests/ast_json_fixtures/shapes/9b3224037b7af415.sql b/tests/ast_json_fixtures/shapes/9b3224037b7af415.sql new file mode 100644 index 000000000000..b96453861d0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b3224037b7af415.sql @@ -0,0 +1 @@ +create table Null engine=Null as Example diff --git a/tests/ast_json_fixtures/shapes/9b3342385820fbf4.json b/tests/ast_json_fixtures/shapes/9b3342385820fbf4.json new file mode 100644 index 000000000000..84a33e548278 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b3342385820fbf4.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9b3342385820fbf4.sql b/tests/ast_json_fixtures/shapes/9b3342385820fbf4.sql new file mode 100644 index 000000000000..8963431281bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b3342385820fbf4.sql @@ -0,0 +1 @@ +CREATE TABLE t (x UInt8) ENGINE = MergeTree ORDER BY () diff --git a/tests/ast_json_fixtures/shapes/9b55ec027a2cae9c.json b/tests/ast_json_fixtures/shapes/9b55ec027a2cae9c.json new file mode 100644 index 000000000000..6fa993287f79 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b55ec027a2cae9c.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "v" + }, + { + "type": "Function", + "name": "variantElement", + "arguments": [ + { + "type": "Identifier", + "name": "v" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Bool" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "format", + "arguments": [ + { + "type": "Identifier", + "name": "Values" + }, + { + "type": "Literal", + "value_type": "String", + "value": "v Variant(String, Bool)" + }, + { + "type": "Literal", + "value_type": "String", + "value": "(NULL), (true)" + } + ] + } + } + } + ] + } + } + ], + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/9b55ec027a2cae9c.sql b/tests/ast_json_fixtures/shapes/9b55ec027a2cae9c.sql new file mode 100644 index 000000000000..f45d8ba328f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b55ec027a2cae9c.sql @@ -0,0 +1 @@ +select v, variantElement(v, 'Bool') from format(Values, 'v Variant(String, Bool)', '(NULL), (true)') format Values diff --git a/tests/ast_json_fixtures/shapes/9b5a83e222217068.json b/tests/ast_json_fixtures/shapes/9b5a83e222217068.json new file mode 100644 index 000000000000..4715b72a0504 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b5a83e222217068.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SYSTEM", + "system_type": "CLEAR SCHEMA CACHE", + "schema_cache_storage": "HDFS" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9b5a83e222217068.sql b/tests/ast_json_fixtures/shapes/9b5a83e222217068.sql new file mode 100644 index 000000000000..df63e7a47d7a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b5a83e222217068.sql @@ -0,0 +1 @@ +explain syntax system clear schema cache for hdfs diff --git a/tests/ast_json_fixtures/shapes/9b600d1f26e533b2.json b/tests/ast_json_fixtures/shapes/9b600d1f26e533b2.json new file mode 100644 index 000000000000..4aefa91f68e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b600d1f26e533b2.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-02-29" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Date" + } + ] + } + ] + } + ], + "format": "PrettyNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/9b600d1f26e533b2.sql b/tests/ast_json_fixtures/shapes/9b600d1f26e533b2.sql new file mode 100644 index 000000000000..6cc413be00dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b600d1f26e533b2.sql @@ -0,0 +1 @@ +SELECT '2024-02-29'::Date FORMAT PrettyNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/9b62691b44652dbd.json b/tests/ast_json_fixtures/shapes/9b62691b44652dbd.json new file mode 100644 index 000000000000..ee333bc11a18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b62691b44652dbd.json @@ -0,0 +1,126 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "uid" + }, + { + "type": "Function", + "alias": "res", + "name": "windowFunnel", + "arguments": [ + { + "type": "Identifier", + "name": "dt" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event" + }, + { + "type": "Literal", + "value_type": "String", + "value": "b" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event" + }, + { + "type": "Literal", + "value_type": "String", + "value": "c" + } + ] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Literal", + "value_type": "String", + "value": "strict_order" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "funnel_test_reentry" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "uid" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "uid" + } + ] + } + ], + "format": "JSONCompactEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/9b62691b44652dbd.sql b/tests/ast_json_fixtures/shapes/9b62691b44652dbd.sql new file mode 100644 index 000000000000..40f16404cd8a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b62691b44652dbd.sql @@ -0,0 +1,2 @@ +select uid, windowFunnel(100, 'strict_order')(dt, event='a', event='b', event='c') as res +from funnel_test_reentry where uid = 2 group by uid format JSONCompactEachRow diff --git a/tests/ast_json_fixtures/shapes/9b78023b28facf64.json b/tests/ast_json_fixtures/shapes/9b78023b28facf64.json new file mode 100644 index 000000000000..ace26a1482c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b78023b28facf64.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "test_dict" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "y" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "test_table" + } + } + ] + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "direct", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9b78023b28facf64.sql b/tests/ast_json_fixtures/shapes/9b78023b28facf64.sql new file mode 100644 index 000000000000..f391eab6c578 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9b78023b28facf64.sql @@ -0,0 +1 @@ +CREATE DICTIONARY test_dict (y String, value UInt64 DEFAULT 0) PRIMARY KEY y SOURCE(CLICKHOUSE(TABLE 'test_table')) LAYOUT(DIRECT()) diff --git a/tests/ast_json_fixtures/shapes/9bb12d6106e02dc9.json b/tests/ast_json_fixtures/shapes/9bb12d6106e02dc9.json new file mode 100644 index 000000000000..cbb1e95dcda4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9bb12d6106e02dc9.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u3_01292@192.168.%.%"] + } +} diff --git a/tests/ast_json_fixtures/shapes/9bb12d6106e02dc9.sql b/tests/ast_json_fixtures/shapes/9bb12d6106e02dc9.sql new file mode 100644 index 000000000000..d8a2683d177e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9bb12d6106e02dc9.sql @@ -0,0 +1 @@ +SHOW CREATE USER 'u3_01292@192.168.%.%' diff --git a/tests/ast_json_fixtures/shapes/9bd08cfbcaed5dc4.json b/tests/ast_json_fixtures/shapes/9bd08cfbcaed5dc4.json new file mode 100644 index 000000000000..c0409214c895 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9bd08cfbcaed5dc4.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "123" + }, + { + "type": "Subquery", + "alias": "y", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9bd08cfbcaed5dc4.sql b/tests/ast_json_fixtures/shapes/9bd08cfbcaed5dc4.sql new file mode 100644 index 000000000000..630cde7e5fea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9bd08cfbcaed5dc4.sql @@ -0,0 +1 @@ +SELECT 123 AS x, (SELECT x) AS y diff --git a/tests/ast_json_fixtures/shapes/9be3df296fdaf6aa.json b/tests/ast_json_fixtures/shapes/9be3df296fdaf6aa.json new file mode 100644 index 000000000000..6dcc153d92af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9be3df296fdaf6aa.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01319" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_unavailable_shard" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "dist_layer_01319" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + }, + "as_table": "data_01319" + } +} diff --git a/tests/ast_json_fixtures/shapes/9be3df296fdaf6aa.sql b/tests/ast_json_fixtures/shapes/9be3df296fdaf6aa.sql new file mode 100644 index 000000000000..1c28f28a990f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9be3df296fdaf6aa.sql @@ -0,0 +1 @@ +create table dist_01319 as data_01319 Engine=Distributed(test_unavailable_shard, currentDatabase(), dist_layer_01319, key+1) diff --git a/tests/ast_json_fixtures/shapes/9bf548366496bd5e.json b/tests/ast_json_fixtures/shapes/9bf548366496bd5e.json new file mode 100644 index 000000000000..c90c15f1078e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9bf548366496bd5e.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "03222_timeseries_table4" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "TimeSeries", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "store_min_time_and_max_time": "0" + } + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/9bf548366496bd5e.sql b/tests/ast_json_fixtures/shapes/9bf548366496bd5e.sql new file mode 100644 index 000000000000..dff3f2a1b77c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9bf548366496bd5e.sql @@ -0,0 +1 @@ +CREATE TABLE 03222_timeseries_table4 ENGINE = TimeSeries SETTINGS store_min_time_and_max_time = 0 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/9bf70112108bd574.json b/tests/ast_json_fixtures/shapes/9bf70112108bd574.json new file mode 100644 index 000000000000..f6027dfd016e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9bf70112108bd574.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_table": "t2", + "to_table": "t2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9bf70112108bd574.sql b/tests/ast_json_fixtures/shapes/9bf70112108bd574.sql new file mode 100644 index 000000000000..7c7fd5a175b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9bf70112108bd574.sql @@ -0,0 +1 @@ +EXCHANGE TABLES t2 AND t2 diff --git a/tests/ast_json_fixtures/shapes/9c009dc748921f7b.json b/tests/ast_json_fixtures/shapes/9c009dc748921f7b.json new file mode 100644 index 000000000000..9cd564055dd4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c009dc748921f7b.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "13" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9c009dc748921f7b.sql b/tests/ast_json_fixtures/shapes/9c009dc748921f7b.sql new file mode 100644 index 000000000000..d5f7a638cab5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c009dc748921f7b.sql @@ -0,0 +1 @@ +SELECT 13 AS n GROUP BY n WITH CUBE diff --git a/tests/ast_json_fixtures/shapes/9c1437654ccbcbe9.json b/tests/ast_json_fixtures/shapes/9c1437654ccbcbe9.json new file mode 100644 index 000000000000..47caf6cc5326 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c1437654ccbcbe9.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q4_01297"], + "roles": { + "type": "RolesOrUsersSet", + "names": ["u1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9c1437654ccbcbe9.sql b/tests/ast_json_fixtures/shapes/9c1437654ccbcbe9.sql new file mode 100644 index 000000000000..77fe483145f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c1437654ccbcbe9.sql @@ -0,0 +1 @@ +CREATE QUOTA q4_01297 TO u1_01297 diff --git a/tests/ast_json_fixtures/shapes/9c148d6b1216331b.json b/tests/ast_json_fixtures/shapes/9c148d6b1216331b.json new file mode 100644 index 000000000000..08fa6acffa98 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c148d6b1216331b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q1_01297", "q2_01297", "q3_01297", "q4_01297", "q5_01297", "q6_01297", "q7_01297", "q8_01297", "q9_01297", "q10_01297", "q11_01297", "q12_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/9c148d6b1216331b.sql b/tests/ast_json_fixtures/shapes/9c148d6b1216331b.sql new file mode 100644 index 000000000000..be54609d0441 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c148d6b1216331b.sql @@ -0,0 +1 @@ +DROP QUOTA q1_01297, q2_01297, q3_01297, q4_01297, q5_01297, q6_01297, q7_01297, q8_01297, q9_01297, q10_01297, q11_01297, q12_01297 diff --git a/tests/ast_json_fixtures/shapes/9c30a6535fe65723.json b/tests/ast_json_fixtures/shapes/9c30a6535fe65723.json new file mode 100644 index 000000000000..03c37561df90 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c30a6535fe65723.json @@ -0,0 +1,95 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "alias": "d", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test02313" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9c30a6535fe65723.sql b/tests/ast_json_fixtures/shapes/9c30a6535fe65723.sql new file mode 100644 index 000000000000..8c2a5edb0992 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c30a6535fe65723.sql @@ -0,0 +1,5 @@ +SELECT + count() as d, a, b, c +FROM test02313 +GROUP BY ROLLUP(a, b, c) +ORDER BY d, a, b, c diff --git a/tests/ast_json_fixtures/shapes/9c35b07f745a527f.json b/tests/ast_json_fixtures/shapes/9c35b07f745a527f.json new file mode 100644 index 000000000000..9853ea553884 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c35b07f745a527f.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateDictionaryQuery", + "database": { + "type": "Identifier", + "name": "sqllt" + }, + "table": { + "type": "Identifier", + "name": "dictionary" + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/9c35b07f745a527f.sql b/tests/ast_json_fixtures/shapes/9c35b07f745a527f.sql new file mode 100644 index 000000000000..0f23348c3b1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c35b07f745a527f.sql @@ -0,0 +1 @@ +SHOW CREATE DICTIONARY sqllt.dictionary FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/9c4ea1926a28d008.json b/tests/ast_json_fixtures/shapes/9c4ea1926a28d008.json new file mode 100644 index 000000000000..97fdc1bb48fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c4ea1926a28d008.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lc_00906" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9c4ea1926a28d008.sql b/tests/ast_json_fixtures/shapes/9c4ea1926a28d008.sql new file mode 100644 index 000000000000..822b16f69c0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c4ea1926a28d008.sql @@ -0,0 +1 @@ +select count(), b from lc_00906 group by b diff --git a/tests/ast_json_fixtures/shapes/9c60c74a8c84147e.json b/tests/ast_json_fixtures/shapes/9c60c74a8c84147e.json new file mode 100644 index 000000000000..855e228cd2a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c60c74a8c84147e.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "t_lwd_vertical" + }, + "predicate": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9c60c74a8c84147e.sql b/tests/ast_json_fixtures/shapes/9c60c74a8c84147e.sql new file mode 100644 index 000000000000..592d2990e9f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c60c74a8c84147e.sql @@ -0,0 +1 @@ +DELETE FROM t_lwd_vertical WHERE 1 diff --git a/tests/ast_json_fixtures/shapes/9c8524709b8cc059.json b/tests/ast_json_fixtures/shapes/9c8524709b8cc059.json new file mode 100644 index 000000000000..f6720a4e6eee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c8524709b8cc059.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH ASYNC INSERT QUEUE", + "tables": [ + { + "table": "03733_table_join" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9c8524709b8cc059.sql b/tests/ast_json_fixtures/shapes/9c8524709b8cc059.sql new file mode 100644 index 000000000000..e163bc34c030 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c8524709b8cc059.sql @@ -0,0 +1 @@ +system flush async insert queue 03733_table_join diff --git a/tests/ast_json_fixtures/shapes/9c8cc3b0fd59f141.json b/tests/ast_json_fixtures/shapes/9c8cc3b0fd59f141.json new file mode 100644 index 000000000000..e050908c8df8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c8cc3b0fd59f141.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "primary_key_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "v1", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "v2", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "v3", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Function", + "name": "gcd", + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + } + ] + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Function", + "name": "gcd", + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Identifier", + "name": "v2" + } + ] + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "v1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9c8cc3b0fd59f141.sql b/tests/ast_json_fixtures/shapes/9c8cc3b0fd59f141.sql new file mode 100644 index 000000000000..b49185170dd6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c8cc3b0fd59f141.sql @@ -0,0 +1 @@ +CREATE TABLE primary_key_test(v1 Int64, v2 Int32, v3 String, PRIMARY KEY(v1, gcd(v1, v2))) ENGINE=ReplacingMergeTree ORDER BY v1 diff --git a/tests/ast_json_fixtures/shapes/9c8cffc4acd0e0e4.json b/tests/ast_json_fixtures/shapes/9c8cffc4acd0e0e4.json new file mode 100644 index 000000000000..08af33896ef2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c8cffc4acd0e0e4.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distr1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "shard1" + }, + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + ] + } + }, + "as_table": "shard1" + } +} diff --git a/tests/ast_json_fixtures/shapes/9c8cffc4acd0e0e4.sql b/tests/ast_json_fixtures/shapes/9c8cffc4acd0e0e4.sql new file mode 100644 index 000000000000..e4a06e8c8e63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c8cffc4acd0e0e4.sql @@ -0,0 +1 @@ +create table distr1 as shard1 engine Distributed (test_cluster_two_shards_localhost, currentDatabase(), shard1, cityHash64(id)) diff --git a/tests/ast_json_fixtures/shapes/9c8edb8a28a48260.json b/tests/ast_json_fixtures/shapes/9c8edb8a28a48260.json new file mode 100644 index 000000000000..dba05bdf4997 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c8edb8a28a48260.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "indexHint", + "arguments": [] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/9c8edb8a28a48260.sql b/tests/ast_json_fixtures/shapes/9c8edb8a28a48260.sql new file mode 100644 index 000000000000..666934c092ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9c8edb8a28a48260.sql @@ -0,0 +1,4 @@ +SELECT * +FROM tab +PREWHERE indexHint() +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/9caa7ac61894b5e6.json b/tests/ast_json_fixtures/shapes/9caa7ac61894b5e6.json new file mode 100644 index 000000000000..e96652298fc6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9caa7ac61894b5e6.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u3_01292" + } + ] + }, + "alter_settings": { + "type": "AlterSettingsProfileElements", + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9caa7ac61894b5e6.sql b/tests/ast_json_fixtures/shapes/9caa7ac61894b5e6.sql new file mode 100644 index 000000000000..a3fba8f61b7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9caa7ac61894b5e6.sql @@ -0,0 +1 @@ +ALTER USER u3_01292 SETTINGS NONE diff --git a/tests/ast_json_fixtures/shapes/9caef808da48c24d.json b/tests/ast_json_fixtures/shapes/9caef808da48c24d.json new file mode 100644 index 000000000000..e9435b1a06e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9caef808da48c24d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["user_03141"] + } +} diff --git a/tests/ast_json_fixtures/shapes/9caef808da48c24d.sql b/tests/ast_json_fixtures/shapes/9caef808da48c24d.sql new file mode 100644 index 000000000000..bab94f83bd5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9caef808da48c24d.sql @@ -0,0 +1 @@ +DROP USER user_03141 diff --git a/tests/ast_json_fixtures/shapes/9cb27bcb856beed6.json b/tests/ast_json_fixtures/shapes/9cb27bcb856beed6.json new file mode 100644 index 000000000000..a8b6bb194cdd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9cb27bcb856beed6.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "t1" + } +} diff --git a/tests/ast_json_fixtures/shapes/9cb27bcb856beed6.sql b/tests/ast_json_fixtures/shapes/9cb27bcb856beed6.sql new file mode 100644 index 000000000000..35f15f0ac7f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9cb27bcb856beed6.sql @@ -0,0 +1 @@ +CREATE TABLE t2 AS t1 Engine=Memory diff --git a/tests/ast_json_fixtures/shapes/9cbb35a31d59a85e.json b/tests/ast_json_fixtures/shapes/9cbb35a31d59a85e.json new file mode 100644 index 000000000000..38265fa9a630 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9cbb35a31d59a85e.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "subquery", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "subquery" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9cbb35a31d59a85e.sql b/tests/ast_json_fixtures/shapes/9cbb35a31d59a85e.sql new file mode 100644 index 000000000000..e7b7783b7204 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9cbb35a31d59a85e.sql @@ -0,0 +1 @@ +WITH subquery AS (SELECT 1 AS a) SELECT * FROM subquery diff --git a/tests/ast_json_fixtures/shapes/9cc244cabb63847a.json b/tests/ast_json_fixtures/shapes/9cc244cabb63847a.json new file mode 100644 index 000000000000..65f9c02ecd8b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9cc244cabb63847a.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "parallel_replicas_reading_response_timeout" + } +} diff --git a/tests/ast_json_fixtures/shapes/9cc244cabb63847a.sql b/tests/ast_json_fixtures/shapes/9cc244cabb63847a.sql new file mode 100644 index 000000000000..8d3b8f5fd8b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9cc244cabb63847a.sql @@ -0,0 +1 @@ +SYSTEM ENABLE FAILPOINT parallel_replicas_reading_response_timeout diff --git a/tests/ast_json_fixtures/shapes/9cced09419fb9a0d.json b/tests/ast_json_fixtures/shapes/9cced09419fb9a0d.json new file mode 100644 index 000000000000..a7968ddd9d93 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9cced09419fb9a0d.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "kek" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9cced09419fb9a0d.sql b/tests/ast_json_fixtures/shapes/9cced09419fb9a0d.sql new file mode 100644 index 000000000000..40f5cf9af1fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9cced09419fb9a0d.sql @@ -0,0 +1 @@ +CREATE TABLE kek (n int) SETTINGS log_queries=1 diff --git a/tests/ast_json_fixtures/shapes/9d09712879f74b86.json b/tests/ast_json_fixtures/shapes/9d09712879f74b86.json new file mode 100644 index 000000000000..e370321a334a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9d09712879f74b86.json @@ -0,0 +1,128 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "name": "finalizeAggregation", + "arguments": [ + { + "type": "Function", + "name": "uniqState", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "alias": "x", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9d09712879f74b86.sql b/tests/ast_json_fixtures/shapes/9d09712879f74b86.sql new file mode 100644 index 000000000000..783b907aac02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9d09712879f74b86.sql @@ -0,0 +1 @@ +SELECT k, finalizeAggregation(uniqState(x)) FROM (SELECT intDiv(number, 3) AS k, toNullable(1) AS x FROM system.numbers LIMIT 100000) GROUP BY k WITH TOTALS ORDER BY k LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/9d1f9d61c68e9469.json b/tests/ast_json_fixtures/shapes/9d1f9d61c68e9469.json new file mode 100644 index 000000000000..7c073af4616f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9d1f9d61c68e9469.json @@ -0,0 +1,170 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_syntax_fuse_functions": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9d1f9d61c68e9469.sql b/tests/ast_json_fixtures/shapes/9d1f9d61c68e9469.sql new file mode 100644 index 000000000000..94b11d3da7bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9d1f9d61c68e9469.sql @@ -0,0 +1,7 @@ +SELECT sum(number) +FROM t1 +PREWHERE number IN ( SELECT sum(number) FROM t1 GROUP BY number ) + WHERE number IN ( SELECT sum(number) FROM t1 GROUP BY number ) +GROUP BY number +ORDER BY number +SETTINGS optimize_syntax_fuse_functions = 1 diff --git a/tests/ast_json_fixtures/shapes/9d476fed99c5c889.json b/tests/ast_json_fixtures/shapes/9d476fed99c5c889.json new file mode 100644 index 000000000000..5590d68445c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9d476fed99c5c889.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "t0_tmp", + "to_table": "t1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9d476fed99c5c889.sql b/tests/ast_json_fixtures/shapes/9d476fed99c5c889.sql new file mode 100644 index 000000000000..90f0a14343c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9d476fed99c5c889.sql @@ -0,0 +1 @@ +RENAME TABLE t0_tmp TO t1 diff --git a/tests/ast_json_fixtures/shapes/9d552da24b2e37ce.json b/tests/ast_json_fixtures/shapes/9d552da24b2e37ce.json new file mode 100644 index 000000000000..f486b539bb46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9d552da24b2e37ce.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "i" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03644_data" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "i" + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "rows_before_aggregation": "1", + "exact_rows_before_limit": "1", + "output_format_write_statistics": "0", + "max_block_size": "100", + "aggregation_in_order_max_block_bytes": "8", + "optimize_aggregation_in_order": "1" + } + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/9d552da24b2e37ce.sql b/tests/ast_json_fixtures/shapes/9d552da24b2e37ce.sql new file mode 100644 index 000000000000..4371a0e515ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9d552da24b2e37ce.sql @@ -0,0 +1,12 @@ +select i +from 03644_data +group by i +having count() > 1 +settings + rows_before_aggregation = 1, + exact_rows_before_limit = 1, + output_format_write_statistics = 0, + max_block_size = 100, + aggregation_in_order_max_block_bytes = 8, + optimize_aggregation_in_order=1 +format JSONCompact diff --git a/tests/ast_json_fixtures/shapes/9d9e6283fc024089.json b/tests/ast_json_fixtures/shapes/9d9e6283fc024089.json new file mode 100644 index 000000000000..5c817840fddf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9d9e6283fc024089.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u3_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwe123" + } + ] + } + ], + "replace_authentication_methods": true, + "hosts": { + "local_host": true, + "addresses": ["192.169.1.1"], + "subnets": ["192.168.0.0\/16"] + }, + "default_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9d9e6283fc024089.sql b/tests/ast_json_fixtures/shapes/9d9e6283fc024089.sql new file mode 100644 index 000000000000..eb491bad6310 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9d9e6283fc024089.sql @@ -0,0 +1 @@ +CREATE USER u3_01292 IDENTIFIED BY 'qwe123' HOST IP '192.168.0.0/16', '192.169.1.1', '::1' DEFAULT ROLE r1_01292 diff --git a/tests/ast_json_fixtures/shapes/9db11c64c746c389.json b/tests/ast_json_fixtures/shapes/9db11c64c746c389.json new file mode 100644 index 000000000000..056a208d5125 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9db11c64c746c389.json @@ -0,0 +1,234 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "start_ts", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:15" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Function", + "alias": "end_ts", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Function", + "name": "toIntervalSecond", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "step_seconds", + "value_type": "UInt64", + "value": "15" + }, + { + "type": "Literal", + "alias": "window_seconds", + "value_type": "UInt64", + "value": "45" + } + ], + "select": [ + { + "type": "Identifier", + "name": "metric_id" + }, + { + "type": "Function", + "name": "timeSeriesInstantDeltaToGrid", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + }, + { + "type": "Identifier", + "name": "value" + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Identifier", + "name": "end_ts" + }, + { + "type": "Identifier", + "name": "step_seconds" + }, + { + "type": "Identifier", + "name": "window_seconds" + } + ] + }, + { + "type": "Function", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + }, + { + "type": "Identifier", + "name": "value" + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Identifier", + "name": "end_ts" + }, + { + "type": "Identifier", + "name": "step_seconds" + }, + { + "type": "Identifier", + "name": "window_seconds" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_raw_timeseries" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "metric_id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Function", + "name": "toIntervalSecond", + "arguments": [ + { + "type": "Identifier", + "name": "window_seconds" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + }, + { + "type": "Identifier", + "name": "end_ts" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "metric_id" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9db11c64c746c389.sql b/tests/ast_json_fixtures/shapes/9db11c64c746c389.sql new file mode 100644 index 000000000000..cfeaac90deca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9db11c64c746c389.sql @@ -0,0 +1,12 @@ +WITH + '2024-12-12 12:00:15'::DateTime64(3,'UTC') AS start_ts, + start_ts + interval 60 second AS end_ts, + 15 AS step_seconds, + 45 AS window_seconds +SELECT + metric_id, + timeSeriesInstantDeltaToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value), + timeSeriesInstantRateToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamp, value) +FROM t_raw_timeseries +WHERE metric_id = 3 AND timestamp BETWEEN start_ts - interval window_seconds seconds AND end_ts +GROUP BY metric_id diff --git a/tests/ast_json_fixtures/shapes/9dc2767ef3f94c03.json b/tests/ast_json_fixtures/shapes/9dc2767ef3f94c03.json new file mode 100644 index 000000000000..bedabc02c152 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9dc2767ef3f94c03.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table3" + }, + "as_table": "table2" + } +} diff --git a/tests/ast_json_fixtures/shapes/9dc2767ef3f94c03.sql b/tests/ast_json_fixtures/shapes/9dc2767ef3f94c03.sql new file mode 100644 index 000000000000..8ac8b843d1c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9dc2767ef3f94c03.sql @@ -0,0 +1 @@ +CREATE TABLE table3 AS table2 diff --git a/tests/ast_json_fixtures/shapes/9dc753ff7dc761ec.json b/tests/ast_json_fixtures/shapes/9dc753ff7dc761ec.json new file mode 100644 index 000000000000..24e2906df436 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9dc753ff7dc761ec.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "k", + "name": "i" + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "alias_key_condition" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "i" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "alias_key_condition" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9dc753ff7dc761ec.sql b/tests/ast_json_fixtures/shapes/9dc753ff7dc761ec.sql new file mode 100644 index 000000000000..8703f1c5c1ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9dc753ff7dc761ec.sql @@ -0,0 +1 @@ +with i as k select * from alias_key_condition where k = (select i from alias_key_condition where i = 3) diff --git a/tests/ast_json_fixtures/shapes/9dd23183ad586059.json b/tests/ast_json_fixtures/shapes/9dd23183ad586059.json new file mode 100644 index 000000000000..3d179c518ca5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9dd23183ad586059.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "offset", + "value_type": "Int64", + "value": "-4" + }, + { + "type": "Identifier", + "alias": "length", + "name": "number" + }, + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "Hello" + }, + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Function", + "name": "bin", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "length" + } + ] + }, + { + "type": "Function", + "name": "bin", + "arguments": [ + { + "type": "Function", + "name": "bitSlice", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "length" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9dd23183ad586059.sql b/tests/ast_json_fixtures/shapes/9dd23183ad586059.sql new file mode 100644 index 000000000000..8e52223c18ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9dd23183ad586059.sql @@ -0,0 +1 @@ +select -4 as offset, number as length, 'Hello' as s, subString(bin(s), offset , length), bin(bitSlice(s, offset, length)) from numbers(9) diff --git a/tests/ast_json_fixtures/shapes/9dea5f1e9e1a3717.json b/tests/ast_json_fixtures/shapes/9dea5f1e9e1a3717.json new file mode 100644 index 000000000000..e8037abdf237 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9dea5f1e9e1a3717.json @@ -0,0 +1,83 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "EXCEPT DISTINCT", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9dea5f1e9e1a3717.sql b/tests/ast_json_fixtures/shapes/9dea5f1e9e1a3717.sql new file mode 100644 index 000000000000..79c2eb51a838 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9dea5f1e9e1a3717.sql @@ -0,0 +1 @@ +SELECT 2 FROM numbers(10) EXCEPT DISTINCT SELECT 1 FROM numbers(5) diff --git a/tests/ast_json_fixtures/shapes/9deacacc072715af.json b/tests/ast_json_fixtures/shapes/9deacacc072715af.json new file mode 100644 index 000000000000..d2234f7ac921 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9deacacc072715af.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_virtual_row_sparse_pk" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "settings": { + "type": "Settings", + "changes": { + "read_in_order_use_virtual_row": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9deacacc072715af.sql b/tests/ast_json_fixtures/shapes/9deacacc072715af.sql new file mode 100644 index 000000000000..a1f77901b0a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9deacacc072715af.sql @@ -0,0 +1 @@ +SELECT a, b FROM t_virtual_row_sparse_pk PREWHERE a < 100000 ORDER BY (a, b) LIMIT 5 SETTINGS read_in_order_use_virtual_row = 1 diff --git a/tests/ast_json_fixtures/shapes/9e02b53905982bfe.json b/tests/ast_json_fixtures/shapes/9e02b53905982bfe.json new file mode 100644 index 000000000000..728b221fc033 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e02b53905982bfe.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": " spaces " + } + ] + }, + "new_name": " INTERSERVER SECRET " + } +} diff --git a/tests/ast_json_fixtures/shapes/9e02b53905982bfe.sql b/tests/ast_json_fixtures/shapes/9e02b53905982bfe.sql new file mode 100644 index 000000000000..26b59ec28434 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e02b53905982bfe.sql @@ -0,0 +1 @@ +alter user " spaces " rename to " INTERSERVER SECRET " diff --git a/tests/ast_json_fixtures/shapes/9e07077e8b6fc679.json b/tests/ast_json_fixtures/shapes/9e07077e8b6fc679.json new file mode 100644 index 000000000000..08446e378122 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e07077e8b6fc679.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "number" + } + }, + "as_database": "system", + "as_table": "numbers" + } +} diff --git a/tests/ast_json_fixtures/shapes/9e07077e8b6fc679.sql b/tests/ast_json_fixtures/shapes/9e07077e8b6fc679.sql new file mode 100644 index 000000000000..411ee6afb220 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e07077e8b6fc679.sql @@ -0,0 +1 @@ +CREATE TABLE x AS system.numbers ENGINE = MergeTree ORDER BY number diff --git a/tests/ast_json_fixtures/shapes/9e11918c6dd9b62c.json b/tests/ast_json_fixtures/shapes/9e11918c6dd9b62c.json new file mode 100644 index 000000000000..4d14f3794aa2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e11918c6dd9b62c.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_distributed_1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test_local_1" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "test_local_1" + } +} diff --git a/tests/ast_json_fixtures/shapes/9e11918c6dd9b62c.sql b/tests/ast_json_fixtures/shapes/9e11918c6dd9b62c.sql new file mode 100644 index 000000000000..c4f5758b7a6f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e11918c6dd9b62c.sql @@ -0,0 +1 @@ +CREATE TABLE test_distributed_1 AS test_local_1 ENGINE = Distributed('test_shard_localhost', currentDatabase(), test_local_1, rand()) diff --git a/tests/ast_json_fixtures/shapes/9e11e0cdf6d683e1.json b/tests/ast_json_fixtures/shapes/9e11e0cdf6d683e1.json new file mode 100644 index 000000000000..7da2d6fa2fd3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e11e0cdf6d683e1.json @@ -0,0 +1,104 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "used_functions" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryStart" + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%repeat%" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "query_start_time" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "TabSeparatedWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/9e11e0cdf6d683e1.sql b/tests/ast_json_fixtures/shapes/9e11e0cdf6d683e1.sql new file mode 100644 index 000000000000..a0a64fe92de3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e11e0cdf6d683e1.sql @@ -0,0 +1,3 @@ +SELECT used_functions +FROM system.query_log WHERE current_database = currentDatabase() AND type != 'QueryStart' AND (query LIKE '%repeat%') +ORDER BY query_start_time DESC LIMIT 1 FORMAT TabSeparatedWithNames diff --git a/tests/ast_json_fixtures/shapes/9e220ebff2a2fa27.json b/tests/ast_json_fixtures/shapes/9e220ebff2a2fa27.json new file mode 100644 index 000000000000..f89018f3a95d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e220ebff2a2fa27.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_STATISTICS", + "if_exists": true, + "statistics_declaration": { + "type": "Stat", + "columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "no_such_column" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9e220ebff2a2fa27.sql b/tests/ast_json_fixtures/shapes/9e220ebff2a2fa27.sql new file mode 100644 index 000000000000..8269022c8924 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e220ebff2a2fa27.sql @@ -0,0 +1 @@ +ALTER TABLE tab MATERIALIZE STATISTICS IF EXISTS no_such_column diff --git a/tests/ast_json_fixtures/shapes/9e41a102a9fc8333.json b/tests/ast_json_fixtures/shapes/9e41a102a9fc8333.json new file mode 100644 index 000000000000..b27c595a3fb5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e41a102a9fc8333.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "03655_keepermap" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "COMMENT_COLUMN", + "column": { + "type": "Identifier", + "name": "k" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "some comment" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9e41a102a9fc8333.sql b/tests/ast_json_fixtures/shapes/9e41a102a9fc8333.sql new file mode 100644 index 000000000000..1fc93011faea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e41a102a9fc8333.sql @@ -0,0 +1 @@ +ALTER TABLE 03655_keepermap COMMENT COLUMN k 'some comment' diff --git a/tests/ast_json_fixtures/shapes/9e72fab3a55fd2a4.json b/tests/ast_json_fixtures/shapes/9e72fab3a55fd2a4.json new file mode 100644 index 000000000000..0edd52ef6534 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e72fab3a55fd2a4.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["test_user_01999"] + } +} diff --git a/tests/ast_json_fixtures/shapes/9e72fab3a55fd2a4.sql b/tests/ast_json_fixtures/shapes/9e72fab3a55fd2a4.sql new file mode 100644 index 000000000000..7442ab5ef5e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e72fab3a55fd2a4.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS test_user_01999 diff --git a/tests/ast_json_fixtures/shapes/9e8d3fb4e9eabcb6.json b/tests/ast_json_fixtures/shapes/9e8d3fb4e9eabcb6.json new file mode 100644 index 000000000000..41d8771ea02b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e8d3fb4e9eabcb6.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "i" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "j" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9e8d3fb4e9eabcb6.sql b/tests/ast_json_fixtures/shapes/9e8d3fb4e9eabcb6.sql new file mode 100644 index 000000000000..4f914604d5ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9e8d3fb4e9eabcb6.sql @@ -0,0 +1 @@ +select i from t prewhere j = 4 diff --git a/tests/ast_json_fixtures/shapes/9ea344ff627ae79b.json b/tests/ast_json_fixtures/shapes/9ea344ff627ae79b.json new file mode 100644 index 000000000000..0290e184e058 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ea344ff627ae79b.json @@ -0,0 +1,154 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c1.key", + "name_parts": ["c1", "key"] + }, + { + "type": "Identifier", + "name": "c1.name", + "name_parts": ["c1", "name"] + }, + { + "type": "Identifier", + "name": "c1.ref_valueF32", + "name_parts": ["c1", "ref_valueF32"] + }, + { + "type": "Identifier", + "name": "c1.valueF32", + "name_parts": ["c1", "valueF32"] + }, + { + "type": "Function", + "alias": "dF32", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c1.ref_valueF32", + "name_parts": ["c1", "ref_valueF32"] + }, + { + "type": "Identifier", + "name": "c1.valueF32", + "name_parts": ["c1", "valueF32"] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "prev:" + }, + { + "type": "Identifier", + "name": "c2.key", + "name_parts": ["c2", "key"] + }, + { + "type": "Identifier", + "name": "c2.ref_valueF32", + "name_parts": ["c2", "ref_valueF32"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "c1", + "name": "codecTest" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "c2", + "name": "codecTest" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "dF32" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c2.key", + "name_parts": ["c2", "key"] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c1.key", + "name_parts": ["c1", "key"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9ea344ff627ae79b.sql b/tests/ast_json_fixtures/shapes/9ea344ff627ae79b.sql new file mode 100644 index 000000000000..465e7f125305 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ea344ff627ae79b.sql @@ -0,0 +1,12 @@ +SELECT + c1.key, c1.name, + c1.ref_valueF32, c1.valueF32, c1.ref_valueF32 - c1.valueF32 AS dF32, + 'prev:', + c2.key, c2.ref_valueF32 +FROM + codecTest as c1, codecTest as c2 +WHERE + dF32 != 0 +AND + c2.key = c1.key - 1 +LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/9eb0b6e906432899.json b/tests/ast_json_fixtures/shapes/9eb0b6e906432899.json new file mode 100644 index 000000000000..3b2c85be79d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9eb0b6e906432899.json @@ -0,0 +1,83 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "with": [ + { + "type": "Function", + "alias": "resolutions", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "resolution" + }, + { + "type": "Function", + "name": "h3PolygonToCells", + "arguments": [ + { + "type": "Identifier", + "name": "ring" + }, + { + "type": "Function", + "alias": "resolution", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "resolutions" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "rings" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "resolution" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9eb0b6e906432899.sql b/tests/ast_json_fixtures/shapes/9eb0b6e906432899.sql new file mode 100644 index 000000000000..8acf16aeb7fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9eb0b6e906432899.sql @@ -0,0 +1,3 @@ +WITH range(0, 8) AS resolutions +SELECT DISTINCT resolution, h3PolygonToCells(ring, arrayJoin(resolutions) AS resolution) FROM rings +ORDER BY resolution diff --git a/tests/ast_json_fixtures/shapes/9ed13d4c284af5a6.json b/tests/ast_json_fixtures/shapes/9ed13d4c284af5a6.json new file mode 100644 index 000000000000..a180a5c70464 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ed13d4c284af5a6.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "prime" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "primes", + "database": "system" + } + } + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9ed13d4c284af5a6.sql b/tests/ast_json_fixtures/shapes/9ed13d4c284af5a6.sql new file mode 100644 index 000000000000..a91760676210 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ed13d4c284af5a6.sql @@ -0,0 +1,3 @@ +SELECT prime +FROM system.primes +LIMIT 10 OFFSET 5 diff --git a/tests/ast_json_fixtures/shapes/9ef17ede4fcb13dc.json b/tests/ast_json_fixtures/shapes/9ef17ede4fcb13dc.json new file mode 100644 index 000000000000..68c1639249a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ef17ede4fcb13dc.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/9ef17ede4fcb13dc.sql b/tests/ast_json_fixtures/shapes/9ef17ede4fcb13dc.sql new file mode 100644 index 000000000000..1ac8d0e27377 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ef17ede4fcb13dc.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) ORDER BY number FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/9f119cecf44da275.json b/tests/ast_json_fixtures/shapes/9f119cecf44da275.json new file mode 100644 index 000000000000..2f7214a2e87f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f119cecf44da275.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "cc" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ATTACH_PARTITION", + "part": true, + "partition": { + "type": "Literal", + "value_type": "String", + "value": "all_1_1_0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9f119cecf44da275.sql b/tests/ast_json_fixtures/shapes/9f119cecf44da275.sql new file mode 100644 index 000000000000..bc7034f61a4c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f119cecf44da275.sql @@ -0,0 +1 @@ +alter table cc attach part 'all_1_1_0' diff --git a/tests/ast_json_fixtures/shapes/9f3f9db46831e0c8.json b/tests/ast_json_fixtures/shapes/9f3f9db46831e0c8.json new file mode 100644 index 000000000000..94cff5c0e80e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f3f9db46831e0c8.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "STOP REPLICATED SENDS", + "table": { + "type": "Identifier", + "name": "r1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9f3f9db46831e0c8.sql b/tests/ast_json_fixtures/shapes/9f3f9db46831e0c8.sql new file mode 100644 index 000000000000..7a3f04223ed5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f3f9db46831e0c8.sql @@ -0,0 +1 @@ +SYSTEM STOP REPLICATED SENDS r1 diff --git a/tests/ast_json_fixtures/shapes/9f496a3b08c0bcbb.json b/tests/ast_json_fixtures/shapes/9f496a3b08c0bcbb.json new file mode 100644 index 000000000000..59a12dff3192 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f496a3b08c0bcbb.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN CURRENT TRANSACTION" + } +} diff --git a/tests/ast_json_fixtures/shapes/9f496a3b08c0bcbb.sql b/tests/ast_json_fixtures/shapes/9f496a3b08c0bcbb.sql new file mode 100644 index 000000000000..fe719d9f51ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f496a3b08c0bcbb.sql @@ -0,0 +1 @@ +EXPLAIN CURRENT TRANSACTION diff --git a/tests/ast_json_fixtures/shapes/9f6a5ef8bcd7d441.json b/tests/ast_json_fixtures/shapes/9f6a5ef8bcd7d441.json new file mode 100644 index 000000000000..9458bd5c7f88 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f6a5ef8bcd7d441.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s9_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "parent_profile": "default" + }, + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "value": "5000000", + "writability": "WRITABLE" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/9f6a5ef8bcd7d441.sql b/tests/ast_json_fixtures/shapes/9f6a5ef8bcd7d441.sql new file mode 100644 index 000000000000..4a695fd9ab67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f6a5ef8bcd7d441.sql @@ -0,0 +1 @@ +CREATE PROFILE s9_01294 SETTINGS INHERIT 'default', max_memory_usage=5000000 WRITABLE diff --git a/tests/ast_json_fixtures/shapes/9f776eb5f8f5547e.json b/tests/ast_json_fixtures/shapes/9f776eb5f8f5547e.json new file mode 100644 index 000000000000..9c64fe5a6b8c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f776eb5f8f5547e.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q3_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/9f776eb5f8f5547e.sql b/tests/ast_json_fixtures/shapes/9f776eb5f8f5547e.sql new file mode 100644 index 000000000000..f80ca6d119a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f776eb5f8f5547e.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q3_01297 diff --git a/tests/ast_json_fixtures/shapes/9f8373c499c16d09.json b/tests/ast_json_fixtures/shapes/9f8373c499c16d09.json new file mode 100644 index 000000000000..04d2555e784c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f8373c499c16d09.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/9f8373c499c16d09.sql b/tests/ast_json_fixtures/shapes/9f8373c499c16d09.sql new file mode 100644 index 000000000000..6cef3755935a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f8373c499c16d09.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) ORDER BY number FORMAT PrettySpace diff --git a/tests/ast_json_fixtures/shapes/9f9965c34df63a90.json b/tests/ast_json_fixtures/shapes/9f9965c34df63a90.json new file mode 100644 index 000000000000..1c510387b65e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f9965c34df63a90.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "asynchronous_insert_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9f9965c34df63a90.sql b/tests/ast_json_fixtures/shapes/9f9965c34df63a90.sql new file mode 100644 index 000000000000..3cead50c307c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9f9965c34df63a90.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS asynchronous_insert_log diff --git a/tests/ast_json_fixtures/shapes/9fd52e7634614864.json b/tests/ast_json_fixtures/shapes/9fd52e7634614864.json new file mode 100644 index 000000000000..4d5a0833dc9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9fd52e7634614864.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "wkb", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "geom1" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/9fd52e7634614864.sql b/tests/ast_json_fixtures/shapes/9fd52e7634614864.sql new file mode 100644 index 000000000000..5267b5966d8a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9fd52e7634614864.sql @@ -0,0 +1 @@ +SELECT hex(wkb(a)) FROM geom1 ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/9ffd1a5226544515.json b/tests/ast_json_fixtures/shapes/9ffd1a5226544515.json new file mode 100644 index 000000000000..b05a8d020a3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ffd1a5226544515.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "RESTART REPLICAS" + } +} diff --git a/tests/ast_json_fixtures/shapes/9ffd1a5226544515.sql b/tests/ast_json_fixtures/shapes/9ffd1a5226544515.sql new file mode 100644 index 000000000000..4e18dd11600c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/9ffd1a5226544515.sql @@ -0,0 +1 @@ +SYSTEM RESTART REPLICAS diff --git a/tests/ast_json_fixtures/shapes/a0120d59ae09c86a.json b/tests/ast_json_fixtures/shapes/a0120d59ae09c86a.json new file mode 100644 index 000000000000..0fd6fd9c5f03 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0120d59ae09c86a.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c1" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a0120d59ae09c86a.sql b/tests/ast_json_fixtures/shapes/a0120d59ae09c86a.sql new file mode 100644 index 000000000000..2e0940ef2ee6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0120d59ae09c86a.sql @@ -0,0 +1 @@ +SELECT * FROM t1 ORDER BY c1 LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/a027b15c1bed9e3c.json b/tests/ast_json_fixtures/shapes/a027b15c1bed9e3c.json new file mode 100644 index 000000000000..face9eeecc9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a027b15c1bed9e3c.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "mode", + "value_type": "String", + "value": "aes-256-ecb" + }, + { + "type": "Function", + "alias": "ciphertext", + "name": "unhex", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "D1B43643E1D0E9390E39BA4EAE150851" + } + ] + }, + { + "type": "Literal", + "alias": "key", + "value_type": "String", + "value": "test_key________________________" + } + ], + "select": [ + { + "type": "Identifier", + "name": "mode" + }, + { + "type": "Function", + "name": "decrypt", + "arguments": [ + { + "type": "Identifier", + "name": "mode" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Identifier", + "name": "ciphertext" + } + ] + }, + { + "type": "Identifier", + "name": "key" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a027b15c1bed9e3c.sql b/tests/ast_json_fixtures/shapes/a027b15c1bed9e3c.sql new file mode 100644 index 000000000000..4b274888bdc3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a027b15c1bed9e3c.sql @@ -0,0 +1,2 @@ +WITH 'aes-256-ecb' as mode, unhex('D1B43643E1D0E9390E39BA4EAE150851') as ciphertext, 'test_key________________________' as key +SELECT mode, decrypt(mode, toNullable(ciphertext), key) diff --git a/tests/ast_json_fixtures/shapes/a027c9d52c1f7e2f.json b/tests/ast_json_fixtures/shapes/a027c9d52c1f7e2f.json new file mode 100644 index 000000000000..16c3a9130f7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a027c9d52c1f7e2f.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "lo.c4", + "name_parts": ["lo", "c4"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "l", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toInt64OrNull", + "arguments": [ + { + "type": "Identifier", + "name": "l.c3", + "name_parts": ["l", "c3"] + } + ] + }, + { + "type": "Identifier", + "name": "lo.c4", + "name_parts": ["lo", "c4"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "lo", + "name": "t2" + } + } + } + ] + } + } + ], + "format": "NULL" + } +} diff --git a/tests/ast_json_fixtures/shapes/a027c9d52c1f7e2f.sql b/tests/ast_json_fixtures/shapes/a027c9d52c1f7e2f.sql new file mode 100644 index 000000000000..a96594e81f74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a027c9d52c1f7e2f.sql @@ -0,0 +1 @@ +SELECT lo.c4 FROM t1 AS l INNER JOIN t2 AS lo ON toInt64OrNull(l.c3) = lo.c4 FORMAT NULL diff --git a/tests/ast_json_fixtures/shapes/a03625dbf94940b4.json b/tests/ast_json_fixtures/shapes/a03625dbf94940b4.json new file mode 100644 index 000000000000..9c350c98aa17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a03625dbf94940b4.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "Hello" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a03625dbf94940b4.sql b/tests/ast_json_fixtures/shapes/a03625dbf94940b4.sql new file mode 100644 index 000000000000..60cf0c86e888 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a03625dbf94940b4.sql @@ -0,0 +1 @@ +CREATE TABLE t (x UInt8) ENGINE = MergeTree ORDER BY () COMMENT 'Hello' diff --git a/tests/ast_json_fixtures/shapes/a0539d9c27f6449d.json b/tests/ast_json_fixtures/shapes/a0539d9c27f6449d.json new file mode 100644 index 000000000000..4b3a7ab10717 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0539d9c27f6449d.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_all" + } + } + } + ] + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a0539d9c27f6449d.sql b/tests/ast_json_fixtures/shapes/a0539d9c27f6449d.sql new file mode 100644 index 000000000000..d32a560c2c9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0539d9c27f6449d.sql @@ -0,0 +1,3 @@ +SELECT count() +FROM test_limit_by_all +LIMIT 1 BY ALL diff --git a/tests/ast_json_fixtures/shapes/a06c99fd51529efb.json b/tests/ast_json_fixtures/shapes/a06c99fd51529efb.json new file mode 100644 index 000000000000..53f5caeb465b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a06c99fd51529efb.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_table" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "m4" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "d8" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a06c99fd51529efb.sql b/tests/ast_json_fixtures/shapes/a06c99fd51529efb.sql new file mode 100644 index 000000000000..5eb12534c630 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a06c99fd51529efb.sql @@ -0,0 +1 @@ +SELECT _table, * FROM m4 WHERE _table = 'd8' ORDER BY key ASC diff --git a/tests/ast_json_fixtures/shapes/a078af6e6e4d384a.json b/tests/ast_json_fixtures/shapes/a078af6e6e4d384a.json new file mode 100644 index 000000000000..230758902e12 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a078af6e6e4d384a.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "res", + "name": "sleepEachRow", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_execution_time": "2" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/a078af6e6e4d384a.sql b/tests/ast_json_fixtures/shapes/a078af6e6e4d384a.sql new file mode 100644 index 000000000000..f1e0cdce71ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a078af6e6e4d384a.sql @@ -0,0 +1,5 @@ +WITH sleepEachRow(3) AS res +SELECT * +FROM system.one +FORMAT Null +SETTINGS max_execution_time = 2 diff --git a/tests/ast_json_fixtures/shapes/a0993ba3828f5d9c.json b/tests/ast_json_fixtures/shapes/a0993ba3828f5d9c.json new file mode 100644 index 000000000000..eb145635a8d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0993ba3828f5d9c.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DetachQuery", + "kind": "DETACH", + "table": { + "type": "Identifier", + "name": "t" + }, + "sync": true + } +} diff --git a/tests/ast_json_fixtures/shapes/a0993ba3828f5d9c.sql b/tests/ast_json_fixtures/shapes/a0993ba3828f5d9c.sql new file mode 100644 index 000000000000..0acc32691a18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0993ba3828f5d9c.sql @@ -0,0 +1 @@ +DETACH TABLE t SYNC diff --git a/tests/ast_json_fixtures/shapes/a0a370915e88fd78.json b/tests/ast_json_fixtures/shapes/a0a370915e88fd78.json new file mode 100644 index 000000000000..543932bc9b4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0a370915e88fd78.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "\"", + "value_type": "String", + "value": "\\" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_write_statistics": "0" + } + }, + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/a0a370915e88fd78.sql b/tests/ast_json_fixtures/shapes/a0a370915e88fd78.sql new file mode 100644 index 000000000000..4e325559d3e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0a370915e88fd78.sql @@ -0,0 +1 @@ +SELECT '\\' AS `"` FORMAT JSON SETTINGS output_format_write_statistics = 0 diff --git a/tests/ast_json_fixtures/shapes/a0ad7c7472d467fe.json b/tests/ast_json_fixtures/shapes/a0ad7c7472d467fe.json new file mode 100644 index 000000000000..9e694fb01b92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0ad7c7472d467fe.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_max_rows_to_read" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "4" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/a0ad7c7472d467fe.sql b/tests/ast_json_fixtures/shapes/a0ad7c7472d467fe.sql new file mode 100644 index 000000000000..28a5d156d6be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0ad7c7472d467fe.sql @@ -0,0 +1 @@ +SELECT a FROM t_max_rows_to_read WHERE a = 10 OR a = 20 FORMAT Null SETTINGS max_rows_to_read = 4 diff --git a/tests/ast_json_fixtures/shapes/a0c7e8c3646c44e4.json b/tests/ast_json_fixtures/shapes/a0c7e8c3646c44e4.json new file mode 100644 index 000000000000..602094b04f4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0c7e8c3646c44e4.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a0c7e8c3646c44e4.sql b/tests/ast_json_fixtures/shapes/a0c7e8c3646c44e4.sql new file mode 100644 index 000000000000..92269b786cc8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0c7e8c3646c44e4.sql @@ -0,0 +1 @@ +SELECT * FROM tab SETTINGS max_threads=1 diff --git a/tests/ast_json_fixtures/shapes/a0d088187a812531.json b/tests/ast_json_fixtures/shapes/a0d088187a812531.json new file mode 100644 index 000000000000..8239395b700d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0d088187a812531.json @@ -0,0 +1,93 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "toInt8", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.1" + }, + { + "type": "Identifier", + "name": "system.numbers", + "name_parts": ["system", "numbers"] + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a0d088187a812531.sql b/tests/ast_json_fixtures/shapes/a0d088187a812531.sql new file mode 100644 index 000000000000..c01d17315415 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0d088187a812531.sql @@ -0,0 +1 @@ +SELECT toInt8(number / 5 + 100) AS x FROM remote('127.0.0.1', system.numbers) LIMIT 2 BY x LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/a0d15c374ac1cc21.json b/tests/ast_json_fixtures/shapes/a0d15c374ac1cc21.json new file mode 100644 index 000000000000..c9349383e1f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0d15c374ac1cc21.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q1_01297"], + "limits": [ + { + "duration_sec": "432000", + "drop": true + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a0d15c374ac1cc21.sql b/tests/ast_json_fixtures/shapes/a0d15c374ac1cc21.sql new file mode 100644 index 000000000000..5dbb24db4731 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0d15c374ac1cc21.sql @@ -0,0 +1 @@ +ALTER QUOTA q1_01297 FOR INTERVAL 5 DAY NO LIMITS diff --git a/tests/ast_json_fixtures/shapes/a0dec9cf88cc7df9.json b/tests/ast_json_fixtures/shapes/a0dec9cf88cc7df9.json new file mode 100644 index 000000000000..00c4d952f04e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0dec9cf88cc7df9.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "n", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt64" + } + ] + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a0dec9cf88cc7df9.sql b/tests/ast_json_fixtures/shapes/a0dec9cf88cc7df9.sql new file mode 100644 index 000000000000..a07ac2f11644 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0dec9cf88cc7df9.sql @@ -0,0 +1,3 @@ +WITH cast(10, 'UInt64') AS n +SELECT * +FROM numbers(n) diff --git a/tests/ast_json_fixtures/shapes/a0e63e9dea3f43c8.json b/tests/ast_json_fixtures/shapes/a0e63e9dea3f43c8.json new file mode 100644 index 000000000000..63935733f3e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0e63e9dea3f43c8.json @@ -0,0 +1,113 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "t1.dummy", + "name_parts": ["t1", "dummy"] + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t2" + } + }, + { + "type": "Identifier", + "name": "t3.dummy", + "name_parts": ["t3", "dummy"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "one", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.dummy", + "name_parts": ["t1", "dummy"] + }, + { + "type": "Identifier", + "name": "t2.dummy", + "name_parts": ["t2", "dummy"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "one", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.dummy", + "name_parts": ["t1", "dummy"] + }, + { + "type": "Identifier", + "name": "t3.dummy", + "name_parts": ["t3", "dummy"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t3", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a0e63e9dea3f43c8.sql b/tests/ast_json_fixtures/shapes/a0e63e9dea3f43c8.sql new file mode 100644 index 000000000000..1eb5af111d6c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a0e63e9dea3f43c8.sql @@ -0,0 +1 @@ +select t1.dummy, t2.*, t3.dummy from system.one t1 join system.one t2 on t1.dummy = t2.dummy join system.one t3 ON t1.dummy = t3.dummy diff --git a/tests/ast_json_fixtures/shapes/a141e3ed0f80bfe4.json b/tests/ast_json_fixtures/shapes/a141e3ed0f80bfe4.json new file mode 100644 index 000000000000..f7c9af89ca9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a141e3ed0f80bfe4.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s2_01294"], + "to_roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a141e3ed0f80bfe4.sql b/tests/ast_json_fixtures/shapes/a141e3ed0f80bfe4.sql new file mode 100644 index 000000000000..af88846ae002 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a141e3ed0f80bfe4.sql @@ -0,0 +1 @@ +CREATE PROFILE s2_01294 TO ALL diff --git a/tests/ast_json_fixtures/shapes/a14ec8a3155fb285.json b/tests/ast_json_fixtures/shapes/a14ec8a3155fb285.json new file mode 100644 index 000000000000..9c231d4da3ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a14ec8a3155fb285.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "where": { + "type": "Literal", + "value_type": "Null", + "value": null + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a14ec8a3155fb285.sql b/tests/ast_json_fixtures/shapes/a14ec8a3155fb285.sql new file mode 100644 index 000000000000..3782b51a5252 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a14ec8a3155fb285.sql @@ -0,0 +1 @@ +SELECT 1 WHERE NULL diff --git a/tests/ast_json_fixtures/shapes/a1862a902812d74d.json b/tests/ast_json_fixtures/shapes/a1862a902812d74d.json new file mode 100644 index 000000000000..9694b9c4c83b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a1862a902812d74d.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01223" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a1862a902812d74d.sql b/tests/ast_json_fixtures/shapes/a1862a902812d74d.sql new file mode 100644 index 000000000000..20b425293a88 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a1862a902812d74d.sql @@ -0,0 +1 @@ +select * from dist_01223 order by key limit 1 by key diff --git a/tests/ast_json_fixtures/shapes/a18d9bcfbf566491.json b/tests/ast_json_fixtures/shapes/a18d9bcfbf566491.json new file mode 100644 index 000000000000..82abd8b06879 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a18d9bcfbf566491.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "d0" + }, + "is_dictionary": true + } +} diff --git a/tests/ast_json_fixtures/shapes/a18d9bcfbf566491.sql b/tests/ast_json_fixtures/shapes/a18d9bcfbf566491.sql new file mode 100644 index 000000000000..c72343531c06 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a18d9bcfbf566491.sql @@ -0,0 +1 @@ +DROP DICTIONARY d0 diff --git a/tests/ast_json_fixtures/shapes/a1adb40ac0e51cf5.json b/tests/ast_json_fixtures/shapes/a1adb40ac0e51cf5.json new file mode 100644 index 000000000000..c11d28d98b3a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a1adb40ac0e51cf5.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mytable" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "operand", + "data_type": { + "type": "DataType", + "name": "Float64" + } + }, + { + "type": "ColumnDeclaration", + "name": "low", + "data_type": { + "type": "DataType", + "name": "Float64" + } + }, + { + "type": "ColumnDeclaration", + "name": "high", + "data_type": { + "type": "DataType", + "name": "Float64" + } + }, + { + "type": "ColumnDeclaration", + "name": "count", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "operand" + }, + { + "type": "Identifier", + "name": "low" + }, + { + "type": "Identifier", + "name": "high" + }, + { + "type": "Identifier", + "name": "count" + } + ] + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "operand" + }, + { + "type": "Identifier", + "name": "low" + }, + { + "type": "Identifier", + "name": "high" + }, + { + "type": "Identifier", + "name": "count" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a1adb40ac0e51cf5.sql b/tests/ast_json_fixtures/shapes/a1adb40ac0e51cf5.sql new file mode 100644 index 000000000000..33597bccc79c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a1adb40ac0e51cf5.sql @@ -0,0 +1,8 @@ +CREATE TABLE mytable +( + operand Float64, + low Float64, + high Float64, + count UInt64, + PRIMARY KEY (operand, low, high, count) +) ENGINE = MergeTree() diff --git a/tests/ast_json_fixtures/shapes/a1d095909a2677e0.json b/tests/ast_json_fixtures/shapes/a1d095909a2677e0.json new file mode 100644 index 000000000000..8ce195a1a044 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a1d095909a2677e0.json @@ -0,0 +1,238 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "9223372036854775807" + }, + { + "value_type": "Float64", + "value": 1.1754943508222875e-38 + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "polygonsSymDifferenceCartesian", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 1.1754943508222875e-38 + }, + { + "value_type": "Float64", + "value": 1.1920928955078125e-7 + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 0.5 + }, + { + "value_type": "Float64", + "value": 0.5 + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 1.1754943508222875e-38 + }, + { + "value_type": "Float64", + "value": 1.1920928955078125e-7 + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 1.1754943508222875e-38 + }, + { + "value_type": "Float64", + "value": 1.1920928955078125e-7 + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 0 + }, + { + "value_type": "Float64", + "value": 1.0001 + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "x", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 1 + }, + { + "value_type": "Float64", + "value": 1.0001 + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "Float64", + "value": 3.4028234663852886e38 + }, + { + "value_type": "Float64", + "value": 0.9999 + } + ] + } + ] + } + ] + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a1d095909a2677e0.sql b/tests/ast_json_fixtures/shapes/a1d095909a2677e0.sql new file mode 100644 index 000000000000..47b58b0ac88f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a1d095909a2677e0.sql @@ -0,0 +1 @@ +SELECT [(9223372036854775807, 1.1754943508222875e-38)], x, NULL, polygonsSymDifferenceCartesian([[[(1.1754943508222875e-38, 1.1920928955078125e-7), (0.5, 0.5)]], [[(1.1754943508222875e-38, 1.1920928955078125e-7), (1.1754943508222875e-38, 1.1920928955078125e-7)], [(0., 1.0001)]], [[(1., 1.0001)]] AS x], [[[(3.4028234663852886e38, 0.9999)]]]) GROUP BY GROUPING SETS ((x)) WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/a1e8c8d0b58a40d6.json b/tests/ast_json_fixtures/shapes/a1e8c8d0b58a40d6.json new file mode 100644 index 000000000000..9cfb46c43c45 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a1e8c8d0b58a40d6.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "e" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "enum_totals" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "e" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "e" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a1e8c8d0b58a40d6.sql b/tests/ast_json_fixtures/shapes/a1e8c8d0b58a40d6.sql new file mode 100644 index 000000000000..ea967546d447 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a1e8c8d0b58a40d6.sql @@ -0,0 +1 @@ +SELECT e, count() FROM enum_totals GROUP BY e WITH TOTALS ORDER BY e diff --git a/tests/ast_json_fixtures/shapes/a204d7131c55c62a.json b/tests/ast_json_fixtures/shapes/a204d7131c55c62a.json new file mode 100644 index 000000000000..e173f48beb79 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a204d7131c55c62a.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "mv1", + "to_table": "mv2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a204d7131c55c62a.sql b/tests/ast_json_fixtures/shapes/a204d7131c55c62a.sql new file mode 100644 index 000000000000..4a4e6423237f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a204d7131c55c62a.sql @@ -0,0 +1 @@ +RENAME TABLE mv1 TO mv2 diff --git a/tests/ast_json_fixtures/shapes/a20b6e0e8eb643f7.json b/tests/ast_json_fixtures/shapes/a20b6e0e8eb643f7.json new file mode 100644 index 000000000000..9e2ce0583060 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a20b6e0e8eb643f7.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "url", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "http:\/\/127.0.0.1\/foo.tsv" + }, + { + "type": "Literal", + "value_type": "String", + "value": "TabSeparated" + }, + { + "type": "Literal", + "value_type": "String", + "value": "key Int" + } + ] + }, + "format": "Values", + "settings": { + "type": "Settings", + "changes": { + "http_max_tries": "1", + "materialized_views_ignore_errors": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a20b6e0e8eb643f7.sql b/tests/ast_json_fixtures/shapes/a20b6e0e8eb643f7.sql new file mode 100644 index 000000000000..63ea05caf23b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a20b6e0e8eb643f7.sql @@ -0,0 +1 @@ +insert into function url('http://127.0.0.1/foo.tsv', 'TabSeparated', 'key Int') settings http_max_tries=1, materialized_views_ignore_errors=1 values (2) diff --git a/tests/ast_json_fixtures/shapes/a2169032ca6d53c8.json b/tests/ast_json_fixtures/shapes/a2169032ca6d53c8.json new file mode 100644 index 000000000000..814c1e007a69 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a2169032ca6d53c8.json @@ -0,0 +1,367 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1023" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775807" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65537" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775806" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 3.4028234663852886e38 + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1023" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483646" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table1__fuzz_19" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048577" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + } + ] + }, + { + "type": "Identifier", + "name": "id" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1023" + } + ] + }, + "direction": "DESC", + "nulls_first": true + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483646" + } + ] + }, + "direction": "ASC", + "nulls_first": true + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775807" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "257" + } + ] + } + ] + }, + "direction": "DESC", + "nulls_first": true + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a2169032ca6d53c8.sql b/tests/ast_json_fixtures/shapes/a2169032ca6d53c8.sql new file mode 100644 index 000000000000..1dc277e6ef91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a2169032ca6d53c8.sql @@ -0,0 +1 @@ +SELECT 1023, (((id % -9223372036854775807) = NULL) OR ((id % NULL) = 100) OR ((id % NULL) = 65537)) = ((id % inf) = 9223372036854775806), (id % NULL) = NULL, (id % 3.4028234663852886e38) = 1023, 2147483646 FROM table1__fuzz_19 ORDER BY (((id % 1048577) = 1024) % id) = 1023 DESC NULLS FIRST, id % 2147483646 ASC NULLS FIRST, ((id % 1) = 9223372036854775807) OR ((id % NULL) = 257) DESC NULLS FIRST diff --git a/tests/ast_json_fixtures/shapes/a21aaebc545f2a43.json b/tests/ast_json_fixtures/shapes/a21aaebc545f2a43.json new file mode 100644 index 000000000000..ca08dbbfca0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a21aaebc545f2a43.json @@ -0,0 +1,308 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "start_ts", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:15" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Function", + "alias": "end_ts", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Function", + "name": "toIntervalSecond", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "step_seconds", + "value_type": "UInt64", + "value": "15" + }, + { + "type": "Literal", + "alias": "window_seconds", + "value_type": "UInt64", + "value": "45" + } + ], + "select": [ + { + "type": "Identifier", + "name": "metric_id" + }, + { + "type": "Function", + "name": "timeSeriesInstantDeltaToGrid", + "arguments": [ + { + "type": "Identifier", + "name": "timestamps" + }, + { + "type": "Identifier", + "name": "values" + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Identifier", + "name": "end_ts" + }, + { + "type": "Identifier", + "name": "step_seconds" + }, + { + "type": "Identifier", + "name": "window_seconds" + } + ] + }, + { + "type": "Function", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Identifier", + "name": "timestamps" + }, + { + "type": "Identifier", + "name": "values" + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Identifier", + "name": "end_ts" + }, + { + "type": "Identifier", + "name": "step_seconds" + }, + { + "type": "Identifier", + "name": "window_seconds" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "metric_id" + }, + { + "type": "Function", + "alias": "timestamps", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "finalizeAggregation", + "arguments": [ + { + "type": "Identifier", + "name": "samples" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "values", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "finalizeAggregation", + "arguments": [ + { + "type": "Identifier", + "name": "samples" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_resampled_timeseries_15_sec" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "metric_id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "grid_timestamp" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Function", + "name": "toIntervalSecond", + "arguments": [ + { + "type": "Identifier", + "name": "window_seconds" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "grid_timestamp" + }, + { + "type": "Identifier", + "name": "end_ts" + } + ] + } + ] + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "metric_id" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a21aaebc545f2a43.sql b/tests/ast_json_fixtures/shapes/a21aaebc545f2a43.sql new file mode 100644 index 000000000000..463cc7b39a27 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a21aaebc545f2a43.sql @@ -0,0 +1,18 @@ +WITH + '2024-12-12 12:00:15'::DateTime64(3,'UTC') AS start_ts, + start_ts + interval 60 second AS end_ts, + 15 AS step_seconds, + 45 AS window_seconds +SELECT + metric_id, + timeSeriesInstantDeltaToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values), + timeSeriesInstantRateToGrid(start_ts, end_ts, step_seconds, window_seconds)(timestamps, values) +FROM ( + SELECT + metric_id, + finalizeAggregation(samples).1 as timestamps, + finalizeAggregation(samples).2 as values + FROM t_resampled_timeseries_15_sec + WHERE metric_id = 3 AND grid_timestamp BETWEEN start_ts - interval window_seconds seconds AND end_ts +) +GROUP BY metric_id diff --git a/tests/ast_json_fixtures/shapes/a23cc8e86530efd0.json b/tests/ast_json_fixtures/shapes/a23cc8e86530efd0.json new file mode 100644 index 000000000000..90b6e28f180e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a23cc8e86530efd0.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "k", + "value_type": "UInt64", + "value": "10" + } + ], + "select": [ + { + "type": "Identifier", + "alias": "key", + "name": "k" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "repl_tbl" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "k" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a23cc8e86530efd0.sql b/tests/ast_json_fixtures/shapes/a23cc8e86530efd0.sql new file mode 100644 index 000000000000..ad4080922fe6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a23cc8e86530efd0.sql @@ -0,0 +1 @@ +WITH 10 as k SELECT k as key, * FROM repl_tbl WHERE key = k diff --git a/tests/ast_json_fixtures/shapes/a254fd26fa3b8754.json b/tests/ast_json_fixtures/shapes/a254fd26fa3b8754.json new file mode 100644 index 000000000000..b94b11541d67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a254fd26fa3b8754.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "testing" + }, + "assignments": [ + { + "type": "Assignment", + "column": "c", + "expression": { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ], + "predicate": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a254fd26fa3b8754.sql b/tests/ast_json_fixtures/shapes/a254fd26fa3b8754.sql new file mode 100644 index 000000000000..e69d049ec3c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a254fd26fa3b8754.sql @@ -0,0 +1 @@ +UPDATE testing SET c = c-1 WHERE 1 diff --git a/tests/ast_json_fixtures/shapes/a255b823104cf4ce.json b/tests/ast_json_fixtures/shapes/a255b823104cf4ce.json new file mode 100644 index 000000000000..31a04bb3e857 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a255b823104cf4ce.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateTableQuery", + "table": { + "type": "Identifier", + "name": "test_foo" + }, + "settings": { + "type": "Settings", + "changes": { + "enforce_strict_identifier_format": true + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a255b823104cf4ce.sql b/tests/ast_json_fixtures/shapes/a255b823104cf4ce.sql new file mode 100644 index 000000000000..ffaba0c077bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a255b823104cf4ce.sql @@ -0,0 +1,3 @@ +SHOW CREATE TABLE test_foo +SETTINGS + enforce_strict_identifier_format=true diff --git a/tests/ast_json_fixtures/shapes/a26f115874dfbbec.json b/tests/ast_json_fixtures/shapes/a26f115874dfbbec.json new file mode 100644 index 000000000000..ecc2bbe7afea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a26f115874dfbbec.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01148_atomic", + "from_table": "rmt3", + "to_database": "test_01148_ordinary", + "to_table": "rmt3" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a26f115874dfbbec.sql b/tests/ast_json_fixtures/shapes/a26f115874dfbbec.sql new file mode 100644 index 000000000000..8311392ac76d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a26f115874dfbbec.sql @@ -0,0 +1 @@ +RENAME TABLE test_01148_atomic.rmt3 to test_01148_ordinary.rmt3 diff --git a/tests/ast_json_fixtures/shapes/a297547208ed7537.json b/tests/ast_json_fixtures/shapes/a297547208ed7537.json new file mode 100644 index 000000000000..26a00b910927 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a297547208ed7537.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "EXCEPT ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a297547208ed7537.sql b/tests/ast_json_fixtures/shapes/a297547208ed7537.sql new file mode 100644 index 000000000000..0fbe044e7de7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a297547208ed7537.sql @@ -0,0 +1 @@ +SELECT 1 EXCEPT SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/a2ada260337c3cbf.json b/tests/ast_json_fixtures/shapes/a2ada260337c3cbf.json new file mode 100644 index 000000000000..d8e6da28c176 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a2ada260337c3cbf.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_qualify" + } + } + } + ] + }, + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "row_number", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a2ada260337c3cbf.sql b/tests/ast_json_fixtures/shapes/a2ada260337c3cbf.sql new file mode 100644 index 000000000000..6450c3fcb0a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a2ada260337c3cbf.sql @@ -0,0 +1 @@ +select * from test_qualify qualify row_number() over (order by number) = 50 SETTINGS enable_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/a2d086cc3d5876fe.json b/tests/ast_json_fixtures/shapes/a2d086cc3d5876fe.json new file mode 100644 index 000000000000..d03325152adb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a2d086cc3d5876fe.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "ip_part_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "ipv4", + "data_type": { + "type": "DataType", + "name": "IPv4" + } + }, + { + "type": "ColumnDeclaration", + "name": "ipv6", + "data_type": { + "type": "DataType", + "name": "IPv6" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "ipv4" + }, + "order_by": { + "type": "Identifier", + "name": "ipv4" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "1.2.3.4" + }, + { + "type": "Literal", + "value_type": "String", + "value": "::ffff:1.2.3.4" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a2d086cc3d5876fe.sql b/tests/ast_json_fixtures/shapes/a2d086cc3d5876fe.sql new file mode 100644 index 000000000000..e632ab5b5299 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a2d086cc3d5876fe.sql @@ -0,0 +1 @@ +CREATE TABLE ip_part_test ( ipv4 IPv4, ipv6 IPv6 ) ENGINE = MergeTree PARTITION BY ipv4 ORDER BY ipv4 AS SELECT '1.2.3.4', '::ffff:1.2.3.4' diff --git a/tests/ast_json_fixtures/shapes/a2f498c66b601725.json b/tests/ast_json_fixtures/shapes/a2f498c66b601725.json new file mode 100644 index 000000000000..b07826fcc85b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a2f498c66b601725.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "0" + } + }, + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a2f498c66b601725.sql b/tests/ast_json_fixtures/shapes/a2f498c66b601725.sql new file mode 100644 index 000000000000..9b7c87f68603 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a2f498c66b601725.sql @@ -0,0 +1 @@ +delete from test where id % 2 = 0 SETTINGS mutations_sync=0 diff --git a/tests/ast_json_fixtures/shapes/a31524270cee577c.json b/tests/ast_json_fixtures/shapes/a31524270cee577c.json new file mode 100644 index 000000000000..3aab55540bd7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a31524270cee577c.json @@ -0,0 +1,130 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "order", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "indexed", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "proj", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_part_offset" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "indexed" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "order" + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "order" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1970-01-02T00:00:00" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2030-01-01T00:00:00" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime" + } + ] + } + ] + } + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a31524270cee577c.sql b/tests/ast_json_fixtures/shapes/a31524270cee577c.sql new file mode 100644 index 000000000000..9a95c0c0644f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a31524270cee577c.sql @@ -0,0 +1,13 @@ +CREATE TABLE test +( + `order` int, + `indexed` int, + PROJECTION proj + ( + SELECT _part_offset + ORDER BY indexed + ) +) +ENGINE = MergeTree +ORDER BY order +TTL if(order = 1, '1970-01-02T00:00:00'::DateTime, '2030-01-01T00:00:00'::DateTime) diff --git a/tests/ast_json_fixtures/shapes/a334f5706c6e7acb.json b/tests/ast_json_fixtures/shapes/a334f5706c6e7acb.json new file mode 100644 index 000000000000..9fb97ddbc44c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a334f5706c6e7acb.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "ips_v6" + }, + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/a334f5706c6e7acb.sql b/tests/ast_json_fixtures/shapes/a334f5706c6e7acb.sql new file mode 100644 index 000000000000..4f238daf152f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a334f5706c6e7acb.sql @@ -0,0 +1,3 @@ +INSERT INTO ips_v6 FORMAT TSV ::ffff:127.0.0.1 + +INSERT INTO ips_v6 SELECT ('::ffff:127.0.0.1') diff --git a/tests/ast_json_fixtures/shapes/a3353fe5dcb7ca21.json b/tests/ast_json_fixtures/shapes/a3353fe5dcb7ca21.json new file mode 100644 index 000000000000..265a6315194f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a3353fe5dcb7ca21.json @@ -0,0 +1,109 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Function", + "alias": "l", + "name": "avg", + "arguments": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "URL" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits_s3", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "URL" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "CounterID" + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "l" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "25" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a3353fe5dcb7ca21.sql b/tests/ast_json_fixtures/shapes/a3353fe5dcb7ca21.sql new file mode 100644 index 000000000000..6ec620c125b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a3353fe5dcb7ca21.sql @@ -0,0 +1 @@ +SELECT CounterID, avg(length(URL)) AS l, count() AS c FROM test.hits_s3 WHERE URL != '' GROUP BY CounterID HAVING c > 100000 ORDER BY l DESC LIMIT 25 diff --git a/tests/ast_json_fixtures/shapes/a35f92f2502eddcf.json b/tests/ast_json_fixtures/shapes/a35f92f2502eddcf.json new file mode 100644 index 000000000000..d43172a037db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a35f92f2502eddcf.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "e" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_lazy_read_in_order" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a35f92f2502eddcf.sql b/tests/ast_json_fixtures/shapes/a35f92f2502eddcf.sql new file mode 100644 index 000000000000..ad88e5de05b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a35f92f2502eddcf.sql @@ -0,0 +1,4 @@ +SELECT a, e +FROM test_lazy_read_in_order PREWHERE e > 100 +ORDER BY a +LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/a3766d2345f8666b.json b/tests/ast_json_fixtures/shapes/a3766d2345f8666b.json new file mode 100644 index 000000000000..5b616a5df1ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a3766d2345f8666b.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_a" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "company", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "total", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "SummingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "company" + }, + "primary_key": { + "type": "Identifier", + "name": "id" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "company" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a3766d2345f8666b.sql b/tests/ast_json_fixtures/shapes/a3766d2345f8666b.sql new file mode 100644 index 000000000000..a8e9c7d5f500 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a3766d2345f8666b.sql @@ -0,0 +1 @@ +CREATE TABLE test_a (id UInt32, company UInt32, total UInt64) ENGINE=SummingMergeTree() PARTITION BY company PRIMARY KEY (id) ORDER BY (id, company) diff --git a/tests/ast_json_fixtures/shapes/a37bf28733e8485e.json b/tests/ast_json_fixtures/shapes/a37bf28733e8485e.json new file mode 100644 index 000000000000..7df14f79d37f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a37bf28733e8485e.json @@ -0,0 +1,462 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "start_ts", + "name": "toDateTime64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + }, + { + "type": "Function", + "alias": "end_ts", + "name": "toDateTime64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:01:00" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + }, + { + "type": "Literal", + "alias": "step_sec", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "alias": "window_sec", + "value_type": "UInt64", + "value": "50" + }, + { + "type": "Function", + "alias": "grid", + "name": "range", + "arguments": [ + { + "type": "Function", + "name": "toUnixTimestamp", + "arguments": [ + { + "type": "Identifier", + "name": "start_ts" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toUnixTimestamp", + "arguments": [ + { + "type": "Identifier", + "name": "end_ts" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "step_sec" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "metric_id" + }, + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "arrayZip", + "arguments": [ + { + "type": "Identifier", + "name": "grid" + }, + { + "type": "Identifier", + "name": "irate_values" + }, + { + "type": "Identifier", + "name": "idelta_values" + }, + { + "type": "Identifier", + "name": "rate_values" + }, + { + "type": "Identifier", + "name": "delta_values" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "metric_id" + }, + { + "type": "Function", + "alias": "irate_values", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Identifier", + "name": "end_ts" + }, + { + "type": "Identifier", + "name": "step_sec" + }, + { + "type": "Identifier", + "name": "window_sec" + } + ] + }, + { + "type": "Function", + "alias": "idelta_values", + "name": "timeSeriesInstantDeltaToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Identifier", + "name": "end_ts" + }, + { + "type": "Identifier", + "name": "step_sec" + }, + { + "type": "Identifier", + "name": "window_sec" + } + ] + }, + { + "type": "Function", + "alias": "rate_values", + "name": "timeSeriesRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Identifier", + "name": "end_ts" + }, + { + "type": "Identifier", + "name": "step_sec" + }, + { + "type": "Identifier", + "name": "window_sec" + } + ] + }, + { + "type": "Function", + "alias": "delta_values", + "name": "timeSeriesDeltaToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start_ts" + }, + { + "type": "Identifier", + "name": "end_ts" + }, + { + "type": "Identifier", + "name": "step_sec" + }, + { + "type": "Identifier", + "name": "window_sec" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "clusterAllReplicas", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "t_resampled_timeseries_64" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "metric_id" + } + ] + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "metric_id" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_parallel_replicas": "1", + "max_parallel_replicas": "3", + "parallel_replicas_for_non_replicated_merge_tree": "1", + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a37bf28733e8485e.sql b/tests/ast_json_fixtures/shapes/a37bf28733e8485e.sql new file mode 100644 index 000000000000..fe129c1f0f62 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a37bf28733e8485e.sql @@ -0,0 +1,19 @@ +WITH + toDateTime64('2024-12-12 12:00:10', 3, 'UTC') AS start_ts, + toDateTime64('2024-12-12 12:01:00', 3, 'UTC') AS end_ts, + 10 AS step_sec, + 50 as window_sec, + range(toUnixTimestamp(start_ts), toUnixTimestamp(end_ts) + 1, step_sec) as grid +SELECT metric_id, arrayJoin(arrayZip(grid, irate_values, idelta_values, rate_values, delta_values)) +FROM ( + SELECT + metric_id, + timeSeriesInstantRateToGrid(start_ts, end_ts, step_sec, window_sec)(samples.1, samples.2) as irate_values, + timeSeriesInstantDeltaToGrid(start_ts, end_ts, step_sec, window_sec)(samples.1, samples.2) as idelta_values, + timeSeriesRateToGrid(start_ts, end_ts, step_sec, window_sec)(samples.1, samples.2) as rate_values, + timeSeriesDeltaToGrid(start_ts, end_ts, step_sec, window_sec)(samples.1, samples.2) as delta_values + FROM clusterAllReplicas('test_shard_localhost', currentDatabase(), t_resampled_timeseries_64) + GROUP BY metric_id +) +ORDER BY metric_id +SETTINGS enable_parallel_replicas=1, max_parallel_replicas=3, parallel_replicas_for_non_replicated_merge_tree=1, enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/a391ce1f2a533128.json b/tests/ast_json_fixtures/shapes/a391ce1f2a533128.json new file mode 100644 index 000000000000..cc5f60d2e82f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a391ce1f2a533128.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "order_by_all" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_order_by_all": false + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a391ce1f2a533128.sql b/tests/ast_json_fixtures/shapes/a391ce1f2a533128.sql new file mode 100644 index 000000000000..a2504aaf797d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a391ce1f2a533128.sql @@ -0,0 +1 @@ +SELECT * FROM order_by_all ORDER BY all SETTINGS enable_order_by_all = false diff --git a/tests/ast_json_fixtures/shapes/a397ca6a20cd9a31.json b/tests/ast_json_fixtures/shapes/a397ca6a20cd9a31.json new file mode 100644 index 000000000000..b9434c7903d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a397ca6a20cd9a31.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "udf_type_of_int" + } +} diff --git a/tests/ast_json_fixtures/shapes/a397ca6a20cd9a31.sql b/tests/ast_json_fixtures/shapes/a397ca6a20cd9a31.sql new file mode 100644 index 000000000000..e60a05f04543 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a397ca6a20cd9a31.sql @@ -0,0 +1 @@ +DROP FUNCTION udf_type_of_int diff --git a/tests/ast_json_fixtures/shapes/a3e58671d5f75433.json b/tests/ast_json_fixtures/shapes/a3e58671d5f75433.json new file mode 100644 index 000000000000..0ce4677994c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a3e58671d5f75433.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r1_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/a3e58671d5f75433.sql b/tests/ast_json_fixtures/shapes/a3e58671d5f75433.sql new file mode 100644 index 000000000000..04fd73c302b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a3e58671d5f75433.sql @@ -0,0 +1 @@ +CREATE ROLE r1_01293 diff --git a/tests/ast_json_fixtures/shapes/a3eb12971e51435b.json b/tests/ast_json_fixtures/shapes/a3eb12971e51435b.json new file mode 100644 index 000000000000..d3dbf9296d5c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a3eb12971e51435b.json @@ -0,0 +1,150 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value1" + }, + { + "type": "Identifier", + "name": "value2" + }, + { + "type": "Function", + "alias": "start_ts", + "name": "toUInt64", + "arguments": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "join_inner_table__fuzz_1" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "833c9e22-c245-4eb5-8745-117a9a1f26b1" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1610517366120" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value1" + }, + { + "type": "Identifier", + "name": "value2" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value2" + }, + "direction": "ASC", + "nulls_first": false + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/a3eb12971e51435b.sql b/tests/ast_json_fixtures/shapes/a3eb12971e51435b.sql new file mode 100644 index 000000000000..aa2b37120921 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a3eb12971e51435b.sql @@ -0,0 +1,18 @@ +SELECT + key, + value1, + value2, + toUInt64(min(time)) AS start_ts +FROM join_inner_table__fuzz_1 +PREWHERE (id = '833c9e22-c245-4eb5-8745-117a9a1f26b1') AND (number > toUInt64('1610517366120')) +GROUP BY + key, + value1, + value2 + WITH ROLLUP +ORDER BY + key ASC, + value1 ASC, + value2 ASC NULLS LAST +LIMIT 10 +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/a4005be1d573443d.json b/tests/ast_json_fixtures/shapes/a4005be1d573443d.json new file mode 100644 index 000000000000..7946869df733 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4005be1d573443d.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "values_01564" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "constraints": [ + { + "type": "Constraint", + "name": "c1", + "constraint_type": "CHECK", + "expression": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a4005be1d573443d.sql b/tests/ast_json_fixtures/shapes/a4005be1d573443d.sql new file mode 100644 index 000000000000..fc1cdf7be449 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4005be1d573443d.sql @@ -0,0 +1,3 @@ +create table values_01564( + a int, + constraint c1 check a < 10) engine Memory diff --git a/tests/ast_json_fixtures/shapes/a4025671bdfa03fe.json b/tests/ast_json_fixtures/shapes/a4025671bdfa03fe.json new file mode 100644 index 000000000000..de5a52c850b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4025671bdfa03fe.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Identifier", + "name": "primary_key_bytes_in_memory" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-7" + } + ] + }, + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Identifier", + "name": "primary_key_bytes_in_memory_allocated" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-7" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parts", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test" + } + ] + } + ] + } + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/a4025671bdfa03fe.sql b/tests/ast_json_fixtures/shapes/a4025671bdfa03fe.sql new file mode 100644 index 000000000000..7ab74cce125e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4025671bdfa03fe.sql @@ -0,0 +1 @@ +SELECT round(primary_key_bytes_in_memory, -7), round(primary_key_bytes_in_memory_allocated, -7) FROM system.parts WHERE database = currentDatabase() AND table = 'test' FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/a4030753afcbc9ed.json b/tests/ast_json_fixtures/shapes/a4030753afcbc9ed.json new file mode 100644 index 000000000000..a9561bbcdfc9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4030753afcbc9ed.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Enabled" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "account_test" + }, + "final": true + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11338881281426660955" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "split_parts_ranges_into_intersecting_and_non_intersecting_final": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a4030753afcbc9ed.sql b/tests/ast_json_fixtures/shapes/a4030753afcbc9ed.sql new file mode 100644 index 000000000000..163918df0345 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4030753afcbc9ed.sql @@ -0,0 +1 @@ +SELECT 'Enabled', * FROM account_test FINAL WHERE id = 11338881281426660955 SETTINGS split_parts_ranges_into_intersecting_and_non_intersecting_final = 1 diff --git a/tests/ast_json_fixtures/shapes/a40723957ff00c8a.json b/tests/ast_json_fixtures/shapes/a40723957ff00c8a.json new file mode 100644 index 000000000000..8e589a52ea51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a40723957ff00c8a.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "03710" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1", + "max_block_size": "1" + } + } + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/a40723957ff00c8a.sql b/tests/ast_json_fixtures/shapes/a40723957ff00c8a.sql new file mode 100644 index 000000000000..fed06ee2beda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a40723957ff00c8a.sql @@ -0,0 +1 @@ +SELECT '03710', c FROM tab SETTINGS use_query_cache = 1, max_block_size = 1 FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/a40af2a8479c6603.json b/tests/ast_json_fixtures/shapes/a40af2a8479c6603.json new file mode 100644 index 000000000000..48a9fa0f2871 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a40af2a8479c6603.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "untuple", + "arguments": [ + { + "type": "Function", + "name": "argMax", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk", + "transformers": [ + { + "type": "ColumnsExceptTransformer", + "columns": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "v1" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "kv" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/a40af2a8479c6603.sql b/tests/ast_json_fixtures/shapes/a40af2a8479c6603.sql new file mode 100644 index 000000000000..f93e706c527c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a40af2a8479c6603.sql @@ -0,0 +1 @@ +select key, untuple(argMax((* except (key),), v1)) from kv group by key order by key format TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/a41bab671294c9d4.json b/tests/ast_json_fixtures/shapes/a41bab671294c9d4.json new file mode 100644 index 000000000000..f597cccf70f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a41bab671294c9d4.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR INDEX MARK CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/a41bab671294c9d4.sql b/tests/ast_json_fixtures/shapes/a41bab671294c9d4.sql new file mode 100644 index 000000000000..dc9f6c8dbf93 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a41bab671294c9d4.sql @@ -0,0 +1 @@ +SYSTEM CLEAR INDEX MARK CACHE diff --git a/tests/ast_json_fixtures/shapes/a424d6e81fa31aa2.json b/tests/ast_json_fixtures/shapes/a424d6e81fa31aa2.json new file mode 100644 index 000000000000..c1c5a34647e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a424d6e81fa31aa2.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "STOP DISTRIBUTED SENDS", + "table": { + "type": "Identifier", + "name": "buf" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a424d6e81fa31aa2.sql b/tests/ast_json_fixtures/shapes/a424d6e81fa31aa2.sql new file mode 100644 index 000000000000..7c52c4d5e0b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a424d6e81fa31aa2.sql @@ -0,0 +1 @@ +system stop distributed sends buf diff --git a/tests/ast_json_fixtures/shapes/a429c330e73c2c98.json b/tests/ast_json_fixtures/shapes/a429c330e73c2c98.json new file mode 100644 index 000000000000..ee7e21875c82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a429c330e73c2c98.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "test2_00843", + "to_table": "test1_00843" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a429c330e73c2c98.sql b/tests/ast_json_fixtures/shapes/a429c330e73c2c98.sql new file mode 100644 index 000000000000..895439a1aa94 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a429c330e73c2c98.sql @@ -0,0 +1 @@ +RENAME TABLE test2_00843 TO test1_00843 diff --git a/tests/ast_json_fixtures/shapes/a46b7752b4933225.json b/tests/ast_json_fixtures/shapes/a46b7752b4933225.json new file mode 100644 index 000000000000..77be0f094baa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a46b7752b4933225.json @@ -0,0 +1,186 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "sub", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "text" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "hasAnyTokens", + "arguments": [ + { + "type": "Identifier", + "name": "text" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "Alick" + } + ] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "text" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "hasAnyTokens", + "arguments": [ + { + "type": "Identifier", + "name": "text" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "Alick" + } + ] + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "sub" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "use_skip_indexes_on_data_read": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a46b7752b4933225.sql b/tests/ast_json_fixtures/shapes/a46b7752b4933225.sql new file mode 100644 index 000000000000..03aea1531f92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a46b7752b4933225.sql @@ -0,0 +1,15 @@ +WITH sub AS +( + SELECT text + FROM tab + WHERE hasAnyTokens(text, ['Alick']) +) +SELECT * +FROM +( + SELECT text + FROM tab + WHERE hasAnyTokens(text, ['Alick']) +) +WHERE (SELECT * FROM sub) != '' +SETTINGS use_skip_indexes_on_data_read = 1 diff --git a/tests/ast_json_fixtures/shapes/a478215b6a32e40c.json b/tests/ast_json_fixtures/shapes/a478215b6a32e40c.json new file mode 100644 index 000000000000..40c449b3442f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a478215b6a32e40c.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02125_function_2" + } +} diff --git a/tests/ast_json_fixtures/shapes/a478215b6a32e40c.sql b/tests/ast_json_fixtures/shapes/a478215b6a32e40c.sql new file mode 100644 index 000000000000..dab88040f05d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a478215b6a32e40c.sql @@ -0,0 +1 @@ +DROP FUNCTION 02125_function_2 diff --git a/tests/ast_json_fixtures/shapes/a4d17c66a792f65d.json b/tests/ast_json_fixtures/shapes/a4d17c66a792f65d.json new file mode 100644 index 000000000000..6c8f8ae9a470 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4d17c66a792f65d.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "key" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dst" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "step" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a4d17c66a792f65d.sql b/tests/ast_json_fixtures/shapes/a4d17c66a792f65d.sql new file mode 100644 index 000000000000..4693f523e6a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4d17c66a792f65d.sql @@ -0,0 +1 @@ +SELECT count(), key FROM dst WHERE step = 30 group by key ORDER BY key LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/a4e618c973605617.json b/tests/ast_json_fixtures/shapes/a4e618c973605617.json new file mode 100644 index 000000000000..c151615687bf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4e618c973605617.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "replace_table": true, + "create_or_replace": true, + "table": { + "type": "Identifier", + "name": "test_dict" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Identifier", + "name": "view" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 1000 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a4e618c973605617.sql b/tests/ast_json_fixtures/shapes/a4e618c973605617.sql new file mode 100644 index 000000000000..43b47cb24c02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4e618c973605617.sql @@ -0,0 +1,9 @@ +CREATE OR REPLACE DICTIONARY test_dict +( + id UInt64, + value String +) +PRIMARY KEY id +SOURCE(CLICKHOUSE(TABLE view)) +LAYOUT(FLAT()) +LIFETIME(MIN 0 MAX 1000) diff --git a/tests/ast_json_fixtures/shapes/a4f67fa6725542b2.json b/tests/ast_json_fixtures/shapes/a4f67fa6725542b2.json new file mode 100644 index 000000000000..fb8200ce58d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4f67fa6725542b2.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "无名氏 " + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a4f67fa6725542b2.sql b/tests/ast_json_fixtures/shapes/a4f67fa6725542b2.sql new file mode 100644 index 000000000000..4ddca87d1178 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4f67fa6725542b2.sql @@ -0,0 +1 @@ +create user "无名氏 " diff --git a/tests/ast_json_fixtures/shapes/a4f6d3df98a251cb.json b/tests/ast_json_fixtures/shapes/a4f6d3df98a251cb.json new file mode 100644 index 000000000000..794b467d807a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4f6d3df98a251cb.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01527" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01527" + }, + { + "type": "Function", + "name": "dictGetUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "db_01527_ranges.dict" + }, + { + "type": "Literal", + "value_type": "String", + "value": "shard" + }, + { + "type": "Identifier", + "name": "key" + } + ] + } + ] + } + }, + "as_table": "data_01527" + } +} diff --git a/tests/ast_json_fixtures/shapes/a4f6d3df98a251cb.sql b/tests/ast_json_fixtures/shapes/a4f6d3df98a251cb.sql new file mode 100644 index 000000000000..1ac0772898f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a4f6d3df98a251cb.sql @@ -0,0 +1 @@ +create table dist_01527 as data_01527 engine=Distributed('test_cluster_two_shards', currentDatabase(), data_01527, dictGetUInt64('db_01527_ranges.dict', 'shard', key)) diff --git a/tests/ast_json_fixtures/shapes/a501651a0ec5f1d5.json b/tests/ast_json_fixtures/shapes/a501651a0ec5f1d5.json new file mode 100644 index 000000000000..69995fa6fbaa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a501651a0ec5f1d5.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "from": { + "type": "Identifier", + "name": "sqllt" + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/a501651a0ec5f1d5.sql b/tests/ast_json_fixtures/shapes/a501651a0ec5f1d5.sql new file mode 100644 index 000000000000..f47f2de2e6d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a501651a0ec5f1d5.sql @@ -0,0 +1 @@ +SHOW TABLES FROM sqllt FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/a50bd855a392db32.json b/tests/ast_json_fixtures/shapes/a50bd855a392db32.json new file mode 100644 index 000000000000..2af4e7d74710 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a50bd855a392db32.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "is_populate": true, + "table": { + "type": "Identifier", + "name": "test_mv_pk" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "value" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a50bd855a392db32.sql b/tests/ast_json_fixtures/shapes/a50bd855a392db32.sql new file mode 100644 index 000000000000..59318e76b516 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a50bd855a392db32.sql @@ -0,0 +1,6 @@ +CREATE MATERIALIZED VIEW test_mv_pk +( + value String, + id UInt64 +) ENGINE=MergeTree PRIMARY KEY value +POPULATE AS SELECT value, id FROM test diff --git a/tests/ast_json_fixtures/shapes/a50d1c28ab3b3f7b.json b/tests/ast_json_fixtures/shapes/a50d1c28ab3b3f7b.json new file mode 100644 index 000000000000..2f884b4518c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a50d1c28ab3b3f7b.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "ParallelWithQuery", + "children": [ + { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "x" + } + } + }, + { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table2" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "y" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a50d1c28ab3b3f7b.sql b/tests/ast_json_fixtures/shapes/a50d1c28ab3b3f7b.sql new file mode 100644 index 000000000000..06d4a77d46b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a50d1c28ab3b3f7b.sql @@ -0,0 +1,3 @@ +CREATE TABLE table1(x Int32) ENGINE=MergeTree order by x +PARALLEL WITH +CREATE TABLE table2(y Int32) ENGINE=MergeTree order by y diff --git a/tests/ast_json_fixtures/shapes/a51a5ae4ec8f67c8.json b/tests/ast_json_fixtures/shapes/a51a5ae4ec8f67c8.json new file mode 100644 index 000000000000..b49dcb77875a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a51a5ae4ec8f67c8.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "load_marks_asynchronously": "1" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/a51a5ae4ec8f67c8.sql b/tests/ast_json_fixtures/shapes/a51a5ae4ec8f67c8.sql new file mode 100644 index 000000000000..a175ab13cabb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a51a5ae4ec8f67c8.sql @@ -0,0 +1 @@ +select * from data settings load_marks_asynchronously=1 format Null diff --git a/tests/ast_json_fixtures/shapes/a51fecfe6ffab971.json b/tests/ast_json_fixtures/shapes/a51fecfe6ffab971.json new file mode 100644 index 000000000000..ba5f5dc7bf0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a51fecfe6ffab971.json @@ -0,0 +1,83 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "b" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "key" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ID" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ID" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a51fecfe6ffab971.sql b/tests/ast_json_fixtures/shapes/a51fecfe6ffab971.sql new file mode 100644 index 000000000000..a220145fe95f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a51fecfe6ffab971.sql @@ -0,0 +1 @@ +SELECT * FROM b JOIN a USING (key) WHERE ID = '1' HAVING ID = '1' diff --git a/tests/ast_json_fixtures/shapes/a5204ec9582b37ed.json b/tests/ast_json_fixtures/shapes/a5204ec9582b37ed.json new file mode 100644 index 000000000000..d2178aa9abe7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5204ec9582b37ed.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "other", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "arr" + }, + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Function", + "name": "arrayJaccardIndex", + "arguments": [ + { + "type": "Identifier", + "name": "other" + }, + { + "type": "Identifier", + "name": "arr" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "array_jaccard_index" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "arr" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a5204ec9582b37ed.sql b/tests/ast_json_fixtures/shapes/a5204ec9582b37ed.sql new file mode 100644 index 000000000000..42f851771bf2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5204ec9582b37ed.sql @@ -0,0 +1 @@ +SELECT [1,2] AS other, arr, round(arrayJaccardIndex(other, arr), 2) FROM array_jaccard_index ORDER BY arr diff --git a/tests/ast_json_fixtures/shapes/a5221ff21b9f5a78.json b/tests/ast_json_fixtures/shapes/a5221ff21b9f5a78.json new file mode 100644 index 000000000000..39a8bad4e00f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5221ff21b9f5a78.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "alter": true, + "names": ["s3_01294"], + "alter_settings": { + "type": "AlterSettingsProfileElements", + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a5221ff21b9f5a78.sql b/tests/ast_json_fixtures/shapes/a5221ff21b9f5a78.sql new file mode 100644 index 000000000000..2c10c0801c73 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5221ff21b9f5a78.sql @@ -0,0 +1 @@ +ALTER PROFILE s3_01294 SETTINGS NONE diff --git a/tests/ast_json_fixtures/shapes/a52ef02498a13ee3.json b/tests/ast_json_fixtures/shapes/a52ef02498a13ee3.json new file mode 100644 index 000000000000..01f8fac239a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a52ef02498a13ee3.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ExistsDatabaseQuery", + "database": { + "type": "Identifier", + "name": "db_01048" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a52ef02498a13ee3.sql b/tests/ast_json_fixtures/shapes/a52ef02498a13ee3.sql new file mode 100644 index 000000000000..87df0193aa73 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a52ef02498a13ee3.sql @@ -0,0 +1 @@ +EXISTS DATABASE db_01048 diff --git a/tests/ast_json_fixtures/shapes/a53c5e3285be79ff.json b/tests/ast_json_fixtures/shapes/a53c5e3285be79ff.json new file mode 100644 index 000000000000..508feb2ca59d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a53c5e3285be79ff.json @@ -0,0 +1,123 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "alias": "mA", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "A" + } + ] + }, + { + "type": "Function", + "alias": "mB", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "B" + } + ] + }, + { + "type": "Function", + "alias": "mC", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "C" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ], + "having": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "mA" + }, + { + "type": "Identifier", + "name": "mB" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "mA" + }, + { + "type": "Identifier", + "name": "mC" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a53c5e3285be79ff.sql b/tests/ast_json_fixtures/shapes/a53c5e3285be79ff.sql new file mode 100644 index 000000000000..37fe0a5e853a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a53c5e3285be79ff.sql @@ -0,0 +1 @@ +SELECT x, max(A) AS mA, max(B) AS mB, max(C) AS mC FROM x GROUP BY x HAVING (mA AND mB) OR (mA AND mC) ORDER BY x LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/a544ff80d14f9574.json b/tests/ast_json_fixtures/shapes/a544ff80d14f9574.json new file mode 100644 index 000000000000..1b50d65e7456 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a544ff80d14f9574.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "1.1.1.1" + }, + { + "value_type": "String", + "value": "255.255.255.255" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "y", + "name": "toIPv4", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "alias": "z", + "name": "toUInt32", + "arguments": [ + { + "type": "Identifier", + "name": "y" + } + ] + } + ] + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/a544ff80d14f9574.sql b/tests/ast_json_fixtures/shapes/a544ff80d14f9574.sql new file mode 100644 index 000000000000..757e0f6a4533 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a544ff80d14f9574.sql @@ -0,0 +1 @@ +SELECT arrayJoin(['1.1.1.1', '255.255.255.255']) AS x, toIPv4(x) AS y, toUInt32(y) AS z FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/a560bfd409aa31ae.json b/tests/ast_json_fixtures/shapes/a560bfd409aa31ae.json new file mode 100644 index 000000000000..70fbb13c884c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a560bfd409aa31ae.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "true" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Bool" + } + ] + } + ] + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/a560bfd409aa31ae.sql b/tests/ast_json_fixtures/shapes/a560bfd409aa31ae.sql new file mode 100644 index 000000000000..d291d4a15bdf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a560bfd409aa31ae.sql @@ -0,0 +1 @@ +SELECT CAST('true', 'Bool') format TSV diff --git a/tests/ast_json_fixtures/shapes/a5657752baee4af7.json b/tests/ast_json_fixtures/shapes/a5657752baee4af7.json new file mode 100644 index 000000000000..75a60c19edd5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5657752baee4af7.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s2_01418"] + } +} diff --git a/tests/ast_json_fixtures/shapes/a5657752baee4af7.sql b/tests/ast_json_fixtures/shapes/a5657752baee4af7.sql new file mode 100644 index 000000000000..7dceecf2044e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5657752baee4af7.sql @@ -0,0 +1 @@ +DROP SETTINGS PROFILE s2_01418 diff --git a/tests/ast_json_fixtures/shapes/a584005dd71e83c7.json b/tests/ast_json_fixtures/shapes/a584005dd71e83c7.json new file mode 100644 index 000000000000..e14cc4e1f028 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a584005dd71e83c7.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_result_rows": "1" + } + }, + "format": "JSONCompactEachRowWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/a584005dd71e83c7.sql b/tests/ast_json_fixtures/shapes/a584005dd71e83c7.sql new file mode 100644 index 000000000000..2c0218a11d8e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a584005dd71e83c7.sql @@ -0,0 +1 @@ +select * from numbers(100) FORMAT JSONCompactEachRowWithNamesAndTypes settings max_result_rows = 1 diff --git a/tests/ast_json_fixtures/shapes/a5d920d70148eac6.json b/tests/ast_json_fixtures/shapes/a5d920d70148eac6.json new file mode 100644 index 000000000000..41f102bc6d01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5d920d70148eac6.json @@ -0,0 +1,95 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_index" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key_string", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "key_uint32", + "default_specifier": "ALIAS", + "default_expression": { + "type": "Function", + "name": "toUInt32", + "arguments": [ + { + "type": "Identifier", + "name": "key_string" + } + ] + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx", + "expression": { + "type": "Function", + "name": "toUInt32", + "arguments": [ + { + "type": "Identifier", + "name": "key_string" + } + ] + }, + "index_type": { + "type": "Function", + "name": "set", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "key_string" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a5d920d70148eac6.sql b/tests/ast_json_fixtures/shapes/a5d920d70148eac6.sql new file mode 100644 index 000000000000..602b72faba32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5d920d70148eac6.sql @@ -0,0 +1,10 @@ +CREATE TABLE test_index +( + `key_string` String, + `key_uint32` ALIAS toUInt32(key_string), + INDEX idx toUInt32(key_string) TYPE set(0) GRANULARITY 1 +) +ENGINE = MergeTree +PARTITION BY tuple() +PRIMARY KEY tuple() +ORDER BY key_string SETTINGS index_granularity = 1 diff --git a/tests/ast_json_fixtures/shapes/a5e57d0967df81f6.json b/tests/ast_json_fixtures/shapes/a5e57d0967df81f6.json new file mode 100644 index 000000000000..4e1b376c7bba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5e57d0967df81f6.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "temporary": true, + "table": { + "type": "Identifier", + "name": "tview_basic" + }, + "if_exists": true, + "is_view": true + } +} diff --git a/tests/ast_json_fixtures/shapes/a5e57d0967df81f6.sql b/tests/ast_json_fixtures/shapes/a5e57d0967df81f6.sql new file mode 100644 index 000000000000..256b60572cd5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5e57d0967df81f6.sql @@ -0,0 +1 @@ +DROP TEMPORARY VIEW IF EXISTS tview_basic diff --git a/tests/ast_json_fixtures/shapes/a5e616e6e4aa1025.json b/tests/ast_json_fixtures/shapes/a5e616e6e4aa1025.json new file mode 100644 index 000000000000..113d59093fb7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5e616e6e4aa1025.json @@ -0,0 +1,115 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "alias": "amount", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test02315" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + { + "type": "ExpressionList" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "amount" + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_grouping_standard_compatibility": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a5e616e6e4aa1025.sql b/tests/ast_json_fixtures/shapes/a5e616e6e4aa1025.sql new file mode 100644 index 000000000000..9d4570bc7a18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5e616e6e4aa1025.sql @@ -0,0 +1 @@ +SELECT count() AS amount, a, b, GROUPING(a, b) FROM test02315 GROUP BY GROUPING SETS ((a, b), (a), ()) ORDER BY (amount, a, b) SETTINGS force_grouping_standard_compatibility=0 diff --git a/tests/ast_json_fixtures/shapes/a5f9d0881b42a452.json b/tests/ast_json_fixtures/shapes/a5f9d0881b42a452.json new file mode 100644 index 000000000000..6c653b113b7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5f9d0881b42a452.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "database": { + "type": "Identifier", + "name": "db_1" + }, + "if_exists": true, + "sync": true + } +} diff --git a/tests/ast_json_fixtures/shapes/a5f9d0881b42a452.sql b/tests/ast_json_fixtures/shapes/a5f9d0881b42a452.sql new file mode 100644 index 000000000000..aad34ac6c6a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a5f9d0881b42a452.sql @@ -0,0 +1 @@ +DROP DATABASE IF EXISTS db_1 SYNC diff --git a/tests/ast_json_fixtures/shapes/a6123a8c5fe0ddbc.json b/tests/ast_json_fixtures/shapes/a6123a8c5fe0ddbc.json new file mode 100644 index 000000000000..d469637acc59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6123a8c5fe0ddbc.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t" + } + }, + { + "type": "Identifier", + "name": "s.a", + "name_parts": ["s", "a"] + }, + { + "type": "Identifier", + "name": "s.b", + "name_parts": ["s", "b"] + }, + { + "type": "Identifier", + "name": "s.c", + "name_parts": ["s", "c"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.a", + "name_parts": ["s", "a"] + }, + { + "type": "Identifier", + "name": "t.a", + "name_parts": ["t", "a"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.b", + "name_parts": ["s", "b"] + }, + { + "type": "Identifier", + "name": "t.b", + "name_parts": ["t", "b"] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "s" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a6123a8c5fe0ddbc.sql b/tests/ast_json_fixtures/shapes/a6123a8c5fe0ddbc.sql new file mode 100644 index 000000000000..a0dd689128fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6123a8c5fe0ddbc.sql @@ -0,0 +1 @@ +select t.*, s.a, s.b, s.c from t left join s on (s.a = t.a and s.b = t.b) diff --git a/tests/ast_json_fixtures/shapes/a6143dfb7e4e0ad6.json b/tests/ast_json_fixtures/shapes/a6143dfb7e4e0ad6.json new file mode 100644 index 000000000000..f42937eb0f3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6143dfb7e4e0ad6.json @@ -0,0 +1,121 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Lambda as function parameter" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + } + ] + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "28" + } + ] + }, + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "marks" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parts", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_injective_functions_in_group_by": "1", + "optimize_group_by_function_keys": "1", + "group_by_use_nulls": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/a6143dfb7e4e0ad6.sql b/tests/ast_json_fixtures/shapes/a6143dfb7e4e0ad6.sql new file mode 100644 index 000000000000..c261aad96344 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6143dfb7e4e0ad6.sql @@ -0,0 +1 @@ +SELECT ignore(toFixedString('Lambda as function parameter', 28), toNullable(28), ignore(8)), sum(marks) FROM system.parts WHERE database = currentDatabase() GROUP BY GROUPING SETS ((2)) FORMAT Null settings optimize_injective_functions_in_group_by=1, optimize_group_by_function_keys=1, group_by_use_nulls=1 diff --git a/tests/ast_json_fixtures/shapes/a636ab0145c26f42.json b/tests/ast_json_fixtures/shapes/a636ab0145c26f42.json new file mode 100644 index 000000000000..e8cd03b28dae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a636ab0145c26f42.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "moving_sum_num" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "dt" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TabSeparatedWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/a636ab0145c26f42.sql b/tests/ast_json_fixtures/shapes/a636ab0145c26f42.sql new file mode 100644 index 000000000000..ec46a4b19f9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a636ab0145c26f42.sql @@ -0,0 +1 @@ +SELECT * FROM moving_sum_num ORDER BY k,dt FORMAT TabSeparatedWithNames diff --git a/tests/ast_json_fixtures/shapes/a636b9ac9ffa4989.json b/tests/ast_json_fixtures/shapes/a636b9ac9ffa4989.json new file mode 100644 index 000000000000..39c85b350f57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a636b9ac9ffa4989.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "metric_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a636b9ac9ffa4989.sql b/tests/ast_json_fixtures/shapes/a636b9ac9ffa4989.sql new file mode 100644 index 000000000000..8c866364ced4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a636b9ac9ffa4989.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS metric_log diff --git a/tests/ast_json_fixtures/shapes/a6372dbbcdcda8de.json b/tests/ast_json_fixtures/shapes/a6372dbbcdcda8de.json new file mode 100644 index 000000000000..e77e1dffedaa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6372dbbcdcda8de.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["default"] + } +} diff --git a/tests/ast_json_fixtures/shapes/a6372dbbcdcda8de.sql b/tests/ast_json_fixtures/shapes/a6372dbbcdcda8de.sql new file mode 100644 index 000000000000..7937099e96c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6372dbbcdcda8de.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA default diff --git a/tests/ast_json_fixtures/shapes/a63c164c957158c2.json b/tests/ast_json_fixtures/shapes/a63c164c957158c2.json new file mode 100644 index 000000000000..e6bc166c93b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a63c164c957158c2.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "ttl" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_TTL" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a63c164c957158c2.sql b/tests/ast_json_fixtures/shapes/a63c164c957158c2.sql new file mode 100644 index 000000000000..7ae45864b806 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a63c164c957158c2.sql @@ -0,0 +1 @@ +alter table ttl materialize ttl settings mutations_sync=2 diff --git a/tests/ast_json_fixtures/shapes/a65e1d8e5be87a4c.json b/tests/ast_json_fixtures/shapes/a65e1d8e5be87a4c.json new file mode 100644 index 000000000000..34e810c7c78c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a65e1d8e5be87a4c.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_02000" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_02000" + }, + { + "type": "Identifier", + "name": "key" + } + ] + } + }, + "as_table": "data_02000" + } +} diff --git a/tests/ast_json_fixtures/shapes/a65e1d8e5be87a4c.sql b/tests/ast_json_fixtures/shapes/a65e1d8e5be87a4c.sql new file mode 100644 index 000000000000..19b96d48917a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a65e1d8e5be87a4c.sql @@ -0,0 +1 @@ +create table dist_02000 as data_02000 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_02000, key) diff --git a/tests/ast_json_fixtures/shapes/a687b549f374b199.json b/tests/ast_json_fixtures/shapes/a687b549f374b199.json new file mode 100644 index 000000000000..fa24bd0bef36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a687b549f374b199.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "one_0023" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a687b549f374b199.sql b/tests/ast_json_fixtures/shapes/a687b549f374b199.sql new file mode 100644 index 000000000000..ba373b8fe033 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a687b549f374b199.sql @@ -0,0 +1 @@ +create temporary table one_0023 as select 1 diff --git a/tests/ast_json_fixtures/shapes/a68b2698ed39cb2a.json b/tests/ast_json_fixtures/shapes/a68b2698ed39cb2a.json new file mode 100644 index 000000000000..e810b6d77860 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a68b2698ed39cb2a.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "vv", + "name": "finalizeAggregation", + "arguments": [ + { + "type": "Identifier", + "name": "v" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_index_agg_func" + }, + "final": true + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "vv" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a68b2698ed39cb2a.sql b/tests/ast_json_fixtures/shapes/a68b2698ed39cb2a.sql new file mode 100644 index 000000000000..a316b96fb9fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a68b2698ed39cb2a.sql @@ -0,0 +1 @@ +SELECT id, finalizeAggregation(v) AS vv FROM t_index_agg_func FINAL WHERE vv >= 10 ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/a68f23c45046772b.json b/tests/ast_json_fixtures/shapes/a68f23c45046772b.json new file mode 100644 index 000000000000..5a5ab631bffb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a68f23c45046772b.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "03578_rocksdb" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "UInt16" + } + }, + { + "type": "ColumnDeclaration", + "name": "val", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "EmbeddedRocksDB", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "key" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a68f23c45046772b.sql b/tests/ast_json_fixtures/shapes/a68f23c45046772b.sql new file mode 100644 index 000000000000..255162d021b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a68f23c45046772b.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS 03578_rocksdb +( + key UInt16, + val String +) +ENGINE = EmbeddedRocksDB() +PRIMARY KEY key diff --git a/tests/ast_json_fixtures/shapes/a6ab0bb2736ec138.json b/tests/ast_json_fixtures/shapes/a6ab0bb2736ec138.json new file mode 100644 index 000000000000..066a81289899 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6ab0bb2736ec138.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "DetachQuery", + "kind": "DETACH", + "database": { + "type": "Identifier", + "name": "test1601_detach_permanently_atomic" + }, + "table": { + "type": "Identifier", + "name": "test_name_reuse" + }, + "permanently": true + } +} diff --git a/tests/ast_json_fixtures/shapes/a6ab0bb2736ec138.sql b/tests/ast_json_fixtures/shapes/a6ab0bb2736ec138.sql new file mode 100644 index 000000000000..8d51862fda4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6ab0bb2736ec138.sql @@ -0,0 +1 @@ +DETACH table test1601_detach_permanently_atomic.test_name_reuse PERMANENTLY diff --git a/tests/ast_json_fixtures/shapes/a6c358ebb97e90df.json b/tests/ast_json_fixtures/shapes/a6c358ebb97e90df.json new file mode 100644 index 000000000000..c616f2803a21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6c358ebb97e90df.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "alter": true, + "names": ["r2_01293"], + "alter_settings": { + "type": "AlterSettingsProfileElements", + "add_settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "1" + } + ] + }, + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a6c358ebb97e90df.sql b/tests/ast_json_fixtures/shapes/a6c358ebb97e90df.sql new file mode 100644 index 000000000000..06ad546f29cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6c358ebb97e90df.sql @@ -0,0 +1 @@ +ALTER ROLE r2_01293 SETTINGS readonly=1 diff --git a/tests/ast_json_fixtures/shapes/a6d3ec34ebc9a9f3.json b/tests/ast_json_fixtures/shapes/a6d3ec34ebc9a9f3.json new file mode 100644 index 000000000000..f95baddb627f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6d3ec34ebc9a9f3.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "z" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_PROJECTION", + "projection": { + "type": "Identifier", + "name": "pp" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a6d3ec34ebc9a9f3.sql b/tests/ast_json_fixtures/shapes/a6d3ec34ebc9a9f3.sql new file mode 100644 index 000000000000..c285772af0b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6d3ec34ebc9a9f3.sql @@ -0,0 +1 @@ +alter table z materialize projection pp settings mutations_sync=1 diff --git a/tests/ast_json_fixtures/shapes/a6f29ae9dee81d78.json b/tests/ast_json_fixtures/shapes/a6f29ae9dee81d78.json new file mode 100644 index 000000000000..e471b011a672 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6f29ae9dee81d78.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "ok", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t.val", + "name_parts": ["t", "val"] + }, + { + "type": "Identifier", + "name": "t.expected", + "name_parts": ["t", "expected"] + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t", + "name": "t_leading_zeroes" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a6f29ae9dee81d78.sql b/tests/ast_json_fixtures/shapes/a6f29ae9dee81d78.sql new file mode 100644 index 000000000000..593682d80d7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a6f29ae9dee81d78.sql @@ -0,0 +1 @@ +SELECT t.val == t.expected AS ok, * FROM t_leading_zeroes t ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/a706e5431ae796c0.json b/tests/ast_json_fixtures/shapes/a706e5431ae796c0.json new file mode 100644 index 000000000000..3382b27249ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a706e5431ae796c0.json @@ -0,0 +1,161 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "stats", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "avg_u", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "tup.u", + "name_parts": ["tup", "u"] + } + ] + }, + { + "type": "Function", + "alias": "max_u", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "tup.u", + "name_parts": ["tup", "u"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tuple_test" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "tup.u", + "name_parts": ["tup", "u"] + }, + { + "type": "Function", + "alias": "diff_from_avg", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tup.u", + "name_parts": ["tup", "u"] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "avg_u" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "stats" + } + } + } + ] + } + } + ] + } + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tuple_test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tup" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a706e5431ae796c0.sql b/tests/ast_json_fixtures/shapes/a706e5431ae796c0.sql new file mode 100644 index 000000000000..2354f402ed49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a706e5431ae796c0.sql @@ -0,0 +1,13 @@ +WITH stats AS ( + SELECT + avg(tup.u) as avg_u, + max(tup.u) as max_u + FROM tuple_test +) +SELECT + id, + tup.u, + tup.u - (SELECT avg_u FROM stats) as diff_from_avg +FROM tuple_test +WHERE tup IS NOT NULL +ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/a718d08325055673.json b/tests/ast_json_fixtures/shapes/a718d08325055673.json new file mode 100644 index 000000000000..afad5e4b2c78 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a718d08325055673.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "db1" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a718d08325055673.sql b/tests/ast_json_fixtures/shapes/a718d08325055673.sql new file mode 100644 index 000000000000..1bd016120e2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a718d08325055673.sql @@ -0,0 +1 @@ +GRANT SELECT ON db1.* TO test_user_01999 diff --git a/tests/ast_json_fixtures/shapes/a729658aaacdec6f.json b/tests/ast_json_fixtures/shapes/a729658aaacdec6f.json new file mode 100644 index 000000000000..45706e1d691a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a729658aaacdec6f.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["SHOW"], + "database": "db8" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a729658aaacdec6f.sql b/tests/ast_json_fixtures/shapes/a729658aaacdec6f.sql new file mode 100644 index 000000000000..4c6bda7ec4b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a729658aaacdec6f.sql @@ -0,0 +1 @@ +GRANT SHOW ON db8.* TO test_user_01999 diff --git a/tests/ast_json_fixtures/shapes/a7309ecc4c894a11.json b/tests/ast_json_fixtures/shapes/a7309ecc4c894a11.json new file mode 100644 index 000000000000..aae3547aedf8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7309ecc4c894a11.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "child_key" + }, + { + "type": "Identifier", + "name": "parent_key" + }, + { + "type": "Identifier", + "name": "child_key" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data_02233" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "parent_key" + }, + { + "type": "Identifier", + "name": "child_key" + }, + { + "type": "Identifier", + "name": "child_key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "parent_key" + }, + "direction": "ASC", + "nulls_first": false + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1", + "optimize_aggregation_in_order": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a7309ecc4c894a11.sql b/tests/ast_json_fixtures/shapes/a7309ecc4c894a11.sql new file mode 100644 index 000000000000..f2dfece9250f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7309ecc4c894a11.sql @@ -0,0 +1 @@ +SELECT child_key, parent_key, child_key FROM data_02233 GROUP BY parent_key, child_key, child_key WITH TOTALS ORDER BY parent_key ASC NULLS LAST SETTINGS max_threads = 1, optimize_aggregation_in_order = 1 diff --git a/tests/ast_json_fixtures/shapes/a75870198a5dc38c.json b/tests/ast_json_fixtures/shapes/a75870198a5dc38c.json new file mode 100644 index 000000000000..f4c5b96c76ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a75870198a5dc38c.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR QUERY CACHE", + "query_result_cache_tag": "abc" + } +} diff --git a/tests/ast_json_fixtures/shapes/a75870198a5dc38c.sql b/tests/ast_json_fixtures/shapes/a75870198a5dc38c.sql new file mode 100644 index 000000000000..ee43cc896433 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a75870198a5dc38c.sql @@ -0,0 +1 @@ +SYSTEM CLEAR QUERY CACHE TAG 'abc' diff --git a/tests/ast_json_fixtures/shapes/a7837fa515518fc8.json b/tests/ast_json_fixtures/shapes/a7837fa515518fc8.json new file mode 100644 index 000000000000..bed6a862a33a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7837fa515518fc8.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "marks" + }, + { + "type": "Identifier", + "name": "marks" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parts", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "adaptive_table" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Identifier", + "name": "active" + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/a7837fa515518fc8.sql b/tests/ast_json_fixtures/shapes/a7837fa515518fc8.sql new file mode 100644 index 000000000000..c86cb6c020e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7837fa515518fc8.sql @@ -0,0 +1 @@ +SELECT 'marks', marks FROM system.parts WHERE table = 'adaptive_table' AND database = currentDatabase() AND active FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/a785a4eb43d0cad5.json b/tests/ast_json_fixtures/shapes/a785a4eb43d0cad5.json new file mode 100644 index 000000000000..56a1ed684e4c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a785a4eb43d0cad5.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowIndexes", + "table": "NULL" + } +} diff --git a/tests/ast_json_fixtures/shapes/a785a4eb43d0cad5.sql b/tests/ast_json_fixtures/shapes/a785a4eb43d0cad5.sql new file mode 100644 index 000000000000..b20a5dba4bef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a785a4eb43d0cad5.sql @@ -0,0 +1 @@ +SHOW INDEX FROM NULL diff --git a/tests/ast_json_fixtures/shapes/a78f04204f7915a4.json b/tests/ast_json_fixtures/shapes/a78f04204f7915a4.json new file mode 100644 index 000000000000..d04d9c85fc82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a78f04204f7915a4.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "03400_dist_users" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "03400_users" + } + ] + } + }, + "as_table": "03400_users" + } +} diff --git a/tests/ast_json_fixtures/shapes/a78f04204f7915a4.sql b/tests/ast_json_fixtures/shapes/a78f04204f7915a4.sql new file mode 100644 index 000000000000..0c902f869978 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a78f04204f7915a4.sql @@ -0,0 +1,2 @@ +CREATE TABLE 03400_dist_users AS 03400_users +ENGINE = Distributed(test_cluster_two_shards, currentDatabase(), 03400_users) diff --git a/tests/ast_json_fixtures/shapes/a792a7f1792414f5.json b/tests/ast_json_fixtures/shapes/a792a7f1792414f5.json new file mode 100644 index 000000000000..867db23a94fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a792a7f1792414f5.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "0" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a792a7f1792414f5.sql b/tests/ast_json_fixtures/shapes/a792a7f1792414f5.sql new file mode 100644 index 000000000000..37b428370aea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a792a7f1792414f5.sql @@ -0,0 +1 @@ +SELECT (1 IN (0,2)) AS x GROUP BY x diff --git a/tests/ast_json_fixtures/shapes/a79bd7fac68e9f0c.json b/tests/ast_json_fixtures/shapes/a79bd7fac68e9f0c.json new file mode 100644 index 000000000000..21a6e117a823 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a79bd7fac68e9f0c.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "SYNC REPLICA", + "table": { + "type": "Identifier", + "name": "mut" + }, + "sync_replica_mode": "PULL" + } +} diff --git a/tests/ast_json_fixtures/shapes/a79bd7fac68e9f0c.sql b/tests/ast_json_fixtures/shapes/a79bd7fac68e9f0c.sql new file mode 100644 index 000000000000..cf264bf1d3db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a79bd7fac68e9f0c.sql @@ -0,0 +1 @@ +system sync replica mut pull diff --git a/tests/ast_json_fixtures/shapes/a7a3385c4687eff9.json b/tests/ast_json_fixtures/shapes/a7a3385c4687eff9.json new file mode 100644 index 000000000000..7340700e2fc2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7a3385c4687eff9.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "local_t" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Log", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a7a3385c4687eff9.sql b/tests/ast_json_fixtures/shapes/a7a3385c4687eff9.sql new file mode 100644 index 000000000000..fa4e669643af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7a3385c4687eff9.sql @@ -0,0 +1 @@ +create table local_t engine Log as select 1 a diff --git a/tests/ast_json_fixtures/shapes/a7f8d44eaa1ea677.json b/tests/ast_json_fixtures/shapes/a7f8d44eaa1ea677.json new file mode 100644 index 000000000000..4097c7754fda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7f8d44eaa1ea677.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "RevokeQuery", + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "team", + "wildcard": true + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["user_03141"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a7f8d44eaa1ea677.sql b/tests/ast_json_fixtures/shapes/a7f8d44eaa1ea677.sql new file mode 100644 index 000000000000..497d3d5e71d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7f8d44eaa1ea677.sql @@ -0,0 +1 @@ +REVOKE SELECT ON team*.* FROM user_03141 diff --git a/tests/ast_json_fixtures/shapes/a7fb146b42d5e1a7.json b/tests/ast_json_fixtures/shapes/a7fb146b42d5e1a7.json new file mode 100644 index 000000000000..795699f5e398 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7fb146b42d5e1a7.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a7fb146b42d5e1a7.sql b/tests/ast_json_fixtures/shapes/a7fb146b42d5e1a7.sql new file mode 100644 index 000000000000..8ee6f2b5cabe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7fb146b42d5e1a7.sql @@ -0,0 +1 @@ +SELECT count() FROM t PREWHERE NOT ignore(a) WHERE b > 0 diff --git a/tests/ast_json_fixtures/shapes/a7fbbeb4c3f25157.json b/tests/ast_json_fixtures/shapes/a7fbbeb4c3f25157.json new file mode 100644 index 000000000000..237abe85866b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7fbbeb4c3f25157.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "exp10", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "exp10", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_color": "1" + } + }, + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/a7fbbeb4c3f25157.sql b/tests/ast_json_fixtures/shapes/a7fbbeb4c3f25157.sql new file mode 100644 index 000000000000..5c54af8db5cf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a7fbbeb4c3f25157.sql @@ -0,0 +1 @@ +SELECT exp10(number) + exp10(-number) FROM numbers(10) FORMAT PrettySpace SETTINGS output_format_pretty_color = 1 diff --git a/tests/ast_json_fixtures/shapes/a80956adaa4d3434.json b/tests/ast_json_fixtures/shapes/a80956adaa4d3434.json new file mode 100644 index 000000000000..883d439a80f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a80956adaa4d3434.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a80956adaa4d3434.sql b/tests/ast_json_fixtures/shapes/a80956adaa4d3434.sql new file mode 100644 index 000000000000..b2e6321b4b9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a80956adaa4d3434.sql @@ -0,0 +1 @@ +SELECT count(NULL) FROM remote('127.0.0.{1,2}', numbers(3)) GROUP BY number % 2 WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/a815fad48efe4c1f.json b/tests/ast_json_fixtures/shapes/a815fad48efe4c1f.json new file mode 100644 index 000000000000..d9d3a63fad1d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a815fad48efe4c1f.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "� �" + } + ] + } + ], + "format": "JSONColumns" + } +} diff --git a/tests/ast_json_fixtures/shapes/a815fad48efe4c1f.sql b/tests/ast_json_fixtures/shapes/a815fad48efe4c1f.sql new file mode 100644 index 000000000000..96d1d9d1cded --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a815fad48efe4c1f.sql @@ -0,0 +1 @@ +SELECT '\xED\x20\xA8' AS s FORMAT JSONColumns diff --git a/tests/ast_json_fixtures/shapes/a82a7f3ba4aaaf13.json b/tests/ast_json_fixtures/shapes/a82a7f3ba4aaaf13.json new file mode 100644 index 000000000000..56f9636771fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a82a7f3ba4aaaf13.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "arr" + } + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "arr" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "src", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "String", + "value": "c" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Array(Nullable(Tuple(a Int32, s String)))" + } + ] + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a82a7f3ba4aaaf13.sql b/tests/ast_json_fixtures/shapes/a82a7f3ba4aaaf13.sql new file mode 100644 index 000000000000..bed3029cd6ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a82a7f3ba4aaaf13.sql @@ -0,0 +1,8 @@ +SELECT + arr.*, + toTypeName(arr) +FROM +( + SELECT + [tuple(1, 'a'), NULL, tuple(3, 'c')]::Array(Nullable(Tuple(a Int32, s String))) AS arr +) AS src diff --git a/tests/ast_json_fixtures/shapes/a8454fd8914af420.json b/tests/ast_json_fixtures/shapes/a8454fd8914af420.json new file mode 100644 index 000000000000..557fda9c73cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8454fd8914af420.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s1_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a8454fd8914af420.sql b/tests/ast_json_fixtures/shapes/a8454fd8914af420.sql new file mode 100644 index 000000000000..5b9a18d70587 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8454fd8914af420.sql @@ -0,0 +1 @@ +CREATE PROFILE s1_01294 SETTINGS NONE diff --git a/tests/ast_json_fixtures/shapes/a8617320289cda87.json b/tests/ast_json_fixtures/shapes/a8617320289cda87.json new file mode 100644 index 000000000000..cc58c97460a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8617320289cda87.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "insert_select_dst" + }, + "columns": [ + { + "type": "Asterisk", + "transformers": [ + { + "type": "ColumnsExceptTransformer", + "columns": [ + { + "type": "Identifier", + "name": "middle_a" + }, + { + "type": "Identifier", + "name": "middle_b" + } + ] + } + ] + } + ], + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "insert_select_src" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a8617320289cda87.sql b/tests/ast_json_fixtures/shapes/a8617320289cda87.sql new file mode 100644 index 000000000000..16c361c0b492 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8617320289cda87.sql @@ -0,0 +1 @@ +INSERT INTO insert_select_dst(* EXCEPT (middle_a, middle_b)) SELECT * FROM insert_select_src diff --git a/tests/ast_json_fixtures/shapes/a8a2e22dfddabf78.json b/tests/ast_json_fixtures/shapes/a8a2e22dfddabf78.json new file mode 100644 index 000000000000..82853bc9e47a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8a2e22dfddabf78.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "STOP PULLING REPLICATION LOG", + "table": { + "type": "Identifier", + "name": "t1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a8a2e22dfddabf78.sql b/tests/ast_json_fixtures/shapes/a8a2e22dfddabf78.sql new file mode 100644 index 000000000000..246b0881a69c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8a2e22dfddabf78.sql @@ -0,0 +1 @@ +SYSTEM STOP PULLING REPLICATION LOG t1 diff --git a/tests/ast_json_fixtures/shapes/a8b12085be5e4bc8.json b/tests/ast_json_fixtures/shapes/a8b12085be5e4bc8.json new file mode 100644 index 000000000000..c29e11809dbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8b12085be5e4bc8.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "u", + "value_type": "String", + "value": "test" + } + ], + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ev" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "idx" + } + } + } + ] + } + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_global_with_statement": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a8b12085be5e4bc8.sql b/tests/ast_json_fixtures/shapes/a8b12085be5e4bc8.sql new file mode 100644 index 000000000000..9512d6452be0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8b12085be5e4bc8.sql @@ -0,0 +1 @@ +WITH 'test' AS u SELECT count() FROM ev WHERE a IN (SELECT a FROM idx) SETTINGS enable_global_with_statement = 0 diff --git a/tests/ast_json_fixtures/shapes/a8c210dee7ea1cee.json b/tests/ast_json_fixtures/shapes/a8c210dee7ea1cee.json new file mode 100644 index 000000000000..8157805a41a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8c210dee7ea1cee.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + "assignments": [ + { + "type": "Assignment", + "column": "a", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a8c210dee7ea1cee.sql b/tests/ast_json_fixtures/shapes/a8c210dee7ea1cee.sql new file mode 100644 index 000000000000..e8b130c0edbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8c210dee7ea1cee.sql @@ -0,0 +1 @@ +ALTER TABLE test UPDATE a=0 WHERE id<4 diff --git a/tests/ast_json_fixtures/shapes/a8d5dade5de45fe4.json b/tests/ast_json_fixtures/shapes/a8d5dade5de45fe4.json new file mode 100644 index 000000000000..8bbc5dec9cd4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8d5dade5de45fe4.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "query_log" + }, + { + "table": "trace_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a8d5dade5de45fe4.sql b/tests/ast_json_fixtures/shapes/a8d5dade5de45fe4.sql new file mode 100644 index 000000000000..494d0ba17e1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8d5dade5de45fe4.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS query_log, trace_log diff --git a/tests/ast_json_fixtures/shapes/a8deb1e88698ecdd.json b/tests/ast_json_fixtures/shapes/a8deb1e88698ecdd.json new file mode 100644 index 000000000000..36a20a7d29c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8deb1e88698ecdd.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "d", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "alias": "b", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "alias": "c", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "TSKV" + } +} diff --git a/tests/ast_json_fixtures/shapes/a8deb1e88698ecdd.sql b/tests/ast_json_fixtures/shapes/a8deb1e88698ecdd.sql new file mode 100644 index 000000000000..a3ce009a4d7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8deb1e88698ecdd.sql @@ -0,0 +1 @@ +SELECT (1 as a) ? (number + 2 as b) : (number + 3 as c) as d, a, b, c, d FROM system.numbers LIMIT 1 FORMAT TSKV diff --git a/tests/ast_json_fixtures/shapes/a8ed023320e1d00a.json b/tests/ast_json_fixtures/shapes/a8ed023320e1d00a.json new file mode 100644 index 000000000000..a9463b7d4194 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8ed023320e1d00a.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tmerge" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^t$" + } + ] + } + }, + "as_table": "t" + } +} diff --git a/tests/ast_json_fixtures/shapes/a8ed023320e1d00a.sql b/tests/ast_json_fixtures/shapes/a8ed023320e1d00a.sql new file mode 100644 index 000000000000..85adadd8d811 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a8ed023320e1d00a.sql @@ -0,0 +1 @@ +CREATE TABLE tmerge AS t ENGINE = Merge(currentDatabase(), '^t$') diff --git a/tests/ast_json_fixtures/shapes/a9229f5543102a7b.json b/tests/ast_json_fixtures/shapes/a9229f5543102a7b.json new file mode 100644 index 000000000000..b2c4ba4a677b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9229f5543102a7b.json @@ -0,0 +1,111 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "cluster", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "i" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/a9229f5543102a7b.sql b/tests/ast_json_fixtures/shapes/a9229f5543102a7b.sql new file mode 100644 index 000000000000..f089defc7bb4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9229f5543102a7b.sql @@ -0,0 +1 @@ +select * from (select * from cluster(test_cluster_two_shards, currentDatabase(), test) where i < 10) group by i order by i limit 10 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/a97855aac42bda74.json b/tests/ast_json_fixtures/shapes/a97855aac42bda74.json new file mode 100644 index 000000000000..a5d0910132d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a97855aac42bda74.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "z" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a97855aac42bda74.sql b/tests/ast_json_fixtures/shapes/a97855aac42bda74.sql new file mode 100644 index 000000000000..ddd4719f1312 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a97855aac42bda74.sql @@ -0,0 +1 @@ +EXPLAIN SELECT DISTINCT z FROM tab diff --git a/tests/ast_json_fixtures/shapes/a97a40042a76f369.json b/tests/ast_json_fixtures/shapes/a97a40042a76f369.json new file mode 100644 index 000000000000..d84d85f27c51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a97a40042a76f369.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "database": true, + "elements": [ + { + "from_database": "test_01155_ordinary", + "to_database": "test_01155_atomic" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a97a40042a76f369.sql b/tests/ast_json_fixtures/shapes/a97a40042a76f369.sql new file mode 100644 index 000000000000..a26dd942a12d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a97a40042a76f369.sql @@ -0,0 +1 @@ +RENAME DATABASE test_01155_ordinary TO test_01155_atomic diff --git a/tests/ast_json_fixtures/shapes/a9824ed1f894b054.json b/tests/ast_json_fixtures/shapes/a9824ed1f894b054.json new file mode 100644 index 000000000000..c4b82c189444 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9824ed1f894b054.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e" + }, + { + "type": "Literal", + "value_type": "String", + "value": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "enums" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a9824ed1f894b054.sql b/tests/ast_json_fixtures/shapes/a9824ed1f894b054.sql new file mode 100644 index 000000000000..0bab8acc56f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9824ed1f894b054.sql @@ -0,0 +1 @@ +select *, e < 'b' from enums diff --git a/tests/ast_json_fixtures/shapes/a98fb5356cb14b21.json b/tests/ast_json_fixtures/shapes/a98fb5356cb14b21.json new file mode 100644 index 000000000000..242256a3a068 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a98fb5356cb14b21.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + }, + "final": true + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a98fb5356cb14b21.sql b/tests/ast_json_fixtures/shapes/a98fb5356cb14b21.sql new file mode 100644 index 000000000000..3de9a8917614 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a98fb5356cb14b21.sql @@ -0,0 +1 @@ +SELECT 42 FROM t0 FINAL PREWHERE t0.c0 = 1 diff --git a/tests/ast_json_fixtures/shapes/a9938a5ed6fcfe7e.json b/tests/ast_json_fixtures/shapes/a9938a5ed6fcfe7e.json new file mode 100644 index 000000000000..caa2e4095351 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9938a5ed6fcfe7e.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "alter_ttl" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "i" + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2020-05-05" + } + ] + } + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a9938a5ed6fcfe7e.sql b/tests/ast_json_fixtures/shapes/a9938a5ed6fcfe7e.sql new file mode 100644 index 000000000000..50f4a78290ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9938a5ed6fcfe7e.sql @@ -0,0 +1 @@ +create table alter_ttl(i Int) engine = MergeTree order by i ttl toDate('2020-05-05') diff --git a/tests/ast_json_fixtures/shapes/a9966fab1dc4590c.json b/tests/ast_json_fixtures/shapes/a9966fab1dc4590c.json new file mode 100644 index 000000000000..7462b11620dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9966fab1dc4590c.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "rename_table" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/a9966fab1dc4590c.sql b/tests/ast_json_fixtures/shapes/a9966fab1dc4590c.sql new file mode 100644 index 000000000000..15c6b7214ca0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9966fab1dc4590c.sql @@ -0,0 +1 @@ +SELECT * FROM rename_table ORDER BY k FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/a9aa365f67b9d298.json b/tests/ast_json_fixtures/shapes/a9aa365f67b9d298.json new file mode 100644 index 000000000000..09a907c2dcda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9aa365f67b9d298.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "str", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a string" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(String)" + } + ] + } + ], + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "str" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%" + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/a9aa365f67b9d298.sql b/tests/ast_json_fixtures/shapes/a9aa365f67b9d298.sql new file mode 100644 index 000000000000..4f96bd39459b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9aa365f67b9d298.sql @@ -0,0 +1 @@ +SELECT CAST('a string', 'Nullable(String)') AS str WHERE str LIKE '%' format Null diff --git a/tests/ast_json_fixtures/shapes/a9c037e658519232.json b/tests/ast_json_fixtures/shapes/a9c037e658519232.json new file mode 100644 index 000000000000..803538996a39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9c037e658519232.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p0", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Identifier", + "name": "c0" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_row_order": "1", + "allow_suspicious_indices": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a9c037e658519232.sql b/tests/ast_json_fixtures/shapes/a9c037e658519232.sql new file mode 100644 index 000000000000..fb16b0dc5910 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9c037e658519232.sql @@ -0,0 +1 @@ +CREATE TABLE t0 (c0 Int, PROJECTION p0 (SELECT c0 GROUP BY c0, c0)) ENGINE = MergeTree() PRIMARY KEY tuple() SETTINGS optimize_row_order = 1, allow_suspicious_indices = 1 diff --git a/tests/ast_json_fixtures/shapes/a9d433e6c74d2e72.json b/tests/ast_json_fixtures/shapes/a9d433e6c74d2e72.json new file mode 100644 index 000000000000..d87cb61b4f02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9d433e6c74d2e72.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t.t.t", + "name_parts": ["t", "t", "t"] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tables", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a9d433e6c74d2e72.sql b/tests/ast_json_fixtures/shapes/a9d433e6c74d2e72.sql new file mode 100644 index 000000000000..42eeab23272e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9d433e6c74d2e72.sql @@ -0,0 +1 @@ +SELECT t.t.t.* FROM system.tables WHERE database = currentDatabase() diff --git a/tests/ast_json_fixtures/shapes/a9e50d1e71fcb9f3.json b/tests/ast_json_fixtures/shapes/a9e50d1e71fcb9f3.json new file mode 100644 index 000000000000..c699ef9254c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9e50d1e71fcb9f3.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "ColumnsRegexpMatcher", + "pattern": "product.*" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ColumnsClauseTest" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "product_price" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a9e50d1e71fcb9f3.sql b/tests/ast_json_fixtures/shapes/a9e50d1e71fcb9f3.sql new file mode 100644 index 000000000000..827868ab4b36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9e50d1e71fcb9f3.sql @@ -0,0 +1 @@ +SELECT COLUMNS('product.*') from ColumnsClauseTest ORDER BY product_price diff --git a/tests/ast_json_fixtures/shapes/a9e9382d37ecf692.json b/tests/ast_json_fixtures/shapes/a9e9382d37ecf692.json new file mode 100644 index 000000000000..9df0ae0a508b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9e9382d37ecf692.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "01504_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "EmbeddedRocksDB", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/a9e9382d37ecf692.sql b/tests/ast_json_fixtures/shapes/a9e9382d37ecf692.sql new file mode 100644 index 000000000000..b1e8b6db3196 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9e9382d37ecf692.sql @@ -0,0 +1 @@ +CREATE TABLE 01504_test (key String, value UInt32) Engine=EmbeddedRocksDB PRIMARY KEY(key, value) diff --git a/tests/ast_json_fixtures/shapes/a9fabeae87369f25.json b/tests/ast_json_fixtures/shapes/a9fabeae87369f25.json new file mode 100644 index 000000000000..97d6ca3ef0f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9fabeae87369f25.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "99999999" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/a9fabeae87369f25.sql b/tests/ast_json_fixtures/shapes/a9fabeae87369f25.sql new file mode 100644 index 000000000000..562a8559a261 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/a9fabeae87369f25.sql @@ -0,0 +1 @@ +SELECT s != '' FROM test WHERE s < '99999999' LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/aa019eb77b0c90c4.json b/tests/ast_json_fixtures/shapes/aa019eb77b0c90c4.json new file mode 100644 index 000000000000..45ad7378d38d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa019eb77b0c90c4.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "alias_2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Alias", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "alias_1" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/aa019eb77b0c90c4.sql b/tests/ast_json_fixtures/shapes/aa019eb77b0c90c4.sql new file mode 100644 index 000000000000..c35b97e7ee03 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa019eb77b0c90c4.sql @@ -0,0 +1 @@ +CREATE TABLE alias_2 ENGINE = Alias('alias_1') diff --git a/tests/ast_json_fixtures/shapes/aa2bd5672194ea1c.json b/tests/ast_json_fixtures/shapes/aa2bd5672194ea1c.json new file mode 100644 index 000000000000..cebe7f65769f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa2bd5672194ea1c.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "UseQuery", + "database": { + "type": "Identifier", + "name": "db1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/aa2bd5672194ea1c.sql b/tests/ast_json_fixtures/shapes/aa2bd5672194ea1c.sql new file mode 100644 index 000000000000..bc9213228d8a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa2bd5672194ea1c.sql @@ -0,0 +1 @@ +USE db1 diff --git a/tests/ast_json_fixtures/shapes/aa38bf3ed5898bb2.json b/tests/ast_json_fixtures/shapes/aa38bf3ed5898bb2.json new file mode 100644 index 000000000000..01f8addf30eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa38bf3ed5898bb2.json @@ -0,0 +1,122 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x1" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "x2" + } + ] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "x3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test2" + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "x1" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + "direction": "DESC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/aa38bf3ed5898bb2.sql b/tests/ast_json_fixtures/shapes/aa38bf3ed5898bb2.sql new file mode 100644 index 000000000000..94609e7f2cc5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa38bf3ed5898bb2.sql @@ -0,0 +1 @@ +select x1, x1 * 2, max(x2), max(x3) from test2 group by 2, 1, x1 order by 1, 2, 4 desc, 3 asc diff --git a/tests/ast_json_fixtures/shapes/aa452a088bbc4848.json b/tests/ast_json_fixtures/shapes/aa452a088bbc4848.json new file mode 100644 index 000000000000..c88c3e213cdc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa452a088bbc4848.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q13_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/aa452a088bbc4848.sql b/tests/ast_json_fixtures/shapes/aa452a088bbc4848.sql new file mode 100644 index 000000000000..3cd3d6778478 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa452a088bbc4848.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q13_01297 diff --git a/tests/ast_json_fixtures/shapes/aa664fabd255b8e4.json b/tests/ast_json_fixtures/shapes/aa664fabd255b8e4.json new file mode 100644 index 000000000000..a07bc4582f90 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa664fabd255b8e4.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "1,a1,1" + }, + { + "type": "Function", + "name": "arrayEnumerateUniqRanked", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "a1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "arrays_test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a2" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/aa664fabd255b8e4.sql b/tests/ast_json_fixtures/shapes/aa664fabd255b8e4.sql new file mode 100644 index 000000000000..002459fdadbf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa664fabd255b8e4.sql @@ -0,0 +1 @@ +SELECT '1,a1,1', arrayEnumerateUniqRanked(1,a1,1) FROM arrays_test ORDER BY a1, a2 diff --git a/tests/ast_json_fixtures/shapes/aa675dea923b9561.json b/tests/ast_json_fixtures/shapes/aa675dea923b9561.json new file mode 100644 index 000000000000..e717a7acb1e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa675dea923b9561.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p2_01295", + "database": "db", + "table": "table" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/aa675dea923b9561.sql b/tests/ast_json_fixtures/shapes/aa675dea923b9561.sql new file mode 100644 index 000000000000..13b5a9880315 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa675dea923b9561.sql @@ -0,0 +1 @@ +CREATE POLICY p2_01295 ON db.table TO ALL diff --git a/tests/ast_json_fixtures/shapes/aa80bea3d4771257.json b/tests/ast_json_fixtures/shapes/aa80bea3d4771257.json new file mode 100644 index 000000000000..3ef5217ff5ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa80bea3d4771257.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "01913_db" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Atomic", + "kind": "DATABASE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/aa80bea3d4771257.sql b/tests/ast_json_fixtures/shapes/aa80bea3d4771257.sql new file mode 100644 index 000000000000..5ea2d800d941 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aa80bea3d4771257.sql @@ -0,0 +1 @@ +CREATE DATABASE 01913_db ENGINE=Atomic diff --git a/tests/ast_json_fixtures/shapes/aaa300a29b35b00b.json b/tests/ast_json_fixtures/shapes/aaa300a29b35b00b.json new file mode 100644 index 000000000000..d773c6f3d60a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aaa300a29b35b00b.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "Raw" + } +} diff --git a/tests/ast_json_fixtures/shapes/aaa300a29b35b00b.sql b/tests/ast_json_fixtures/shapes/aaa300a29b35b00b.sql new file mode 100644 index 000000000000..15c8b1fdb767 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aaa300a29b35b00b.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT Raw diff --git a/tests/ast_json_fixtures/shapes/aac6d4e70e193b32.json b/tests/ast_json_fixtures/shapes/aac6d4e70e193b32.json new file mode 100644 index 000000000000..2ed6c8aa8e79 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aac6d4e70e193b32.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "some_table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DELETE", + "predicate": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/aac6d4e70e193b32.sql b/tests/ast_json_fixtures/shapes/aac6d4e70e193b32.sql new file mode 100644 index 000000000000..1bf6b9a21a08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aac6d4e70e193b32.sql @@ -0,0 +1 @@ +ALTER TABLE some_table DELETE WHERE 1 diff --git a/tests/ast_json_fixtures/shapes/aadb958fdecaa594.json b/tests/ast_json_fixtures/shapes/aadb958fdecaa594.json new file mode 100644 index 000000000000..784355e1209c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aadb958fdecaa594.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowIndexes", + "extended": true, + "table": "tbl" + } +} diff --git a/tests/ast_json_fixtures/shapes/aadb958fdecaa594.sql b/tests/ast_json_fixtures/shapes/aadb958fdecaa594.sql new file mode 100644 index 000000000000..ea00094cc7bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aadb958fdecaa594.sql @@ -0,0 +1 @@ +SHOW EXTENDED INDEX FROM tbl diff --git a/tests/ast_json_fixtures/shapes/ab0969b53cbf9ff2.json b/tests/ast_json_fixtures/shapes/ab0969b53cbf9ff2.json new file mode 100644 index 000000000000..7843f1337543 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ab0969b53cbf9ff2.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ab0969b53cbf9ff2.sql b/tests/ast_json_fixtures/shapes/ab0969b53cbf9ff2.sql new file mode 100644 index 000000000000..24871c95f471 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ab0969b53cbf9ff2.sql @@ -0,0 +1 @@ +SELECT (SELECT 1) FROM remote('127.0.0.{1,2}') diff --git a/tests/ast_json_fixtures/shapes/ab1d8d26f8c75c6c.json b/tests/ast_json_fixtures/shapes/ab1d8d26f8c75c6c.json new file mode 100644 index 000000000000..d9ba27f918ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ab1d8d26f8c75c6c.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Ok." + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "warnings", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "ilike", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%Ordinary%" + } + ] + }, + { + "type": "Function", + "name": "ilike", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%deprecated%" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ab1d8d26f8c75c6c.sql b/tests/ast_json_fixtures/shapes/ab1d8d26f8c75c6c.sql new file mode 100644 index 000000000000..42281b9c1df0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ab1d8d26f8c75c6c.sql @@ -0,0 +1 @@ +SELECT DISTINCT 'Ok.' FROM system.warnings WHERE message ILIKE '%Ordinary%' and message ILIKE '%deprecated%' diff --git a/tests/ast_json_fixtures/shapes/ab6a6c869c112238.json b/tests/ast_json_fixtures/shapes/ab6a6c869c112238.json new file mode 100644 index 000000000000..30724d26b523 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ab6a6c869c112238.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_00609" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "100" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/ab6a6c869c112238.sql b/tests/ast_json_fixtures/shapes/ab6a6c869c112238.sql new file mode 100644 index 000000000000..48838b87351c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ab6a6c869c112238.sql @@ -0,0 +1 @@ +select * from `table_00609` prewhere val > 2 format Null SETTINGS max_block_size=100 diff --git a/tests/ast_json_fixtures/shapes/ab6b18956bda246a.json b/tests/ast_json_fixtures/shapes/ab6b18956bda246a.json new file mode 100644 index 000000000000..4318fffe8d72 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ab6b18956bda246a.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s4_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "value": "5000000" + } + ] + }, + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ab6b18956bda246a.sql b/tests/ast_json_fixtures/shapes/ab6b18956bda246a.sql new file mode 100644 index 000000000000..a308ce59cbee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ab6b18956bda246a.sql @@ -0,0 +1 @@ +CREATE PROFILE s4_01294 SETTINGS max_memory_usage=5000000 TO r1_01294 diff --git a/tests/ast_json_fixtures/shapes/ab747294d7f7e4e4.json b/tests/ast_json_fixtures/shapes/ab747294d7f7e4e4.json new file mode 100644 index 000000000000..9b0902fb8043 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ab747294d7f7e4e4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q1_01297", "q2_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/ab747294d7f7e4e4.sql b/tests/ast_json_fixtures/shapes/ab747294d7f7e4e4.sql new file mode 100644 index 000000000000..842f29be22a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ab747294d7f7e4e4.sql @@ -0,0 +1 @@ +DROP QUOTA q1_01297, q2_01297 diff --git a/tests/ast_json_fixtures/shapes/abaad4e635eba50a.json b/tests/ast_json_fixtures/shapes/abaad4e635eba50a.json new file mode 100644 index 000000000000..9eeb2f80a8ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abaad4e635eba50a.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "n" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/abaad4e635eba50a.sql b/tests/ast_json_fixtures/shapes/abaad4e635eba50a.sql new file mode 100644 index 000000000000..7de65d788933 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abaad4e635eba50a.sql @@ -0,0 +1 @@ +create table t (n int) engine MergeTree order by n diff --git a/tests/ast_json_fixtures/shapes/abb857b1382f0231.json b/tests/ast_json_fixtures/shapes/abb857b1382f0231.json new file mode 100644 index 000000000000..5a80bf451a57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abb857b1382f0231.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "constBF16" + } +} diff --git a/tests/ast_json_fixtures/shapes/abb857b1382f0231.sql b/tests/ast_json_fixtures/shapes/abb857b1382f0231.sql new file mode 100644 index 000000000000..b0a33ee6ac9a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abb857b1382f0231.sql @@ -0,0 +1 @@ +DROP FUNCTION constBF16 diff --git a/tests/ast_json_fixtures/shapes/abb9227088944ed2.json b/tests/ast_json_fixtures/shapes/abb9227088944ed2.json new file mode 100644 index 000000000000..31d18a573957 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abb9227088944ed2.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "right_table" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "right_table_local" + } + ] + } + }, + "as_table": "right_table_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/abb9227088944ed2.sql b/tests/ast_json_fixtures/shapes/abb9227088944ed2.sql new file mode 100644 index 000000000000..dce31de61b51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abb9227088944ed2.sql @@ -0,0 +1 @@ +create table if not exists right_table engine=Distributed('test_shard_localhost', currentDatabase(), right_table_local) AS right_table_local diff --git a/tests/ast_json_fixtures/shapes/abbb6f90c29f6d6a.json b/tests/ast_json_fixtures/shapes/abbb6f90c29f6d6a.json new file mode 100644 index 000000000000..613cb0fdf4de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abbb6f90c29f6d6a.json @@ -0,0 +1,98 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "reference_vec", + "value_type": "Array", + "value": [ + { + "value_type": "Float64", + "value": 0.5 + }, + { + "value_type": "Float64", + "value": 0.5 + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "settings": { + "type": "Settings", + "changes": { + "hnsw_candidate_list_size_for_search": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/abbb6f90c29f6d6a.sql b/tests/ast_json_fixtures/shapes/abbb6f90c29f6d6a.sql new file mode 100644 index 000000000000..67c1e1ff0a0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abbb6f90c29f6d6a.sql @@ -0,0 +1,6 @@ +WITH [0.5, 0.5] AS reference_vec +SELECT id, vec, L2Distance(vec, reference_vec) +FROM tab +ORDER BY L2Distance(vec, reference_vec) +LIMIT 3 +SETTINGS hnsw_candidate_list_size_for_search = 0 diff --git a/tests/ast_json_fixtures/shapes/abcf591a928c0ce7.json b/tests/ast_json_fixtures/shapes/abcf591a928c0ce7.json new file mode 100644 index 000000000000..f92b133d92ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abcf591a928c0ce7.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "test_repl" + }, + "cluster": "test_shard_localhost", + "sync": true + } +} diff --git a/tests/ast_json_fixtures/shapes/abcf591a928c0ce7.sql b/tests/ast_json_fixtures/shapes/abcf591a928c0ce7.sql new file mode 100644 index 000000000000..82b950ebb1f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abcf591a928c0ce7.sql @@ -0,0 +1 @@ +DROP TABLE test_repl ON CLUSTER test_shard_localhost NO DELAY diff --git a/tests/ast_json_fixtures/shapes/abe0e3dbea266fab.json b/tests/ast_json_fixtures/shapes/abe0e3dbea266fab.json new file mode 100644 index 000000000000..0357e95d9396 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abe0e3dbea266fab.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "i" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "3" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/abe0e3dbea266fab.sql b/tests/ast_json_fixtures/shapes/abe0e3dbea266fab.sql new file mode 100644 index 000000000000..e9437cd8766f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abe0e3dbea266fab.sql @@ -0,0 +1 @@ +CREATE TABLE x (i int) engine MergeTree ORDER BY i SETTINGS index_granularity = 3 diff --git a/tests/ast_json_fixtures/shapes/abf1a308ee6daec9.json b/tests/ast_json_fixtures/shapes/abf1a308ee6daec9.json new file mode 100644 index 000000000000..ed316167e903 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abf1a308ee6daec9.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "y", + "value_type": "UInt64", + "value": "123" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/abf1a308ee6daec9.sql b/tests/ast_json_fixtures/shapes/abf1a308ee6daec9.sql new file mode 100644 index 000000000000..8321b7af83e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/abf1a308ee6daec9.sql @@ -0,0 +1 @@ +SELECT arrayMap(x -> 1, [2]), 123 AS y diff --git a/tests/ast_json_fixtures/shapes/ac0d53f536884d40.json b/tests/ast_json_fixtures/shapes/ac0d53f536884d40.json new file mode 100644 index 000000000000..a8d3a5e9f549 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac0d53f536884d40.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "having": { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "3" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ac0d53f536884d40.sql b/tests/ast_json_fixtures/shapes/ac0d53f536884d40.sql new file mode 100644 index 000000000000..29da555cd089 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac0d53f536884d40.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(4) GROUP BY number WITH TOTALS HAVING sum(number) <= arrayJoin([3, 2, 1, 0]) ORDER BY number diff --git a/tests/ast_json_fixtures/shapes/ac1b56bf0704c33b.json b/tests/ast_json_fixtures/shapes/ac1b56bf0704c33b.json new file mode 100644 index 000000000000..7c75d4670f99 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac1b56bf0704c33b.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "rename_table" + } + } + } + ] + } + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/ac1b56bf0704c33b.sql b/tests/ast_json_fixtures/shapes/ac1b56bf0704c33b.sql new file mode 100644 index 000000000000..5a657f7b9aeb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac1b56bf0704c33b.sql @@ -0,0 +1 @@ +SELECT * FROM rename_table FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/ac1b603f9d7e34c2.json b/tests/ast_json_fixtures/shapes/ac1b603f9d7e34c2.json new file mode 100644 index 000000000000..ff5d4003cda8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac1b603f9d7e34c2.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t2_local" + }, + "as_table": "t1_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/ac1b603f9d7e34c2.sql b/tests/ast_json_fixtures/shapes/ac1b603f9d7e34c2.sql new file mode 100644 index 000000000000..8bb70144da65 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac1b603f9d7e34c2.sql @@ -0,0 +1 @@ +create table t2_local as t1_local diff --git a/tests/ast_json_fixtures/shapes/ac21b71bb0f27b25.json b/tests/ast_json_fixtures/shapes/ac21b71bb0f27b25.json new file mode 100644 index 000000000000..5d49b58e4780 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac21b71bb0f27b25.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_mutation_rows_counter" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ac21b71bb0f27b25.sql b/tests/ast_json_fixtures/shapes/ac21b71bb0f27b25.sql new file mode 100644 index 000000000000..970f94941723 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac21b71bb0f27b25.sql @@ -0,0 +1 @@ +SELECT x, count() FROM t_mutation_rows_counter GROUP BY x HAVING count() > 1 diff --git a/tests/ast_json_fixtures/shapes/ac28720e842041fd.json b/tests/ast_json_fixtures/shapes/ac28720e842041fd.json new file mode 100644 index 000000000000..fdf099f35244 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac28720e842041fd.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x_as" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_block_number_column": "1", + "enable_block_offset_column": "1" + } + } + }, + "as_table": "x" + } +} diff --git a/tests/ast_json_fixtures/shapes/ac28720e842041fd.sql b/tests/ast_json_fixtures/shapes/ac28720e842041fd.sql new file mode 100644 index 000000000000..83780e49df6b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac28720e842041fd.sql @@ -0,0 +1 @@ +CREATE TABLE x_as AS x ENGINE = MergeTree SETTINGS enable_block_number_column = 1, enable_block_offset_column = 1 diff --git a/tests/ast_json_fixtures/shapes/ac2dfd447d2ce271.json b/tests/ast_json_fixtures/shapes/ac2dfd447d2ce271.json new file mode 100644 index 000000000000..d5c115dcb1b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac2dfd447d2ce271.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "BackupQuery", + "kind": "BACKUP", + "elements": [ + { + "element_type": "TABLE", + "table": "t0" + } + ], + "backup_name": { + "type": "Function", + "name": "Disk", + "kind": "BACKUP_NAME", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "backups" + }, + { + "type": "Literal", + "value_type": "String", + "value": "03760_backup_tar_archive.tar" + } + ] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/ac2dfd447d2ce271.sql b/tests/ast_json_fixtures/shapes/ac2dfd447d2ce271.sql new file mode 100644 index 000000000000..642a14993ab7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac2dfd447d2ce271.sql @@ -0,0 +1 @@ +BACKUP TABLE t0 TO Disk('backups', '03760_backup_tar_archive.tar') FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/ac49f70b644d6cd9.json b/tests/ast_json_fixtures/shapes/ac49f70b644d6cd9.json new file mode 100644 index 000000000000..d3e0e0e59596 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac49f70b644d6cd9.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "default_table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "key" + }, + "remove_property": "ALIAS" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ac49f70b644d6cd9.sql b/tests/ast_json_fixtures/shapes/ac49f70b644d6cd9.sql new file mode 100644 index 000000000000..6e08261c1b41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac49f70b644d6cd9.sql @@ -0,0 +1 @@ +ALTER TABLE default_table MODIFY COLUMN key REMOVE ALIAS diff --git a/tests/ast_json_fixtures/shapes/ac6fce5b026d41c9.json b/tests/ast_json_fixtures/shapes/ac6fce5b026d41c9.json new file mode 100644 index 000000000000..598e831d846f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac6fce5b026d41c9.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ac6fce5b026d41c9.sql b/tests/ast_json_fixtures/shapes/ac6fce5b026d41c9.sql new file mode 100644 index 000000000000..95ffe65f3a0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac6fce5b026d41c9.sql @@ -0,0 +1 @@ +SELECT 1 FROM a PREWHERE v IN (SELECT 1) WHERE v IN (SELECT 2) diff --git a/tests/ast_json_fixtures/shapes/ac79acb4ddfb13bd.json b/tests/ast_json_fixtures/shapes/ac79acb4ddfb13bd.json new file mode 100644 index 000000000000..4ae272a15881 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac79acb4ddfb13bd.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_bf_cast" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "x1", + "expression": { + "type": "Identifier", + "name": "c" + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "c" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ac79acb4ddfb13bd.sql b/tests/ast_json_fixtures/shapes/ac79acb4ddfb13bd.sql new file mode 100644 index 000000000000..7c7e83b7bac3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac79acb4ddfb13bd.sql @@ -0,0 +1 @@ +CREATE TABLE test_bf_cast (c Int32, INDEX x1 (c) type bloom_filter) ENGINE = MergeTree ORDER BY c AS SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/ac81dc308bfd5d9b.json b/tests/ast_json_fixtures/shapes/ac81dc308bfd5d9b.json new file mode 100644 index 000000000000..e0b060652f0b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac81dc308bfd5d9b.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "name": "sipHash64", + "arguments": [ + { + "type": "Identifier", + "name": "v" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "998" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_read_in_order": "1", + "log_comment": "02898_inorder_190aed82-2423-413b-ad4c-24dcca50f65b" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ac81dc308bfd5d9b.sql b/tests/ast_json_fixtures/shapes/ac81dc308bfd5d9b.sql new file mode 100644 index 000000000000..fdbda3b76c82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ac81dc308bfd5d9b.sql @@ -0,0 +1 @@ +SELECT k, sipHash64(v) FROM t1 order by k limit 5 offset 998 SETTINGS optimize_read_in_order=1, log_comment='02898_inorder_190aed82-2423-413b-ad4c-24dcca50f65b' diff --git a/tests/ast_json_fixtures/shapes/aca64d6cfe05e457.json b/tests/ast_json_fixtures/shapes/aca64d6cfe05e457.json new file mode 100644 index 000000000000..0c009c4b15b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aca64d6cfe05e457.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "v" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_lightweight_mut_7" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "apply_mutations_on_fly": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/aca64d6cfe05e457.sql b/tests/ast_json_fixtures/shapes/aca64d6cfe05e457.sql new file mode 100644 index 000000000000..323fc5e55c15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aca64d6cfe05e457.sql @@ -0,0 +1 @@ +SELECT 2, sum(v) FROM t_lightweight_mut_7 SETTINGS apply_mutations_on_fly = 0 diff --git a/tests/ast_json_fixtures/shapes/aca75eef675982f2.json b/tests/ast_json_fixtures/shapes/aca75eef675982f2.json new file mode 100644 index 000000000000..cf4ffebab366 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aca75eef675982f2.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u2_01292" + } + ] + }, + "default_roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r2_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/aca75eef675982f2.sql b/tests/ast_json_fixtures/shapes/aca75eef675982f2.sql new file mode 100644 index 000000000000..8e02528a7e53 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aca75eef675982f2.sql @@ -0,0 +1 @@ +ALTER USER u2_01292 DEFAULT ROLE ALL EXCEPT r2_01292 diff --git a/tests/ast_json_fixtures/shapes/acc0b307614fbed0.json b/tests/ast_json_fixtures/shapes/acc0b307614fbed0.json new file mode 100644 index 000000000000..57d8b885ea9f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/acc0b307614fbed0.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_ordinary", + "from_table": "mv2", + "to_database": "test_01155_atomic", + "to_table": "mv2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/acc0b307614fbed0.sql b/tests/ast_json_fixtures/shapes/acc0b307614fbed0.sql new file mode 100644 index 000000000000..894dc37c3de0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/acc0b307614fbed0.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_ordinary.mv2 TO test_01155_atomic.mv2 diff --git a/tests/ast_json_fixtures/shapes/acc66b28561df222.json b/tests/ast_json_fixtures/shapes/acc66b28561df222.json new file mode 100644 index 000000000000..26b7007a6e08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/acc66b28561df222.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s8_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "value": "5000000", + "min_value": "4000000", + "max_value": "6000000", + "writability": "CONST" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/acc66b28561df222.sql b/tests/ast_json_fixtures/shapes/acc66b28561df222.sql new file mode 100644 index 000000000000..83e137b99eff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/acc66b28561df222.sql @@ -0,0 +1 @@ +CREATE PROFILE s8_01294 SETTINGS max_memory_usage=5000000 MIN 4000000 MAX 6000000 CONST diff --git a/tests/ast_json_fixtures/shapes/ace13c360c177d24.json b/tests/ast_json_fixtures/shapes/ace13c360c177d24.json new file mode 100644 index 000000000000..f21db6813d57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ace13c360c177d24.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN AST", + "query": { + "type": "CreateFunctionQuery", + "function_name": { + "type": "Identifier", + "name": "double" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ace13c360c177d24.sql b/tests/ast_json_fixtures/shapes/ace13c360c177d24.sql new file mode 100644 index 000000000000..6190d20378a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ace13c360c177d24.sql @@ -0,0 +1 @@ +explain ast create function double AS (n) -> 2*n diff --git a/tests/ast_json_fixtures/shapes/ace86bc10a673ba3.json b/tests/ast_json_fixtures/shapes/ace86bc10a673ba3.json new file mode 100644 index 000000000000..c706dc98c75f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ace86bc10a673ba3.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "id" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ace86bc10a673ba3.sql b/tests/ast_json_fixtures/shapes/ace86bc10a673ba3.sql new file mode 100644 index 000000000000..39419cf58fd3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ace86bc10a673ba3.sql @@ -0,0 +1 @@ +create table t(id UInt32) engine MergeTree order by id as select 1 diff --git a/tests/ast_json_fixtures/shapes/acf8e40b15589231.json b/tests/ast_json_fixtures/shapes/acf8e40b15589231.json new file mode 100644 index 000000000000..e8c930dae37c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/acf8e40b15589231.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "alias": "k", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "k" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Identifier", + "name": "k" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/acf8e40b15589231.sql b/tests/ast_json_fixtures/shapes/acf8e40b15589231.sql new file mode 100644 index 000000000000..7f67f5bda20a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/acf8e40b15589231.sql @@ -0,0 +1,6 @@ +SELECT + count(), + number AS k +FROM remote('127.0.0.{1,2}', numbers(10)) +GROUP BY GROUPING SETS ((k), (k, k)) +ORDER BY k diff --git a/tests/ast_json_fixtures/shapes/ad2356dc806e4da6.json b/tests/ast_json_fixtures/shapes/ad2356dc806e4da6.json new file mode 100644 index 000000000000..cc3219d57acb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ad2356dc806e4da6.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "y", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "t" + }, + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "alias": "x", + "value_type": "String", + "value": "rue" + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "String", + "value": "true" + } + ] + } + } + ] + } + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ad2356dc806e4da6.sql b/tests/ast_json_fixtures/shapes/ad2356dc806e4da6.sql new file mode 100644 index 000000000000..67607ed75e16 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ad2356dc806e4da6.sql @@ -0,0 +1,4 @@ +with ('t' || x) as y, + 'rue' as x +select * from + (select 1 from tab where y = 'true') settings enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/ad270e2589d1a1bb.json b/tests/ast_json_fixtures/shapes/ad270e2589d1a1bb.json new file mode 100644 index 000000000000..eef15570d142 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ad270e2589d1a1bb.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t_sample_factor" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "sample_by": { + "type": "Identifier", + "name": "b" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ad270e2589d1a1bb.sql b/tests/ast_json_fixtures/shapes/ad270e2589d1a1bb.sql new file mode 100644 index 000000000000..da2c5a973fda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ad270e2589d1a1bb.sql @@ -0,0 +1 @@ +CREATE TABLE t_sample_factor(a UInt64, b UInt64) ENGINE = MergeTree ORDER BY (a, b) SAMPLE BY b diff --git a/tests/ast_json_fixtures/shapes/ad3dbd94ad001fb3.json b/tests/ast_json_fixtures/shapes/ad3dbd94ad001fb3.json new file mode 100644 index 000000000000..c73565795794 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ad3dbd94ad001fb3.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "d" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "j", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ad3dbd94ad001fb3.sql b/tests/ast_json_fixtures/shapes/ad3dbd94ad001fb3.sql new file mode 100644 index 000000000000..7051d9573dc0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ad3dbd94ad001fb3.sql @@ -0,0 +1 @@ +create table d (i int, j int) engine MergeTree partition by i % 2 order by tuple() settings index_granularity = 1 diff --git a/tests/ast_json_fixtures/shapes/ad6258368a9d021f.json b/tests/ast_json_fixtures/shapes/ad6258368a9d021f.json new file mode 100644 index 000000000000..78d53d1acbb8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ad6258368a9d021f.json @@ -0,0 +1,226 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "x", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "y", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "y" + } + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "x" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "y" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "using": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "y.id", + "name_parts": ["y", "id"] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ad6258368a9d021f.sql b/tests/ast_json_fixtures/shapes/ad6258368a9d021f.sql new file mode 100644 index 000000000000..afa15618f3b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ad6258368a9d021f.sql @@ -0,0 +1,6 @@ +WITH RECURSIVE + x AS + (SELECT 1 AS id UNION ALL SELECT id+1 FROM x WHERE id < 5), + y AS + (SELECT 1 AS id UNION ALL SELECT id+1 FROM x WHERE id < 10) + SELECT y.*, x.* FROM y LEFT JOIN x USING (id) ORDER BY y.id diff --git a/tests/ast_json_fixtures/shapes/ad8b97ea5f64ac73.json b/tests/ast_json_fixtures/shapes/ad8b97ea5f64ac73.json new file mode 100644 index 000000000000..85a9b09ad946 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ad8b97ea5f64ac73.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q6_01297"], + "limits": [ + { + "duration_sec": "5259492", + "max": { + "QUERIES": "100", + "ERRORS": "11", + "RESULT_ROWS": "1000", + "RESULT_BYTES": "10000", + "READ_ROWS": "1001", + "READ_BYTES": "10001", + "EXECUTION_TIME": "2500000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ad8b97ea5f64ac73.sql b/tests/ast_json_fixtures/shapes/ad8b97ea5f64ac73.sql new file mode 100644 index 000000000000..c95bf91a24a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ad8b97ea5f64ac73.sql @@ -0,0 +1 @@ +CREATE QUOTA q6_01297 FOR 2 MONTH MAX errors = 11, queries = 100, result_rows = 1000, result_bytes = 10000, read_rows = 1001, read_bytes = 10001, execution_time=2.5 diff --git a/tests/ast_json_fixtures/shapes/ada0d872186397eb.json b/tests/ast_json_fixtures/shapes/ada0d872186397eb.json new file mode 100644 index 000000000000..609b903b2174 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ada0d872186397eb.json @@ -0,0 +1,125 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "03408_local" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "val", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "min_bytes_for_wide_part": "1" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "name": "leftPad", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "String", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ada0d872186397eb.sql b/tests/ast_json_fixtures/shapes/ada0d872186397eb.sql new file mode 100644 index 000000000000..64392072f315 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ada0d872186397eb.sql @@ -0,0 +1,3 @@ +CREATE TABLE 03408_local (id Int32, val String) ENGINE = MergeTree ORDER BY tuple() SETTINGS min_bytes_for_wide_part=1 +AS +SELECT number % 10, leftPad(toString(number), 2, '0') FROM numbers(50) diff --git a/tests/ast_json_fixtures/shapes/add302063d779a1c.json b/tests/ast_json_fixtures/shapes/add302063d779a1c.json new file mode 100644 index 000000000000..6db2f6b2021b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/add302063d779a1c.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u3_01292" + } + ] + }, + "default_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/add302063d779a1c.sql b/tests/ast_json_fixtures/shapes/add302063d779a1c.sql new file mode 100644 index 000000000000..3e62437c00ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/add302063d779a1c.sql @@ -0,0 +1 @@ +CREATE USER u3_01292 DEFAULT ROLE r1_01292 diff --git a/tests/ast_json_fixtures/shapes/add96b2332c678c5.json b/tests/ast_json_fixtures/shapes/add96b2332c678c5.json new file mode 100644 index 000000000000..0c920e53a5b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/add96b2332c678c5.json @@ -0,0 +1,131 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "query_vec", + "value_type": "Array", + "value": [ + { + "value_type": "Float64", + "value": -0.042587746 + }, + { + "value_type": "Float64", + "value": 0.029204812 + }, + { + "value_type": "Float64", + "value": -0.018542241 + }, + { + "value_type": "Float64", + "value": -0.0006326993 + }, + { + "value_type": "Float64", + "value": -0.046840265 + }, + { + "value_type": "Float64", + "value": 0.017869968 + }, + { + "value_type": "Float64", + "value": -0.036177695 + }, + { + "value_type": "Float64", + "value": 0.008778641 + }, + { + "value_type": "Float64", + "value": -0.0062302556 + }, + { + "value_type": "Float64", + "value": 0.030549359 + }, + { + "value_type": "Float64", + "value": -0.009787052 + }, + { + "value_type": "Float64", + "value": -0.01996496 + }, + { + "value_type": "Float64", + "value": -0.0034493103 + }, + { + "value_type": "Float64", + "value": -0.01415683 + }, + { + "value_type": "Float64", + "value": -0.04583967 + }, + { + "value_type": "Float64", + "value": -0.047684517 + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "distance", + "name": "L2DistanceTransposed", + "arguments": [ + { + "type": "Identifier", + "name": "qbit" + }, + { + "type": "Identifier", + "name": "query_vec" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "32" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/add96b2332c678c5.sql b/tests/ast_json_fixtures/shapes/add96b2332c678c5.sql new file mode 100644 index 000000000000..da337f3b4a91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/add96b2332c678c5.sql @@ -0,0 +1,3 @@ +WITH [-0.042587746, 0.029204812, -0.018542241, -0.0006326993, -0.046840265, 0.017869968, -0.036177695, 0.008778641, -0.0062302556, 0.030549359, -0.009787052, -0.01996496, -0.0034493103, -0.01415683, -0.04583967, -0.047684517] AS query_vec +SELECT id, L2DistanceTransposed(qbit, query_vec, 32) AS distance +FROM test SETTINGS enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/ae07d93f8054a2b8.json b/tests/ast_json_fixtures/shapes/ae07d93f8054a2b8.json new file mode 100644 index 000000000000..cf56f3ad7676 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae07d93f8054a2b8.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ae07d93f8054a2b8.sql b/tests/ast_json_fixtures/shapes/ae07d93f8054a2b8.sql new file mode 100644 index 000000000000..ebdb9fc3d34e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae07d93f8054a2b8.sql @@ -0,0 +1 @@ +select count(), min(number) from dist_01247 group by 1 diff --git a/tests/ast_json_fixtures/shapes/ae1809fd0feeedcb.json b/tests/ast_json_fixtures/shapes/ae1809fd0feeedcb.json new file mode 100644 index 000000000000..41ac8b9a8620 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae1809fd0feeedcb.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CheckQuery", + "table": { + "type": "Identifier", + "name": "check_query_tiny_log" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "8", + "check_query_single_value_result": "0" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/ae1809fd0feeedcb.sql b/tests/ast_json_fixtures/shapes/ae1809fd0feeedcb.sql new file mode 100644 index 000000000000..2c67a3a2dfcc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae1809fd0feeedcb.sql @@ -0,0 +1 @@ +CHECK TABLE check_query_tiny_log FORMAT Null SETTINGS max_threads = 8, check_query_single_value_result = 0 diff --git a/tests/ast_json_fixtures/shapes/ae1dde20a4678b66.json b/tests/ast_json_fixtures/shapes/ae1dde20a4678b66.json new file mode 100644 index 000000000000..899f5384d597 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae1dde20a4678b66.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ae1dde20a4678b66.sql b/tests/ast_json_fixtures/shapes/ae1dde20a4678b66.sql new file mode 100644 index 000000000000..1e687f66250b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae1dde20a4678b66.sql @@ -0,0 +1,11 @@ +SELECT + number +FROM + numbers(10) +GROUP BY + GROUPING SETS + ( + number, + number % 2 + ) + WITH ROLLUP diff --git a/tests/ast_json_fixtures/shapes/ae467e833840901b.json b/tests/ast_json_fixtures/shapes/ae467e833840901b.json new file mode 100644 index 000000000000..0b1afa5104c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae467e833840901b.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "int" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "i" + }, + "order_by": { + "type": "StorageOrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "DESC" + }, + "settings": { + "type": "Settings", + "changes": { + "allow_nullable_key": "1", + "index_granularity": "2", + "allow_experimental_reverse_key": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ae467e833840901b.sql b/tests/ast_json_fixtures/shapes/ae467e833840901b.sql new file mode 100644 index 000000000000..0668d46b9132 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae467e833840901b.sql @@ -0,0 +1 @@ +create table x1 (i Nullable(int)) engine MergeTree order by i desc primary key i settings allow_nullable_key = 1, index_granularity = 2, allow_experimental_reverse_key = 1 diff --git a/tests/ast_json_fixtures/shapes/ae48e5b0257b58a6.json b/tests/ast_json_fixtures/shapes/ae48e5b0257b58a6.json new file mode 100644 index 000000000000..66c6304b2ff7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae48e5b0257b58a6.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "CreateIndexQuery", + "table": { + "type": "Identifier", + "name": "t_index" + }, + "index_name": { + "type": "Identifier", + "name": "i_a" + }, + "index_declaration": { + "type": "Index", + "name": "i_a", + "expression": { + "type": "Identifier", + "name": "a" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 4 + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ae48e5b0257b58a6.sql b/tests/ast_json_fixtures/shapes/ae48e5b0257b58a6.sql new file mode 100644 index 000000000000..47ea0e05a6da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae48e5b0257b58a6.sql @@ -0,0 +1 @@ +create index i_a on t_index(a) TYPE minmax GRANULARITY 4 diff --git a/tests/ast_json_fixtures/shapes/ae50d356cd623b77.json b/tests/ast_json_fixtures/shapes/ae50d356cd623b77.json new file mode 100644 index 000000000000..cea9e0205bbf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae50d356cd623b77.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t4" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "Int8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Kafka", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "kafka_broker_list": "localhost:10000", + "kafka_topic_list": "test", + "kafka_group_name": "test", + "kafka_format": "JSONEachRow" + } + } + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "this is a Kafka table" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ae50d356cd623b77.sql b/tests/ast_json_fixtures/shapes/ae50d356cd623b77.sql new file mode 100644 index 000000000000..c9cb2dc85c82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae50d356cd623b77.sql @@ -0,0 +1,11 @@ +CREATE TABLE t4 +( + `n` Int8 +) +ENGINE = Kafka +SETTINGS + kafka_broker_list = 'localhost:10000', + kafka_topic_list = 'test', + kafka_group_name = 'test', + kafka_format = 'JSONEachRow' +COMMENT 'this is a Kafka table' diff --git a/tests/ast_json_fixtures/shapes/ae634d0e5c163f71.json b/tests/ast_json_fixtures/shapes/ae634d0e5c163f71.json new file mode 100644 index 000000000000..f3efb1e344d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae634d0e5c163f71.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "prime" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "primes", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "bitAnd", + "arguments": [ + { + "type": "Identifier", + "name": "prime" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "prime" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ae634d0e5c163f71.sql b/tests/ast_json_fixtures/shapes/ae634d0e5c163f71.sql new file mode 100644 index 000000000000..0df3b4402c13 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae634d0e5c163f71.sql @@ -0,0 +1,4 @@ +SELECT prime +FROM system.primes +WHERE bitAnd(prime, prime + 1) = 0 +LIMIT 4 OFFSET 3 diff --git a/tests/ast_json_fixtures/shapes/ae6aabd3ae6a6b07.json b/tests/ast_json_fixtures/shapes/ae6aabd3ae6a6b07.json new file mode 100644 index 000000000000..310daa466f32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae6aabd3ae6a6b07.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "mut" + }, + "settings": { + "type": "Settings", + "changes": { + "alter_sync": "0" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "k" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ae6aabd3ae6a6b07.sql b/tests/ast_json_fixtures/shapes/ae6aabd3ae6a6b07.sql new file mode 100644 index 000000000000..3cdfbee7e193 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae6aabd3ae6a6b07.sql @@ -0,0 +1 @@ +alter table mut drop column k settings alter_sync=0 diff --git a/tests/ast_json_fixtures/shapes/ae7ab588cc2e6ace.json b/tests/ast_json_fixtures/shapes/ae7ab588cc2e6ace.json new file mode 100644 index 000000000000..55ee69d920af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae7ab588cc2e6ace.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test", + "from_table": "hits", + "to_database": "test", + "to_table": "visits" + }, + { + "from_database": "default", + "from_table": "hits", + "to_database": "test", + "to_table": "hits" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ae7ab588cc2e6ace.sql b/tests/ast_json_fixtures/shapes/ae7ab588cc2e6ace.sql new file mode 100644 index 000000000000..7951e0bcc165 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ae7ab588cc2e6ace.sql @@ -0,0 +1 @@ +RENAME TABLE test.hits TO test.visits, default.hits TO test.hits diff --git a/tests/ast_json_fixtures/shapes/aeb66c810488c8b1.json b/tests/ast_json_fixtures/shapes/aeb66c810488c8b1.json new file mode 100644 index 000000000000..c5928e02d3bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aeb66c810488c8b1.json @@ -0,0 +1,195 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "l", + "name": "tab_l" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l.a", + "name_parts": ["l", "a"] + }, + { + "type": "Identifier", + "name": "m.a", + "name_parts": ["m", "a"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "m", + "name": "tab_m" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l.a", + "name_parts": ["l", "a"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "r.a", + "name_parts": ["r", "a"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l.b", + "name_parts": ["l", "b"] + }, + { + "type": "Identifier", + "name": "l.c", + "name_parts": ["l", "c"] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "r.c", + "name_parts": ["r", "c"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l.d", + "name_parts": ["l", "d"] + }, + { + "type": "Identifier", + "name": "r.d", + "name_parts": ["r", "d"] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "r", + "name": "tab_r" + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/aeb66c810488c8b1.sql b/tests/ast_json_fixtures/shapes/aeb66c810488c8b1.sql new file mode 100644 index 000000000000..7ebf18758983 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aeb66c810488c8b1.sql @@ -0,0 +1,4 @@ +SELECT * FROM tab_l AS l +INNER JOIN tab_m AS m ON l.a = m.a +INNER JOIN tab_r AS r ON ((l.a * 2) = (r.a * 2)) AND ((l.b + l.c) = (r.c * 2)) AND (l.d = r.d) +WHERE 0 LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/aedb3cf841617b7f.json b/tests/ast_json_fixtures/shapes/aedb3cf841617b7f.json new file mode 100644 index 000000000000..2bb29a03043e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aedb3cf841617b7f.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "v" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_lightweight_mut_6" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "apply_mutations_on_fly": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/aedb3cf841617b7f.sql b/tests/ast_json_fixtures/shapes/aedb3cf841617b7f.sql new file mode 100644 index 000000000000..694b946d7dbb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aedb3cf841617b7f.sql @@ -0,0 +1 @@ +SELECT count(), sum(v) FROM t_lightweight_mut_6 PREWHERE id % 5 = 0 SETTINGS apply_mutations_on_fly = 0 diff --git a/tests/ast_json_fixtures/shapes/aee2b9a11a7358d7.json b/tests/ast_json_fixtures/shapes/aee2b9a11a7358d7.json new file mode 100644 index 000000000000..ebb3a103a25a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aee2b9a11a7358d7.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q1_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/aee2b9a11a7358d7.sql b/tests/ast_json_fixtures/shapes/aee2b9a11a7358d7.sql new file mode 100644 index 000000000000..f7f093024217 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aee2b9a11a7358d7.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q1_01297 diff --git a/tests/ast_json_fixtures/shapes/aeeac976b47c0d61.json b/tests/ast_json_fixtures/shapes/aeeac976b47c0d61.json new file mode 100644 index 000000000000..0f591952275a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aeeac976b47c0d61.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_00184" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "alias": "n", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "distributed_group_by_no_merge": "2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/aeeac976b47c0d61.sql b/tests/ast_json_fixtures/shapes/aeeac976b47c0d61.sql new file mode 100644 index 000000000000..15d22bba581f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aeeac976b47c0d61.sql @@ -0,0 +1 @@ +SELECT n FROM remote('127.0.0.{2,3}', currentDatabase(), data_00184) GROUP BY number AS n ORDER BY n SETTINGS distributed_group_by_no_merge=2 diff --git a/tests/ast_json_fixtures/shapes/aef650fd6721f4f3.json b/tests/ast_json_fixtures/shapes/aef650fd6721f4f3.json new file mode 100644 index 000000000000..95d193cc8a64 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aef650fd6721f4f3.json @@ -0,0 +1,146 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "value1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "date_t__fuzz_45" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toStartOfSecond", + "arguments": [ + { + "type": "Identifier", + "name": "date1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "199203" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "199300" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "199203" + }, + { + "type": "Function", + "name": "toStartOfSecond", + "arguments": [ + { + "type": "Identifier", + "name": "date1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "199300" + } + ] + } + ] + } + ] + }, + "qualify": { + "type": "Function", + "name": "isNull", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/aef650fd6721f4f3.sql b/tests/ast_json_fixtures/shapes/aef650fd6721f4f3.sql new file mode 100644 index 000000000000..b3874c1b6d6d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/aef650fd6721f4f3.sql @@ -0,0 +1 @@ +SELECT value1 FROM date_t__fuzz_45 PREWHERE (toStartOfSecond(date1) < 199203) AND (199300 < 1) WHERE (199203 <= toStartOfSecond(date1)) AND (1 < toLowCardinality(199300)) QUALIFY isNull(id) SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/af02bbbe79bfc561.json b/tests/ast_json_fixtures/shapes/af02bbbe79bfc561.json new file mode 100644 index 000000000000..32ab455854bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af02bbbe79bfc561.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q10_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/af02bbbe79bfc561.sql b/tests/ast_json_fixtures/shapes/af02bbbe79bfc561.sql new file mode 100644 index 000000000000..818092d64b80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af02bbbe79bfc561.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q10_01297 diff --git a/tests/ast_json_fixtures/shapes/af0a1c00b9d3a0b8.json b/tests/ast_json_fixtures/shapes/af0a1c00b9d3a0b8.json new file mode 100644 index 000000000000..143ca8817f8e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af0a1c00b9d3a0b8.json @@ -0,0 +1,494 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "q", + "name": "anyIf", + "arguments": [ + { + "type": "Function", + "name": "normalizeQuery", + "arguments": [ + { + "type": "Identifier", + "name": "query" + } + ] + }, + { + "type": "Identifier", + "name": "is_initial_query" + } + ] + }, + { + "type": "Function", + "alias": "queries_with_subqueries", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "any", + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Settings" + }, + { + "type": "Literal", + "value_type": "String", + "value": "allow_experimental_parallel_reading_from_replicas" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "any", + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Settings" + }, + { + "type": "Literal", + "value_type": "String", + "value": "cluster_for_parallel_replicas" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "parallel_replicas" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max2", + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt64" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max2", + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt64" + } + ] + } + ] + }, + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "any", + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Settings" + }, + { + "type": "Literal", + "value_type": "String", + "value": "cluster_for_parallel_replicas" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "parallel_replicas" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max2", + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt64" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max2", + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt64" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "distributed_index_analysis_replicas", + "name": "anyIf", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DistributedIndexAnalysisScheduledReplicas" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Identifier", + "name": "is_initial_query" + } + ] + }, + { + "type": "Function", + "alias": "read_with_parallel_replicas", + "name": "anyIf", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "ParallelReplicasUsedCount" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Identifier", + "name": "is_initial_query" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "yesterday", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryFinish" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_kind" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Select" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Settings" + }, + { + "type": "Literal", + "value_type": "String", + "value": "distributed_index_analysis" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "endsWith", + "arguments": [ + { + "type": "Identifier", + "name": "log_comment" + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "-" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "initial_query_id" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "event_time_microseconds" + } + ] + }, + "direction": "ASC" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/af0a1c00b9d3a0b8.sql b/tests/ast_json_fixtures/shapes/af0a1c00b9d3a0b8.sql new file mode 100644 index 000000000000..791a846c14c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af0a1c00b9d3a0b8.sql @@ -0,0 +1,30 @@ +select + anyIf(normalizeQuery(query), is_initial_query) q, + if( + + any(Settings['allow_experimental_parallel_reading_from_replicas']) = '1', + if(any(Settings['cluster_for_parallel_replicas']) = 'parallel_replicas', + + max2(count(), 19)::UInt64, + + max2(count(), 3)::UInt64, + ), + + if(any(Settings['cluster_for_parallel_replicas']) = 'parallel_replicas', + max2(count(), 10)::UInt64, + max2(count(), 2)::UInt64 + ) + ) queries_with_subqueries, + anyIf(ProfileEvents['DistributedIndexAnalysisScheduledReplicas'] > 0, is_initial_query) distributed_index_analysis_replicas, + anyIf(ProfileEvents['ParallelReplicasUsedCount'] > 0, is_initial_query) read_with_parallel_replicas +from system.query_log +where + event_date >= yesterday() + and type = 'QueryFinish' + and query_kind = 'Select' + and Settings['distributed_index_analysis'] = '1' + + and endsWith(log_comment, '-' || currentDatabase()) +group by initial_query_id +order by min(event_time_microseconds) +format Vertical diff --git a/tests/ast_json_fixtures/shapes/af16687afca3f3d2.json b/tests/ast_json_fixtures/shapes/af16687afca3f3d2.json new file mode 100644 index 000000000000..f80637090526 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af16687afca3f3d2.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "null", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/af16687afca3f3d2.sql b/tests/ast_json_fixtures/shapes/af16687afca3f3d2.sql new file mode 100644 index 000000000000..db11be9965de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af16687afca3f3d2.sql @@ -0,0 +1 @@ +DESCRIBE null() diff --git a/tests/ast_json_fixtures/shapes/af18fb2c9b84db49.json b/tests/ast_json_fixtures/shapes/af18fb2c9b84db49.json new file mode 100644 index 000000000000..b414ff8c5df6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af18fb2c9b84db49.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "hits_dst" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "EventDate" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Identifier", + "name": "EventDate" + }, + { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + } + ] + }, + "sample_by": { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "storage_policy": "default" + } + } + }, + "as_database": "test", + "as_table": "hits" + } +} diff --git a/tests/ast_json_fixtures/shapes/af18fb2c9b84db49.sql b/tests/ast_json_fixtures/shapes/af18fb2c9b84db49.sql new file mode 100644 index 000000000000..94d608e987eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af18fb2c9b84db49.sql @@ -0,0 +1,6 @@ +CREATE TABLE hits_dst AS test.hits +ENGINE = MergeTree +PARTITION BY toYYYYMM(EventDate) +ORDER BY (CounterID, EventDate, intHash32(UserID)) +SAMPLE BY intHash32(UserID) +SETTINGS storage_policy = 'default' diff --git a/tests/ast_json_fixtures/shapes/af2646519517d2d4.json b/tests/ast_json_fixtures/shapes/af2646519517d2d4.json new file mode 100644 index 000000000000..27649e1cd5a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af2646519517d2d4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s1_01294", "s2_01294", "s3_01294", "s4_01294", "s5_01294", "s6_01294", "s7_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/af2646519517d2d4.sql b/tests/ast_json_fixtures/shapes/af2646519517d2d4.sql new file mode 100644 index 000000000000..204099929bd7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af2646519517d2d4.sql @@ -0,0 +1 @@ +DROP PROFILE s1_01294, s2_01294, s3_01294, s4_01294, s5_01294, s6_01294, s7_01294 diff --git a/tests/ast_json_fixtures/shapes/af89e69986b44042.json b/tests/ast_json_fixtures/shapes/af89e69986b44042.json new file mode 100644 index 000000000000..26cbd4d704ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af89e69986b44042.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "src_table" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Null", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "dst_table" + } +} diff --git a/tests/ast_json_fixtures/shapes/af89e69986b44042.sql b/tests/ast_json_fixtures/shapes/af89e69986b44042.sql new file mode 100644 index 000000000000..417bce5d5b63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af89e69986b44042.sql @@ -0,0 +1 @@ +CREATE TABLE src_table AS dst_table ENGINE = Null diff --git a/tests/ast_json_fixtures/shapes/af9356eced4e3647.json b/tests/ast_json_fixtures/shapes/af9356eced4e3647.json new file mode 100644 index 000000000000..572bb39ebfa6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af9356eced4e3647.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "a", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/af9356eced4e3647.sql b/tests/ast_json_fixtures/shapes/af9356eced4e3647.sql new file mode 100644 index 000000000000..54ec576a52f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/af9356eced4e3647.sql @@ -0,0 +1,5 @@ +WITH arrayMap(x -> (x + 1), [0]) AS a +SELECT 1 +WHERE 1 IN ( + SELECT arrayJoin(a) +) diff --git a/tests/ast_json_fixtures/shapes/afa4b8fff2b4e12e.json b/tests/ast_json_fixtures/shapes/afa4b8fff2b4e12e.json new file mode 100644 index 000000000000..4ab1bca9f5d9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/afa4b8fff2b4e12e.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "part" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "p_partkey", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Identifier", + "name": "p_partkey" + }, + "settings": { + "type": "Settings", + "changes": { + "auto_statistics_types": "uniq" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/afa4b8fff2b4e12e.sql b/tests/ast_json_fixtures/shapes/afa4b8fff2b4e12e.sql new file mode 100644 index 000000000000..235b4b974a71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/afa4b8fff2b4e12e.sql @@ -0,0 +1 @@ +CREATE TABLE part (p_partkey Int32) ORDER BY (p_partkey) SETTINGS auto_statistics_types = 'uniq' diff --git a/tests/ast_json_fixtures/shapes/afb03e25459fd440.json b/tests/ast_json_fixtures/shapes/afb03e25459fd440.json new file mode 100644 index 000000000000..d0ea903ee152 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/afb03e25459fd440.json @@ -0,0 +1,151 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "key_a" + } + ] + }, + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "key_b" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "key_a", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "key_b", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key_a" + }, + { + "type": "Identifier", + "name": "key_b" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/afb03e25459fd440.sql b/tests/ast_json_fixtures/shapes/afb03e25459fd440.sql new file mode 100644 index 000000000000..cbe923db8336 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/afb03e25459fd440.sql @@ -0,0 +1,14 @@ +SELECT grouping(key_a) + grouping(key_b) AS d +FROM + ( + SELECT + rand() % 10 AS key_a, + rand(toLowCardinality(1)) % 5 AS key_b, + number + FROM numbers(100) + ) +GROUP BY + key_a, + key_b +WITH ROLLUP +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/afb9ca3ea55931b9.json b/tests/ast_json_fixtures/shapes/afb9ca3ea55931b9.json new file mode 100644 index 000000000000..f80c550dadcf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/afb9ca3ea55931b9.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "source_null" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Null", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "source" + } +} diff --git a/tests/ast_json_fixtures/shapes/afb9ca3ea55931b9.sql b/tests/ast_json_fixtures/shapes/afb9ca3ea55931b9.sql new file mode 100644 index 000000000000..636c2931139d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/afb9ca3ea55931b9.sql @@ -0,0 +1 @@ +CREATE TABLE source_null AS source ENGINE=Null diff --git a/tests/ast_json_fixtures/shapes/afd3ea34b21c466e.json b/tests/ast_json_fixtures/shapes/afd3ea34b21c466e.json new file mode 100644 index 000000000000..d02c3741d08c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/afd3ea34b21c466e.json @@ -0,0 +1,192 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "alias": "mA", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "A" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + ] + } + }, + { + "type": "Function", + "alias": "mB", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "B" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + ] + } + }, + { + "type": "Function", + "alias": "mC", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "C" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "qualify": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "mA" + }, + { + "type": "Identifier", + "name": "mB" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "mA" + }, + { + "type": "Identifier", + "name": "mC" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_extract_common_expressions": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/afd3ea34b21c466e.sql b/tests/ast_json_fixtures/shapes/afd3ea34b21c466e.sql new file mode 100644 index 000000000000..d5ea82148413 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/afd3ea34b21c466e.sql @@ -0,0 +1,10 @@ +SELECT + x, + max(A) OVER (PARTITION BY x % 1000) AS mA, + max(B) OVER (PARTITION BY x % 1000) AS mB, + max(C) OVER (PARTITION BY x % 1000) AS mC +FROM x +QUALIFY (mA AND mB) OR (mA AND mC) +ORDER BY x +LIMIT 10 +SETTINGS optimize_extract_common_expressions = 0 diff --git a/tests/ast_json_fixtures/shapes/afea3770a45cfdce.json b/tests/ast_json_fixtures/shapes/afea3770a45cfdce.json new file mode 100644 index 000000000000..86318b36a783 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/afea3770a45cfdce.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u2_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "PLAINTEXT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwe123" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/afea3770a45cfdce.sql b/tests/ast_json_fixtures/shapes/afea3770a45cfdce.sql new file mode 100644 index 000000000000..76128acf8923 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/afea3770a45cfdce.sql @@ -0,0 +1 @@ +CREATE USER u2_01292 IDENTIFIED WITH plaintext_password BY 'qwe123' diff --git a/tests/ast_json_fixtures/shapes/affad6db7d6ecb0b.json b/tests/ast_json_fixtures/shapes/affad6db7d6ecb0b.json new file mode 100644 index 000000000000..dd41b55b95bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/affad6db7d6ecb0b.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_materialize_delete" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "APPLY_DELETED_MASK", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/affad6db7d6ecb0b.sql b/tests/ast_json_fixtures/shapes/affad6db7d6ecb0b.sql new file mode 100644 index 000000000000..807bb8da3a26 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/affad6db7d6ecb0b.sql @@ -0,0 +1 @@ +ALTER TABLE t_materialize_delete APPLY DELETED MASK IN PARTITION 5 diff --git a/tests/ast_json_fixtures/shapes/b0005349f026b249.json b/tests/ast_json_fixtures/shapes/b0005349f026b249.json new file mode 100644 index 000000000000..592681732238 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0005349f026b249.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775808" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b0005349f026b249.sql b/tests/ast_json_fixtures/shapes/b0005349f026b249.sql new file mode 100644 index 000000000000..b31ee98403c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0005349f026b249.sql @@ -0,0 +1 @@ +SELECT 1 GROUP BY -9223372036854775808 diff --git a/tests/ast_json_fixtures/shapes/b002be5e1eb3657b.json b/tests/ast_json_fixtures/shapes/b002be5e1eb3657b.json new file mode 100644 index 000000000000..238afe6e7ebf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b002be5e1eb3657b.json @@ -0,0 +1,150 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "hits.date", + "name_parts": ["hits", "date"] + }, + { + "type": "Function", + "alias": "filtered", + "name": "arrayFilter", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "data" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "arrayExists", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "data" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b002be5e1eb3657b.sql b/tests/ast_json_fixtures/shapes/b002be5e1eb3657b.sql new file mode 100644 index 000000000000..ef0f269881e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b002be5e1eb3657b.sql @@ -0,0 +1,6 @@ +SELECT + hits.date, + arrayFilter(x -> (x IN (2, 3)), data) AS filtered +FROM hits +WHERE arrayExists(x -> (x IN (2, 3)), data) +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/b004bdfb06b45f8e.json b/tests/ast_json_fixtures/shapes/b004bdfb06b45f8e.json new file mode 100644 index 000000000000..b727564c8e2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b004bdfb06b45f8e.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "replace_table": true, + "table": { + "type": "Identifier", + "name": "test_dict" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Identifier", + "name": "view" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 1000 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b004bdfb06b45f8e.sql b/tests/ast_json_fixtures/shapes/b004bdfb06b45f8e.sql new file mode 100644 index 000000000000..23b674d5dc9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b004bdfb06b45f8e.sql @@ -0,0 +1,9 @@ +REPLACE DICTIONARY test_dict +( + id UInt64, + value String +) +PRIMARY KEY id +SOURCE(CLICKHOUSE(TABLE view)) +LAYOUT(FLAT()) +LIFETIME(MIN 0 MAX 1000) diff --git a/tests/ast_json_fixtures/shapes/b00580d86ca18d40.json b/tests/ast_json_fixtures/shapes/b00580d86ca18d40.json new file mode 100644 index 000000000000..e6eb9dae5a59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b00580d86ca18d40.json @@ -0,0 +1,131 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_rollup": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "-21474836.48" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 10000000000 + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Identifier", + "name": "kbytes" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 10.0001 + }, + { + "type": "Function", + "alias": "dt_m", + "name": "toStartOfMinute", + "arguments": [ + { + "type": "Identifier", + "name": "datetime" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "projection_test__fuzz_0" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "dt_m" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "retry_count" + }, + { + "type": "Identifier", + "name": "duration" + } + ] + } + ] + }, + "direction": "ASC", + "nulls_first": false + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "Float64", + "value": 100000000000000000000 + }, + "direction": "ASC", + "nulls_first": true + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/b00580d86ca18d40.sql b/tests/ast_json_fixtures/shapes/b00580d86ca18d40.sql new file mode 100644 index 000000000000..df754c33af62 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b00580d86ca18d40.sql @@ -0,0 +1 @@ +SELECT '-21474836.48', 10000000000., '', count(kbytes), '', 10.0001, toStartOfMinute(datetime) AS dt_m, 10, NULL FROM projection_test__fuzz_0 GROUP BY dt_m WITH ROLLUP WITH TOTALS ORDER BY count(retry_count / duration) ASC NULLS LAST, 100000000000000000000. ASC NULLS FIRST format Null diff --git a/tests/ast_json_fixtures/shapes/b0103c61d7262cff.json b/tests/ast_json_fixtures/shapes/b0103c61d7262cff.json new file mode 100644 index 000000000000..efed170b8467 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0103c61d7262cff.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_s64_distributed" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test_s64_local" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "test_s64_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/b0103c61d7262cff.sql b/tests/ast_json_fixtures/shapes/b0103c61d7262cff.sql new file mode 100644 index 000000000000..596c99d30684 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0103c61d7262cff.sql @@ -0,0 +1 @@ +CREATE TABLE test_s64_distributed AS test_s64_local ENGINE = Distributed('test_shard_localhost', currentDatabase(), test_s64_local, rand()) diff --git a/tests/ast_json_fixtures/shapes/b02bd27aa1aa25ab.json b/tests/ast_json_fixtures/shapes/b02bd27aa1aa25ab.json new file mode 100644 index 000000000000..ac62ac78a11b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b02bd27aa1aa25ab.json @@ -0,0 +1,6 @@ +{ + "version": 2, + "ast": { + "type": "ShowPrivilegesQuery" + } +} diff --git a/tests/ast_json_fixtures/shapes/b02bd27aa1aa25ab.sql b/tests/ast_json_fixtures/shapes/b02bd27aa1aa25ab.sql new file mode 100644 index 000000000000..e0d5c0b87f82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b02bd27aa1aa25ab.sql @@ -0,0 +1 @@ +SHOW PRIVILEGES diff --git a/tests/ast_json_fixtures/shapes/b03f68e10e2f96e2.json b/tests/ast_json_fixtures/shapes/b03f68e10e2f96e2.json new file mode 100644 index 000000000000..d018e60c6e58 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b03f68e10e2f96e2.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Literal", + "alias": "z", + "value_type": "UInt64", + "value": "41" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "z" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b03f68e10e2f96e2.sql b/tests/ast_json_fixtures/shapes/b03f68e10e2f96e2.sql new file mode 100644 index 000000000000..d6880eda1c9f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b03f68e10e2f96e2.sql @@ -0,0 +1 @@ +select 41 as z from remote('127.0.0.{2,3}', system.one) group by z WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/b067ac55b3090ddb.json b/tests/ast_json_fixtures/shapes/b067ac55b3090ddb.json new file mode 100644 index 000000000000..eba2a3a17dec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b067ac55b3090ddb.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "CreateIndexQuery", + "table": { + "type": "Identifier", + "name": "t_index" + }, + "index_name": { + "type": "Identifier", + "name": "i_b" + }, + "index_declaration": { + "type": "Index", + "name": "i_b", + "expression": { + "type": "Identifier", + "name": "b" + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [] + }, + "granularity": 2 + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b067ac55b3090ddb.sql b/tests/ast_json_fixtures/shapes/b067ac55b3090ddb.sql new file mode 100644 index 000000000000..135ee13f5fed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b067ac55b3090ddb.sql @@ -0,0 +1 @@ +create index i_b on t_index(b) TYPE bloom_filter GRANULARITY 2 diff --git a/tests/ast_json_fixtures/shapes/b07db8aa36ceaee9.json b/tests/ast_json_fixtures/shapes/b07db8aa36ceaee9.json new file mode 100644 index 000000000000..c8f4db266378 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b07db8aa36ceaee9.json @@ -0,0 +1,154 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "alias": "ym:s:goalDimension", + "name": "goals_alias.ID", + "name_parts": ["goals_alias", "ID"] + }, + { + "type": "Function", + "name": "uniqIf", + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "_uniq_Goals" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "visits", + "database": "test" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "INNER", + "expressions": [ + { + "type": "Identifier", + "alias": "goals_alias", + "name": "Goals" + }, + { + "type": "Function", + "alias": "_uniq_Goals", + "name": "arrayEnumerateUniq", + "arguments": [ + { + "type": "Identifier", + "name": "Goals.ID", + "name_parts": ["Goals", "ID"] + } + ] + } + ] + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "842440" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "ym:s:goalDimension" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ym:s:goalDimension" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/b07db8aa36ceaee9.sql b/tests/ast_json_fixtures/shapes/b07db8aa36ceaee9.sql new file mode 100644 index 000000000000..967ed7e2bf9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b07db8aa36ceaee9.sql @@ -0,0 +1 @@ +SELECT goals_alias.ID AS `ym:s:goalDimension`, uniqIf(UserID, (UserID != 0) AND (`_uniq_Goals` = 1)) FROM test.visits ARRAY JOIN Goals AS goals_alias, arrayEnumerateUniq(Goals.ID) AS `_uniq_Goals` WHERE (CounterID = 842440) GROUP BY `ym:s:goalDimension` WITH TOTALS ORDER BY `ym:s:goalDimension` LIMIT 0, 1 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/b07f742f6e170c7e.json b/tests/ast_json_fixtures/shapes/b07f742f6e170c7e.json new file mode 100644 index 000000000000..f94364d1c45d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b07f742f6e170c7e.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "log" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "collectorReceiptTime", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "eventId", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "ruleId", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "ailog_rule_count", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "collectorReceiptTime" + }, + { + "type": "Identifier", + "name": "ruleId" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Identifier", + "name": "ruleId" + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "collectorReceiptTime" + }, + { + "type": "Identifier", + "name": "ruleId" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMMDD", + "arguments": [ + { + "type": "Identifier", + "name": "collectorReceiptTime" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "collectorReceiptTime" + }, + { + "type": "Identifier", + "name": "eventId" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b07f742f6e170c7e.sql b/tests/ast_json_fixtures/shapes/b07f742f6e170c7e.sql new file mode 100644 index 000000000000..5444b08de5e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b07f742f6e170c7e.sql @@ -0,0 +1,17 @@ +CREATE TABLE log( + collectorReceiptTime DateTime, + eventId String, + ruleId String, + PROJECTION ailog_rule_count ( + SELECT + collectorReceiptTime, + ruleId, + count(ruleId) + GROUP BY + collectorReceiptTime, + ruleId + ) +) +ENGINE = MergeTree +PARTITION BY toYYYYMMDD(collectorReceiptTime) +ORDER BY (collectorReceiptTime, eventId) diff --git a/tests/ast_json_fixtures/shapes/b0982d38e8378d8c.json b/tests/ast_json_fixtures/shapes/b0982d38e8378d8c.json new file mode 100644 index 000000000000..0daedaddbe7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0982d38e8378d8c.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u3_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwe123" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/b0982d38e8378d8c.sql b/tests/ast_json_fixtures/shapes/b0982d38e8378d8c.sql new file mode 100644 index 000000000000..4e18fe814882 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0982d38e8378d8c.sql @@ -0,0 +1 @@ +CREATE USER u3_01292 IDENTIFIED BY 'qwe123' diff --git a/tests/ast_json_fixtures/shapes/b0b02fc62c3bc075.json b/tests/ast_json_fixtures/shapes/b0b02fc62c3bc075.json new file mode 100644 index 000000000000..75cbc7dc15b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0b02fc62c3bc075.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.1" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_02344" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "prefer_localhost_replica": "0" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 3000000000 + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "prefer_localhost_replica": "0" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b0b02fc62c3bc075.sql b/tests/ast_json_fixtures/shapes/b0b02fc62c3bc075.sql new file mode 100644 index 000000000000..8fdb5added49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0b02fc62c3bc075.sql @@ -0,0 +1 @@ +insert into function remote('127.1', currentDatabase(), data_02344) select number from numbers(3e9) settings prefer_localhost_replica=0 diff --git a/tests/ast_json_fixtures/shapes/b0b5e37e461915d1.json b/tests/ast_json_fixtures/shapes/b0b5e37e461915d1.json new file mode 100644 index 000000000000..ec2302a5929f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0b5e37e461915d1.json @@ -0,0 +1,145 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Pacific\/Apia" + }, + { + "type": "Function", + "alias": "r", + "name": "rand", + "arguments": [] + }, + { + "type": "Function", + "alias": "h", + "name": "toHour", + "arguments": [ + { + "type": "Function", + "alias": "t", + "name": "toDateTime", + "arguments": [ + { + "type": "Identifier", + "name": "r" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Pacific\/Apia" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "h" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "h" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "23" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "h" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "h" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b0b5e37e461915d1.sql b/tests/ast_json_fixtures/shapes/b0b5e37e461915d1.sql new file mode 100644 index 000000000000..4a952260618a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0b5e37e461915d1.sql @@ -0,0 +1 @@ +SELECT 'Pacific/Apia', rand() as r, toHour(toDateTime(r, 'Pacific/Apia') AS t) AS h, t, toTypeName(t) FROM numbers(1000000) WHERE h < 0 OR h > 23 ORDER BY h LIMIT 1 BY h diff --git a/tests/ast_json_fixtures/shapes/b0bea60c735e8ca2.json b/tests/ast_json_fixtures/shapes/b0bea60c735e8ca2.json new file mode 100644 index 000000000000..976b8ea51430 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0bea60c735e8ca2.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "v" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "v" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "table": "t" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b0bea60c735e8ca2.sql b/tests/ast_json_fixtures/shapes/b0bea60c735e8ca2.sql new file mode 100644 index 000000000000..c46962dec639 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0bea60c735e8ca2.sql @@ -0,0 +1 @@ +CREATE MATERIALIZED VIEW v to t AS SELECT * FROM v diff --git a/tests/ast_json_fixtures/shapes/b0c116298b0bd542.json b/tests/ast_json_fixtures/shapes/b0c116298b0bd542.json new file mode 100644 index 000000000000..30f47c112e24 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0c116298b0bd542.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_table" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "EventDate", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "CounterID", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "UserID", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "EventTime", + "data_type": { + "type": "DataType", + "name": "DateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "America\/Los_Angeles" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "UTCEventTime", + "data_type": { + "type": "DataType", + "name": "DateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "partition_by": { + "type": "Identifier", + "name": "EventDate" + }, + "primary_key": { + "type": "Identifier", + "name": "CounterID" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b0c116298b0bd542.sql b/tests/ast_json_fixtures/shapes/b0c116298b0bd542.sql new file mode 100644 index 000000000000..e205d31062da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0c116298b0bd542.sql @@ -0,0 +1 @@ +CREATE TABLE test_table (EventDate Date, CounterID UInt32, UserID UInt64, EventTime DateTime('America/Los_Angeles'), UTCEventTime DateTime('UTC')) PARTITION BY EventDate PRIMARY KEY CounterID diff --git a/tests/ast_json_fixtures/shapes/b0d2f6347c44c7d0.json b/tests/ast_json_fixtures/shapes/b0d2f6347c44c7d0.json new file mode 100644 index 000000000000..202b720d9f21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0d2f6347c44c7d0.json @@ -0,0 +1,246 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC", + "nulls_first": true + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + } + ] + } + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "xp_d" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "globalIn", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "A" + } + ] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "DESC", + "nulls_first": false + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "A" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "xp_d" + } + } + } + ] + } + } + ] + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "B" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/b0d2f6347c44c7d0.sql b/tests/ast_json_fixtures/shapes/b0d2f6347c44c7d0.sql new file mode 100644 index 000000000000..c07579e7c3ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0d2f6347c44c7d0.sql @@ -0,0 +1 @@ +SELECT count(7 = (SELECT number FROM numbers(0) ORDER BY number ASC NULLS FIRST LIMIT 7)) FROM xp_d PREWHERE toYYYYMM(A) GLOBAL IN (SELECT NULL = (SELECT number FROM numbers(1) ORDER BY number DESC NULLS LAST LIMIT 1), toYYYYMM(min(A)) FROM xp_d) WHERE B > NULL FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/b0d78254708029fd.json b/tests/ast_json_fixtures/shapes/b0d78254708029fd.json new file mode 100644 index 000000000000..998a48a1fd11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0d78254708029fd.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Literal", + "alias": "key", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "alias": "value", + "value_type": "String", + "value": "b" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b0d78254708029fd.sql b/tests/ast_json_fixtures/shapes/b0d78254708029fd.sql new file mode 100644 index 000000000000..1532ec531da9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0d78254708029fd.sql @@ -0,0 +1 @@ +SELECT 'a' AS key, 'b' as value GROUP BY key WITH CUBE SETTINGS enable_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/b0df80e46e278664.json b/tests/ast_json_fixtures/shapes/b0df80e46e278664.json new file mode 100644 index 000000000000..ed3406379fd0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0df80e46e278664.json @@ -0,0 +1,103 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b0df80e46e278664.sql b/tests/ast_json_fixtures/shapes/b0df80e46e278664.sql new file mode 100644 index 000000000000..b9be5a0ce5c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0df80e46e278664.sql @@ -0,0 +1 @@ +SELECT (SELECT count() FROM system.one WHERE number = 2) FROM numbers(2) GROUP BY number % 2 diff --git a/tests/ast_json_fixtures/shapes/b0f891943e1b8a44.json b/tests/ast_json_fixtures/shapes/b0f891943e1b8a44.json new file mode 100644 index 000000000000..332cf1e63ac2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0f891943e1b8a44.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t0" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "clear_column": true, + "column": { + "type": "Identifier", + "name": "c0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b0f891943e1b8a44.sql b/tests/ast_json_fixtures/shapes/b0f891943e1b8a44.sql new file mode 100644 index 000000000000..da6758dd915b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b0f891943e1b8a44.sql @@ -0,0 +1 @@ +ALTER TABLE t0 CLEAR COLUMN c0 diff --git a/tests/ast_json_fixtures/shapes/b124a688de20d7b4.json b/tests/ast_json_fixtures/shapes/b124a688de20d7b4.json new file mode 100644 index 000000000000..48f7ea3109f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b124a688de20d7b4.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "data_01801" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "key" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "10" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b124a688de20d7b4.sql b/tests/ast_json_fixtures/shapes/b124a688de20d7b4.sql new file mode 100644 index 000000000000..4b879bc9f597 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b124a688de20d7b4.sql @@ -0,0 +1 @@ +create table data_01801 (key Int) engine=MergeTree() order by key settings index_granularity=10 as select number/10 from numbers(100) diff --git a/tests/ast_json_fixtures/shapes/b134a9bb5b2fd8de.json b/tests/ast_json_fixtures/shapes/b134a9bb5b2fd8de.json new file mode 100644 index 000000000000..6c72d06ba647 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b134a9bb5b2fd8de.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u2_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "NO_PASSWORD", + "arguments": [] + } + ], + "replace_authentication_methods": true, + "hosts": { + "any_host": true + }, + "default_roles": { + "type": "RolesOrUsersSet", + "all": true + }, + "settings": { + "type": "SettingsProfileElements", + "elements": [] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b134a9bb5b2fd8de.sql b/tests/ast_json_fixtures/shapes/b134a9bb5b2fd8de.sql new file mode 100644 index 000000000000..c58ed8b97319 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b134a9bb5b2fd8de.sql @@ -0,0 +1 @@ +CREATE USER u2_01292 NOT IDENTIFIED HOST ANY SETTINGS NONE DEFAULT ROLE ALL diff --git a/tests/ast_json_fixtures/shapes/b14baadd7f204baa.json b/tests/ast_json_fixtures/shapes/b14baadd7f204baa.json new file mode 100644 index 000000000000..20b39333df89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b14baadd7f204baa.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10000000" + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1234567890123456789" + } + ] + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "9999990" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_memory_usage": "300Mi", + "max_bytes_before_external_sort": "10M" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b14baadd7f204baa.sql b/tests/ast_json_fixtures/shapes/b14baadd7f204baa.sql new file mode 100644 index 000000000000..7bff85f09d94 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b14baadd7f204baa.sql @@ -0,0 +1 @@ +SELECT number FROM (SELECT number FROM system.numbers LIMIT 10000000) ORDER BY number * 1234567890123456789 LIMIT 9999990, 10 SETTINGS max_memory_usage='300Mi', max_bytes_before_external_sort='10M' diff --git a/tests/ast_json_fixtures/shapes/b159302f748cd7ae.json b/tests/ast_json_fixtures/shapes/b159302f748cd7ae.json new file mode 100644 index 000000000000..73f2f92618d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b159302f748cd7ae.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_alter_if_exists" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "x" + } + }, + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "if_exists": true, + "column": { + "type": "Identifier", + "name": "x" + }, + "rename_to": { + "type": "Identifier", + "name": "z" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b159302f748cd7ae.sql b/tests/ast_json_fixtures/shapes/b159302f748cd7ae.sql new file mode 100644 index 000000000000..63d60976e5f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b159302f748cd7ae.sql @@ -0,0 +1 @@ +ALTER TABLE test_alter_if_exists DROP COLUMN x, RENAME COLUMN IF EXISTS x TO z diff --git a/tests/ast_json_fixtures/shapes/b16ed0edd2851166.json b/tests/ast_json_fixtures/shapes/b16ed0edd2851166.json new file mode 100644 index 000000000000..2513311e0acd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b16ed0edd2851166.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "strings_whitespace" + } + } + } + ] + } + } + ], + "format": "PrettySpaceMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/b16ed0edd2851166.sql b/tests/ast_json_fixtures/shapes/b16ed0edd2851166.sql new file mode 100644 index 000000000000..7b8f5995cc2b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b16ed0edd2851166.sql @@ -0,0 +1 @@ +SELECT * FROM strings_whitespace FORMAT PrettySpaceMonoBlock diff --git a/tests/ast_json_fixtures/shapes/b1a1ebf9fd09e34f.json b/tests/ast_json_fixtures/shapes/b1a1ebf9fd09e34f.json new file mode 100644 index 000000000000..b4e558b117af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b1a1ebf9fd09e34f.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "01746_merge" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "01746_merge_t" + } + ] + } + }, + "as_table": "01746_merge_t" + } +} diff --git a/tests/ast_json_fixtures/shapes/b1a1ebf9fd09e34f.sql b/tests/ast_json_fixtures/shapes/b1a1ebf9fd09e34f.sql new file mode 100644 index 000000000000..f02cf69fe324 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b1a1ebf9fd09e34f.sql @@ -0,0 +1,2 @@ +CREATE TABLE `01746_merge` AS `01746_merge_t` +ENGINE = Merge(currentDatabase(), '01746_merge_t') diff --git a/tests/ast_json_fixtures/shapes/b1adbc0f102c242c.json b/tests/ast_json_fixtures/shapes/b1adbc0f102c242c.json new file mode 100644 index 000000000000..b4840f03ef7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b1adbc0f102c242c.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "cte", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "WithElement", + "name": "query", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "cte" + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b1adbc0f102c242c.sql b/tests/ast_json_fixtures/shapes/b1adbc0f102c242c.sql new file mode 100644 index 000000000000..5cf15c8211a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b1adbc0f102c242c.sql @@ -0,0 +1,10 @@ +WITH + (a > b) as cte, + query AS + ( + SELECT count() + FROM test + WHERE cte + ) +SELECT * +FROM query diff --git a/tests/ast_json_fixtures/shapes/b1b32ac7de50fe49.json b/tests/ast_json_fixtures/shapes/b1b32ac7de50fe49.json new file mode 100644 index 000000000000..a6acf4dcafee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b1b32ac7de50fe49.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "inner_distributed" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "inner" + }, + { + "type": "Function", + "name": "intHash64", + "arguments": [ + { + "type": "Identifier", + "name": "organization_id" + } + ] + } + ] + } + }, + "as_table": "inner" + } +} diff --git a/tests/ast_json_fixtures/shapes/b1b32ac7de50fe49.sql b/tests/ast_json_fixtures/shapes/b1b32ac7de50fe49.sql new file mode 100644 index 000000000000..8d7b9a5f18f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b1b32ac7de50fe49.sql @@ -0,0 +1,2 @@ +CREATE TABLE inner_distributed AS inner +ENGINE = Distributed('test_cluster_two_shards', currentDatabase(), 'inner', intHash64(organization_id)) diff --git a/tests/ast_json_fixtures/shapes/b20fc86745ae0ef5.json b/tests/ast_json_fixtures/shapes/b20fc86745ae0ef5.json new file mode 100644 index 000000000000..acdfd572ad16 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b20fc86745ae0ef5.json @@ -0,0 +1,98 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b20fc86745ae0ef5.sql b/tests/ast_json_fixtures/shapes/b20fc86745ae0ef5.sql new file mode 100644 index 000000000000..34be8d2bffd9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b20fc86745ae0ef5.sql @@ -0,0 +1,5 @@ +WITH RECURSIVE t AS ( + SELECT 1 AS n +UNION ALL + SELECT n+1 FROM t) +SELECT * FROM t LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/b2170002da6af3bb.json b/tests/ast_json_fixtures/shapes/b2170002da6af3bb.json new file mode 100644 index 000000000000..94881f881d67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2170002da6af3bb.json @@ -0,0 +1,110 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "t", + "name": "toDate", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4096" + } + ] + } + ] + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "formatDateTime", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%F" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b2170002da6af3bb.sql b/tests/ast_json_fixtures/shapes/b2170002da6af3bb.sql new file mode 100644 index 000000000000..26e405ef2b5e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2170002da6af3bb.sql @@ -0,0 +1 @@ +WITH toDate(today() + rand() % 4096) AS t SELECT count() FROM numbers(1000000) WHERE formatDateTime(t, '%F') != toString(t) diff --git a/tests/ast_json_fixtures/shapes/b224fb4ce99d6b43.json b/tests/ast_json_fixtures/shapes/b224fb4ce99d6b43.json new file mode 100644 index 000000000000..231d1da878f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b224fb4ce99d6b43.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["sqllt_user"] + } +} diff --git a/tests/ast_json_fixtures/shapes/b224fb4ce99d6b43.sql b/tests/ast_json_fixtures/shapes/b224fb4ce99d6b43.sql new file mode 100644 index 000000000000..8512f64f9d1d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b224fb4ce99d6b43.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS sqllt_user diff --git a/tests/ast_json_fixtures/shapes/b2269b871e1f6abc.json b/tests/ast_json_fixtures/shapes/b2269b871e1f6abc.json new file mode 100644 index 000000000000..797b42e2f72b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2269b871e1f6abc.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "nums_buf" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Buffer", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "nums" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000000" + } + ] + } + }, + "as_table": "nums" + } +} diff --git a/tests/ast_json_fixtures/shapes/b2269b871e1f6abc.sql b/tests/ast_json_fixtures/shapes/b2269b871e1f6abc.sql new file mode 100644 index 000000000000..ed911bb1a783 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2269b871e1f6abc.sql @@ -0,0 +1 @@ +CREATE TABLE nums_buf AS nums ENGINE = Buffer(currentDatabase(), nums, 1, 10, 100, 1, 3, 10000000, 100000000) diff --git a/tests/ast_json_fixtures/shapes/b226e7ecb2d62e00.json b/tests/ast_json_fixtures/shapes/b226e7ecb2d62e00.json new file mode 100644 index 000000000000..1413cf074ad9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b226e7ecb2d62e00.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "nest" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b226e7ecb2d62e00.sql b/tests/ast_json_fixtures/shapes/b226e7ecb2d62e00.sql new file mode 100644 index 000000000000..12a6caa5b743 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b226e7ecb2d62e00.sql @@ -0,0 +1 @@ +SELECT x, nest.* FROM t diff --git a/tests/ast_json_fixtures/shapes/b229060416cd4827.json b/tests/ast_json_fixtures/shapes/b229060416cd4827.json new file mode 100644 index 000000000000..73a65d74d58c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b229060416cd4827.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "receiver_02572" + }, + "as_table": "data_02572" + } +} diff --git a/tests/ast_json_fixtures/shapes/b229060416cd4827.sql b/tests/ast_json_fixtures/shapes/b229060416cd4827.sql new file mode 100644 index 000000000000..1606e01b8ecd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b229060416cd4827.sql @@ -0,0 +1 @@ +create table receiver_02572 as data_02572 diff --git a/tests/ast_json_fixtures/shapes/b2322969f0c3c50e.json b/tests/ast_json_fixtures/shapes/b2322969f0c3c50e.json new file mode 100644 index 000000000000..ae21036588d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2322969f0c3c50e.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b2322969f0c3c50e.sql b/tests/ast_json_fixtures/shapes/b2322969f0c3c50e.sql new file mode 100644 index 000000000000..1fc8ad8a22cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2322969f0c3c50e.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number order by number limit 1 by number diff --git a/tests/ast_json_fixtures/shapes/b247460959550111.json b/tests/ast_json_fixtures/shapes/b247460959550111.json new file mode 100644 index 000000000000..221f01e330bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b247460959550111.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "function_name": { + "type": "Identifier", + "name": "foo" + }, + "function_core": { + "type": "Identifier", + "name": "x" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b247460959550111.sql b/tests/ast_json_fixtures/shapes/b247460959550111.sql new file mode 100644 index 000000000000..8b3906189e91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b247460959550111.sql @@ -0,0 +1 @@ +create function foo as x diff --git a/tests/ast_json_fixtures/shapes/b2569faa17715eb0.json b/tests/ast_json_fixtures/shapes/b2569faa17715eb0.json new file mode 100644 index 000000000000..56ab9a790cdf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2569faa17715eb0.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b2569faa17715eb0.sql b/tests/ast_json_fixtures/shapes/b2569faa17715eb0.sql new file mode 100644 index 000000000000..0ca26797b19e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2569faa17715eb0.sql @@ -0,0 +1 @@ +desc tab diff --git a/tests/ast_json_fixtures/shapes/b256c63c98e6bc9d.json b/tests/ast_json_fixtures/shapes/b256c63c98e6bc9d.json new file mode 100644 index 000000000000..75d0695097db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b256c63c98e6bc9d.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "alias": "value", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "u" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_sparse_full" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "alias": "k", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b256c63c98e6bc9d.sql b/tests/ast_json_fixtures/shapes/b256c63c98e6bc9d.sql new file mode 100644 index 000000000000..eaa910e901e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b256c63c98e6bc9d.sql @@ -0,0 +1 @@ +SELECT sum(u) AS value FROM t_sparse_full GROUP BY id % 3 AS k WITH CUBE ORDER BY value diff --git a/tests/ast_json_fixtures/shapes/b25ac7a96623549d.json b/tests/ast_json_fixtures/shapes/b25ac7a96623549d.json new file mode 100644 index 000000000000..57ff7cd37cfa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b25ac7a96623549d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "'", + "database": "'" + } +} diff --git a/tests/ast_json_fixtures/shapes/b25ac7a96623549d.sql b/tests/ast_json_fixtures/shapes/b25ac7a96623549d.sql new file mode 100644 index 000000000000..4b557bfb9cab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b25ac7a96623549d.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM `'`.`'` diff --git a/tests/ast_json_fixtures/shapes/b288dad8e409911d.json b/tests/ast_json_fixtures/shapes/b288dad8e409911d.json new file mode 100644 index 000000000000..2f705e1b463e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b288dad8e409911d.json @@ -0,0 +1,384 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "weightedmeanmag", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arraySum", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayZip", + "arguments": [ + { + "type": "Identifier", + "name": "mag" + }, + { + "type": "Identifier", + "name": "magerr" + } + ] + } + ] + }, + { + "type": "Function", + "name": "arraySum", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1 + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "magerr" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "chi2", + "name": "arraySum", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "weightedmeanmag" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "weightedmeanmag" + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayZip", + "arguments": [ + { + "type": "Identifier", + "name": "mag" + }, + { + "type": "Identifier", + "name": "magerr" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "mag", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + }, + { + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Literal", + "alias": "magerr", + "value_type": "Array", + "value": [ + { + "value_type": "Float64", + "value": 0.1 + }, + { + "value_type": "Float64", + "value": 0.2 + }, + { + "value_type": "Float64", + "value": 0.1 + }, + { + "value_type": "Float64", + "value": 0.2 + } + ] + } + ], + "where": { + "type": "Function", + "name": "isFinite", + "arguments": [ + { + "type": "Identifier", + "name": "chi2" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b288dad8e409911d.sql b/tests/ast_json_fixtures/shapes/b288dad8e409911d.sql new file mode 100644 index 000000000000..9b41d704eb2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b288dad8e409911d.sql @@ -0,0 +1,6 @@ +SELECT + arraySum(x -> ((x.1) / ((x.2) * (x.2))), arrayZip(mag, magerr)) / arraySum(x -> (1. / (x * x)), magerr) AS weightedmeanmag, + arraySum(x -> ((((x.1) - weightedmeanmag) * ((x.1) - weightedmeanmag)) / ((x.2) * (x.2))), arrayZip(mag, magerr)) AS chi2, + [1, 2, 3, 4] AS mag, + [0.1, 0.2, 0.1, 0.2] AS magerr +WHERE isFinite(chi2) diff --git a/tests/ast_json_fixtures/shapes/b28e7847a7a2139d.json b/tests/ast_json_fixtures/shapes/b28e7847a7a2139d.json new file mode 100644 index 000000000000..748519897657 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b28e7847a7a2139d.json @@ -0,0 +1,177 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "t1.a", + "name_parts": ["t1", "a"] + }, + { + "type": "Identifier", + "name": "t2.a", + "name_parts": ["t2", "a"] + }, + { + "type": "Identifier", + "name": "t2.b", + "name_parts": ["t2", "b"] + }, + { + "type": "Identifier", + "name": "t3.b", + "name_parts": ["t3", "b"] + }, + { + "type": "Identifier", + "name": "t3.c", + "name_parts": ["t3", "c"] + }, + { + "type": "Identifier", + "name": "t5.a", + "name_parts": ["t5", "a"] + }, + { + "type": "Identifier", + "name": "t5.b", + "name_parts": ["t5", "b"] + }, + { + "type": "Identifier", + "name": "t5.c", + "name_parts": ["t5", "c"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "table1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.a", + "name_parts": ["t1", "a"] + }, + { + "type": "Identifier", + "name": "t2.a", + "name_parts": ["t2", "a"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "table2" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.b", + "name_parts": ["t2", "b"] + }, + { + "type": "Identifier", + "name": "t3.b", + "name_parts": ["t3", "b"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t3", + "name": "table3" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t3.c", + "name_parts": ["t3", "c"] + }, + { + "type": "Identifier", + "name": "t5.c", + "name_parts": ["t5", "c"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t5", + "name": "table5" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.a", + "name_parts": ["t1", "a"] + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/b28e7847a7a2139d.sql b/tests/ast_json_fixtures/shapes/b28e7847a7a2139d.sql new file mode 100644 index 000000000000..fb8beff55a7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b28e7847a7a2139d.sql @@ -0,0 +1,7 @@ +select t1.a, t2.a, t2.b, t3.b, t3.c, t5.a, t5.b, t5.c +from table1 as t1 +join table2 as t2 on t1.a = t2.a +join table3 as t3 on t2.b = t3.b +join table5 as t5 on t3.c = t5.c +ORDER BY t1.a +FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/b295173d255303c8.json b/tests/ast_json_fixtures/shapes/b295173d255303c8.json new file mode 100644 index 000000000000..62d56a27f820 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b295173d255303c8.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "ParallelWithQuery", + "children": [ + { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "table1" + } + }, + { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "table2" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b295173d255303c8.sql b/tests/ast_json_fixtures/shapes/b295173d255303c8.sql new file mode 100644 index 000000000000..f2c562052899 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b295173d255303c8.sql @@ -0,0 +1,3 @@ +DROP TABLE table1 +PARALLEL WITH +DROP TABLE table2 diff --git a/tests/ast_json_fixtures/shapes/b2a6ec0da6f35858.json b/tests/ast_json_fixtures/shapes/b2a6ec0da6f35858.json new file mode 100644 index 000000000000..defc73e6226a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2a6ec0da6f35858.json @@ -0,0 +1,126 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "name": "lessOrEquals", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "18" + }, + { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "having": { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Function", + "name": "isZeroOrNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b2a6ec0da6f35858.sql b/tests/ast_json_fixtures/shapes/b2a6ec0da6f35858.sql new file mode 100644 index 000000000000..19bdca82cc60 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2a6ec0da6f35858.sql @@ -0,0 +1,11 @@ +SELECT * +FROM +( + SELECT materialize(toUInt256(2)) + UNION ALL + SELECT DISTINCT 1 +) +GROUP BY + ignore(lessOrEquals(18, isNotNull(toLowCardinality(10)))), + 1 +HAVING ignore(isZeroOrNull(5)) diff --git a/tests/ast_json_fixtures/shapes/b2a9375e6a259aa9.json b/tests/ast_json_fixtures/shapes/b2a9375e6a259aa9.json new file mode 100644 index 000000000000..d8477945ce51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2a9375e6a259aa9.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "replace_access": true, + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "db3", + "table": "table", + "columns": ["col1"] + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b2a9375e6a259aa9.sql b/tests/ast_json_fixtures/shapes/b2a9375e6a259aa9.sql new file mode 100644 index 000000000000..1110f0e1a4b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2a9375e6a259aa9.sql @@ -0,0 +1 @@ +GRANT SELECT(col1) ON db3.table TO test_user_01999 WITH REPLACE OPTION diff --git a/tests/ast_json_fixtures/shapes/b2cd4af9adf46671.json b/tests/ast_json_fixtures/shapes/b2cd4af9adf46671.json new file mode 100644 index 000000000000..ec0f36a606ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2cd4af9adf46671.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "val" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "key", + "name": "number" + }, + { + "type": "Identifier", + "alias": "val", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2000000" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "03772_temporary_files_codec\/agg", + "temporary_files_codec": "LZ4" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/b2cd4af9adf46671.sql b/tests/ast_json_fixtures/shapes/b2cd4af9adf46671.sql new file mode 100644 index 000000000000..1ddc4acdb293 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2cd4af9adf46671.sql @@ -0,0 +1,3 @@ +SELECT key, sum(val) FROM (SELECT number AS key, number as val FROM numbers(2_000_000)) GROUP BY key +SETTINGS log_comment='03772_temporary_files_codec/agg', temporary_files_codec = 'LZ4' +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/b2e34e2393b0b673.json b/tests/ast_json_fixtures/shapes/b2e34e2393b0b673.json new file mode 100644 index 000000000000..7293189bcd02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2e34e2393b0b673.json @@ -0,0 +1,290 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "alias": "total", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "a.number", + "name_parts": ["a", "number"] + } + ] + }, + { + "type": "Identifier", + "alias": "cn", + "name": "c.number", + "name_parts": ["c", "number"] + }, + { + "type": "Identifier", + "alias": "bn", + "name": "b.number", + "name_parts": ["b", "number"] + }, + { + "type": "Function", + "alias": "l", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "c.number", + "name_parts": ["c", "number"] + } + ] + }, + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "b.number", + "name_parts": ["b", "number"] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "r", + "name": "rank", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "c.number", + "name_parts": ["c", "number"] + } + ] + }, + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "b.number", + "name_parts": ["b", "number"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "c.number", + "name_parts": ["c", "number"] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Identifier", + "name": "b.number", + "name_parts": ["b", "number"] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "a.number", + "name_parts": ["a", "number"] + } + ] + }, + "direction": "DESC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "a", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "b", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "c", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "cn" + }, + { + "type": "Identifier", + "name": "bn" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "total" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "cn" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "bn" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "l" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "r" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b2e34e2393b0b673.sql b/tests/ast_json_fixtures/shapes/b2e34e2393b0b673.sql new file mode 100644 index 000000000000..adb93295031c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2e34e2393b0b673.sql @@ -0,0 +1,18 @@ +SELECT + sum(a.number) AS total, + c.number AS cn, + b.number AS bn, + grouping(c.number) + grouping(b.number) AS l, + rank() OVER (PARTITION BY grouping(c.number) + grouping(b.number), multiIf(grouping(c.number) = 0, b.number, NULL) ORDER BY sum(a.number) DESC) AS r +FROM numbers(10) AS a, numbers(10) AS b, numbers(10) AS c +GROUP BY + cn, + bn + WITH ROLLUP +ORDER BY + total ASC, + cn ASC, + bn ASC, + l ASC, + r ASC +LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/b2f99e27f71095d1.json b/tests/ast_json_fixtures/shapes/b2f99e27f71095d1.json new file mode 100644 index 000000000000..d992f2e952f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2f99e27f71095d1.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u1_01292", "u2_01292@%.myhost.com", "u3_01292@192.168.%.%", "u4_01292@::1", "u5_01292@65:ff0c::\/96"] + } +} diff --git a/tests/ast_json_fixtures/shapes/b2f99e27f71095d1.sql b/tests/ast_json_fixtures/shapes/b2f99e27f71095d1.sql new file mode 100644 index 000000000000..1a4602ff8a93 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b2f99e27f71095d1.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS u1_01292@'%', 'u2_01292@%.myhost.com', u3_01292@'192.168.%.%', 'u4_01292@::1', u5_01292@'65:ff0c::/96' diff --git a/tests/ast_json_fixtures/shapes/b311d4630e261ce8.json b/tests/ast_json_fixtures/shapes/b311d4630e261ce8.json new file mode 100644 index 000000000000..1362d75b1c08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b311d4630e261ce8.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "tupleElement", + "arguments": [ + { + "type": "Identifier", + "name": "tuple" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "run_query_tree_passes": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b311d4630e261ce8.sql b/tests/ast_json_fixtures/shapes/b311d4630e261ce8.sql new file mode 100644 index 000000000000..f10900b1c328 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b311d4630e261ce8.sql @@ -0,0 +1 @@ +explain syntax run_query_tree_passes=1 select tupleElement(tuple, -1) from test diff --git a/tests/ast_json_fixtures/shapes/b316375add59b367.json b/tests/ast_json_fixtures/shapes/b316375add59b367.json new file mode 100644 index 000000000000..99770849c284 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b316375add59b367.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "partition_all2" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_INDEX", + "clear_index": true, + "index": { + "type": "Identifier", + "name": "p" + }, + "partition": { + "type": "Partition_ID", + "all": true + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b316375add59b367.sql b/tests/ast_json_fixtures/shapes/b316375add59b367.sql new file mode 100644 index 000000000000..73e5ed30c8da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b316375add59b367.sql @@ -0,0 +1 @@ +ALTER TABLE partition_all2 CLEAR INDEX p IN PARTITION ALL diff --git a/tests/ast_json_fixtures/shapes/b3193f80b05307ad.json b/tests/ast_json_fixtures/shapes/b3193f80b05307ad.json new file mode 100644 index 000000000000..fdf3c3f20a2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3193f80b05307ad.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ], + "group_by": [ + { + "type": "Function", + "name": "toUUID", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "0" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "0.0000065535" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b3193f80b05307ad.sql b/tests/ast_json_fixtures/shapes/b3193f80b05307ad.sql new file mode 100644 index 000000000000..1ba2e166eb42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3193f80b05307ad.sql @@ -0,0 +1 @@ +SELECT NULL GROUP BY toUUID(NULL, '0', NULL, '0.0000065535'), 1 WITH CUBE WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/b34f7a3bd5dc1c93.json b/tests/ast_json_fixtures/shapes/b34f7a3bd5dc1c93.json new file mode 100644 index 000000000000..7cdf01876dc5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b34f7a3bd5dc1c93.json @@ -0,0 +1,119 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "service_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_rows_count_bug_local" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "globalIn", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test_rows_count_bug_local" + } + ] + } + } + } + ] + } + } + ] + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "service_name" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "service_name" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_write_statistics": "0" + } + }, + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/b34f7a3bd5dc1c93.sql b/tests/ast_json_fixtures/shapes/b34f7a3bd5dc1c93.sql new file mode 100644 index 000000000000..a1db42889763 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b34f7a3bd5dc1c93.sql @@ -0,0 +1,3 @@ +SELECT service_name FROM test_rows_count_bug_local +WHERE id global in (select id from remote('127.0.0.{2,3}', currentDatabase(), test_rows_count_bug_local)) +GROUP BY service_name ORDER BY service_name limit 20 FORMAT JSON SETTINGS output_format_write_statistics=0 diff --git a/tests/ast_json_fixtures/shapes/b3570c58bc4b47bf.json b/tests/ast_json_fixtures/shapes/b3570c58bc4b47bf.json new file mode 100644 index 000000000000..75c66061511b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3570c58bc4b47bf.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "02271_temporary_table_show_rows_bytes" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "A", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b3570c58bc4b47bf.sql b/tests/ast_json_fixtures/shapes/b3570c58bc4b47bf.sql new file mode 100644 index 000000000000..68c89636d489 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3570c58bc4b47bf.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE 02271_temporary_table_show_rows_bytes (A Int64) Engine=Memory as SELECT * FROM numbers(1000) diff --git a/tests/ast_json_fixtures/shapes/b35b19b2ef8b1096.json b/tests/ast_json_fixtures/shapes/b35b19b2ef8b1096.json new file mode 100644 index 000000000000..250aa0039f42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b35b19b2ef8b1096.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s3_01294"], + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b35b19b2ef8b1096.sql b/tests/ast_json_fixtures/shapes/b35b19b2ef8b1096.sql new file mode 100644 index 000000000000..aaa00d4bd1e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b35b19b2ef8b1096.sql @@ -0,0 +1 @@ +CREATE PROFILE s3_01294 TO r1_01294 diff --git a/tests/ast_json_fixtures/shapes/b35bd815647851cd.json b/tests/ast_json_fixtures/shapes/b35bd815647851cd.json new file mode 100644 index 000000000000..ac361cb90efd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b35bd815647851cd.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t_remove_sample_by" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "id" + }, + "sample_by": { + "type": "Identifier", + "name": "id" + }, + "settings": { + "type": "Settings", + "changes": { + "check_sample_column_is_correct": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b35bd815647851cd.sql b/tests/ast_json_fixtures/shapes/b35bd815647851cd.sql new file mode 100644 index 000000000000..2707a27293ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b35bd815647851cd.sql @@ -0,0 +1,3 @@ +CREATE TABLE t_remove_sample_by(id String) +ENGINE = MergeTree ORDER BY id SAMPLE BY id +SETTINGS check_sample_column_is_correct = 0 diff --git a/tests/ast_json_fixtures/shapes/b37ceb9de0433174.json b/tests/ast_json_fixtures/shapes/b37ceb9de0433174.json new file mode 100644 index 000000000000..9301c128eeeb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b37ceb9de0433174.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.{1,2}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_02176" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "settings": { + "type": "Settings", + "changes": { + "distributed_aggregation_memory_efficient": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b37ceb9de0433174.sql b/tests/ast_json_fixtures/shapes/b37ceb9de0433174.sql new file mode 100644 index 000000000000..0814a48308eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b37ceb9de0433174.sql @@ -0,0 +1 @@ +select count() from remote('127.{1,2}', currentDatabase(), data_02176) where key = 0 group by key settings distributed_aggregation_memory_efficient=0 diff --git a/tests/ast_json_fixtures/shapes/b39f3ab01db856c9.json b/tests/ast_json_fixtures/shapes/b39f3ab01db856c9.json new file mode 100644 index 000000000000..2bf44b82e555 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b39f3ab01db856c9.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettyMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/b39f3ab01db856c9.sql b/tests/ast_json_fixtures/shapes/b39f3ab01db856c9.sql new file mode 100644 index 000000000000..f9f2e3551ec6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b39f3ab01db856c9.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettyMonoBlock diff --git a/tests/ast_json_fixtures/shapes/b3b089dfc50b4b5f.json b/tests/ast_json_fixtures/shapes/b3b089dfc50b4b5f.json new file mode 100644 index 000000000000..bc32370dd982 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3b089dfc50b4b5f.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "ttl" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "remove_empty_parts": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b3b089dfc50b4b5f.sql b/tests/ast_json_fixtures/shapes/b3b089dfc50b4b5f.sql new file mode 100644 index 000000000000..e8ed7dd690df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3b089dfc50b4b5f.sql @@ -0,0 +1 @@ +CREATE TABLE ttl (d DateTime) ENGINE = MergeTree ORDER BY tuple() TTL d + INTERVAL 10 DAY SETTINGS remove_empty_parts=0 diff --git a/tests/ast_json_fixtures/shapes/b3b7ef3e402a25f4.json b/tests/ast_json_fixtures/shapes/b3b7ef3e402a25f4.json new file mode 100644 index 000000000000..e35d151f6515 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3b7ef3e402a25f4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q4_01297"], + "key_type": "CLIENT_KEY" + } +} diff --git a/tests/ast_json_fixtures/shapes/b3b7ef3e402a25f4.sql b/tests/ast_json_fixtures/shapes/b3b7ef3e402a25f4.sql new file mode 100644 index 000000000000..47faab367c70 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3b7ef3e402a25f4.sql @@ -0,0 +1 @@ +CREATE QUOTA q4_01297 KEY BY client_key diff --git a/tests/ast_json_fixtures/shapes/b3c32eab4e6e9784.json b/tests/ast_json_fixtures/shapes/b3c32eab4e6e9784.json new file mode 100644 index 000000000000..bc4edc0be712 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3c32eab4e6e9784.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "AdvEngineID" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "AdvEngineID" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "AdvEngineID" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b3c32eab4e6e9784.sql b/tests/ast_json_fixtures/shapes/b3c32eab4e6e9784.sql new file mode 100644 index 000000000000..f17272de57d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3c32eab4e6e9784.sql @@ -0,0 +1 @@ +SELECT AdvEngineID FROM test.hits GROUP BY AdvEngineID WITH TOTALS ORDER BY AdvEngineID diff --git a/tests/ast_json_fixtures/shapes/b3d9136dd494b995.json b/tests/ast_json_fixtures/shapes/b3d9136dd494b995.json new file mode 100644 index 000000000000..3b79d1db9e15 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3d9136dd494b995.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "window": [ + { + "type": "WindowListElement", + "name": "w0", + "definition": { + "type": "WindowDefinition", + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "min", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "window_definition": { + "type": "WindowDefinition", + "parent_window_name": "w0" + } + }, + "direction": "ASC" + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b3d9136dd494b995.sql b/tests/ast_json_fixtures/shapes/b3d9136dd494b995.sql new file mode 100644 index 000000000000..280414124fcf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3d9136dd494b995.sql @@ -0,0 +1,3 @@ +SELECT 1 +WINDOW w0 AS (ORDER BY min(1) OVER (w0)) +SETTINGS allow_experimental_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/b3e0dd130fc9a3e4.json b/tests/ast_json_fixtures/shapes/b3e0dd130fc9a3e4.json new file mode 100644 index 000000000000..d6cb9e086f61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3e0dd130fc9a3e4.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "base" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "TinyLog", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "original comment" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b3e0dd130fc9a3e4.sql b/tests/ast_json_fixtures/shapes/b3e0dd130fc9a3e4.sql new file mode 100644 index 000000000000..6227fabe3c39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3e0dd130fc9a3e4.sql @@ -0,0 +1 @@ +CREATE TABLE base (a Int32) ENGINE = TinyLog COMMENT 'original comment' diff --git a/tests/ast_json_fixtures/shapes/b3e430ade18edd03.json b/tests/ast_json_fixtures/shapes/b3e430ade18edd03.json new file mode 100644 index 000000000000..56b596fb4588 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3e430ade18edd03.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_materialize" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "APPLY_DELETED_MASK" + }, + { + "type": "AlterCommand", + "command_type": "REWRITE_PARTS" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b3e430ade18edd03.sql b/tests/ast_json_fixtures/shapes/b3e430ade18edd03.sql new file mode 100644 index 000000000000..9051e17fae2d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3e430ade18edd03.sql @@ -0,0 +1 @@ +alter table test_materialize (APPLY DELETED MASK), (REWRITE PARTS) diff --git a/tests/ast_json_fixtures/shapes/b3fc7309af77cc5b.json b/tests/ast_json_fixtures/shapes/b3fc7309af77cc5b.json new file mode 100644 index 000000000000..1054151e13e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3fc7309af77cc5b.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "final": true, + "cleanup": true + } +} diff --git a/tests/ast_json_fixtures/shapes/b3fc7309af77cc5b.sql b/tests/ast_json_fixtures/shapes/b3fc7309af77cc5b.sql new file mode 100644 index 000000000000..96f7149101a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b3fc7309af77cc5b.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE test FINAL CLEANUP diff --git a/tests/ast_json_fixtures/shapes/b41c3eeceb08eedf.json b/tests/ast_json_fixtures/shapes/b41c3eeceb08eedf.json new file mode 100644 index 000000000000..578d42a10038 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b41c3eeceb08eedf.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "02987_logical_optimizer_merge" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "v1" + } + ] + } + }, + "as_table": "v1" + } +} diff --git a/tests/ast_json_fixtures/shapes/b41c3eeceb08eedf.sql b/tests/ast_json_fixtures/shapes/b41c3eeceb08eedf.sql new file mode 100644 index 000000000000..e6276981ff93 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b41c3eeceb08eedf.sql @@ -0,0 +1 @@ +CREATE TABLE 02987_logical_optimizer_merge AS v1 ENGINE=Merge(currentDatabase(), 'v1') diff --git a/tests/ast_json_fixtures/shapes/b4378a042f5e358e.json b/tests/ast_json_fixtures/shapes/b4378a042f5e358e.json new file mode 100644 index 000000000000..645ed2a0b2f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4378a042f5e358e.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s6_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/b4378a042f5e358e.sql b/tests/ast_json_fixtures/shapes/b4378a042f5e358e.sql new file mode 100644 index 000000000000..927536c619f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4378a042f5e358e.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s6_01294 diff --git a/tests/ast_json_fixtures/shapes/b43c0f541e4d0874.json b/tests/ast_json_fixtures/shapes/b43c0f541e4d0874.json new file mode 100644 index 000000000000..b96f4b9d60a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b43c0f541e4d0874.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "trunc" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PARTITION", + "detach": true, + "partition": { + "type": "Partition_ID", + "all": true + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b43c0f541e4d0874.sql b/tests/ast_json_fixtures/shapes/b43c0f541e4d0874.sql new file mode 100644 index 000000000000..1a7761366730 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b43c0f541e4d0874.sql @@ -0,0 +1 @@ +alter table trunc detach partition all diff --git a/tests/ast_json_fixtures/shapes/b45705357049e5bc.json b/tests/ast_json_fixtures/shapes/b45705357049e5bc.json new file mode 100644 index 000000000000..f23c53e9821f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b45705357049e5bc.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "t_lwu_defaults" + }, + "assignments": [ + { + "type": "Assignment", + "column": "y", + "expression": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + } + ] + } + } + ], + "predicate": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b45705357049e5bc.sql b/tests/ast_json_fixtures/shapes/b45705357049e5bc.sql new file mode 100644 index 000000000000..9ddb2f02dac9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b45705357049e5bc.sql @@ -0,0 +1 @@ +UPDATE t_lwu_defaults SET y = y + 10000 WHERE x > 0 diff --git a/tests/ast_json_fixtures/shapes/b46ae3a5834daa18.json b/tests/ast_json_fixtures/shapes/b46ae3a5834daa18.json new file mode 100644 index 000000000000..db253179885d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b46ae3a5834daa18.json @@ -0,0 +1,95 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "hello", + "name": "number" + }, + { + "type": "Function", + "alias": "world", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Identifier", + "name": "world" + } + ] + }, + { + "type": "Function", + "alias": "sometimes_nulls", + "name": "nullIf", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ], + "format": "Hash" + } +} diff --git a/tests/ast_json_fixtures/shapes/b46ae3a5834daa18.sql b/tests/ast_json_fixtures/shapes/b46ae3a5834daa18.sql new file mode 100644 index 000000000000..92d8755a385b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b46ae3a5834daa18.sql @@ -0,0 +1 @@ +SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 20 FORMAT Hash diff --git a/tests/ast_json_fixtures/shapes/b474c8fbcfb9d1eb.json b/tests/ast_json_fixtures/shapes/b474c8fbcfb9d1eb.json new file mode 100644 index 000000000000..56cf60d42668 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b474c8fbcfb9d1eb.json @@ -0,0 +1,168 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "name", + "name": "transform", + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "Henry" + }, + { + "value_type": "String", + "value": "Irene" + }, + { + "value_type": "String", + "value": "Dave" + }, + { + "value_type": "String", + "value": "Cindy" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "Henry or Irene" + }, + { + "value_type": "String", + "value": "Henry or Irene" + }, + { + "value_type": "String", + "value": "Dave or Cindy" + }, + { + "value_type": "String", + "value": "Dave or Cindy" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "department" + }, + { + "type": "Identifier", + "name": "salary" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "employees" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "department" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "salary" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "salary" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/b474c8fbcfb9d1eb.sql b/tests/ast_json_fixtures/shapes/b474c8fbcfb9d1eb.sql new file mode 100644 index 000000000000..1eba1705e667 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b474c8fbcfb9d1eb.sql @@ -0,0 +1,4 @@ +select transform(name, ['Henry', 'Irene', 'Dave', 'Cindy'], ['Henry or Irene', 'Henry or Irene', 'Dave or Cindy', 'Dave or Cindy']) AS name, department, salary from (SELECT * FROM employees ORDER BY id, name, department, salary) +order by salary desc +limit 5 +format PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/b49a4af77dc73f56.json b/tests/ast_json_fixtures/shapes/b49a4af77dc73f56.json new file mode 100644 index 000000000000..2a697c2f14db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b49a4af77dc73f56.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "default_table" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "value1" + }, + "remove_property": "DEFAULT" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b49a4af77dc73f56.sql b/tests/ast_json_fixtures/shapes/b49a4af77dc73f56.sql new file mode 100644 index 000000000000..68db74e398bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b49a4af77dc73f56.sql @@ -0,0 +1 @@ +ALTER TABLE default_table MODIFY COLUMN value1 REMOVE DEFAULT diff --git a/tests/ast_json_fixtures/shapes/b49bb56e7fef8dff.json b/tests/ast_json_fixtures/shapes/b49bb56e7fef8dff.json new file mode 100644 index 000000000000..0ee7a9eb27e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b49bb56e7fef8dff.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "extended": true, + "table": "tab" + } +} diff --git a/tests/ast_json_fixtures/shapes/b49bb56e7fef8dff.sql b/tests/ast_json_fixtures/shapes/b49bb56e7fef8dff.sql new file mode 100644 index 000000000000..ae760c35ddde --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b49bb56e7fef8dff.sql @@ -0,0 +1 @@ +SHOW EXTENDED COLUMNS FROM tab diff --git a/tests/ast_json_fixtures/shapes/b4a995be555e78b1.json b/tests/ast_json_fixtures/shapes/b4a995be555e78b1.json new file mode 100644 index 000000000000..acc1b6e4ae19 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4a995be555e78b1.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "database", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".test-data.json" + } + ] + }, + { + "type": "Identifier", + "name": "JSON" + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "numeric", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b4a995be555e78b1.sql b/tests/ast_json_fixtures/shapes/b4a995be555e78b1.sql new file mode 100644 index 000000000000..3b61f037cc4f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4a995be555e78b1.sql @@ -0,0 +1,2 @@ +INSERT INTO TABLE FUNCTION file(database() || '.test-data.json', JSON) + SELECT number numeric FROM numbers(10) diff --git a/tests/ast_json_fixtures/shapes/b4cd273b9a6ce629.json b/tests/ast_json_fixtures/shapes/b4cd273b9a6ce629.json new file mode 100644 index 000000000000..3e2d52dadee3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4cd273b9a6ce629.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q2_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/b4cd273b9a6ce629.sql b/tests/ast_json_fixtures/shapes/b4cd273b9a6ce629.sql new file mode 100644 index 000000000000..e1d1863893ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4cd273b9a6ce629.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q2_01297 diff --git a/tests/ast_json_fixtures/shapes/b4ce9ad2a16efea9.json b/tests/ast_json_fixtures/shapes/b4ce9ad2a16efea9.json new file mode 100644 index 000000000000..5eb86a8142b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4ce9ad2a16efea9.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "hierarchy_flat_dictionary_index" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "parent_id", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "hierarchical": true, + "bidirectional": true + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "test_hierarchy_source_table" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 0 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b4ce9ad2a16efea9.sql b/tests/ast_json_fixtures/shapes/b4ce9ad2a16efea9.sql new file mode 100644 index 000000000000..a7d6b5187ce2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4ce9ad2a16efea9.sql @@ -0,0 +1,9 @@ +CREATE DICTIONARY hierarchy_flat_dictionary_index +( + id UInt64, + parent_id UInt64 HIERARCHICAL BIDIRECTIONAL +) +PRIMARY KEY id +SOURCE(CLICKHOUSE(TABLE 'test_hierarchy_source_table')) +LAYOUT(FLAT()) +LIFETIME(0) diff --git a/tests/ast_json_fixtures/shapes/b4d9cff31d0fd5e7.json b/tests/ast_json_fixtures/shapes/b4d9cff31d0fd5e7.json new file mode 100644 index 000000000000..9b171278e212 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4d9cff31d0fd5e7.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "d1" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b4d9cff31d0fd5e7.sql b/tests/ast_json_fixtures/shapes/b4d9cff31d0fd5e7.sql new file mode 100644 index 000000000000..e40f43ffd877 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4d9cff31d0fd5e7.sql @@ -0,0 +1 @@ +SELECT 1 FROM d1 diff --git a/tests/ast_json_fixtures/shapes/b4e9d877b7fb061f.json b/tests/ast_json_fixtures/shapes/b4e9d877b7fb061f.json new file mode 100644 index 000000000000..af7f816ddeb6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4e9d877b7fb061f.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "IPv6NumToString", + "arguments": [ + { + "type": "Identifier", + "name": "ip" + } + ] + }, + { + "type": "Identifier", + "name": "cidr" + }, + { + "type": "Function", + "name": "IPv6CIDRToRange", + "arguments": [ + { + "type": "Identifier", + "name": "ip" + }, + { + "type": "Identifier", + "name": "cidr" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ipv6_range" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b4e9d877b7fb061f.sql b/tests/ast_json_fixtures/shapes/b4e9d877b7fb061f.sql new file mode 100644 index 000000000000..31a547699cf5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4e9d877b7fb061f.sql @@ -0,0 +1 @@ +SELECT IPv6NumToString(ip), cidr, IPv6CIDRToRange(ip, cidr) FROM ipv6_range diff --git a/tests/ast_json_fixtures/shapes/b4feec43f4ca871f.json b/tests/ast_json_fixtures/shapes/b4feec43f4ca871f.json new file mode 100644 index 000000000000..33431420deca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4feec43f4ca871f.json @@ -0,0 +1,126 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "key", + "name": "domainWithoutWWW", + "arguments": [ + { + "type": "Identifier", + "name": "Referer" + } + ] + }, + { + "type": "Function", + "alias": "l", + "name": "avg", + "arguments": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "Referer" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "Referer" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits_s3", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Referer" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "l" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "25" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b4feec43f4ca871f.sql b/tests/ast_json_fixtures/shapes/b4feec43f4ca871f.sql new file mode 100644 index 000000000000..bef89a83f7ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b4feec43f4ca871f.sql @@ -0,0 +1 @@ +SELECT domainWithoutWWW(Referer) AS key, avg(length(Referer)) AS l, count() AS c, max(Referer) FROM test.hits_s3 WHERE Referer != '' GROUP BY key HAVING c > 100000 ORDER BY l DESC LIMIT 25 diff --git a/tests/ast_json_fixtures/shapes/b521411e8b1638bb.json b/tests/ast_json_fixtures/shapes/b521411e8b1638bb.json new file mode 100644 index 000000000000..a0408db940ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b521411e8b1638bb.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b521411e8b1638bb.sql b/tests/ast_json_fixtures/shapes/b521411e8b1638bb.sql new file mode 100644 index 000000000000..96d491ae2882 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b521411e8b1638bb.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number with rollup diff --git a/tests/ast_json_fixtures/shapes/b52c437f034b481d.json b/tests/ast_json_fixtures/shapes/b52c437f034b481d.json new file mode 100644 index 000000000000..4d157c87f11b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b52c437f034b481d.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab2" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "vec", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "Float32" + } + ] + } + } + ], + "indices": [ + { + "type": "Index", + "name": "vec_idx", + "expression": { + "type": "Identifier", + "name": "vec" + }, + "index_type": { + "type": "Function", + "name": "vector_similarity", + "arguments": [ + { + "type": "Identifier", + "name": "hnsw" + }, + { + "type": "Identifier", + "name": "L2Distance" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "granularity": 100000000 + } + ], + "primary_key": { + "type": "Identifier", + "name": "id" + } + }, + "storage": { + "type": "Storage", + "primary_key": { + "type": "Identifier", + "name": "id" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b52c437f034b481d.sql b/tests/ast_json_fixtures/shapes/b52c437f034b481d.sql new file mode 100644 index 000000000000..065f80dce52d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b52c437f034b481d.sql @@ -0,0 +1 @@ +CREATE TABLE tab2 (id Int32, vec Array(Float32), PRIMARY KEY id, INDEX vec_idx(vec) TYPE vector_similarity(hnsw, L2Distance, 1)) diff --git a/tests/ast_json_fixtures/shapes/b5315ef1eb767c88.json b/tests/ast_json_fixtures/shapes/b5315ef1eb767c88.json new file mode 100644 index 000000000000..6e8e0c53b48a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5315ef1eb767c88.json @@ -0,0 +1,171 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "l_t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "key", + "value_type": "UInt64", + "value": "42" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "l_t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l_t.key", + "name_parts": ["l_t", "key"] + }, + { + "type": "Identifier", + "name": "r_t.number", + "name_parts": ["r_t", "number"] + } + ] + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "r_t.number", + "name_parts": ["r_t", "number"] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1000 + } + ] + } + } + } + ] + } + } + ] + } + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "r_t", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b5315ef1eb767c88.sql b/tests/ast_json_fixtures/shapes/b5315ef1eb767c88.sql new file mode 100644 index 000000000000..9e4dbc7d131f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5315ef1eb767c88.sql @@ -0,0 +1 @@ +with l_t as (select 42 as key) select * from l_t inner join numbers(50) as r_t on l_t.key = r_t.number and r_t.number in (select number * 2 from numbers(1e3)) SETTINGS enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/b5395b1ad7f7ca78.json b/tests/ast_json_fixtures/shapes/b5395b1ad7f7ca78.json new file mode 100644 index 000000000000..1feeb8190420 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5395b1ad7f7ca78.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t50" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b5395b1ad7f7ca78.sql b/tests/ast_json_fixtures/shapes/b5395b1ad7f7ca78.sql new file mode 100644 index 000000000000..aaafa911d6e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5395b1ad7f7ca78.sql @@ -0,0 +1 @@ +select a, b from t50 prewhere b = 1 order by a diff --git a/tests/ast_json_fixtures/shapes/b53d5d2c97aa657c.json b/tests/ast_json_fixtures/shapes/b53d5d2c97aa657c.json new file mode 100644 index 000000000000..386de9173505 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b53d5d2c97aa657c.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateTableQuery", + "table": { + "type": "Identifier", + "name": "v1" + }, + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/b53d5d2c97aa657c.sql b/tests/ast_json_fixtures/shapes/b53d5d2c97aa657c.sql new file mode 100644 index 000000000000..62f3226fae77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b53d5d2c97aa657c.sql @@ -0,0 +1 @@ +SHOW CREATE TABLE v1 FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/b55d127232d01b3a.json b/tests/ast_json_fixtures/shapes/b55d127232d01b3a.json new file mode 100644 index 000000000000..ca9e0d61d018 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b55d127232d01b3a.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "18" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b55d127232d01b3a.sql b/tests/ast_json_fixtures/shapes/b55d127232d01b3a.sql new file mode 100644 index 000000000000..cc8a989dbb4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b55d127232d01b3a.sql @@ -0,0 +1 @@ +SELECT * FROM test ORDER BY i LIMIT 18 OFFSET 5 diff --git a/tests/ast_json_fixtures/shapes/b5644cf5e3be7e6b.json b/tests/ast_json_fixtures/shapes/b5644cf5e3be7e6b.json new file mode 100644 index 000000000000..4dfaa1312c43 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5644cf5e3be7e6b.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "_03755_test_data.csv" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "CSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "foo_key String, date Date, bar_key String" + } + ] + }, + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/b5644cf5e3be7e6b.sql b/tests/ast_json_fixtures/shapes/b5644cf5e3be7e6b.sql new file mode 100644 index 000000000000..4b049bf048a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5644cf5e3be7e6b.sql @@ -0,0 +1,2 @@ +INSERT INTO FUNCTION file(currentDatabase() || '_03755_test_data.csv', 'CSV', 'foo_key String, date Date, bar_key String') +VALUES ('foo', '2019-04-04', 'bar') diff --git a/tests/ast_json_fixtures/shapes/b5664a80d479d2fc.json b/tests/ast_json_fixtures/shapes/b5664a80d479d2fc.json new file mode 100644 index 000000000000..064e5089ee70 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5664a80d479d2fc.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "URL" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%google%" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "EventTime" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "query_23" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/b5664a80d479d2fc.sql b/tests/ast_json_fixtures/shapes/b5664a80d479d2fc.sql new file mode 100644 index 000000000000..e1d82d7e2742 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5664a80d479d2fc.sql @@ -0,0 +1 @@ +SELECT * FROM test.hits WHERE URL LIKE '%google%' ORDER BY EventTime LIMIT 10 FORMAT Null SETTINGS log_comment='query_23' diff --git a/tests/ast_json_fixtures/shapes/b58b0c7cab87deb1.json b/tests/ast_json_fixtures/shapes/b58b0c7cab87deb1.json new file mode 100644 index 000000000000..4eb46e5b2c24 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b58b0c7cab87deb1.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s7_01294"], + "to_roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r1_01294", "u1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b58b0c7cab87deb1.sql b/tests/ast_json_fixtures/shapes/b58b0c7cab87deb1.sql new file mode 100644 index 000000000000..8543b0a2d11a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b58b0c7cab87deb1.sql @@ -0,0 +1 @@ +CREATE PROFILE s7_01294 TO ALL EXCEPT r1_01294, u1_01294 diff --git a/tests/ast_json_fixtures/shapes/b594da633b854858.json b/tests/ast_json_fixtures/shapes/b594da633b854858.json new file mode 100644 index 000000000000..ae7b25e3e02e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b594da633b854858.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "database": { + "type": "Identifier", + "name": "shard_0" + }, + "table": { + "type": "Identifier", + "name": "from_0" + }, + "settings": { + "type": "Settings", + "changes": { + "distributed_ddl_output_mode": "never_throw", + "distributed_ddl_task_timeout": "1" + } + }, + "format": "Null", + "cluster": "test_cluster_two_shards_different_databases", + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "move_destination_type": "TABLE", + "to_database": "shard_0", + "to_table": "to" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b594da633b854858.sql b/tests/ast_json_fixtures/shapes/b594da633b854858.sql new file mode 100644 index 000000000000..f7b0fd6ab094 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b594da633b854858.sql @@ -0,0 +1 @@ +alter table shard_0.from_0 on cluster test_cluster_two_shards_different_databases move partition tuple() to table shard_0.to format Null settings distributed_ddl_output_mode='never_throw', distributed_ddl_task_timeout = 1 diff --git a/tests/ast_json_fixtures/shapes/b5bfe3ef172c8b24.json b/tests/ast_json_fixtures/shapes/b5bfe3ef172c8b24.json new file mode 100644 index 000000000000..8a04919cab35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5bfe3ef172c8b24.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "test_deletes" + }, + "settings": { + "type": "Settings", + "changes": { + "lightweight_deletes_sync": "1" + } + }, + "predicate": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "200" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b5bfe3ef172c8b24.sql b/tests/ast_json_fixtures/shapes/b5bfe3ef172c8b24.sql new file mode 100644 index 000000000000..efb7ecff4239 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5bfe3ef172c8b24.sql @@ -0,0 +1 @@ +DELETE FROM test_deletes WHERE a >= 100 AND a < 200 SETTINGS lightweight_deletes_sync = 1 diff --git a/tests/ast_json_fixtures/shapes/b5c517e1d90ee47e.json b/tests/ast_json_fixtures/shapes/b5c517e1d90ee47e.json new file mode 100644 index 000000000000..7cb25accda2b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5c517e1d90ee47e.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns": [ + { + "type": "Identifier", + "name": "c1" + } + ], + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/b5c517e1d90ee47e.sql b/tests/ast_json_fixtures/shapes/b5c517e1d90ee47e.sql new file mode 100644 index 000000000000..a47e46815a11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5c517e1d90ee47e.sql @@ -0,0 +1 @@ +insert into t(c1) values(1) diff --git a/tests/ast_json_fixtures/shapes/b5e7fdbe0d84edee.json b/tests/ast_json_fixtures/shapes/b5e7fdbe0d84edee.json new file mode 100644 index 000000000000..c9b7720604e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5e7fdbe0d84edee.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "foo" + } + ] + } + ], + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/b5e7fdbe0d84edee.sql b/tests/ast_json_fixtures/shapes/b5e7fdbe0d84edee.sql new file mode 100644 index 000000000000..ac0c842b3154 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5e7fdbe0d84edee.sql @@ -0,0 +1 @@ +select 'foo' format Values diff --git a/tests/ast_json_fixtures/shapes/b5edf2b1a42a11d0.json b/tests/ast_json_fixtures/shapes/b5edf2b1a42a11d0.json new file mode 100644 index 000000000000..4fc0e9ee0d0e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5edf2b1a42a11d0.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "column": { + "type": "Identifier", + "name": "d" + }, + "rename_to": { + "type": "Identifier", + "name": "d1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b5edf2b1a42a11d0.sql b/tests/ast_json_fixtures/shapes/b5edf2b1a42a11d0.sql new file mode 100644 index 000000000000..034200bd4825 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5edf2b1a42a11d0.sql @@ -0,0 +1 @@ +alter table test rename column d to d1 settings mutations_sync=1 diff --git a/tests/ast_json_fixtures/shapes/b5efff874fa36f69.json b/tests/ast_json_fixtures/shapes/b5efff874fa36f69.json new file mode 100644 index 000000000000..102b5b515c46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5efff874fa36f69.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q2_01297"], + "roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b5efff874fa36f69.sql b/tests/ast_json_fixtures/shapes/b5efff874fa36f69.sql new file mode 100644 index 000000000000..963f257998a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b5efff874fa36f69.sql @@ -0,0 +1 @@ +ALTER QUOTA q2_01297 TO NONE diff --git a/tests/ast_json_fixtures/shapes/b61c836ecde61d4e.json b/tests/ast_json_fixtures/shapes/b61c836ecde61d4e.json new file mode 100644 index 000000000000..fbab6e875986 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b61c836ecde61d4e.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q2_01297"], + "limits": [ + { + "duration_sec": "5259492", + "max": { + "QUERIES": "100", + "ERRORS": "11", + "RESULT_ROWS": "1000", + "RESULT_BYTES": "10000", + "READ_ROWS": "1001", + "READ_BYTES": "10001", + "EXECUTION_TIME": "2500000000" + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01297", "u1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b61c836ecde61d4e.sql b/tests/ast_json_fixtures/shapes/b61c836ecde61d4e.sql new file mode 100644 index 000000000000..45f19f87b8a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b61c836ecde61d4e.sql @@ -0,0 +1 @@ +CREATE QUOTA q2_01297 FOR 2 MONTH MAX errors = 11, queries = 100, result_rows = 1000, result_bytes = 10000, read_rows = 1001, read_bytes = 10001, execution_time=2.5 TO r1_01297, u1_01297 diff --git a/tests/ast_json_fixtures/shapes/b62de8124d9f5ea6.json b/tests/ast_json_fixtures/shapes/b62de8124d9f5ea6.json new file mode 100644 index 000000000000..f2bbfdc172c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b62de8124d9f5ea6.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "123" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b62de8124d9f5ea6.sql b/tests/ast_json_fixtures/shapes/b62de8124d9f5ea6.sql new file mode 100644 index 000000000000..272ffc036194 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b62de8124d9f5ea6.sql @@ -0,0 +1 @@ +SELECT arrayMap(x -> 1, [2]), 123 AS x, x + 1 diff --git a/tests/ast_json_fixtures/shapes/b63359d5c82b50ca.json b/tests/ast_json_fixtures/shapes/b63359d5c82b50ca.json new file mode 100644 index 000000000000..05d54cb17e44 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b63359d5c82b50ca.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "is_create_empty": true, + "table": { + "type": "Identifier", + "name": "v0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "String" + }, + "codec": { + "type": "Function", + "name": "CODEC", + "kind": "CODEC", + "arguments": [ + { + "type": "Function", + "name": "DoubleDelta", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c0", + "value_type": "String", + "value": "a" + } + ] + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "table": "tab" + } + ] + }, + "refresh": { + "type": "RefreshStrategy", + "schedule_kind": "AFTER", + "append": true, + "period": { + "type": "TimeInterval", + "interval": [ + { + "kind": "Second", + "value": "1" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b63359d5c82b50ca.sql b/tests/ast_json_fixtures/shapes/b63359d5c82b50ca.sql new file mode 100644 index 000000000000..7ae304f3bcdf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b63359d5c82b50ca.sql @@ -0,0 +1 @@ +CREATE MATERIALIZED VIEW v0 REFRESH AFTER 1 SECOND APPEND TO tab (c0 String CODEC(DoubleDelta(2))) EMPTY AS (SELECT 'a' AS c0) diff --git a/tests/ast_json_fixtures/shapes/b664e855923902f4.json b/tests/ast_json_fixtures/shapes/b664e855923902f4.json new file mode 100644 index 000000000000..eb7897b6804e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b664e855923902f4.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_3" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "mem3" + } + ] + } + }, + "as_table": "mem3" + } +} diff --git a/tests/ast_json_fixtures/shapes/b664e855923902f4.sql b/tests/ast_json_fixtures/shapes/b664e855923902f4.sql new file mode 100644 index 000000000000..913ec2529efe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b664e855923902f4.sql @@ -0,0 +1 @@ +CREATE TABLE dist_3 AS mem3 Engine=Distributed(test_shard_localhost, currentDatabase(), mem3) diff --git a/tests/ast_json_fixtures/shapes/b6781810191078ea.json b/tests/ast_json_fixtures/shapes/b6781810191078ea.json new file mode 100644 index 000000000000..17a70c7f7c39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b6781810191078ea.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + } + } + } + ] + } + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/b6781810191078ea.sql b/tests/ast_json_fixtures/shapes/b6781810191078ea.sql new file mode 100644 index 000000000000..405fcf17feee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b6781810191078ea.sql @@ -0,0 +1 @@ +SELECT sleep(0.01), number FROM numbers(11) FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/b6ab6ec7ead90fa2.json b/tests/ast_json_fixtures/shapes/b6ab6ec7ead90fa2.json new file mode 100644 index 000000000000..06a8a01ef944 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b6ab6ec7ead90fa2.json @@ -0,0 +1,127 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t1" + } + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t2" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "table1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1_a" + }, + { + "type": "Identifier", + "name": "t2_a" + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "table2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "alias": "t1_a", + "name": "t1.a", + "name_parts": ["t1", "a"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "alias": "t2_a", + "name": "t2.a", + "name_parts": ["t2", "a"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b6ab6ec7ead90fa2.sql b/tests/ast_json_fixtures/shapes/b6ab6ec7ead90fa2.sql new file mode 100644 index 000000000000..71c1e8bbad8a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b6ab6ec7ead90fa2.sql @@ -0,0 +1,5 @@ +select t1.*, t2.* +from table1 as t1 +join table2 as t2 on t1_a = t2_a +where (t1.a as t1_a) > 2 and (t2.a as t2_a) > 4 +order by all diff --git a/tests/ast_json_fixtures/shapes/b6be6f6f1b5f2a60.json b/tests/ast_json_fixtures/shapes/b6be6f6f1b5f2a60.json new file mode 100644 index 000000000000..ef81ded2a518 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b6be6f6f1b5f2a60.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "alter_test" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "if_exists": true, + "column": { + "type": "Identifier", + "name": "ToDrop" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b6be6f6f1b5f2a60.sql b/tests/ast_json_fixtures/shapes/b6be6f6f1b5f2a60.sql new file mode 100644 index 000000000000..684d2aefb1af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b6be6f6f1b5f2a60.sql @@ -0,0 +1 @@ +ALTER TABLE alter_test DROP COLUMN IF EXISTS ToDrop diff --git a/tests/ast_json_fixtures/shapes/b6ed7350b86dd275.json b/tests/ast_json_fixtures/shapes/b6ed7350b86dd275.json new file mode 100644 index 000000000000..f92f41258a00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b6ed7350b86dd275.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "03636_data_partitions" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "ts", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toStartOfDay", + "arguments": [ + { + "type": "Identifier", + "name": "ts" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1756882680" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b6ed7350b86dd275.sql b/tests/ast_json_fixtures/shapes/b6ed7350b86dd275.sql new file mode 100644 index 000000000000..8f49b470df0c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b6ed7350b86dd275.sql @@ -0,0 +1,3 @@ +CREATE TABLE 03636_data_partitions (ts DateTime) ENGINE = MergeTree ORDER BY tuple() PARTITION BY toStartOfDay(ts) +AS +SELECT 1756882680 diff --git a/tests/ast_json_fixtures/shapes/b7307ddb591c15d6.json b/tests/ast_json_fixtures/shapes/b7307ddb591c15d6.json new file mode 100644 index 000000000000..150730fc4052 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7307ddb591c15d6.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "n.b", + "name_parts": ["n", "b"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "nested" + } + } + } + ] + }, + "prewhere": { + "type": "Identifier", + "name": "filter" + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b7307ddb591c15d6.sql b/tests/ast_json_fixtures/shapes/b7307ddb591c15d6.sql new file mode 100644 index 000000000000..2a10711d783f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7307ddb591c15d6.sql @@ -0,0 +1 @@ +SELECT DISTINCT n.b FROM nested PREWHERE filter ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/b73b9987753d71b0.json b/tests/ast_json_fixtures/shapes/b73b9987753d71b0.json new file mode 100644 index 000000000000..4450814b276b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b73b9987753d71b0.json @@ -0,0 +1,183 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.{1,2}" + }, + { + "type": "Function", + "name": "view", + "arguments": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "number", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "40" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "shardNum", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "settings": { + "type": "Settings", + "changes": { + "distributed_group_by_no_merge": "2", + "distributed_push_down_limit": "1" + } + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b73b9987753d71b0.sql b/tests/ast_json_fixtures/shapes/b73b9987753d71b0.sql new file mode 100644 index 000000000000..40d61a5276af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b73b9987753d71b0.sql @@ -0,0 +1,13 @@ +SELECT * +FROM remote('127.{1,2}', view( + SELECT number%20 number + FROM numbers(40) + WHERE (number % 2) = (shardNum() - 1) +), number) +GROUP BY number +ORDER BY number ASC +LIMIT 1 BY number +LIMIT 5, 5 +SETTINGS + distributed_group_by_no_merge=2, + distributed_push_down_limit=1 diff --git a/tests/ast_json_fixtures/shapes/b73c3626d327c9a6.json b/tests/ast_json_fixtures/shapes/b73c3626d327c9a6.json new file mode 100644 index 000000000000..a2abd9ce3ef8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b73c3626d327c9a6.json @@ -0,0 +1,155 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "n", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "j1" + }, + { + "type": "Identifier", + "name": "j2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Identifier", + "name": "system.numbers", + "name_parts": ["system", "numbers"] + } + ] + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ANY", + "locality": "GLOBAL", + "using": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Identifier", + "alias": "j1", + "name": "number" + }, + { + "type": "Literal", + "alias": "j2", + "value_type": "String", + "value": "Hello" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1048577" + } + } + ] + } + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/b73c3626d327c9a6.sql b/tests/ast_json_fixtures/shapes/b73c3626d327c9a6.sql new file mode 100644 index 000000000000..eee66edb837c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b73c3626d327c9a6.sql @@ -0,0 +1 @@ +SELECT number, number / 2 AS n, j1, j2 FROM remote('127.0.0.{2,3}', system.numbers) GLOBAL ANY LEFT JOIN (SELECT number / 3 AS n, number AS j1, 'Hello' AS j2 FROM system.numbers LIMIT 1048577) USING (n) LIMIT 10 format Null diff --git a/tests/ast_json_fixtures/shapes/b74a8365c82073ec.json b/tests/ast_json_fixtures/shapes/b74a8365c82073ec.json new file mode 100644 index 000000000000..142500d53efa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b74a8365c82073ec.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "replicated_merge_tree_commit_zk_fail_after_op" + } +} diff --git a/tests/ast_json_fixtures/shapes/b74a8365c82073ec.sql b/tests/ast_json_fixtures/shapes/b74a8365c82073ec.sql new file mode 100644 index 000000000000..044dd7910d6c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b74a8365c82073ec.sql @@ -0,0 +1 @@ +system enable failpoint replicated_merge_tree_commit_zk_fail_after_op diff --git a/tests/ast_json_fixtures/shapes/b75facc31989ddc4.json b/tests/ast_json_fixtures/shapes/b75facc31989ddc4.json new file mode 100644 index 000000000000..0add5fee16a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b75facc31989ddc4.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_foo" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "insecure_$", + "data_type": { + "type": "DataType", + "name": "Int8" + } + }, + { + "type": "ColumnDeclaration", + "name": "date", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "town", + "data_type": { + "type": "DataType", + "name": "LowCardinality", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYear", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "town" + }, + { + "type": "Identifier", + "name": "date" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b75facc31989ddc4.sql b/tests/ast_json_fixtures/shapes/b75facc31989ddc4.sql new file mode 100644 index 000000000000..2eab38f240f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b75facc31989ddc4.sql @@ -0,0 +1,8 @@ +CREATE TABLE `test_foo` ( + `insecure_$` Int8, + `date` Date, + `town` LowCardinality(String), +) +ENGINE = MergeTree +PRIMARY KEY (town, date) +PARTITION BY toYear(date) diff --git a/tests/ast_json_fixtures/shapes/b77bf28e681ebfbc.json b/tests/ast_json_fixtures/shapes/b77bf28e681ebfbc.json new file mode 100644 index 000000000000..ef43943c97b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b77bf28e681ebfbc.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Identifier", + "name": "dummy" + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b77bf28e681ebfbc.sql b/tests/ast_json_fixtures/shapes/b77bf28e681ebfbc.sql new file mode 100644 index 000000000000..91fa939e545e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b77bf28e681ebfbc.sql @@ -0,0 +1 @@ +SELECT 0 = (2 = dummy) GROUP BY GROUPING SETS ((1)) SETTINGS group_by_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/b78bf1ce993bd161.json b/tests/ast_json_fixtures/shapes/b78bf1ce993bd161.json new file mode 100644 index 000000000000..725321939390 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b78bf1ce993bd161.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "name" + } + ] + }, + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "." + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "users", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "position", + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": " " + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b78bf1ce993bd161.sql b/tests/ast_json_fixtures/shapes/b78bf1ce993bd161.sql new file mode 100644 index 000000000000..acedf118ecfa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b78bf1ce993bd161.sql @@ -0,0 +1 @@ +select length(name), name, '.' from system.users where position(name, ' ')!=0 order by name diff --git a/tests/ast_json_fixtures/shapes/b7b1bd5bdf19e7f5.json b/tests/ast_json_fixtures/shapes/b7b1bd5bdf19e7f5.json new file mode 100644 index 000000000000..b104b7403c14 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7b1bd5bdf19e7f5.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "a", + "name": "number" + }, + { + "type": "Function", + "alias": "b", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/b7b1bd5bdf19e7f5.sql b/tests/ast_json_fixtures/shapes/b7b1bd5bdf19e7f5.sql new file mode 100644 index 000000000000..020557146a56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7b1bd5bdf19e7f5.sql @@ -0,0 +1 @@ +select number a, number * 2 b from numbers(3) format JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/b7b6a71bb73bfdf5.json b/tests/ast_json_fixtures/shapes/b7b6a71bb73bfdf5.json new file mode 100644 index 000000000000..a5794079525f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7b6a71bb73bfdf5.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "SYNC REPLICA", + "table": { + "type": "Identifier", + "name": "r1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b7b6a71bb73bfdf5.sql b/tests/ast_json_fixtures/shapes/b7b6a71bb73bfdf5.sql new file mode 100644 index 000000000000..139742a7c113 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7b6a71bb73bfdf5.sql @@ -0,0 +1 @@ +SYSTEM SYNC REPLICA r1 diff --git a/tests/ast_json_fixtures/shapes/b7c373dc102fb228.json b/tests/ast_json_fixtures/shapes/b7c373dc102fb228.json new file mode 100644 index 000000000000..65e4cad479fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7c373dc102fb228.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "db1" + }, + "table": { + "type": "Identifier", + "name": "tab" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "a" + } + }, + "storage": { + "type": "Storage", + "primary_key": { + "type": "Identifier", + "name": "a" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b7c373dc102fb228.sql b/tests/ast_json_fixtures/shapes/b7c373dc102fb228.sql new file mode 100644 index 000000000000..ce4736219a61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7c373dc102fb228.sql @@ -0,0 +1 @@ +CREATE TABLE db1.tab(a UInt64, PRIMARY KEY a) diff --git a/tests/ast_json_fixtures/shapes/b7ccc1b8a33c3fcf.json b/tests/ast_json_fixtures/shapes/b7ccc1b8a33c3fcf.json new file mode 100644 index 000000000000..1ff3f5e8207a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7ccc1b8a33c3fcf.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "visits_order_dst" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "2" + } + }, + "replace": false, + "from_table": "visits_order" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b7ccc1b8a33c3fcf.sql b/tests/ast_json_fixtures/shapes/b7ccc1b8a33c3fcf.sql new file mode 100644 index 000000000000..3ad569834de8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7ccc1b8a33c3fcf.sql @@ -0,0 +1 @@ +ALTER TABLE visits_order_dst ATTACH PARTITION ID '2' FROM visits_order diff --git a/tests/ast_json_fixtures/shapes/b7d919c8602794b2.json b/tests/ast_json_fixtures/shapes/b7d919c8602794b2.json new file mode 100644 index 000000000000..ddd18ba6d801 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7d919c8602794b2.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01293", "r2_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/b7d919c8602794b2.sql b/tests/ast_json_fixtures/shapes/b7d919c8602794b2.sql new file mode 100644 index 000000000000..e44b500e3323 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b7d919c8602794b2.sql @@ -0,0 +1 @@ +DROP ROLE r1_01293, r2_01293 diff --git a/tests/ast_json_fixtures/shapes/b8059ad75a99f7ac.json b/tests/ast_json_fixtures/shapes/b8059ad75a99f7ac.json new file mode 100644 index 000000000000..bde2dccfab1b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b8059ad75a99f7ac.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "Dynamic" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "d" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b8059ad75a99f7ac.sql b/tests/ast_json_fixtures/shapes/b8059ad75a99f7ac.sql new file mode 100644 index 000000000000..e4cb0d3d07a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b8059ad75a99f7ac.sql @@ -0,0 +1 @@ +create table test (d Dynamic) engine=MergeTree order by tuple() partition by d diff --git a/tests/ast_json_fixtures/shapes/b814140b04241a2d.json b/tests/ast_json_fixtures/shapes/b814140b04241a2d.json new file mode 100644 index 000000000000..48bb8e73d879 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b814140b04241a2d.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TabSeparatedRawWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/b814140b04241a2d.sql b/tests/ast_json_fixtures/shapes/b814140b04241a2d.sql new file mode 100644 index 000000000000..187e96194186 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b814140b04241a2d.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TabSeparatedRawWithNames diff --git a/tests/ast_json_fixtures/shapes/b827b0f8217649a7.json b/tests/ast_json_fixtures/shapes/b827b0f8217649a7.json new file mode 100644 index 000000000000..d46c2e7338d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b827b0f8217649a7.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "\u0000" + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [] + }, + { + "type": "Function", + "name": "singleValueOrNull", + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "\u0000" + } + ] + } + ] + } + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b827b0f8217649a7.sql b/tests/ast_json_fixtures/shapes/b827b0f8217649a7.sql new file mode 100644 index 000000000000..27d2f3fda120 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b827b0f8217649a7.sql @@ -0,0 +1 @@ +SELECT '', ['\0'], [], singleValueOrNull(( SELECT '\0' ) ), [''] diff --git a/tests/ast_json_fixtures/shapes/b837ede069b4e04c.json b/tests/ast_json_fixtures/shapes/b837ede069b4e04c.json new file mode 100644 index 000000000000..b085d684ef8d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b837ede069b4e04c.json @@ -0,0 +1,115 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "EventDate" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.1" + }, + { + "type": "Identifier", + "name": "test.hits", + "name_parts": ["test", "hits"] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "globalIn", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "UserID" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "UserID" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + } + } + ] + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "EventDate" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "EventDate" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/b837ede069b4e04c.sql b/tests/ast_json_fixtures/shapes/b837ede069b4e04c.sql new file mode 100644 index 000000000000..f775337133c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b837ede069b4e04c.sql @@ -0,0 +1 @@ +SELECT EventDate, count() FROM remote('127.0.0.1', test.hits) WHERE UserID GLOBAL IN (SELECT UserID FROM test.hits) GROUP BY EventDate ORDER BY EventDate LIMIT 5 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/b83e108f87157eb2.json b/tests/ast_json_fixtures/shapes/b83e108f87157eb2.json new file mode 100644 index 000000000000..f0782978fbb1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b83e108f87157eb2.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR FILESYSTEM CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/b83e108f87157eb2.sql b/tests/ast_json_fixtures/shapes/b83e108f87157eb2.sql new file mode 100644 index 000000000000..8b2477809983 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b83e108f87157eb2.sql @@ -0,0 +1 @@ +SYSTEM CLEAR FILESYSTEM CACHE diff --git a/tests/ast_json_fixtures/shapes/b84a7ceb0c95b104.json b/tests/ast_json_fixtures/shapes/b84a7ceb0c95b104.json new file mode 100644 index 000000000000..2ac4edc1e9f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b84a7ceb0c95b104.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN PIPELINE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b84a7ceb0c95b104.sql b/tests/ast_json_fixtures/shapes/b84a7ceb0c95b104.sql new file mode 100644 index 000000000000..26b9348ff334 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b84a7ceb0c95b104.sql @@ -0,0 +1 @@ +EXPLAIN PIPELINE SELECT sleep(1) diff --git a/tests/ast_json_fixtures/shapes/b86e5118342ef8f9.json b/tests/ast_json_fixtures/shapes/b86e5118342ef8f9.json new file mode 100644 index 000000000000..8ba6075ab2c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b86e5118342ef8f9.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "02484_substitute_udf" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "dt", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "number", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "02484_plustwo", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "order_by": { + "type": "Function", + "name": "02484_plusone", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "sample_by": { + "type": "Function", + "name": "02484_plusone", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "02484_plusthreemonths", + "arguments": [ + { + "type": "Identifier", + "name": "dt" + } + ] + } + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b86e5118342ef8f9.sql b/tests/ast_json_fixtures/shapes/b86e5118342ef8f9.sql new file mode 100644 index 000000000000..8226437a27bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b86e5118342ef8f9.sql @@ -0,0 +1,6 @@ +CREATE TABLE 02484_substitute_udf (id UInt32, dt DateTime, number UInt32) +ENGINE=MergeTree() +ORDER BY 02484_plusone(id) +PARTITION BY 02484_plustwo(id) +SAMPLE BY 02484_plusone(id) +TTL 02484_plusthreemonths(dt) diff --git a/tests/ast_json_fixtures/shapes/b873a57c8609b5ce.json b/tests/ast_json_fixtures/shapes/b873a57c8609b5ce.json new file mode 100644 index 000000000000..65d7b2da8131 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b873a57c8609b5ce.json @@ -0,0 +1,206 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "predicate", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "min_watch_id", + "name": "minIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "maxIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "sumIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "avgIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "avgWeightedIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "groupBitOrIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "groupBitAndIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + }, + { + "type": "Function", + "name": "groupBitXorIf", + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Identifier", + "name": "predicate" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "min_watch_id" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b873a57c8609b5ce.sql b/tests/ast_json_fixtures/shapes/b873a57c8609b5ce.sql new file mode 100644 index 000000000000..dce75cb1062c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b873a57c8609b5ce.sql @@ -0,0 +1,14 @@ +WITH (WatchID % 2 == 0) AS predicate +SELECT + minIf(WatchID, predicate) as min_watch_id, + maxIf(WatchID, predicate), + sumIf(WatchID, predicate), + avgIf(WatchID, predicate), + avgWeightedIf(WatchID, CounterID, predicate), + countIf(WatchID, predicate), + groupBitOrIf(WatchID, predicate), + groupBitAndIf(WatchID, predicate), + groupBitXorIf(WatchID, predicate) +FROM test.hits +ORDER BY min_watch_id +DESC LIMIT 20 diff --git a/tests/ast_json_fixtures/shapes/b8815e38b04a3acc.json b/tests/ast_json_fixtures/shapes/b8815e38b04a3acc.json new file mode 100644 index 000000000000..39aa8a531f26 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b8815e38b04a3acc.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Function", + "name": "avg", + "arguments": [ + { + "type": "Function", + "name": "toUInt32", + "arguments": [ + { + "type": "Identifier", + "name": "val" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_group_by_lowcardinality" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "val" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1", + "max_rows_to_group_by": "100", + "group_by_overflow_mode": "any" + } + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/b8815e38b04a3acc.sql b/tests/ast_json_fixtures/shapes/b8815e38b04a3acc.sql new file mode 100644 index 000000000000..6c8f72c9c84c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b8815e38b04a3acc.sql @@ -0,0 +1 @@ +select val, avg(toUInt32(val)) from t_group_by_lowcardinality group by val limit 10 settings max_threads=1, max_rows_to_group_by=100, group_by_overflow_mode='any' format JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/b885be62cfe8955d.json b/tests/ast_json_fixtures/shapes/b885be62cfe8955d.json new file mode 100644 index 000000000000..9d94fcf30778 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b885be62cfe8955d.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_ALL", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b885be62cfe8955d.sql b/tests/ast_json_fixtures/shapes/b885be62cfe8955d.sql new file mode 100644 index 000000000000..a6c90010366c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b885be62cfe8955d.sql @@ -0,0 +1 @@ +SELECT 1 UNION ALL (SELECT 1 UNION ALL SELECT 1 UNION SELECT 1 UNION DISTINCT SELECT 1 UNION ALL SELECT 1) diff --git a/tests/ast_json_fixtures/shapes/b88e845caf4cd84c.json b/tests/ast_json_fixtures/shapes/b88e845caf4cd84c.json new file mode 100644 index 000000000000..ac3a5c9a692d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b88e845caf4cd84c.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist2_01071" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "dist2_layer_01071" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + }, + "as_table": "data2_01071" + } +} diff --git a/tests/ast_json_fixtures/shapes/b88e845caf4cd84c.sql b/tests/ast_json_fixtures/shapes/b88e845caf4cd84c.sql new file mode 100644 index 000000000000..c8283b4ca7e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b88e845caf4cd84c.sql @@ -0,0 +1 @@ +create table dist2_01071 as data2_01071 Engine=Distributed(test_cluster_two_shards, currentDatabase(), dist2_layer_01071, key%2) diff --git a/tests/ast_json_fixtures/shapes/b8948b69369b71ed.json b/tests/ast_json_fixtures/shapes/b8948b69369b71ed.json new file mode 100644 index 000000000000..278bf54b1759 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b8948b69369b71ed.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "transactions_info_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b8948b69369b71ed.sql b/tests/ast_json_fixtures/shapes/b8948b69369b71ed.sql new file mode 100644 index 000000000000..db1a175c8ae8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b8948b69369b71ed.sql @@ -0,0 +1 @@ +system flush logs transactions_info_log diff --git a/tests/ast_json_fixtures/shapes/b894ea41294ff3cf.json b/tests/ast_json_fixtures/shapes/b894ea41294ff3cf.json new file mode 100644 index 000000000000..3dcc05598bf0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b894ea41294ff3cf.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_1" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "additional_result_filter": "x != 2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b894ea41294ff3cf.sql b/tests/ast_json_fixtures/shapes/b894ea41294ff3cf.sql new file mode 100644 index 000000000000..ba197f7c3fa5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b894ea41294ff3cf.sql @@ -0,0 +1 @@ +select * from table_1 prewhere x != 3 where x != 1 settings additional_result_filter='x != 2' diff --git a/tests/ast_json_fixtures/shapes/b895d1b4ed447673.json b/tests/ast_json_fixtures/shapes/b895d1b4ed447673.json new file mode 100644 index 000000000000..a3798a5a6a5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b895d1b4ed447673.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "concat", + "arguments": [ + { + "type": "Identifier", + "name": "func.name", + "name_parts": ["func", "name"] + }, + { + "type": "Identifier", + "name": "comb.name", + "name_parts": ["comb", "name"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "func", + "name": "functions", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "name" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "comb", + "name": "aggregate_function_combinators", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "is_aggregate" + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b895d1b4ed447673.sql b/tests/ast_json_fixtures/shapes/b895d1b4ed447673.sql new file mode 100644 index 000000000000..3e68c38f8884 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b895d1b4ed447673.sql @@ -0,0 +1 @@ +SELECT concat(func.name, comb.name) AS x FROM system.functions AS func JOIN system.aggregate_function_combinators AS comb using name WHERE is_aggregate settings enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/b89fff919cece6d3.json b/tests/ast_json_fixtures/shapes/b89fff919cece6d3.json new file mode 100644 index 000000000000..6e93ddb4e145 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b89fff919cece6d3.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "j" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "d" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "ceil", + "arguments": [ + { + "type": "Identifier", + "name": "j" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b89fff919cece6d3.sql b/tests/ast_json_fixtures/shapes/b89fff919cece6d3.sql new file mode 100644 index 000000000000..85fa8c4d8fda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b89fff919cece6d3.sql @@ -0,0 +1 @@ +SELECT min(j) FROM d PREWHERE ceil(j) <= 0 diff --git a/tests/ast_json_fixtures/shapes/b8ad87a7e1ef86d3.json b/tests/ast_json_fixtures/shapes/b8ad87a7e1ef86d3.json new file mode 100644 index 000000000000..ec44641020bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b8ad87a7e1ef86d3.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_cluster_two_shards_different_databases", + "database": { + "type": "Identifier", + "name": "shard_0" + }, + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ], + "constraints": [ + { + "type": "Constraint", + "name": "cc", + "constraint_type": "CHECK", + "expression": { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b8ad87a7e1ef86d3.sql b/tests/ast_json_fixtures/shapes/b8ad87a7e1ef86d3.sql new file mode 100644 index 000000000000..1286cc012006 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b8ad87a7e1ef86d3.sql @@ -0,0 +1 @@ +CREATE TABLE shard_0.t0 ON CLUSTER 'test_cluster_two_shards_different_databases' (c0 Int, CONSTRAINT cc CHECK currentDatabase()) ENGINE = MergeTree() ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/b90504d9e82b7c83.json b/tests/ast_json_fixtures/shapes/b90504d9e82b7c83.json new file mode 100644 index 000000000000..2af4001dec7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b90504d9e82b7c83.json @@ -0,0 +1,146 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "sub", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "sub" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_push_predicate_ast_for_distributed_subqueries": "1", + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b90504d9e82b7c83.sql b/tests/ast_json_fixtures/shapes/b90504d9e82b7c83.sql new file mode 100644 index 000000000000..0fcdc9086410 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b90504d9e82b7c83.sql @@ -0,0 +1 @@ +with sub as (select number from numbers(1)) select x from (select number as x from remote('127.0.0.{1,2}', numbers(2))) where x in sub settings allow_push_predicate_ast_for_distributed_subqueries = 1, enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/b9054eae4f73d66f.json b/tests/ast_json_fixtures/shapes/b9054eae4f73d66f.json new file mode 100644 index 000000000000..a46c494181d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9054eae4f73d66f.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "a" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "j", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "j" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "i" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/b9054eae4f73d66f.sql b/tests/ast_json_fixtures/shapes/b9054eae4f73d66f.sql new file mode 100644 index 000000000000..16ea09b7477d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9054eae4f73d66f.sql @@ -0,0 +1 @@ +create table a (i int, j int, projection p (select * order by j)) engine MergeTree partition by i order by tuple() settings index_granularity = 1 diff --git a/tests/ast_json_fixtures/shapes/b92fa787fe2a967e.json b/tests/ast_json_fixtures/shapes/b92fa787fe2a967e.json new file mode 100644 index 000000000000..c9b9fc1480ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b92fa787fe2a967e.json @@ -0,0 +1,131 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "lambda_1", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Identifier", + "alias": "lambda_2", + "name": "lambda_1" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Identifier", + "name": "lambda_2" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "1" + }, + { + "value_type": "String", + "value": "2" + }, + { + "value_type": "String", + "value": "3" + } + ] + } + ] + } + ] + } + ], + "where": { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "lambda_2" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b92fa787fe2a967e.sql b/tests/ast_json_fixtures/shapes/b92fa787fe2a967e.sql new file mode 100644 index 000000000000..5b2bd3907e19 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b92fa787fe2a967e.sql @@ -0,0 +1,7 @@ +WITH x -> toString(x) AS lambda_1 +SELECT + 3, + arrayMap(lambda_1 AS lambda_2, [1, 2, 3]), + arrayMap(lambda_2, materialize(['1', '2', '3'])) +WHERE toNullable(9) +GROUP BY lambda_2 diff --git a/tests/ast_json_fixtures/shapes/b93c1098bc94b652.json b/tests/ast_json_fixtures/shapes/b93c1098bc94b652.json new file mode 100644 index 000000000000..5a35709f8288 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b93c1098bc94b652.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Identifier", + "name": "age" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "users" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b93c1098bc94b652.sql b/tests/ast_json_fixtures/shapes/b93c1098bc94b652.sql new file mode 100644 index 000000000000..1e771b3341e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b93c1098bc94b652.sql @@ -0,0 +1,12 @@ +SELECT * +FROM +( + SELECT + name, + age + FROM users +) +GROUP BY + 1, + 2 +ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/b9518e6a6591a4d1.json b/tests/ast_json_fixtures/shapes/b9518e6a6591a4d1.json new file mode 100644 index 000000000000..7303754698f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9518e6a6591a4d1.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH ASYNC INSERT QUEUE", + "tables": [ + { + "table": "03732_table_join" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b9518e6a6591a4d1.sql b/tests/ast_json_fixtures/shapes/b9518e6a6591a4d1.sql new file mode 100644 index 000000000000..df3e5c1effef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9518e6a6591a4d1.sql @@ -0,0 +1 @@ +system flush async insert queue 03732_table_join diff --git a/tests/ast_json_fixtures/shapes/b957306406fd7c46.json b/tests/ast_json_fixtures/shapes/b957306406fd7c46.json new file mode 100644 index 000000000000..f06bb359b0d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b957306406fd7c46.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q11_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "EXECUTION_TIME": "12000000000000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b957306406fd7c46.sql b/tests/ast_json_fixtures/shapes/b957306406fd7c46.sql new file mode 100644 index 000000000000..70781a6c6d48 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b957306406fd7c46.sql @@ -0,0 +1 @@ +CREATE QUOTA q11_01297 FOR INTERVAL 1 MINUTE MAX execution_time = '12M' diff --git a/tests/ast_json_fixtures/shapes/b96eb7757449a6c4.json b/tests/ast_json_fixtures/shapes/b96eb7757449a6c4.json new file mode 100644 index 000000000000..6a045a571085 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b96eb7757449a6c4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u2_01292_renamed", "u3_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/b96eb7757449a6c4.sql b/tests/ast_json_fixtures/shapes/b96eb7757449a6c4.sql new file mode 100644 index 000000000000..741f5159150f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b96eb7757449a6c4.sql @@ -0,0 +1 @@ +DROP USER u1_01292, u2_01292_renamed, u3_01292 diff --git a/tests/ast_json_fixtures/shapes/b98c32114922fa25.json b/tests/ast_json_fixtures/shapes/b98c32114922fa25.json new file mode 100644 index 000000000000..3cbc98b4b0ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b98c32114922fa25.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TSVWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/b98c32114922fa25.sql b/tests/ast_json_fixtures/shapes/b98c32114922fa25.sql new file mode 100644 index 000000000000..6b000a35c4fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b98c32114922fa25.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TSVWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/b98e5b5d60fc5ce7.json b/tests/ast_json_fixtures/shapes/b98e5b5d60fc5ce7.json new file mode 100644 index 000000000000..d3fd76663a07 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b98e5b5d60fc5ce7.json @@ -0,0 +1,104 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_all": true, + "group_by_with_rollup": true, + "select": [ + { + "type": "Identifier", + "name": "l.number", + "name_parts": ["l", "number"] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "r.number", + "name_parts": ["r", "number"] + } + ] + }, + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "l.number", + "name_parts": ["l", "number"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "l", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l.number", + "name_parts": ["l", "number"] + }, + { + "type": "Identifier", + "name": "r.number", + "name_parts": ["r", "number"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "r", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b98e5b5d60fc5ce7.sql b/tests/ast_json_fixtures/shapes/b98e5b5d60fc5ce7.sql new file mode 100644 index 000000000000..e426860d0a4f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b98e5b5d60fc5ce7.sql @@ -0,0 +1,3 @@ +SELECT l.number, sum(r.number), grouping(l.number) +FROM numbers(1) l JOIN numbers(2) r ON l.number < r.number +GROUP BY ALL WITH ROLLUP diff --git a/tests/ast_json_fixtures/shapes/b9c47ba1ab4b0cde.json b/tests/ast_json_fixtures/shapes/b9c47ba1ab4b0cde.json new file mode 100644 index 000000000000..0224f703b4a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9c47ba1ab4b0cde.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "sqllt", + "from_table": "table_new", + "to_database": "sqllt", + "to_table": "table" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b9c47ba1ab4b0cde.sql b/tests/ast_json_fixtures/shapes/b9c47ba1ab4b0cde.sql new file mode 100644 index 000000000000..0831feab78cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9c47ba1ab4b0cde.sql @@ -0,0 +1 @@ +RENAME TABLE sqllt.table_new TO sqllt.table diff --git a/tests/ast_json_fixtures/shapes/b9cd021c324de78c.json b/tests/ast_json_fixtures/shapes/b9cd021c324de78c.json new file mode 100644 index 000000000000..51f884cd55d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9cd021c324de78c.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b9cd021c324de78c.sql b/tests/ast_json_fixtures/shapes/b9cd021c324de78c.sql new file mode 100644 index 000000000000..b3ef37ee0baf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9cd021c324de78c.sql @@ -0,0 +1 @@ +SELECT number % 3 + 1 AS n, min(n), max(n) FROM numbers(100) GROUP BY n WITH ROLLUP diff --git a/tests/ast_json_fixtures/shapes/b9e6efe44e685bcd.json b/tests/ast_json_fixtures/shapes/b9e6efe44e685bcd.json new file mode 100644 index 000000000000..9329315f6ac5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9e6efe44e685bcd.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "arr" + }, + { + "type": "Literal", + "alias": "other", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Function", + "name": "arrayJaccardIndex", + "arguments": [ + { + "type": "Identifier", + "name": "arr" + }, + { + "type": "Identifier", + "name": "other" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "array_jaccard_index" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "arr" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/b9e6efe44e685bcd.sql b/tests/ast_json_fixtures/shapes/b9e6efe44e685bcd.sql new file mode 100644 index 000000000000..0c296d2d1c8c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9e6efe44e685bcd.sql @@ -0,0 +1 @@ +SELECT arr, [1,2] AS other, round(arrayJaccardIndex(arr, other), 2) FROM array_jaccard_index ORDER BY arr diff --git a/tests/ast_json_fixtures/shapes/b9f21c105d4fba5e.json b/tests/ast_json_fixtures/shapes/b9f21c105d4fba5e.json new file mode 100644 index 000000000000..063cc578735c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9f21c105d4fba5e.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ], + "format": "JSONCompactEachRowWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/b9f21c105d4fba5e.sql b/tests/ast_json_fixtures/shapes/b9f21c105d4fba5e.sql new file mode 100644 index 000000000000..4739489d6878 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/b9f21c105d4fba5e.sql @@ -0,0 +1 @@ +SELECT * FROM test_table FORMAT JSONCompactEachRowWithNames diff --git a/tests/ast_json_fixtures/shapes/ba21d02073f26b50.json b/tests/ast_json_fixtures/shapes/ba21d02073f26b50.json new file mode 100644 index 000000000000..3153eaa5d316 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba21d02073f26b50.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q3_01297"], + "key_type": "CLIENT_KEY_OR_USER_NAME", + "limits": [ + { + "duration_sec": "15778476", + "max": { + "QUERIES": "100", + "ERRORS": "11" + } + }, + { + "duration_sec": "5259492", + "max": { + "RESULT_ROWS": "1002" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ba21d02073f26b50.sql b/tests/ast_json_fixtures/shapes/ba21d02073f26b50.sql new file mode 100644 index 000000000000..9c6d7bbc72f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba21d02073f26b50.sql @@ -0,0 +1 @@ +CREATE QUOTA q3_01297 KEYED BY client_key, user_name FOR 0.5 YEAR ERRORS MAX 11, QUERIES MAX 100, FOR 2 MONTH RESULT ROWS MAX 1002 diff --git a/tests/ast_json_fixtures/shapes/ba27739e6168e4bc.json b/tests/ast_json_fixtures/shapes/ba27739e6168e4bc.json new file mode 100644 index 000000000000..824d0d260408 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba27739e6168e4bc.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab_v" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ba27739e6168e4bc.sql b/tests/ast_json_fixtures/shapes/ba27739e6168e4bc.sql new file mode 100644 index 000000000000..62ed329398cf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba27739e6168e4bc.sql @@ -0,0 +1 @@ +SELECT DISTINCT x FROM tab_v ORDER BY x diff --git a/tests/ast_json_fixtures/shapes/ba30a18de4e993b4.json b/tests/ast_json_fixtures/shapes/ba30a18de4e993b4.json new file mode 100644 index 000000000000..5697794e32a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba30a18de4e993b4.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/ba30a18de4e993b4.sql b/tests/ast_json_fixtures/shapes/ba30a18de4e993b4.sql new file mode 100644 index 000000000000..ae6c38430ad5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba30a18de4e993b4.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettySpace diff --git a/tests/ast_json_fixtures/shapes/ba34643b496354dc.json b/tests/ast_json_fixtures/shapes/ba34643b496354dc.json new file mode 100644 index 000000000000..f510c53b582f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba34643b496354dc.json @@ -0,0 +1,239 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "test1", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "alias": "z", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "x", + "name": "test1" + } + } + } + ] + }, + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "z" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "41" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test1" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ba34643b496354dc.sql b/tests/ast_json_fixtures/shapes/ba34643b496354dc.sql new file mode 100644 index 000000000000..d2aeb527964d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba34643b496354dc.sql @@ -0,0 +1,2 @@ +WITH test1 AS (SELECT number-1 as n FROM numbers(42)) +SELECT max(n+1)+1 z FROM test1 join test1 x using n having z - 1 = (select min(n-1)+41 from test1) + 2 diff --git a/tests/ast_json_fixtures/shapes/ba5290dac8814d55.json b/tests/ast_json_fixtures/shapes/ba5290dac8814d55.json new file mode 100644 index 000000000000..9fcf141dcda7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba5290dac8814d55.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t1" + }, + "as_table": "t0" + } +} diff --git a/tests/ast_json_fixtures/shapes/ba5290dac8814d55.sql b/tests/ast_json_fixtures/shapes/ba5290dac8814d55.sql new file mode 100644 index 000000000000..33d7cd7a0267 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba5290dac8814d55.sql @@ -0,0 +1 @@ +CREATE TABLE t1 AS t0 diff --git a/tests/ast_json_fixtures/shapes/ba6f2c6ce728925e.json b/tests/ast_json_fixtures/shapes/ba6f2c6ce728925e.json new file mode 100644 index 000000000000..c0a381a94899 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba6f2c6ce728925e.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "check_system_tables" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "name1", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "name2", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "name3", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "name2" + }, + "order_by": { + "type": "Identifier", + "name": "name1" + }, + "sample_by": { + "type": "Identifier", + "name": "name1" + }, + "settings": { + "type": "Settings", + "changes": { + "min_bytes_for_wide_part": "0", + "compress_marks": false, + "compress_primary_key": false, + "ratio_of_defaults_for_sparse_serialization": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ba6f2c6ce728925e.sql b/tests/ast_json_fixtures/shapes/ba6f2c6ce728925e.sql new file mode 100644 index 000000000000..57b44d25316f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba6f2c6ce728925e.sql @@ -0,0 +1,10 @@ +CREATE TABLE check_system_tables + ( + name1 UInt8, + name2 UInt8, + name3 UInt8 + ) ENGINE = MergeTree() + ORDER BY name1 + PARTITION BY name2 + SAMPLE BY name1 + SETTINGS min_bytes_for_wide_part = 0, compress_marks = false, compress_primary_key = false, ratio_of_defaults_for_sparse_serialization = 1 diff --git a/tests/ast_json_fixtures/shapes/ba7c4224e8903681.json b/tests/ast_json_fixtures/shapes/ba7c4224e8903681.json new file mode 100644 index 000000000000..a2b4c246afe0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba7c4224e8903681.json @@ -0,0 +1,115 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "alias": "b", + "name": "b" + }, + { + "type": "Function", + "alias": "c", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_lazy_mat_prewhere_parallel" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ba7c4224e8903681.sql b/tests/ast_json_fixtures/shapes/ba7c4224e8903681.sql new file mode 100644 index 000000000000..3196d0533694 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba7c4224e8903681.sql @@ -0,0 +1 @@ +SELECT a + 1 AS a, b AS b, c + 1 AS c, d + 1 AS d FROM t_lazy_mat_prewhere_parallel PREWHERE d > 1 ORDER BY c LIMIT 3 diff --git a/tests/ast_json_fixtures/shapes/ba800647e432b740.json b/tests/ast_json_fixtures/shapes/ba800647e432b740.json new file mode 100644 index 000000000000..e2ea458353df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba800647e432b740.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_max_rows_to_read" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "12" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ba800647e432b740.sql b/tests/ast_json_fixtures/shapes/ba800647e432b740.sql new file mode 100644 index 000000000000..c28938b0cb4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba800647e432b740.sql @@ -0,0 +1 @@ +SELECT a FROM t_max_rows_to_read ORDER BY a LIMIT 5 SETTINGS max_rows_to_read = 12 diff --git a/tests/ast_json_fixtures/shapes/ba84b70726993fe0.json b/tests/ast_json_fixtures/shapes/ba84b70726993fe0.json new file mode 100644 index 000000000000..30e81ba3a86d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba84b70726993fe0.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "src" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "p", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "k", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "p" + }, + "order_by": { + "type": "Identifier", + "name": "k" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ba84b70726993fe0.sql b/tests/ast_json_fixtures/shapes/ba84b70726993fe0.sql new file mode 100644 index 000000000000..25ac200f5db1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba84b70726993fe0.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE src (p UInt64, k String, d UInt64) ENGINE = MergeTree PARTITION BY p ORDER BY k diff --git a/tests/ast_json_fixtures/shapes/ba874fb15279bdf8.json b/tests/ast_json_fixtures/shapes/ba874fb15279bdf8.json new file mode 100644 index 000000000000..40f334507f17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba874fb15279bdf8.json @@ -0,0 +1,142 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "limit w\/ GROUP BY" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.{1,2}" + }, + { + "type": "Function", + "name": "view", + "arguments": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "number", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483647" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "DESC", + "nulls_first": false + } + ], + "settings": { + "type": "Settings", + "changes": { + "limit": "2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ba874fb15279bdf8.sql b/tests/ast_json_fixtures/shapes/ba874fb15279bdf8.sql new file mode 100644 index 000000000000..ef09935e50f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba874fb15279bdf8.sql @@ -0,0 +1,2 @@ +SELECT 'limit w/ GROUP BY', count(NULL), number FROM remote('127.{1,2}', view(SELECT intDiv(number, 2147483647) + AS number FROM numbers(10))) GROUP BY number WITH ROLLUP ORDER BY count() ASC, number DESC NULLS LAST SETTINGS limit = 2 diff --git a/tests/ast_json_fixtures/shapes/ba8d414f34640488.json b/tests/ast_json_fixtures/shapes/ba8d414f34640488.json new file mode 100644 index 000000000000..dbbeb9b9925c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba8d414f34640488.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s1_01294", "s2_01294_renamed", "s3_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/ba8d414f34640488.sql b/tests/ast_json_fixtures/shapes/ba8d414f34640488.sql new file mode 100644 index 000000000000..e41370be8b6f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ba8d414f34640488.sql @@ -0,0 +1 @@ +DROP SETTINGS PROFILE s1_01294, s2_01294_renamed, s3_01294 diff --git a/tests/ast_json_fixtures/shapes/bac239fc5f46a4e0.json b/tests/ast_json_fixtures/shapes/bac239fc5f46a4e0.json new file mode 100644 index 000000000000..07aa9fe75efd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bac239fc5f46a4e0.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SetRoleQuery", + "kind": "SET_DEFAULT_ROLE", + "roles": { + "type": "RolesOrUsersSet", + "names": ["sqllt_role"] + }, + "to_users": { + "type": "RolesOrUsersSet", + "names": ["sqllt_user"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bac239fc5f46a4e0.sql b/tests/ast_json_fixtures/shapes/bac239fc5f46a4e0.sql new file mode 100644 index 000000000000..ead3f8f182bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bac239fc5f46a4e0.sql @@ -0,0 +1 @@ +SET DEFAULT ROLE sqllt_role TO sqllt_user diff --git a/tests/ast_json_fixtures/shapes/bad4488a96982b0e.json b/tests/ast_json_fixtures/shapes/bad4488a96982b0e.json new file mode 100644 index 000000000000..7844e11640cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bad4488a96982b0e.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_u64_distributed" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test_u64_local" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "test_u64_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/bad4488a96982b0e.sql b/tests/ast_json_fixtures/shapes/bad4488a96982b0e.sql new file mode 100644 index 000000000000..7a50585a7c21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bad4488a96982b0e.sql @@ -0,0 +1 @@ +CREATE TABLE test_u64_distributed AS test_u64_local ENGINE = Distributed('test_shard_localhost', currentDatabase(), test_u64_local, rand()) diff --git a/tests/ast_json_fixtures/shapes/baf36344589b2daa.json b/tests/ast_json_fixtures/shapes/baf36344589b2daa.json new file mode 100644 index 000000000000..2635409ced9c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/baf36344589b2daa.json @@ -0,0 +1,161 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "246" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "arrayStringConcat", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reinterpretAsString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "RowBinaryWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/baf36344589b2daa.sql b/tests/ast_json_fixtures/shapes/baf36344589b2daa.sql new file mode 100644 index 000000000000..d8bed2ea61b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/baf36344589b2daa.sql @@ -0,0 +1 @@ +SELECT number * 246 + 10 AS n, toDate('2000-01-01') + n AS d, range(n) AS arr, arrayStringConcat(arrayMap(x -> reinterpretAsString(x), arr)) AS s, (n, d) AS tuple FROM system.numbers LIMIT 2 FORMAT RowBinaryWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/bb1bc57e741b1e9c.json b/tests/ast_json_fixtures/shapes/bb1bc57e741b1e9c.json new file mode 100644 index 000000000000..7492e5952504 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb1bc57e741b1e9c.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "primary_key_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "v", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "v" + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "v" + }, + "order_by": { + "type": "Identifier", + "name": "v" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bb1bc57e741b1e9c.sql b/tests/ast_json_fixtures/shapes/bb1bc57e741b1e9c.sql new file mode 100644 index 000000000000..0a5a1625c2f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb1bc57e741b1e9c.sql @@ -0,0 +1 @@ +CREATE TABLE primary_key_test(v Int32, PRIMARY KEY(v)) ENGINE=ReplacingMergeTree ORDER BY v diff --git a/tests/ast_json_fixtures/shapes/bb1fb6256f01073f.json b/tests/ast_json_fixtures/shapes/bb1fb6256f01073f.json new file mode 100644 index 000000000000..541cc0d4b3df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb1fb6256f01073f.json @@ -0,0 +1,106 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2097152" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1234567890123456789" + } + ] + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "2097142" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "log_comment": "02402_external_disk_mertrics\/sort" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/bb1fb6256f01073f.sql b/tests/ast_json_fixtures/shapes/bb1fb6256f01073f.sql new file mode 100644 index 000000000000..eddf07f2bc42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb1fb6256f01073f.sql @@ -0,0 +1,3 @@ +SELECT number FROM (SELECT number FROM numbers(2097152)) ORDER BY number * 1234567890123456789 LIMIT 2097142, 10 +SETTINGS log_comment='02402_external_disk_mertrics/sort' +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/bb24fe113948ac13.json b/tests/ast_json_fixtures/shapes/bb24fe113948ac13.json new file mode 100644 index 000000000000..1db239b45056 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb24fe113948ac13.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/bb24fe113948ac13.sql b/tests/ast_json_fixtures/shapes/bb24fe113948ac13.sql new file mode 100644 index 000000000000..e3d314537b78 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb24fe113948ac13.sql @@ -0,0 +1 @@ +EXPLAIN SELECT number FROM numbers_mt(1000) GROUP BY number FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/bb2a4bbf2b799855.json b/tests/ast_json_fixtures/shapes/bb2a4bbf2b799855.json new file mode 100644 index 000000000000..49ef8d00cf65 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb2a4bbf2b799855.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u2_01292_renamed"] + } +} diff --git a/tests/ast_json_fixtures/shapes/bb2a4bbf2b799855.sql b/tests/ast_json_fixtures/shapes/bb2a4bbf2b799855.sql new file mode 100644 index 000000000000..8be0bbf20636 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb2a4bbf2b799855.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS u2_01292_renamed diff --git a/tests/ast_json_fixtures/shapes/bb3d740211b0b0c9.json b/tests/ast_json_fixtures/shapes/bb3d740211b0b0c9.json new file mode 100644 index 000000000000..b5f09006c263 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb3d740211b0b0c9.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "l", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "r", + "name": "t" + } + } + } + ] + }, + "prewhere": { + "type": "Identifier", + "name": "l.x", + "name_parts": ["l", "x"] + }, + "where": { + "type": "Identifier", + "name": "r.x", + "name_parts": ["r", "x"] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bb3d740211b0b0c9.sql b/tests/ast_json_fixtures/shapes/bb3d740211b0b0c9.sql new file mode 100644 index 000000000000..bfc0c46a6107 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb3d740211b0b0c9.sql @@ -0,0 +1 @@ +select 4 from t as l join t as r using id prewhere l.x where r.x diff --git a/tests/ast_json_fixtures/shapes/bb43cd04b514c614.json b/tests/ast_json_fixtures/shapes/bb43cd04b514c614.json new file mode 100644 index 000000000000..a7e489953771 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb43cd04b514c614.json @@ -0,0 +1,153 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Identifier", + "name": "s0.number", + "name_parts": ["s0", "number"] + } + ] + }, + { + "type": "Identifier", + "name": "s1.half", + "name_parts": ["s1", "half"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "s0", + "name": "numbers", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s0.number", + "name_parts": ["s0", "number"] + }, + { + "type": "Identifier", + "name": "s1.number", + "name_parts": ["s1", "number"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "s1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "half", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s0.number", + "name_parts": ["s0", "number"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bb43cd04b514c614.sql b/tests/ast_json_fixtures/shapes/bb43cd04b514c614.sql new file mode 100644 index 000000000000..a0297fa1bab2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb43cd04b514c614.sql @@ -0,0 +1,14 @@ +SELECT + count(s0.number), + s1.half +FROM system.numbers AS s0 +INNER JOIN +( + SELECT + number, + number / 2 AS half + FROM system.numbers + LIMIT 10 +) AS s1 ON s0.number = s1.number +GROUP BY s0.number > 5 +LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/bb665369d429ca94.json b/tests/ast_json_fixtures/shapes/bb665369d429ca94.json new file mode 100644 index 000000000000..736ff6b9e547 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb665369d429ca94.json @@ -0,0 +1,95 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "key", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bb665369d429ca94.sql b/tests/ast_json_fixtures/shapes/bb665369d429ca94.sql new file mode 100644 index 000000000000..f2d446145254 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb665369d429ca94.sql @@ -0,0 +1 @@ +SELECT (number % 2) AS key, count() FROM numbers(10) GROUP BY key HAVING key = 0 QUALIFY key == 0 diff --git a/tests/ast_json_fixtures/shapes/bb69038d0aee14d0.json b/tests/ast_json_fixtures/shapes/bb69038d0aee14d0.json new file mode 100644 index 000000000000..07946a253e3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb69038d0aee14d0.json @@ -0,0 +1,535 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "YYYYMMDDToDate", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + }, + { + "type": "Function", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "nulls_action": "IGNORE NULLS", + "arguments": [ + { + "type": "Function", + "name": "YYYYMMDDToDate", + "arguments": [ + { + "type": "Function", + "name": "YYYYMMDDToDate", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 19700101.1 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "27" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "37" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 19700101.1 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "27" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "37" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + } + ] + }, + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + } + ] + } + ], + "window_name": "w" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 19700101.1 + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "27" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "37" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "19" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + } + ] + }, + { + "type": "Identifier", + "name": "p" + }, + { + "type": "Identifier", + "name": "pp" + }, + { + "type": "Function", + "alias": "lag2", + "name": "lagInFrame", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "pp" + } + ] + } + ], + "window_name": "w" + }, + { + "type": "Function", + "alias": "lag", + "name": "lagInFrame", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "pp" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + } + ], + "window_name": "w" + }, + { + "type": "Function", + "alias": "lead", + "name": "leadInFrame", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "pp" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + } + ], + "window_name": "w" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "p", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "alias": "pp", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "p" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "p" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC", + "nulls_first": true + } + ], + "frame_type": "ROWS", + "frame_begin": { + "type": "Unbounded", + "preceding": true + }, + "frame_end": { + "type": "Unbounded" + } + } + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "DESC", + "nulls_first": false + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bb69038d0aee14d0.sql b/tests/ast_json_fixtures/shapes/bb69038d0aee14d0.sql new file mode 100644 index 000000000000..7c5c0a87bd77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb69038d0aee14d0.sql @@ -0,0 +1,19 @@ +SELECT + number, + YYYYMMDDToDate(1, toLowCardinality(11), max(YYYYMMDDToDate(YYYYMMDDToDate(toLowCardinality(1), 11, materialize(NULL), 19700101.1, 1, 27, 7, materialize(toUInt256(37)), 9, 19, 9), 1, toUInt128(11), NULL, 19700101.1, 1, 27, 7, 37, 9, 19, 9), toUInt256(30)) IGNORE NULLS OVER w, NULL, 19700101.1, toNullable(1), 27, materialize(7), 37, 9, 19, 9), + p, + pp, + lagInFrame(number, number - pp) OVER w AS lag2, + lagInFrame(number, number - pp, number * 11) OVER w AS lag, + leadInFrame(number, number - pp, number * 11) OVER w AS lead +FROM +( + SELECT + number, + intDiv(number, 5) AS p, + p * 5 AS pp + FROM numbers(16) +) +WHERE toLowCardinality(1) +WINDOW w AS (PARTITION BY p ORDER BY number ASC NULLS FIRST ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) +ORDER BY number DESC NULLS LAST diff --git a/tests/ast_json_fixtures/shapes/bb72046832d53457.json b/tests/ast_json_fixtures/shapes/bb72046832d53457.json new file mode 100644 index 000000000000..0313bd6da38d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb72046832d53457.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "KillQueryQuery", + "kill_type": "MUTATION", + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test_wide_nested" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/bb72046832d53457.sql b/tests/ast_json_fixtures/shapes/bb72046832d53457.sql new file mode 100644 index 000000000000..2c0f32cd470d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb72046832d53457.sql @@ -0,0 +1 @@ +kill mutation where table = 'test_wide_nested' and database = currentDatabase() format Null diff --git a/tests/ast_json_fixtures/shapes/bb7d55db3e530761.json b/tests/ast_json_fixtures/shapes/bb7d55db3e530761.json new file mode 100644 index 000000000000..90efe3af6813 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb7d55db3e530761.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "SetRoleQuery", + "kind": "SET_DEFAULT_ROLE", + "roles": { + "type": "RolesOrUsersSet" + }, + "to_users": { + "type": "RolesOrUsersSet", + "names": ["u6_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bb7d55db3e530761.sql b/tests/ast_json_fixtures/shapes/bb7d55db3e530761.sql new file mode 100644 index 000000000000..0a59d8414875 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb7d55db3e530761.sql @@ -0,0 +1 @@ +SET DEFAULT ROLE NONE TO u6_01292 diff --git a/tests/ast_json_fixtures/shapes/bb7e94ae128b064b.json b/tests/ast_json_fixtures/shapes/bb7e94ae128b064b.json new file mode 100644 index 000000000000..b8f05118e826 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb7e94ae128b064b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q8_01297"], + "key_type": "USER_NAME" + } +} diff --git a/tests/ast_json_fixtures/shapes/bb7e94ae128b064b.sql b/tests/ast_json_fixtures/shapes/bb7e94ae128b064b.sql new file mode 100644 index 000000000000..bb78e1984270 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb7e94ae128b064b.sql @@ -0,0 +1 @@ +CREATE QUOTA q8_01297 KEYED BY 'user name' diff --git a/tests/ast_json_fixtures/shapes/bb7f96913d8adaae.json b/tests/ast_json_fixtures/shapes/bb7f96913d8adaae.json new file mode 100644 index 000000000000..4661c23d108b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb7f96913d8adaae.json @@ -0,0 +1,98 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "s3", + "arguments": [ + { + "type": "Identifier", + "name": "s3_conn" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "filename" + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "\/{_partition_id}\/test.parquet" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "format" + }, + { + "type": "Identifier", + "name": "Parquet" + } + ] + } + ] + }, + "partition_by": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bb7f96913d8adaae.sql b/tests/ast_json_fixtures/shapes/bb7f96913d8adaae.sql new file mode 100644 index 000000000000..1b773b16eda8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb7f96913d8adaae.sql @@ -0,0 +1,9 @@ +INSERT INTO FUNCTION + s3( + s3_conn, + filename = currentDatabase() || '/{_partition_id}/test.parquet', + format = Parquet + ) PARTITION BY 2 SELECT + * +FROM system.numbers +LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/bb83387a04a001cf.json b/tests/ast_json_fixtures/shapes/bb83387a04a001cf.json new file mode 100644 index 000000000000..48ca63a74e9a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb83387a04a001cf.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "t" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "generateRandom", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\n a Array(Int8),\n b UInt32,\n c Nullable(String),\n d Decimal32(4),\n e Nullable(Enum16('h' = 1, 'w' = 5 , 'o' = -200)),\n f Float64,\n g Tuple(Date, DateTime('Asia\/Istanbul'), DateTime64(3, 'Asia\/Istanbul'), UUID),\n h FixedString(2),\n i Array(Nullable(UUID))\n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bb83387a04a001cf.sql b/tests/ast_json_fixtures/shapes/bb83387a04a001cf.sql new file mode 100644 index 000000000000..4bf8b965279e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb83387a04a001cf.sql @@ -0,0 +1,12 @@ +create temporary table t engine Memory as select * from generateRandom( +$$ + a Array(Int8), + b UInt32, + c Nullable(String), + d Decimal32(4), + e Nullable(Enum16('h' = 1, 'w' = 5 , 'o' = -200)), + f Float64, + g Tuple(Date, DateTime('Asia/Istanbul'), DateTime64(3, 'Asia/Istanbul'), UUID), + h FixedString(2), + i Array(Nullable(UUID)) +$$, 10, 5, 3) limit 2 diff --git a/tests/ast_json_fixtures/shapes/bb8429b6974446ed.json b/tests/ast_json_fixtures/shapes/bb8429b6974446ed.json new file mode 100644 index 000000000000..4f1e8d97de7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb8429b6974446ed.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "is_ordinary_view": true, + "table": { + "type": "Identifier", + "name": "v_01210" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bb8429b6974446ed.sql b/tests/ast_json_fixtures/shapes/bb8429b6974446ed.sql new file mode 100644 index 000000000000..803b366aba74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb8429b6974446ed.sql @@ -0,0 +1 @@ +CREATE VIEW IF NOT EXISTS v_01210 AS SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/bb892acf78d0f423.json b/tests/ast_json_fixtures/shapes/bb892acf78d0f423.json new file mode 100644 index 000000000000..23ac175b6962 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb892acf78d0f423.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "cluster": "test", + "table": { + "type": "Identifier", + "name": "tsrc_cluster" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bb892acf78d0f423.sql b/tests/ast_json_fixtures/shapes/bb892acf78d0f423.sql new file mode 100644 index 000000000000..3bfbc0c290c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb892acf78d0f423.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE tsrc_cluster ON CLUSTER 'test' AS SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/bb8c377e366b5ea9.json b/tests/ast_json_fixtures/shapes/bb8c377e366b5ea9.json new file mode 100644 index 000000000000..56065c54506d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb8c377e366b5ea9.json @@ -0,0 +1,143 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table_for_rename_with_primary_key" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "date", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "key1", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "key2", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "key3", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "value1", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "value2", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx", + "expression": { + "type": "Identifier", + "name": "value1" + }, + "index_type": { + "type": "Function", + "name": "set", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/clickhouse\/tables\/{database}\/test_01213\/table_for_rename_pk2" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + "partition_by": { + "type": "Identifier", + "name": "date" + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key1" + }, + { + "type": "Identifier", + "name": "key2" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key1" + }, + { + "type": "Identifier", + "name": "key2" + }, + { + "type": "Identifier", + "name": "key3" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bb8c377e366b5ea9.sql b/tests/ast_json_fixtures/shapes/bb8c377e366b5ea9.sql new file mode 100644 index 000000000000..0d2f23fb4a6c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bb8c377e366b5ea9.sql @@ -0,0 +1,14 @@ +CREATE TABLE table_for_rename_with_primary_key +( + date Date, + key1 UInt64, + key2 UInt64, + key3 UInt64, + value1 String, + value2 String, + INDEX idx (value1) TYPE set(1) GRANULARITY 1 +) +ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test_01213/table_for_rename_pk2', '1') +PARTITION BY date +ORDER BY (key1, key2, key3) +PRIMARY KEY (key1, key2) diff --git a/tests/ast_json_fixtures/shapes/bbbd77f2d646ddd4.json b/tests/ast_json_fixtures/shapes/bbbd77f2d646ddd4.json new file mode 100644 index 000000000000..ca010bdce452 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bbbd77f2d646ddd4.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "number", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "group_by": [ + { + "type": "Function", + "alias": "number", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bbbd77f2d646ddd4.sql b/tests/ast_json_fixtures/shapes/bbbd77f2d646ddd4.sql new file mode 100644 index 000000000000..a0f264f4277a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bbbd77f2d646ddd4.sql @@ -0,0 +1 @@ +select number % 2 as number, count() from numbers(10) where number != 0 group by number % 2 as number diff --git a/tests/ast_json_fixtures/shapes/bbc025184e87c6a9.json b/tests/ast_json_fixtures/shapes/bbc025184e87c6a9.json new file mode 100644 index 000000000000..c304219bef92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bbc025184e87c6a9.json @@ -0,0 +1,244 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "REGEXP_REPLACE", + "arguments": [ + { + "type": "Function", + "name": "trimLeft", + "arguments": [ + { + "type": "Identifier", + "name": "explain" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "__set_Int32_\\d+_\\d+" + }, + { + "type": "Literal", + "value_type": "String", + "value": "__set_Int32_UNIQ_ID" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "viewExplain", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "EXPLAIN" + }, + { + "type": "Literal", + "value_type": "String", + "value": "actions = 1" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "t1.k", + "name_parts": ["t1", "k"] + }, + { + "type": "Identifier", + "name": "t1.a", + "name_parts": ["t1", "a"] + }, + { + "type": "Identifier", + "name": "t2.x", + "name_parts": ["t2", "x"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "tp1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.k", + "name_parts": ["t1", "k"] + }, + { + "type": "Identifier", + "name": "t2.k", + "name_parts": ["t2", "k"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "tp2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.x", + "name_parts": ["t2", "x"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.x", + "name_parts": ["t2", "x"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "200" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.k", + "name_parts": ["t1", "k"] + }, + "direction": "ASC" + } + ] + } + ] + } + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "ilike", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "explain" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%Filter column: %" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_parallel_replicas": "0" + } + } + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/bbc025184e87c6a9.sql b/tests/ast_json_fixtures/shapes/bbc025184e87c6a9.sql new file mode 100644 index 000000000000..637a104780db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bbc025184e87c6a9.sql @@ -0,0 +1,12 @@ +SELECT REGEXP_REPLACE(trimLeft(explain), '__set_Int32_\\d+_\\d+', '__set_Int32_UNIQ_ID') +FROM ( + EXPLAIN actions=1 + SELECT t1.k, t1.a, t2.x + FROM tp1 AS t1 + JOIN tp2 AS t2 ON t1.k = t2.k + WHERE (t2.x = 100) OR (t2.x = 200) + ORDER BY t1.k + ) + +WHERE explain ILIKE '%Filter column: %' SETTINGS enable_parallel_replicas = 0 +FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/bbd6dfd388a587f4.json b/tests/ast_json_fixtures/shapes/bbd6dfd388a587f4.json new file mode 100644 index 000000000000..93036ac3ca72 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bbd6dfd388a587f4.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mem" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bbd6dfd388a587f4.sql b/tests/ast_json_fixtures/shapes/bbd6dfd388a587f4.sql new file mode 100644 index 000000000000..637a9eec6ce3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bbd6dfd388a587f4.sql @@ -0,0 +1 @@ +CREATE TABLE mem AS SELECT 1 as n diff --git a/tests/ast_json_fixtures/shapes/bbf6dedc5887d6b8.json b/tests/ast_json_fixtures/shapes/bbf6dedc5887d6b8.json new file mode 100644 index 000000000000..817374b26caf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bbf6dedc5887d6b8.json @@ -0,0 +1,127 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Function", + "name": "windowFunnel", + "arguments": [ + { + "type": "Identifier", + "name": "ts" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event" + }, + { + "type": "Literal", + "value_type": "String", + "value": "b" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event" + }, + { + "type": "Literal", + "value_type": "String", + "value": "c" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event" + }, + { + "type": "Literal", + "value_type": "String", + "value": "d" + } + ] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "86400" + }, + { + "type": "Literal", + "value_type": "String", + "value": "strict_deduplication" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "strict_BiteTheDDDD" + } + } + } + ] + } + } + ], + "format": "JSONCompactEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/bbf6dedc5887d6b8.sql b/tests/ast_json_fixtures/shapes/bbf6dedc5887d6b8.sql new file mode 100644 index 000000000000..da79f3588bdb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bbf6dedc5887d6b8.sql @@ -0,0 +1 @@ +select 3 = windowFunnel(86400, 'strict_deduplication')(ts, event='a', event='b', event='c', event='d') from strict_BiteTheDDDD format JSONCompactEachRow diff --git a/tests/ast_json_fixtures/shapes/bc36f852689307e6.json b/tests/ast_json_fixtures/shapes/bc36f852689307e6.json new file mode 100644 index 000000000000..272b16065ab0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bc36f852689307e6.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.2" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "t4" + } + ] + }, + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/bc36f852689307e6.sql b/tests/ast_json_fixtures/shapes/bc36f852689307e6.sql new file mode 100644 index 000000000000..3a469296f4ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bc36f852689307e6.sql @@ -0,0 +1 @@ +INSERT INTO FUNCTION remote('127.0.0.2', currentDatabase(), t4) VALUES (2) diff --git a/tests/ast_json_fixtures/shapes/bc49ee70cbc9b90d.json b/tests/ast_json_fixtures/shapes/bc49ee70cbc9b90d.json new file mode 100644 index 000000000000..43470f72cada --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bc49ee70cbc9b90d.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "URL" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "URL" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%yandex%" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "URL" + }, + "direction": "DESC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "query_43" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/bc49ee70cbc9b90d.sql b/tests/ast_json_fixtures/shapes/bc49ee70cbc9b90d.sql new file mode 100644 index 000000000000..921852438976 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bc49ee70cbc9b90d.sql @@ -0,0 +1 @@ +SELECT URL from test.hits WHERE URL LIKE '%yandex%' ORDER BY URL DESC FORMAT Null SETTINGS log_comment='query_43' diff --git a/tests/ast_json_fixtures/shapes/bc5376a3695c56e6.json b/tests/ast_json_fixtures/shapes/bc5376a3695c56e6.json new file mode 100644 index 000000000000..ea773987673d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bc5376a3695c56e6.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "v" + }, + "if_exists": true, + "is_view": true + } +} diff --git a/tests/ast_json_fixtures/shapes/bc5376a3695c56e6.sql b/tests/ast_json_fixtures/shapes/bc5376a3695c56e6.sql new file mode 100644 index 000000000000..d13f17fbc5c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bc5376a3695c56e6.sql @@ -0,0 +1 @@ +DROP VIEW IF EXISTS v diff --git a/tests/ast_json_fixtures/shapes/bc85112f13640cb5.json b/tests/ast_json_fixtures/shapes/bc85112f13640cb5.json new file mode 100644 index 000000000000..8da15530744e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bc85112f13640cb5.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u1_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/bc85112f13640cb5.sql b/tests/ast_json_fixtures/shapes/bc85112f13640cb5.sql new file mode 100644 index 000000000000..4c0d7a94f1fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bc85112f13640cb5.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS u1_01297 diff --git a/tests/ast_json_fixtures/shapes/bcb9193b57a398c8.json b/tests/ast_json_fixtures/shapes/bcb9193b57a398c8.json new file mode 100644 index 000000000000..6297c4df5f91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bcb9193b57a398c8.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "countDistinct", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "testnull" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_memory_usage": "10000000" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bcb9193b57a398c8.sql b/tests/ast_json_fixtures/shapes/bcb9193b57a398c8.sql new file mode 100644 index 000000000000..ca9bc81ad357 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bcb9193b57a398c8.sql @@ -0,0 +1 @@ +SELECT count(distinct b) FROM testnull GROUP BY a SETTINGS max_memory_usage = 10000000 diff --git a/tests/ast_json_fixtures/shapes/bcd5df798c34c148.json b/tests/ast_json_fixtures/shapes/bcd5df798c34c148.json new file mode 100644 index 000000000000..589b7ce211df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bcd5df798c34c148.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "count" + } + } + } + ] + }, + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1234567" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bcd5df798c34c148.sql b/tests/ast_json_fixtures/shapes/bcd5df798c34c148.sql new file mode 100644 index 000000000000..cdbeb73d1e53 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bcd5df798c34c148.sql @@ -0,0 +1 @@ +SELECT count() FROM count HAVING count() = 1234567 diff --git a/tests/ast_json_fixtures/shapes/bcf25b666006528b.json b/tests/ast_json_fixtures/shapes/bcf25b666006528b.json new file mode 100644 index 000000000000..74023f45b9ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bcf25b666006528b.json @@ -0,0 +1,143 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "number", + "name": "zero" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.2" + }, + { + "type": "Identifier", + "name": "system.zeros", + "name_parts": ["system", "zeros"] + } + ] + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bcf25b666006528b.sql b/tests/ast_json_fixtures/shapes/bcf25b666006528b.sql new file mode 100644 index 000000000000..dbf5c06a9fe4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bcf25b666006528b.sql @@ -0,0 +1,12 @@ +SELECT number +FROM +( + SELECT zero AS number + FROM remote('127.0.0.2', system.zeros) + UNION ALL + SELECT number + sleep(0.5) + FROM system.numbers +) +WHERE number = 1 +LIMIT 1 +SETTINGS max_rows_to_read = 0 diff --git a/tests/ast_json_fixtures/shapes/bd0327dc3a85049b.json b/tests/ast_json_fixtures/shapes/bd0327dc3a85049b.json new file mode 100644 index 000000000000..97b357a0b768 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd0327dc3a85049b.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "� �" + } + ] + } + ], + "format": "JSONObjectEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/bd0327dc3a85049b.sql b/tests/ast_json_fixtures/shapes/bd0327dc3a85049b.sql new file mode 100644 index 000000000000..259e75237ddd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd0327dc3a85049b.sql @@ -0,0 +1 @@ +SELECT '\xED\x20\xA8' AS s FORMAT JSONObjectEachRow diff --git a/tests/ast_json_fixtures/shapes/bd095c38b4d007c7.json b/tests/ast_json_fixtures/shapes/bd095c38b4d007c7.json new file mode 100644 index 000000000000..dd27ea7b50ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd095c38b4d007c7.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Date" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Identifier", + "name": "c0" + } + ] + } + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bd095c38b4d007c7.sql b/tests/ast_json_fixtures/shapes/bd095c38b4d007c7.sql new file mode 100644 index 000000000000..33477d875f0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd095c38b4d007c7.sql @@ -0,0 +1 @@ +CREATE TABLE t0 (c0 Date) ENGINE = MergeTree() ORDER BY () TTL (materialize(c0)) diff --git a/tests/ast_json_fixtures/shapes/bd22f2c5e95d74bb.json b/tests/ast_json_fixtures/shapes/bd22f2c5e95d74bb.json new file mode 100644 index 000000000000..bab672b60b0a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd22f2c5e95d74bb.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "SearchPhrase" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits_s3", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "SearchPhrase" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "EventTime" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/bd22f2c5e95d74bb.sql b/tests/ast_json_fixtures/shapes/bd22f2c5e95d74bb.sql new file mode 100644 index 000000000000..f5731ec57f66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd22f2c5e95d74bb.sql @@ -0,0 +1 @@ +SELECT SearchPhrase FROM test.hits_s3 WHERE SearchPhrase != '' ORDER BY EventTime LIMIT 10 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/bd3b27d6b0587602.json b/tests/ast_json_fixtures/shapes/bd3b27d6b0587602.json new file mode 100644 index 000000000000..00f0b9f62afd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd3b27d6b0587602.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "mv2" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "k", + "name": "n1.key", + "name_parts": ["n1", "key"] + }, + { + "type": "Identifier", + "alias": "v1", + "name": "n1.value", + "name_parts": ["n1", "value"] + }, + { + "type": "Identifier", + "alias": "v2", + "name": "n2.value", + "name_parts": ["n2", "value"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "n1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n1.key", + "name_parts": ["n1", "key"] + }, + { + "type": "Identifier", + "name": "n2.key", + "name_parts": ["n2", "key"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "n2" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n1.key", + "name_parts": ["n1", "key"] + }, + "direction": "ASC" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bd3b27d6b0587602.sql b/tests/ast_json_fixtures/shapes/bd3b27d6b0587602.sql new file mode 100644 index 000000000000..3dc9fc060e34 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd3b27d6b0587602.sql @@ -0,0 +1,2 @@ +CREATE MATERIALIZED VIEW mv2 +AS SELECT n1.key as k, n1.value as v1, n2.value as v2 from n1 JOIN n2 ON n1.key = n2.key ORDER BY n1.key diff --git a/tests/ast_json_fixtures/shapes/bd3c97785ef7e3d4.json b/tests/ast_json_fixtures/shapes/bd3c97785ef7e3d4.json new file mode 100644 index 000000000000..b2de0f68cbd2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd3c97785ef7e3d4.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "data2" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "FETCH_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + }, + "from": "\/tables\/{database}\/data1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bd3c97785ef7e3d4.sql b/tests/ast_json_fixtures/shapes/bd3c97785ef7e3d4.sql new file mode 100644 index 000000000000..81d88c7553ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd3c97785ef7e3d4.sql @@ -0,0 +1 @@ +alter table data2 fetch partition () from '/tables/{database}/data1' diff --git a/tests/ast_json_fixtures/shapes/bd404906bc44a720.json b/tests/ast_json_fixtures/shapes/bd404906bc44a720.json new file mode 100644 index 000000000000..ff0dc40fe1cf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd404906bc44a720.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u_03174_multiple_auth_show_create" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "PLAINTEXT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + { + "type": "AuthenticationData", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2" + } + ] + }, + { + "type": "AuthenticationData", + "auth_type": "BCRYPT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "3" + } + ] + }, + { + "type": "AuthenticationData", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "4" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/bd404906bc44a720.sql b/tests/ast_json_fixtures/shapes/bd404906bc44a720.sql new file mode 100644 index 000000000000..89e3757db763 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd404906bc44a720.sql @@ -0,0 +1 @@ +CREATE USER u_03174_multiple_auth_show_create IDENTIFIED WITH plaintext_password by '1', by '2', bcrypt_password by '3', by '4' diff --git a/tests/ast_json_fixtures/shapes/bd76d1cbe0ca61e7.json b/tests/ast_json_fixtures/shapes/bd76d1cbe0ca61e7.json new file mode 100644 index 000000000000..453df9472f5c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd76d1cbe0ca61e7.json @@ -0,0 +1,94 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "test2.col1", + "name_parts": ["test2", "col1"] + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "test1" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test2" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "RIGHT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "test2.col1", + "name_parts": ["test2", "col1"] + }, + { + "type": "Identifier", + "name": "test1.col1", + "name_parts": ["test1", "col1"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "test2.col1", + "name_parts": ["test2", "col1"] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "test2.col1", + "name_parts": ["test2", "col1"] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bd76d1cbe0ca61e7.sql b/tests/ast_json_fixtures/shapes/bd76d1cbe0ca61e7.sql new file mode 100644 index 000000000000..75c3ad7a1276 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bd76d1cbe0ca61e7.sql @@ -0,0 +1,3 @@ +SELECT test2.col1, test1.* FROM test2 RIGHT JOIN test1 ON test2.col1 = test1.col1 +WHERE test2.col1 IS NOT NULL +ORDER BY test2.col1 diff --git a/tests/ast_json_fixtures/shapes/bda326d6cff79c4e.json b/tests/ast_json_fixtures/shapes/bda326d6cff79c4e.json new file mode 100644 index 000000000000..ed2b9972bb7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bda326d6cff79c4e.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "dt" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bda326d6cff79c4e.sql b/tests/ast_json_fixtures/shapes/bda326d6cff79c4e.sql new file mode 100644 index 000000000000..2478cd60e49e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bda326d6cff79c4e.sql @@ -0,0 +1 @@ +SELECT *, dt FROM t diff --git a/tests/ast_json_fixtures/shapes/bda3f9834182a035.json b/tests/ast_json_fixtures/shapes/bda3f9834182a035.json new file mode 100644 index 000000000000..feb608ee60dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bda3f9834182a035.json @@ -0,0 +1,123 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "uniqState", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "x", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bda3f9834182a035.sql b/tests/ast_json_fixtures/shapes/bda3f9834182a035.sql new file mode 100644 index 000000000000..2ca061515e23 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bda3f9834182a035.sql @@ -0,0 +1 @@ +SELECT DISTINCT hex(toString(uniqState(x))) FROM (SELECT materialize(1) AS k, toNullable(1) AS x FROM numbers(1)) GROUP BY k WITH CUBE ORDER BY k diff --git a/tests/ast_json_fixtures/shapes/bdad03ff6a13787e.json b/tests/ast_json_fixtures/shapes/bdad03ff6a13787e.json new file mode 100644 index 000000000000..1217709b0607 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bdad03ff6a13787e.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "alias": "k1", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "k2", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "k3", + "value_type": "UInt64", + "value": "3" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000000" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k1" + }, + { + "type": "Identifier", + "name": "k2" + }, + { + "type": "Identifier", + "name": "k3" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_group_by_constant_keys": "1", + "enable_software_prefetch_in_aggregation": "0", + "compile_aggregate_expressions": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bdad03ff6a13787e.sql b/tests/ast_json_fixtures/shapes/bdad03ff6a13787e.sql new file mode 100644 index 000000000000..12059ddd1050 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bdad03ff6a13787e.sql @@ -0,0 +1 @@ +select count(number), 1 AS k1, 2 as k2, 3 as k3 from numbers_mt(10000000) group by k1, k2, k3 settings optimize_group_by_constant_keys=1, enable_software_prefetch_in_aggregation=0, compile_aggregate_expressions=0 diff --git a/tests/ast_json_fixtures/shapes/bdbf4266074b87eb.json b/tests/ast_json_fixtures/shapes/bdbf4266074b87eb.json new file mode 100644 index 000000000000..f5eb0680f72b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bdbf4266074b87eb.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distributed_00609" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "mergetree_00609" + } + ] + } + }, + "as_table": "mergetree_00609" + } +} diff --git a/tests/ast_json_fixtures/shapes/bdbf4266074b87eb.sql b/tests/ast_json_fixtures/shapes/bdbf4266074b87eb.sql new file mode 100644 index 000000000000..7a81efc2f566 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bdbf4266074b87eb.sql @@ -0,0 +1 @@ +CREATE TABLE distributed_00609 AS mergetree_00609 ENGINE = Distributed(test_shard_localhost, currentDatabase(), mergetree_00609) diff --git a/tests/ast_json_fixtures/shapes/bdc39137ce786f75.json b/tests/ast_json_fixtures/shapes/bdc39137ce786f75.json new file mode 100644 index 000000000000..9cd91396495a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bdc39137ce786f75.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "constraints": [ + { + "type": "Constraint", + "name": "c", + "constraint_type": "ASSUME", + "expression": { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bdc39137ce786f75.sql b/tests/ast_json_fixtures/shapes/bdc39137ce786f75.sql new file mode 100644 index 000000000000..5db266f9667e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bdc39137ce786f75.sql @@ -0,0 +1 @@ +CREATE TABLE t0 (CONSTRAINT c ASSUME NULL ? 1 : c[1]) diff --git a/tests/ast_json_fixtures/shapes/bdd7ac77c49ffae7.json b/tests/ast_json_fixtures/shapes/bdd7ac77c49ffae7.json new file mode 100644 index 000000000000..e5b717777573 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bdd7ac77c49ffae7.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "name", + "value_type": "String", + "value": "1111" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers_mt", + "database": "system" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/bdd7ac77c49ffae7.sql b/tests/ast_json_fixtures/shapes/bdd7ac77c49ffae7.sql new file mode 100644 index 000000000000..9b25384c1372 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bdd7ac77c49ffae7.sql @@ -0,0 +1 @@ +select '1111' as name from system.numbers_mt order by name limit 10000 format Null diff --git a/tests/ast_json_fixtures/shapes/be0584b7ad080b18.json b/tests/ast_json_fixtures/shapes/be0584b7ad080b18.json new file mode 100644 index 000000000000..fd0930a88217 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be0584b7ad080b18.json @@ -0,0 +1,260 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "column_1" + }, + { + "type": "Identifier", + "name": "column_2" + } + ] + }, + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "T2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "column_1", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "column_1" + } + ] + }, + { + "type": "Function", + "alias": "column_2", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "column_2" + } + ] + }, + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "T1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "column_1", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "column_1" + } + ] + }, + { + "type": "Literal", + "alias": "column_2", + "value_type": "Null", + "value": null + }, + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "clickhouse_alias_issue_1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "column_1", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "alias": "column_2", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "column_2" + } + ] + }, + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "clickhouse_alias_issue_2" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ], + "settings": { + "type": "Settings", + "changes": { + "prefer_column_name_to_alias": "1" + } + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "DESC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "prefer_column_name_to_alias": "1" + } + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "column_1" + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "column_2" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "prefer_column_name_to_alias": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/be0584b7ad080b18.sql b/tests/ast_json_fixtures/shapes/be0584b7ad080b18.sql new file mode 100644 index 000000000000..6f13296f719c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be0584b7ad080b18.sql @@ -0,0 +1,30 @@ +SELECT `column_1` / `column_2`, `id` +FROM ( + SELECT + max(`column_1`) AS `column_1`, + max(`column_2`) AS `column_2`, + `id` + FROM ( + SELECT + max(`column_1`) AS `column_1`, + NULL AS `column_2`, + `id` + FROM `clickhouse_alias_issue_1` + GROUP BY + `id` + UNION ALL + SELECT + NULL AS `column_1`, + max(`column_2`) AS `column_2`, + `id` + FROM `clickhouse_alias_issue_2` + GROUP BY + `id` + SETTINGS prefer_column_name_to_alias=1 + ) as T1 + GROUP BY `id` + ORDER BY `id` DESC + SETTINGS prefer_column_name_to_alias=1 +) as T2 +WHERE `column_1` IS NOT NULL AND `column_2` IS NOT NULL +SETTINGS prefer_column_name_to_alias=1 diff --git a/tests/ast_json_fixtures/shapes/be0745710f0c1c1c.json b/tests/ast_json_fixtures/shapes/be0745710f0c1c1c.json new file mode 100644 index 000000000000..035afb5b120f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be0745710f0c1c1c.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q9_01297"], + "key_type": "IP_ADDRESS" + } +} diff --git a/tests/ast_json_fixtures/shapes/be0745710f0c1c1c.sql b/tests/ast_json_fixtures/shapes/be0745710f0c1c1c.sql new file mode 100644 index 000000000000..bab5bf916a4e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be0745710f0c1c1c.sql @@ -0,0 +1 @@ +CREATE QUOTA q9_01297 KEYED BY 'IP_ADDRESS' diff --git a/tests/ast_json_fixtures/shapes/be11eaf792d9dc92.json b/tests/ast_json_fixtures/shapes/be11eaf792d9dc92.json new file mode 100644 index 000000000000..fb11939248c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be11eaf792d9dc92.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "rank", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c0" + }, + "direction": "ASC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "v0", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c0", + "value_type": "String", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + }, + "qualify": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rank", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c0" + }, + "direction": "ASC" + } + ] + } + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/be11eaf792d9dc92.sql b/tests/ast_json_fixtures/shapes/be11eaf792d9dc92.sql new file mode 100644 index 000000000000..fa1fa9194193 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be11eaf792d9dc92.sql @@ -0,0 +1 @@ +SELECT rank() OVER (ORDER BY c0) FROM (SELECT '1' c0) v0 QUALIFY rank() OVER (ORDER BY c0) > 0 diff --git a/tests/ast_json_fixtures/shapes/be1223a970108fb1.json b/tests/ast_json_fixtures/shapes/be1223a970108fb1.json new file mode 100644 index 000000000000..3c1fe55746f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be1223a970108fb1.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "limit_by" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "val" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/be1223a970108fb1.sql b/tests/ast_json_fixtures/shapes/be1223a970108fb1.sql new file mode 100644 index 000000000000..1669249b4b73 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be1223a970108fb1.sql @@ -0,0 +1 @@ +select * from limit_by order by id, val limit 1, 2 by id limit 3 diff --git a/tests/ast_json_fixtures/shapes/be27187bbcbde917.json b/tests/ast_json_fixtures/shapes/be27187bbcbde917.json new file mode 100644 index 000000000000..f46f126c6f56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be27187bbcbde917.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "replicated_constraints1" + }, + "settings": { + "type": "Settings", + "changes": { + "alter_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_CONSTRAINT", + "constraint": { + "type": "Identifier", + "name": "a_constraint" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/be27187bbcbde917.sql b/tests/ast_json_fixtures/shapes/be27187bbcbde917.sql new file mode 100644 index 000000000000..5a47bf919028 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be27187bbcbde917.sql @@ -0,0 +1 @@ +ALTER TABLE replicated_constraints1 DROP CONSTRAINT a_constraint SETTINGS alter_sync=2 diff --git a/tests/ast_json_fixtures/shapes/be4e649d1019ebe0.json b/tests/ast_json_fixtures/shapes/be4e649d1019ebe0.json new file mode 100644 index 000000000000..4718b089b21d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be4e649d1019ebe0.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["SHOW"], + "database": "db2", + "table": "tb2" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/be4e649d1019ebe0.sql b/tests/ast_json_fixtures/shapes/be4e649d1019ebe0.sql new file mode 100644 index 000000000000..9681c8d6aca3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be4e649d1019ebe0.sql @@ -0,0 +1 @@ +GRANT SHOW ON db2.tb2 TO test_user_01999 diff --git a/tests/ast_json_fixtures/shapes/be4fd67cdd4d1132.json b/tests/ast_json_fixtures/shapes/be4fd67cdd4d1132.json new file mode 100644 index 000000000000..d14c6d79c288 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be4fd67cdd4d1132.json @@ -0,0 +1,94 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "partition_count", + "name": "COUNT", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "partition_count" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/be4fd67cdd4d1132.sql b/tests/ast_json_fixtures/shapes/be4fd67cdd4d1132.sql new file mode 100644 index 000000000000..e079f3897b25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be4fd67cdd4d1132.sql @@ -0,0 +1 @@ +SELECT number, COUNT() OVER (PARTITION BY number % 3) AS partition_count FROM numbers(10) QUALIFY partition_count = 4 ORDER BY number diff --git a/tests/ast_json_fixtures/shapes/be72f4a8bd5e5453.json b/tests/ast_json_fixtures/shapes/be72f4a8bd5e5453.json new file mode 100644 index 000000000000..346b10deb052 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be72f4a8bd5e5453.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "01746_buffer" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Buffer", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "01746_buffer_t" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000000" + } + ] + } + }, + "as_table": "01746_buffer_t" + } +} diff --git a/tests/ast_json_fixtures/shapes/be72f4a8bd5e5453.sql b/tests/ast_json_fixtures/shapes/be72f4a8bd5e5453.sql new file mode 100644 index 000000000000..acb80980a208 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be72f4a8bd5e5453.sql @@ -0,0 +1,2 @@ +CREATE TABLE `01746_buffer` AS `01746_buffer_t` +ENGINE = Buffer(currentDatabase(), `01746_buffer_t`, 16, 10, 100, 10000, 1000000, 10000000, 100000000) diff --git a/tests/ast_json_fixtures/shapes/be73c75606189540.json b/tests/ast_json_fixtures/shapes/be73c75606189540.json new file mode 100644 index 000000000000..f6a341da2464 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be73c75606189540.json @@ -0,0 +1,166 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "a", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "key", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "alias": "acol", + "value_type": "String", + "value": "a" + } + ] + } + ] + } + } + }, + { + "type": "WithElement", + "name": "b", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "key", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "a.acol", + "name_parts": ["a", "acol"] + }, + { + "type": "Identifier", + "name": "a1.acol", + "name_parts": ["a1", "acol"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "b" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.key", + "name_parts": ["a", "key"] + }, + { + "type": "Identifier", + "name": "b.key", + "name_parts": ["b", "key"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a1.key", + "name_parts": ["a1", "key"] + }, + { + "type": "Identifier", + "name": "a.key", + "name_parts": ["a", "key"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "a1", + "name": "a" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/be73c75606189540.sql b/tests/ast_json_fixtures/shapes/be73c75606189540.sql new file mode 100644 index 000000000000..7267bee12e85 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be73c75606189540.sql @@ -0,0 +1,8 @@ +WITH + a AS ( SELECT 0 AS key, 'a' AS acol ), + b AS ( SELECT 2 AS key ) +SELECT a.acol, a1.acol +FROM b +FULL JOIN a ON a.key = b.key +FULL JOIN a AS a1 ON a1.key = a.key +ORDER BY 1 diff --git a/tests/ast_json_fixtures/shapes/be99e92d62025d6d.json b/tests/ast_json_fixtures/shapes/be99e92d62025d6d.json new file mode 100644 index 000000000000..a33c2c4d51be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be99e92d62025d6d.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "11" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/be99e92d62025d6d.sql b/tests/ast_json_fixtures/shapes/be99e92d62025d6d.sql new file mode 100644 index 000000000000..6614ca1c1c69 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be99e92d62025d6d.sql @@ -0,0 +1 @@ +SELECT 11 AS n GROUP BY n WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/be9a853a396366d9.json b/tests/ast_json_fixtures/shapes/be9a853a396366d9.json new file mode 100644 index 000000000000..90eb713bd48f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be9a853a396366d9.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "data_02716_1" + }, + "if_empty": true + } +} diff --git a/tests/ast_json_fixtures/shapes/be9a853a396366d9.sql b/tests/ast_json_fixtures/shapes/be9a853a396366d9.sql new file mode 100644 index 000000000000..ddc9838a5bff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/be9a853a396366d9.sql @@ -0,0 +1 @@ +DROP TABLE IF EMPTY data_02716_1 diff --git a/tests/ast_json_fixtures/shapes/bec86c874ce0ea6e.json b/tests/ast_json_fixtures/shapes/bec86c874ce0ea6e.json new file mode 100644 index 000000000000..347f7a181fd4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bec86c874ce0ea6e.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "mycheck", + "name": "exists", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + ] + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/bec86c874ce0ea6e.sql b/tests/ast_json_fixtures/shapes/bec86c874ce0ea6e.sql new file mode 100644 index 000000000000..98c86b112216 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bec86c874ce0ea6e.sql @@ -0,0 +1 @@ +SELECT EXISTS(SELECT 1) AS mycheck FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/bedec8fbab52f7b2.json b/tests/ast_json_fixtures/shapes/bedec8fbab52f7b2.json new file mode 100644 index 000000000000..564c79109fea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bedec8fbab52f7b2.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "a.size0", + "name_parts": ["a", "size0"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "y" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bedec8fbab52f7b2.sql b/tests/ast_json_fixtures/shapes/bedec8fbab52f7b2.sql new file mode 100644 index 000000000000..8fdcf8ce316b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bedec8fbab52f7b2.sql @@ -0,0 +1 @@ +select a, a.size0 from test where y > 5 order by y limit 2 diff --git a/tests/ast_json_fixtures/shapes/beffa9fbaf6ff89c.json b/tests/ast_json_fixtures/shapes/beffa9fbaf6ff89c.json new file mode 100644 index 000000000000..477fcf7dc1e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/beffa9fbaf6ff89c.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH ASYNC INSERT QUEUE", + "tables": [ + { + "table": "test_table with spaces" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/beffa9fbaf6ff89c.sql b/tests/ast_json_fixtures/shapes/beffa9fbaf6ff89c.sql new file mode 100644 index 000000000000..65d427bd8b4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/beffa9fbaf6ff89c.sql @@ -0,0 +1 @@ +system flush async insert queue `test_table with spaces` diff --git a/tests/ast_json_fixtures/shapes/bf074ef9fce96316.json b/tests/ast_json_fixtures/shapes/bf074ef9fce96316.json new file mode 100644 index 000000000000..9b12fb5701da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf074ef9fce96316.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u2_01292@192.168.%.%"] + } +} diff --git a/tests/ast_json_fixtures/shapes/bf074ef9fce96316.sql b/tests/ast_json_fixtures/shapes/bf074ef9fce96316.sql new file mode 100644 index 000000000000..805989c4967e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf074ef9fce96316.sql @@ -0,0 +1 @@ +SHOW CREATE USER u2_01292@'192.168.%.%' diff --git a/tests/ast_json_fixtures/shapes/bf087295aa613dd5.json b/tests/ast_json_fixtures/shapes/bf087295aa613dd5.json new file mode 100644 index 000000000000..2df6009aca74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf087295aa613dd5.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01296"] + } +} diff --git a/tests/ast_json_fixtures/shapes/bf087295aa613dd5.sql b/tests/ast_json_fixtures/shapes/bf087295aa613dd5.sql new file mode 100644 index 000000000000..3e4acb430e14 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf087295aa613dd5.sql @@ -0,0 +1 @@ +DROP USER u1_01296 diff --git a/tests/ast_json_fixtures/shapes/bf209ad25b32583b.json b/tests/ast_json_fixtures/shapes/bf209ad25b32583b.json new file mode 100644 index 000000000000..8f762c997432 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf209ad25b32583b.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "FREEZE_ALL" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bf209ad25b32583b.sql b/tests/ast_json_fixtures/shapes/bf209ad25b32583b.sql new file mode 100644 index 000000000000..b19c4eb71a4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf209ad25b32583b.sql @@ -0,0 +1 @@ +ALTER TABLE t FREEZE diff --git a/tests/ast_json_fixtures/shapes/bf59c10910171581.json b/tests/ast_json_fixtures/shapes/bf59c10910171581.json new file mode 100644 index 000000000000..f46257424c2d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf59c10910171581.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROW POLICY", + "short_name": "sqllt_row_policy", + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/bf59c10910171581.sql b/tests/ast_json_fixtures/shapes/bf59c10910171581.sql new file mode 100644 index 000000000000..adc4e2cbc94b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf59c10910171581.sql @@ -0,0 +1 @@ +SHOW CREATE ROW POLICY sqllt_row_policy FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/bf65555920ef5289.json b/tests/ast_json_fixtures/shapes/bf65555920ef5289.json new file mode 100644 index 000000000000..cfbf54a8de56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf65555920ef5289.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "RevokeQuery", + "access_rights": [ + { + "access_types": ["DROP"], + "database": "sqllt", + "table": "view" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["sqllt_user"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bf65555920ef5289.sql b/tests/ast_json_fixtures/shapes/bf65555920ef5289.sql new file mode 100644 index 000000000000..c3ac8c7deefe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf65555920ef5289.sql @@ -0,0 +1 @@ +REVOKE DROP ON sqllt.view FROM sqllt_user diff --git a/tests/ast_json_fixtures/shapes/bf798261b53c3fb2.json b/tests/ast_json_fixtures/shapes/bf798261b53c3fb2.json new file mode 100644 index 000000000000..c009149cf6e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf798261b53c3fb2.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowSetting", + "setting_name": "max_threads" + } +} diff --git a/tests/ast_json_fixtures/shapes/bf798261b53c3fb2.sql b/tests/ast_json_fixtures/shapes/bf798261b53c3fb2.sql new file mode 100644 index 000000000000..60f6c317ab06 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf798261b53c3fb2.sql @@ -0,0 +1 @@ +SHOW SETTING max_threads diff --git a/tests/ast_json_fixtures/shapes/bf83b714f637ad98.json b/tests/ast_json_fixtures/shapes/bf83b714f637ad98.json new file mode 100644 index 000000000000..62cfddbcb3c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf83b714f637ad98.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "i" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bf83b714f637ad98.sql b/tests/ast_json_fixtures/shapes/bf83b714f637ad98.sql new file mode 100644 index 000000000000..b754dcb57748 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf83b714f637ad98.sql @@ -0,0 +1,8 @@ +CREATE TABLE t +( + i Int32 +) +ENGINE = MergeTree +PARTITION BY i +ORDER BY tuple() +SETTINGS index_granularity = 1 diff --git a/tests/ast_json_fixtures/shapes/bf93aab2f900902c.json b/tests/ast_json_fixtures/shapes/bf93aab2f900902c.json new file mode 100644 index 000000000000..2dc633d4b20b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf93aab2f900902c.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "arr1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Identifier", + "name": "l" + }, + { + "type": "Function", + "name": "arraySlice", + "arguments": [ + { + "type": "Identifier", + "name": "arr1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Identifier", + "name": "l" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "array_functions" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bf93aab2f900902c.sql b/tests/ast_json_fixtures/shapes/bf93aab2f900902c.sql new file mode 100644 index 000000000000..29323dc73f73 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bf93aab2f900902c.sql @@ -0,0 +1 @@ +select arr1, 2, l, arraySlice(arr1, 2, l) from array_functions diff --git a/tests/ast_json_fixtures/shapes/bfaafc956853de12.json b/tests/ast_json_fixtures/shapes/bfaafc956853de12.json new file mode 100644 index 000000000000..ef1e855e474b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfaafc956853de12.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "reference_vec", + "value_type": "Array", + "value": [ + { + "value_type": "Float64", + "value": 0 + }, + { + "value_type": "Float64", + "value": 2 + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "settings": { + "type": "Settings", + "changes": { + "vector_search_with_rescoring": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bfaafc956853de12.sql b/tests/ast_json_fixtures/shapes/bfaafc956853de12.sql new file mode 100644 index 000000000000..d350fb3c6f59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfaafc956853de12.sql @@ -0,0 +1,7 @@ +WITH [0.0, 2.0] AS reference_vec +SELECT id +FROM tab +WHERE id >= 0 +ORDER BY L2Distance(vec, reference_vec) +LIMIT 5 +SETTINGS vector_search_with_rescoring = 0 diff --git a/tests/ast_json_fixtures/shapes/bfb9e59cced6d028.json b/tests/ast_json_fixtures/shapes/bfb9e59cced6d028.json new file mode 100644 index 000000000000..ee17d8a8d199 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfb9e59cced6d028.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_r1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/clickhouse\/{database}\/test_01666" + }, + { + "type": "Literal", + "value_type": "String", + "value": "r1" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "\\" + }, + "settings": { + "type": "Settings", + "changes": { + "min_bytes_for_wide_part": "100G", + "replace_long_file_name_to_hash": "1" + } + } + }, + "as_table": "test" + } +} diff --git a/tests/ast_json_fixtures/shapes/bfb9e59cced6d028.sql b/tests/ast_json_fixtures/shapes/bfb9e59cced6d028.sql new file mode 100644 index 000000000000..819db9d01f2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfb9e59cced6d028.sql @@ -0,0 +1 @@ +CREATE TABLE test_r1 AS test ENGINE = ReplicatedMergeTree('/clickhouse/{database}/test_01666', 'r1') ORDER BY "\\" SETTINGS min_bytes_for_wide_part = '100G', replace_long_file_name_to_hash = 1 diff --git a/tests/ast_json_fixtures/shapes/bfc858fe91645cbb.json b/tests/ast_json_fixtures/shapes/bfc858fe91645cbb.json new file mode 100644 index 000000000000..1736c5827e36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfc858fe91645cbb.json @@ -0,0 +1,121 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_grouping_sets_predicate" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "day_" + } + ] + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day_" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2023-01-05" + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Asterisk" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "type_1" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/bfc858fe91645cbb.sql b/tests/ast_json_fixtures/shapes/bfc858fe91645cbb.sql new file mode 100644 index 000000000000..d7e64974e00c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfc858fe91645cbb.sql @@ -0,0 +1,6 @@ +SELECT * +FROM ( SELECT * FROM test_grouping_sets_predicate GROUP BY GROUPING SETS ( (*), (day_) ) ) +WHERE day_ = '2023-01-05' +GROUP BY GROUPING SETS (*) +ORDER BY type_1 +SETTINGS enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/bfddebad33f4e06d.json b/tests/ast_json_fixtures/shapes/bfddebad33f4e06d.json new file mode 100644 index 000000000000..89e0aba23531 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfddebad33f4e06d.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t_merge" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "02111_modify_table_comment" + }, + { + "type": "Literal", + "value_type": "String", + "value": "t" + } + ] + } + }, + "as_table": "t", + "comment": { + "type": "Literal", + "value_type": "String", + "value": "this is a Merge table" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bfddebad33f4e06d.sql b/tests/ast_json_fixtures/shapes/bfddebad33f4e06d.sql new file mode 100644 index 000000000000..8197077f997a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfddebad33f4e06d.sql @@ -0,0 +1,3 @@ +CREATE TABLE t_merge AS t +ENGINE = Merge('02111_modify_table_comment', 't') +COMMENT 'this is a Merge table' diff --git a/tests/ast_json_fixtures/shapes/bfde1f0f6685f6db.json b/tests/ast_json_fixtures/shapes/bfde1f0f6685f6db.json new file mode 100644 index 000000000000..4d08a5ac0992 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfde1f0f6685f6db.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u1_01295"] + } +} diff --git a/tests/ast_json_fixtures/shapes/bfde1f0f6685f6db.sql b/tests/ast_json_fixtures/shapes/bfde1f0f6685f6db.sql new file mode 100644 index 000000000000..c40888fbf6b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfde1f0f6685f6db.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS u1_01295 diff --git a/tests/ast_json_fixtures/shapes/bfe031637e7427c2.json b/tests/ast_json_fixtures/shapes/bfe031637e7427c2.json new file mode 100644 index 000000000000..0dc003ce0e99 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfe031637e7427c2.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "02131_filter_1", + "table": "02131_rptable" + } + ] + }, + "is_restrictive": false, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/bfe031637e7427c2.sql b/tests/ast_json_fixtures/shapes/bfe031637e7427c2.sql new file mode 100644 index 000000000000..d1bad52893dc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfe031637e7427c2.sql @@ -0,0 +1 @@ +CREATE ROW POLICY 02131_filter_1 ON 02131_rptable USING x=1 AS permissive TO ALL diff --git a/tests/ast_json_fixtures/shapes/bfea4e45c69cdb86.json b/tests/ast_json_fixtures/shapes/bfea4e45c69cdb86.json new file mode 100644 index 000000000000..928b9e5480b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfea4e45c69cdb86.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "mergeTreeIndex", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "t_merge_tree_index" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "part_name" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "mark_number" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompactNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/bfea4e45c69cdb86.sql b/tests/ast_json_fixtures/shapes/bfea4e45c69cdb86.sql new file mode 100644 index 000000000000..9c447176d0a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/bfea4e45c69cdb86.sql @@ -0,0 +1 @@ +SELECT * FROM mergeTreeIndex(currentDatabase(), t_merge_tree_index) ORDER BY part_name, mark_number FORMAT PrettyCompactNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/c0029fbc3be821e4.json b/tests/ast_json_fixtures/shapes/c0029fbc3be821e4.json new file mode 100644 index 000000000000..6417232ceab5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0029fbc3be821e4.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROW POLICY", + "if_exists": true, + "row_policy_names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "filter", + "table": "t" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c0029fbc3be821e4.sql b/tests/ast_json_fixtures/shapes/c0029fbc3be821e4.sql new file mode 100644 index 000000000000..d6f0c4c9817f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0029fbc3be821e4.sql @@ -0,0 +1 @@ +DROP ROW POLICY IF EXISTS filter ON t diff --git a/tests/ast_json_fixtures/shapes/c047e60e7d45725e.json b/tests/ast_json_fixtures/shapes/c047e60e7d45725e.json new file mode 100644 index 000000000000..f077f6ce2b9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c047e60e7d45725e.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/c047e60e7d45725e.sql b/tests/ast_json_fixtures/shapes/c047e60e7d45725e.sql new file mode 100644 index 000000000000..b29d400df019 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c047e60e7d45725e.sql @@ -0,0 +1 @@ +SELECT 1 Format Null diff --git a/tests/ast_json_fixtures/shapes/c063706477080f2f.json b/tests/ast_json_fixtures/shapes/c063706477080f2f.json new file mode 100644 index 000000000000..f7f6d95b6cc6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c063706477080f2f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u7_01292@%.host.com", "u8_01292@%.otherhost.com"] + } +} diff --git a/tests/ast_json_fixtures/shapes/c063706477080f2f.sql b/tests/ast_json_fixtures/shapes/c063706477080f2f.sql new file mode 100644 index 000000000000..62a81ba8d546 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c063706477080f2f.sql @@ -0,0 +1 @@ +SHOW CREATE USER u7_01292@'%.host.com', u8_01292@'%.otherhost.com' diff --git a/tests/ast_json_fixtures/shapes/c06fd8f075cb9f27.json b/tests/ast_json_fixtures/shapes/c06fd8f075cb9f27.json new file mode 100644 index 000000000000..3c1848ef9f64 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c06fd8f075cb9f27.json @@ -0,0 +1,147 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "cte1", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "String", + "value": "1234" + } + ] + } + ] + } + } + }, + { + "type": "WithElement", + "name": "cte2", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "String", + "value": "1234" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "events", + "name": "events" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cte2.x", + "name_parts": ["cte2", "x"] + }, + { + "type": "Identifier", + "name": "events.distinct_id", + "name_parts": ["events", "distinct_id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "cte2" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cte1.x", + "name_parts": ["cte1", "x"] + }, + { + "type": "Identifier", + "name": "cte2.x", + "name_parts": ["cte2", "x"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "cte1" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c06fd8f075cb9f27.sql b/tests/ast_json_fixtures/shapes/c06fd8f075cb9f27.sql new file mode 100644 index 000000000000..eb179b44ba83 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c06fd8f075cb9f27.sql @@ -0,0 +1,10 @@ +WITH cte1 as ( + SELECT '1234' as x + ), cte2 as ( + SELECT '1234' as x + ) +SELECT * +FROM events AS events +JOIN cte2 ON cte2.x = events.distinct_id +JOIN cte1 ON cte1.x = cte2.x +limit 1 diff --git a/tests/ast_json_fixtures/shapes/c070f1cdc2ef98da.json b/tests/ast_json_fixtures/shapes/c070f1cdc2ef98da.json new file mode 100644 index 000000000000..78f3345a8e27 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c070f1cdc2ef98da.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_ordinary", + "from_table": "dist", + "to_database": "test_01155_atomic", + "to_table": "dist" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c070f1cdc2ef98da.sql b/tests/ast_json_fixtures/shapes/c070f1cdc2ef98da.sql new file mode 100644 index 000000000000..7efeaa8b673a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c070f1cdc2ef98da.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_ordinary.dist TO test_01155_atomic.dist diff --git a/tests/ast_json_fixtures/shapes/c093a810df7f7d4d.json b/tests/ast_json_fixtures/shapes/c093a810df7f7d4d.json new file mode 100644 index 000000000000..75823e36e3ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c093a810df7f7d4d.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "Int8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "n" + } + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "this is a MergeTree table" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c093a810df7f7d4d.sql b/tests/ast_json_fixtures/shapes/c093a810df7f7d4d.sql new file mode 100644 index 000000000000..dd7f480f560a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c093a810df7f7d4d.sql @@ -0,0 +1,7 @@ +CREATE TABLE t +( + `n` Int8 +) +ENGINE = MergeTree +ORDER BY n +COMMENT 'this is a MergeTree table' diff --git a/tests/ast_json_fixtures/shapes/c09ad9c10b08b93d.json b/tests/ast_json_fixtures/shapes/c09ad9c10b08b93d.json new file mode 100644 index 000000000000..ea3d8c843e80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c09ad9c10b08b93d.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "_block_number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_with_some_columns" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/c09ad9c10b08b93d.sql b/tests/ast_json_fixtures/shapes/c09ad9c10b08b93d.sql new file mode 100644 index 000000000000..c487dd0c3d49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c09ad9c10b08b93d.sql @@ -0,0 +1 @@ +SELECT *, _block_number FROM table_with_some_columns where not ignore(*) Format Null diff --git a/tests/ast_json_fixtures/shapes/c0a21d418afdf246.json b/tests/ast_json_fixtures/shapes/c0a21d418afdf246.json new file mode 100644 index 000000000000..c49d409e387a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0a21d418afdf246.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "s" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c0a21d418afdf246.sql b/tests/ast_json_fixtures/shapes/c0a21d418afdf246.sql new file mode 100644 index 000000000000..dd8887855f5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0a21d418afdf246.sql @@ -0,0 +1 @@ +alter table t drop column s diff --git a/tests/ast_json_fixtures/shapes/c0a3072db0a116cd.json b/tests/ast_json_fixtures/shapes/c0a3072db0a116cd.json new file mode 100644 index 000000000000..72b6582fdd36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0a3072db0a116cd.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "category" + }, + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Identifier", + "name": "name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_all_old_planner" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_analyzer": "0" + } + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c0a3072db0a116cd.sql b/tests/ast_json_fixtures/shapes/c0a3072db0a116cd.sql new file mode 100644 index 000000000000..81a5d6bd83b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0a3072db0a116cd.sql @@ -0,0 +1,4 @@ +SELECT id, category, value, name +FROM test_limit_by_all_old_planner +LIMIT 1 BY ALL +SETTINGS allow_experimental_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/c0a859c2b79b58ae.json b/tests/ast_json_fixtures/shapes/c0a859c2b79b58ae.json new file mode 100644 index 000000000000..605c3a018cae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0a859c2b79b58ae.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "neighbor", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/c0a859c2b79b58ae.sql b/tests/ast_json_fixtures/shapes/c0a859c2b79b58ae.sql new file mode 100644 index 000000000000..d13e759c5f2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0a859c2b79b58ae.sql @@ -0,0 +1 @@ +SELECT number, neighbor(number, 2) FROM system.numbers LIMIT 10 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/c0b5239937daa5d8.json b/tests/ast_json_fixtures/shapes/c0b5239937daa5d8.json new file mode 100644 index 000000000000..54b11d5cf200 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0b5239937daa5d8.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "cluster", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c0b5239937daa5d8.sql b/tests/ast_json_fixtures/shapes/c0b5239937daa5d8.sql new file mode 100644 index 000000000000..c062149e2dce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0b5239937daa5d8.sql @@ -0,0 +1 @@ +INSERT INTO FUNCTION cluster('test_shard_localhost', currentDatabase(), x, rand()) SELECT * FROM numbers(10) diff --git a/tests/ast_json_fixtures/shapes/c0da40d7ab801f71.json b/tests/ast_json_fixtures/shapes/c0da40d7ab801f71.json new file mode 100644 index 000000000000..dc11231084ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0da40d7ab801f71.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q6_01297"], + "roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c0da40d7ab801f71.sql b/tests/ast_json_fixtures/shapes/c0da40d7ab801f71.sql new file mode 100644 index 000000000000..926a2d8652c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0da40d7ab801f71.sql @@ -0,0 +1 @@ +CREATE QUOTA q6_01297 TO ALL EXCEPT r1_01297 diff --git a/tests/ast_json_fixtures/shapes/c0e0f937de9b2b13.json b/tests/ast_json_fixtures/shapes/c0e0f937de9b2b13.json new file mode 100644 index 000000000000..0f0effc48f25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0e0f937de9b2b13.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "products" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^products_" + } + ] + } + }, + "as_table": "prod_hist" + } +} diff --git a/tests/ast_json_fixtures/shapes/c0e0f937de9b2b13.sql b/tests/ast_json_fixtures/shapes/c0e0f937de9b2b13.sql new file mode 100644 index 000000000000..d998cfeb6e71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0e0f937de9b2b13.sql @@ -0,0 +1 @@ +CREATE TABLE products as prod_hist ENGINE = Merge(currentDatabase(), '^products_') diff --git a/tests/ast_json_fixtures/shapes/c0fce1688cf8c673.json b/tests/ast_json_fixtures/shapes/c0fce1688cf8c673.json new file mode 100644 index 000000000000..09dac274b902 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0fce1688cf8c673.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "sample_prewhere" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "date", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "time", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "date" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "intHash64", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + }, + "sample_by": { + "type": "Function", + "name": "intHash64", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c0fce1688cf8c673.sql b/tests/ast_json_fixtures/shapes/c0fce1688cf8c673.sql new file mode 100644 index 000000000000..b357af9499a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c0fce1688cf8c673.sql @@ -0,0 +1 @@ +create table if not exists sample_prewhere (date Date, id Int32, time Int64) engine = MergeTree partition by date order by (id, time, intHash64(time)) sample by intHash64(time) diff --git a/tests/ast_json_fixtures/shapes/c1149e0fe7a70676.json b/tests/ast_json_fixtures/shapes/c1149e0fe7a70676.json new file mode 100644 index 000000000000..6dffe59333bf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1149e0fe7a70676.json @@ -0,0 +1,117 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "part_name" + }, + { + "type": "Function", + "alias": "hits", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "MarkCacheHits" + } + ] + }, + { + "type": "Function", + "alias": "misses", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "MarkCacheMisses" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "part_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "MergeParts" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time_microseconds" + }, + "direction": "ASC" + } + ] + } + ], + "format": "CSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/c1149e0fe7a70676.sql b/tests/ast_json_fixtures/shapes/c1149e0fe7a70676.sql new file mode 100644 index 000000000000..b2a9adb460bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1149e0fe7a70676.sql @@ -0,0 +1,5 @@ +select part_name, ProfileEvents['MarkCacheHits'] hits, ProfileEvents['MarkCacheMisses'] misses + from system.part_log + where database = currentDatabase() and event_type = 'MergeParts' + order by event_time_microseconds + format CSVWithNames diff --git a/tests/ast_json_fixtures/shapes/c1179b0e62fa4f33.json b/tests/ast_json_fixtures/shapes/c1179b0e62fa4f33.json new file mode 100644 index 000000000000..fb14916c30f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1179b0e62fa4f33.json @@ -0,0 +1,135 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "null_lc_set_index" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "timestamp", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "action", + "data_type": { + "type": "DataType", + "name": "LowCardinality", + "arguments": [ + { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "user", + "data_type": { + "type": "DataType", + "name": "LowCardinality", + "arguments": [ + { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + ] + } + } + ], + "indices": [ + { + "type": "Index", + "name": "test_user_idx", + "expression": { + "type": "Identifier", + "name": "user" + }, + "index_type": { + "type": "Function", + "name": "set", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "granularity": 8192 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMMDD", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + }, + { + "type": "Identifier", + "name": "action" + }, + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "user" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_nullable_key": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c1179b0e62fa4f33.sql b/tests/ast_json_fixtures/shapes/c1179b0e62fa4f33.sql new file mode 100644 index 000000000000..b6dbbafa834e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1179b0e62fa4f33.sql @@ -0,0 +1,8 @@ +CREATE TABLE null_lc_set_index ( + timestamp DateTime, + action LowCardinality(Nullable(String)), + user LowCardinality(Nullable(String)), + INDEX test_user_idx (user) TYPE set(0) GRANULARITY 8192 +) ENGINE=MergeTree + PARTITION BY toYYYYMMDD(timestamp) + ORDER BY (timestamp, action, cityHash64(user)) SETTINGS allow_nullable_key = 1 diff --git a/tests/ast_json_fixtures/shapes/c11f303f68b62c1d.json b/tests/ast_json_fixtures/shapes/c11f303f68b62c1d.json new file mode 100644 index 000000000000..017aa0b48f57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c11f303f68b62c1d.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_map_contains_keys" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "ResourceAttributes", + "data_type": { + "type": "DataType", + "name": "Map", + "arguments": [ + { + "type": "DataType", + "name": "LowCardinality", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + }, + { + "type": "DataType", + "name": "String" + } + ] + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx_res_attr_value", + "expression": { + "type": "Function", + "name": "mapKeys", + "arguments": [ + { + "type": "Identifier", + "name": "ResourceAttributes" + } + ] + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + } + ] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c11f303f68b62c1d.sql b/tests/ast_json_fixtures/shapes/c11f303f68b62c1d.sql new file mode 100644 index 000000000000..bb06108b2278 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c11f303f68b62c1d.sql @@ -0,0 +1,6 @@ +CREATE TABLE test_map_contains_keys +( + `ResourceAttributes` Map(LowCardinality(String), String), + INDEX idx_res_attr_value mapKeys(ResourceAttributes) TYPE bloom_filter(0.01) GRANULARITY 1, +) +ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/c131b400aa50ae9e.json b/tests/ast_json_fixtures/shapes/c131b400aa50ae9e.json new file mode 100644 index 000000000000..3a5562ec24f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c131b400aa50ae9e.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "String", + "value": "Hello, \"World\"" + }, + { + "type": "Literal", + "alias": "y", + "value_type": "UInt64", + "value": "123" + }, + { + "type": "Literal", + "alias": "z", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "alias": "a", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "456" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "abc" + }, + { + "value_type": "String", + "value": "def" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "b", + "value_type": "String", + "value": "Newline\nhere" + } + ] + } + ], + "format": "CSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/c131b400aa50ae9e.sql b/tests/ast_json_fixtures/shapes/c131b400aa50ae9e.sql new file mode 100644 index 000000000000..6053991aa59b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c131b400aa50ae9e.sql @@ -0,0 +1 @@ +SELECT 'Hello, "World"' AS x, 123 AS y, [1, 2, 3] AS z, (456, ['abc', 'def']) AS a, 'Newline\nhere' AS b FORMAT CSVWithNames diff --git a/tests/ast_json_fixtures/shapes/c146fbf7da396a3d.json b/tests/ast_json_fixtures/shapes/c146fbf7da396a3d.json new file mode 100644 index 000000000000..368e05eecdb6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c146fbf7da396a3d.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "t_lwu_deletes_3" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_throw_if_noop": "1" + } + }, + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "all" + } + }, + "final": true + } +} diff --git a/tests/ast_json_fixtures/shapes/c146fbf7da396a3d.sql b/tests/ast_json_fixtures/shapes/c146fbf7da396a3d.sql new file mode 100644 index 000000000000..354f054cfc4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c146fbf7da396a3d.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE t_lwu_deletes_3 PARTITION ID 'all' FINAL SETTINGS optimize_throw_if_noop = 1 diff --git a/tests/ast_json_fixtures/shapes/c14eb979c964901b.json b/tests/ast_json_fixtures/shapes/c14eb979c964901b.json new file mode 100644 index 000000000000..766a6917516b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c14eb979c964901b.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q2_01297_renamed"] + } +} diff --git a/tests/ast_json_fixtures/shapes/c14eb979c964901b.sql b/tests/ast_json_fixtures/shapes/c14eb979c964901b.sql new file mode 100644 index 000000000000..dc84c62514c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c14eb979c964901b.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q2_01297_renamed diff --git a/tests/ast_json_fixtures/shapes/c15dc84a3fb8ea08.json b/tests/ast_json_fixtures/shapes/c15dc84a3fb8ea08.json new file mode 100644 index 000000000000..fb44d11cf270 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c15dc84a3fb8ea08.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "lc" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "lc" + } + ] + }, + { + "type": "Identifier", + "name": "r.lc", + "name_parts": ["r", "lc"] + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "r.lc", + "name_parts": ["r", "lc"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "l", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "using": [ + { + "type": "Identifier", + "name": "lc" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "r", + "name": "nr" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c15dc84a3fb8ea08.sql b/tests/ast_json_fixtures/shapes/c15dc84a3fb8ea08.sql new file mode 100644 index 000000000000..7043bd9641f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c15dc84a3fb8ea08.sql @@ -0,0 +1 @@ +SELECT x, lc, toTypeName(lc), r.lc, toTypeName(r.lc) FROM t AS l FULL JOIN nr AS r USING (lc) ORDER BY x SETTINGS enable_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/c17627ce7c47977d.json b/tests/ast_json_fixtures/shapes/c17627ce7c47977d.json new file mode 100644 index 000000000000..b52e25ebac22 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c17627ce7c47977d.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "alter_test" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "COMMENT_COLUMN", + "if_exists": true, + "column": { + "type": "Identifier", + "name": "ToDrop" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "new comment" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c17627ce7c47977d.sql b/tests/ast_json_fixtures/shapes/c17627ce7c47977d.sql new file mode 100644 index 000000000000..5386c6dbc64d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c17627ce7c47977d.sql @@ -0,0 +1 @@ +ALTER TABLE alter_test COMMENT COLUMN IF EXISTS ToDrop 'new comment' diff --git a/tests/ast_json_fixtures/shapes/c17f639b5cd4b87a.json b/tests/ast_json_fixtures/shapes/c17f639b5cd4b87a.json new file mode 100644 index 000000000000..4c105e20c9da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c17f639b5cd4b87a.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "m", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "foo" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "bar" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "m" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c17f639b5cd4b87a.sql b/tests/ast_json_fixtures/shapes/c17f639b5cd4b87a.sql new file mode 100644 index 000000000000..7b0040f80bb2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c17f639b5cd4b87a.sql @@ -0,0 +1 @@ +WITH map('foo', 1, 'bar', 2) AS m SELECT m.* diff --git a/tests/ast_json_fixtures/shapes/c180466b68942dc6.json b/tests/ast_json_fixtures/shapes/c180466b68942dc6.json new file mode 100644 index 000000000000..5aa88c10b336 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c180466b68942dc6.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "l", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l.id", + "name_parts": ["l", "id"] + }, + { + "type": "Identifier", + "name": "r.id", + "name_parts": ["r", "id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "r", + "name": "t" + } + } + } + ] + }, + "prewhere": { + "type": "Identifier", + "name": "l.x", + "name_parts": ["l", "x"] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c180466b68942dc6.sql b/tests/ast_json_fixtures/shapes/c180466b68942dc6.sql new file mode 100644 index 000000000000..4999813b3e7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c180466b68942dc6.sql @@ -0,0 +1 @@ +select 1 from t as l join t as r on l.id = r.id prewhere l.x diff --git a/tests/ast_json_fixtures/shapes/c1864ffa965e1f81.json b/tests/ast_json_fixtures/shapes/c1864ffa965e1f81.json new file mode 100644 index 000000000000..ad64b4acee53 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1864ffa965e1f81.json @@ -0,0 +1,109 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65536" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "65536" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4294967296" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4294967296" + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 1e-10 + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1e-10 + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c1864ffa965e1f81.sql b/tests/ast_json_fixtures/shapes/c1864ffa965e1f81.sql new file mode 100644 index 000000000000..5916bd7140b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1864ffa965e1f81.sql @@ -0,0 +1 @@ +select 0x1, byteSize(0x1), 0x100, byteSize(0x100), 0x10000, byteSize(0x10000), 0x100000000, byteSize(0x100000000), 0.5, byteSize(0.5), 1e-10, byteSize(1e-10) diff --git a/tests/ast_json_fixtures/shapes/c187be73be5b4351.json b/tests/ast_json_fixtures/shapes/c187be73be5b4351.json new file mode 100644 index 000000000000..01bf9a60de3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c187be73be5b4351.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c187be73be5b4351.sql b/tests/ast_json_fixtures/shapes/c187be73be5b4351.sql new file mode 100644 index 000000000000..c0233c85f73d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c187be73be5b4351.sql @@ -0,0 +1 @@ +SELECT 1 FROM system.one LIMIT 1 BY 1 diff --git a/tests/ast_json_fixtures/shapes/c1b0b05ee0750dc8.json b/tests/ast_json_fixtures/shapes/c1b0b05ee0750dc8.json new file mode 100644 index 000000000000..162fa93e0503 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1b0b05ee0750dc8.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "value", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "String", + "value": "Value" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple (id UInt64, value String)" + } + ] + }, + { + "type": "QualifiedColumnsRegexpMatcher", + "pattern": "i", + "qualifier": { + "type": "Identifier", + "name": "value" + }, + "transformers": { + "type": "ColumnsTransformerList", + "children": [ + { + "type": "ColumnsApplyTransformer", + "func_name": "toString" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c1b0b05ee0750dc8.sql b/tests/ast_json_fixtures/shapes/c1b0b05ee0750dc8.sql new file mode 100644 index 000000000000..daa5370e0f10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1b0b05ee0750dc8.sql @@ -0,0 +1 @@ +SELECT cast((1, 'Value'), 'Tuple (id UInt64, value String)') AS value, value.COLUMNS('i') APPLY toString diff --git a/tests/ast_json_fixtures/shapes/c1c72939c41dffc6.json b/tests/ast_json_fixtures/shapes/c1c72939c41dffc6.json new file mode 100644 index 000000000000..5dbdd3041feb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1c72939c41dffc6.json @@ -0,0 +1,141 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "aid", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ], + "window_definition": { + "type": "WindowDefinition", + "frame_type": "ROWS", + "frame_begin": { + "type": "Offset", + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "preceding": true + }, + "frame_end": { + "type": "Unbounded" + } + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ], + "window_definition": { + "type": "WindowDefinition" + } + }, + { + "type": "Function", + "alias": "id", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/c1c72939c41dffc6.sql b/tests/ast_json_fixtures/shapes/c1c72939c41dffc6.sql new file mode 100644 index 000000000000..80ef75ed204a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1c72939c41dffc6.sql @@ -0,0 +1,13 @@ +SELECT + NULL, + id, + max(id) OVER (Rows BETWEEN 10 PRECEDING AND UNBOUNDED FOLLOWING) AS aid +FROM +( + SELECT + NULL, + max(id) OVER (), + materialize(toLowCardinality('')) AS id + FROM numbers_mt(0, 1) +) +FORMAT `Null` diff --git a/tests/ast_json_fixtures/shapes/c1d15d82a18c1583.json b/tests/ast_json_fixtures/shapes/c1d15d82a18c1583.json new file mode 100644 index 000000000000..40a1844b84cf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1d15d82a18c1583.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "c", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "10" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c1d15d82a18c1583.sql b/tests/ast_json_fixtures/shapes/c1d15d82a18c1583.sql new file mode 100644 index 000000000000..0e316e8d3242 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1d15d82a18c1583.sql @@ -0,0 +1 @@ +create table t (a String, b String, c String, d String) order by (a, b, c, d) settings index_granularity=10 diff --git a/tests/ast_json_fixtures/shapes/c1d3bce04a646bd5.json b/tests/ast_json_fixtures/shapes/c1d3bce04a646bd5.json new file mode 100644 index 000000000000..8d0cafa8ea64 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1d3bce04a646bd5.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03403_data" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1024", + "max_streams_to_max_threads_ratio": "10000000" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/c1d3bce04a646bd5.sql b/tests/ast_json_fixtures/shapes/c1d3bce04a646bd5.sql new file mode 100644 index 000000000000..6ab18c9510b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1d3bce04a646bd5.sql @@ -0,0 +1,6 @@ +SELECT * +FROM 03403_data +ORDER BY id +FORMAT Null +SETTINGS max_threads = 1024, + max_streams_to_max_threads_ratio = 10000000 diff --git a/tests/ast_json_fixtures/shapes/c1ecd66ddc929f10.json b/tests/ast_json_fixtures/shapes/c1ecd66ddc929f10.json new file mode 100644 index 000000000000..0b5f3e97161d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1ecd66ddc929f10.json @@ -0,0 +1,114 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "category" + }, + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Function", + "alias": "rn", + "name": "row_number", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "category" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value" + }, + "direction": "ASC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_all" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "category" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "rn" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c1ecd66ddc929f10.sql b/tests/ast_json_fixtures/shapes/c1ecd66ddc929f10.sql new file mode 100644 index 000000000000..ba1fb50b4c71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1ecd66ddc929f10.sql @@ -0,0 +1,4 @@ +SELECT id, category, value, row_number() OVER (PARTITION BY category ORDER BY value) AS rn +FROM test_limit_by_all +ORDER BY id, category, value, rn +LIMIT 1 BY ALL LIMIT 3 diff --git a/tests/ast_json_fixtures/shapes/c1f4b67ac13333bb.json b/tests/ast_json_fixtures/shapes/c1f4b67ac13333bb.json new file mode 100644 index 000000000000..e5cc7ca637e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1f4b67ac13333bb.json @@ -0,0 +1,110 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Function", + "name": "splitByChar", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "*" + }, + { + "type": "Identifier", + "name": "data_path" + } + ] + } + ] + }, + { + "type": "Function", + "name": "replaceRegexpOne", + "arguments": [ + { + "type": "Identifier", + "name": "data_path" + }, + { + "type": "Literal", + "value_type": "String", + "value": "^.*\/([^\/]*)\/" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\\1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "distribution_queue", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "dist_01555" + } + ] + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/c1f4b67ac13333bb.sql b/tests/ast_json_fixtures/shapes/c1f4b67ac13333bb.sql new file mode 100644 index 000000000000..dc4576e8a5b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1f4b67ac13333bb.sql @@ -0,0 +1 @@ +select length(splitByChar('*', data_path)), replaceRegexpOne(data_path, '^.*/([^/]*)/' , '\\1') from system.distribution_queue where database = currentDatabase() and table = 'dist_01555' format CSV diff --git a/tests/ast_json_fixtures/shapes/c1fa245f5e356bb5.json b/tests/ast_json_fixtures/shapes/c1fa245f5e356bb5.json new file mode 100644 index 000000000000..64c7bc2fae96 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1fa245f5e356bb5.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "name" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_optimize_projection_name": "projection_name" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c1fa245f5e356bb5.sql b/tests/ast_json_fixtures/shapes/c1fa245f5e356bb5.sql new file mode 100644 index 000000000000..be22da7e8e1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c1fa245f5e356bb5.sql @@ -0,0 +1 @@ +SELECT name FROM test GROUP BY name SETTINGS force_optimize_projection_name='projection_name' diff --git a/tests/ast_json_fixtures/shapes/c215506d4a6808ff.json b/tests/ast_json_fixtures/shapes/c215506d4a6808ff.json new file mode 100644 index 000000000000..ab14fce9b0ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c215506d4a6808ff.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "i1", + "expression": { + "type": "Identifier", + "name": "key" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "foo" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c215506d4a6808ff.sql b/tests/ast_json_fixtures/shapes/c215506d4a6808ff.sql new file mode 100644 index 000000000000..9ed4e74a0286 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c215506d4a6808ff.sql @@ -0,0 +1 @@ +CREATE TABLE dist (key int, INDEX i1 key TYPE minmax GRANULARITY 1) Engine=Distributed(test_shard_localhost, currentDatabase(), 'foo') diff --git a/tests/ast_json_fixtures/shapes/c22be5e75450344b.json b/tests/ast_json_fixtures/shapes/c22be5e75450344b.json new file mode 100644 index 000000000000..fa411011ea68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c22be5e75450344b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q5_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/c22be5e75450344b.sql b/tests/ast_json_fixtures/shapes/c22be5e75450344b.sql new file mode 100644 index 000000000000..c115d0026854 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c22be5e75450344b.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q5_01297 diff --git a/tests/ast_json_fixtures/shapes/c2325339094d0ed8.json b/tests/ast_json_fixtures/shapes/c2325339094d0ed8.json new file mode 100644 index 000000000000..a40531b8d8ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2325339094d0ed8.json @@ -0,0 +1,293 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "t", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1970-06-17 07:39:21" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Africa\/Monrovia" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "toUnixTimestamp", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + { + "type": "Function", + "name": "timeZoneOffset", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + { + "type": "Function", + "name": "formatDateTime", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%F %T" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Africa\/Monrovia" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Africa\/Monrovia" + } + ] + }, + { + "type": "Function", + "name": "toStartOfMinute", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + { + "type": "Function", + "name": "toStartOfFiveMinutes", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + { + "type": "Function", + "name": "toStartOfFifteenMinutes", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + { + "type": "Function", + "name": "toStartOfTenMinutes", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + { + "type": "Function", + "name": "toStartOfHour", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + { + "type": "Function", + "name": "toStartOfDay", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + { + "type": "Function", + "name": "toStartOfWeek", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + }, + { + "type": "Function", + "name": "toStartOfInterval", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Function", + "name": "toIntervalSecond", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toStartOfInterval", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Function", + "name": "toIntervalMinute", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toStartOfInterval", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Function", + "name": "toIntervalMinute", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toStartOfInterval", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Function", + "name": "toIntervalMinute", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toStartOfInterval", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Function", + "name": "toIntervalMinute", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + } + ] + }, + { + "type": "Function", + "name": "addMinutes", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "addMinutes", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/c2325339094d0ed8.sql b/tests/ast_json_fixtures/shapes/c2325339094d0ed8.sql new file mode 100644 index 000000000000..cbc660fe1258 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2325339094d0ed8.sql @@ -0,0 +1,20 @@ +WITH toDateTime('1970-06-17 07:39:21', 'Africa/Monrovia') as t +SELECT toUnixTimestamp(t), + timeZoneOffset(t), + formatDateTime(t, '%F %T', 'Africa/Monrovia'), + toString(t, 'Africa/Monrovia'), + toStartOfMinute(t), + toStartOfFiveMinutes(t), + toStartOfFifteenMinutes(t), + toStartOfTenMinutes(t), + toStartOfHour(t), + toStartOfDay(t), + toStartOfWeek(t), + toStartOfInterval(t, INTERVAL 1 second), + toStartOfInterval(t, INTERVAL 1 minute), + toStartOfInterval(t, INTERVAL 2 minute), + toStartOfInterval(t, INTERVAL 5 minute), + toStartOfInterval(t, INTERVAL 60 minute), + addMinutes(t, 1), + addMinutes(t, 60) +FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/c2447cd17d7e8224.json b/tests/ast_json_fixtures/shapes/c2447cd17d7e8224.json new file mode 100644 index 000000000000..c958573a2c0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2447cd17d7e8224.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_database": "test_01109_ordinary", + "from_table": "t4", + "to_database": "test_01109_ordinary", + "to_table": "t4" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c2447cd17d7e8224.sql b/tests/ast_json_fixtures/shapes/c2447cd17d7e8224.sql new file mode 100644 index 000000000000..9f8f8105ff1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2447cd17d7e8224.sql @@ -0,0 +1 @@ +EXCHANGE TABLES test_01109_ordinary.t4 AND test_01109_ordinary.t4 diff --git a/tests/ast_json_fixtures/shapes/c26146b6b2a7b270.json b/tests/ast_json_fixtures/shapes/c26146b6b2a7b270.json new file mode 100644 index 000000000000..4821de9cfc67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c26146b6b2a7b270.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ], + "select": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c26146b6b2a7b270.sql b/tests/ast_json_fixtures/shapes/c26146b6b2a7b270.sql new file mode 100644 index 000000000000..ea6b33114620 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c26146b6b2a7b270.sql @@ -0,0 +1 @@ +WITH 1 as a SELECT a diff --git a/tests/ast_json_fixtures/shapes/c2645f682e2de105.json b/tests/ast_json_fixtures/shapes/c2645f682e2de105.json new file mode 100644 index 000000000000..ea46bb582d95 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2645f682e2de105.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "numbers2" + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + "sample_by": { + "type": "Function", + "name": "intHash32", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c2645f682e2de105.sql b/tests/ast_json_fixtures/shapes/c2645f682e2de105.sql new file mode 100644 index 000000000000..999a6f432fa4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2645f682e2de105.sql @@ -0,0 +1 @@ +CREATE TABLE numbers2 ORDER BY intHash32(number) SAMPLE BY intHash32(number) AS SELECT number FROM numbers(10) diff --git a/tests/ast_json_fixtures/shapes/c276e6f0883e1b6b.json b/tests/ast_json_fixtures/shapes/c276e6f0883e1b6b.json new file mode 100644 index 000000000000..1a7c29f6cb19 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c276e6f0883e1b6b.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c276e6f0883e1b6b.sql b/tests/ast_json_fixtures/shapes/c276e6f0883e1b6b.sql new file mode 100644 index 000000000000..9c147abd3a1d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c276e6f0883e1b6b.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number, 1 diff --git a/tests/ast_json_fixtures/shapes/c281af5b56fbd468.json b/tests/ast_json_fixtures/shapes/c281af5b56fbd468.json new file mode 100644 index 000000000000..3cf4091adf34 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c281af5b56fbd468.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q5_01297"], + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01297", "u1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c281af5b56fbd468.sql b/tests/ast_json_fixtures/shapes/c281af5b56fbd468.sql new file mode 100644 index 000000000000..a76eff792fcd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c281af5b56fbd468.sql @@ -0,0 +1 @@ +CREATE QUOTA q5_01297 TO r1_01297, u1_01297 diff --git a/tests/ast_json_fixtures/shapes/c281afded3804f0b.json b/tests/ast_json_fixtures/shapes/c281afded3804f0b.json new file mode 100644 index 000000000000..f790a9d167a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c281afded3804f0b.json @@ -0,0 +1,296 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "query_id_", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "query_id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Settings" + }, + { + "type": "Literal", + "value_type": "String", + "value": "log_processors_profiles" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Function", + "alias": "elapsed", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "ExpressionTransform" + } + ] + }, + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "elapsed_us" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 900000 + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "elapsed_us" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "SourceFromSingleChunk" + } + ] + }, + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "output_wait_elapsed_us" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 900000 + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "output_wait_elapsed_us" + } + ] + }, + { + "type": "Function", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "input_wait_elapsed_us" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 1000000 + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "input_wait_elapsed_us" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "input_rows" + }, + { + "type": "Identifier", + "name": "input_bytes" + }, + { + "type": "Identifier", + "name": "output_rows" + }, + { + "type": "Identifier", + "name": "output_bytes" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "processors_profile_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Identifier", + "name": "query_id_" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c281afded3804f0b.sql b/tests/ast_json_fixtures/shapes/c281afded3804f0b.sql new file mode 100644 index 000000000000..0190c8bec141 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c281afded3804f0b.sql @@ -0,0 +1,28 @@ +WITH + ( + SELECT query_id + FROM system.query_log + WHERE current_database = currentDatabase() AND Settings['log_processors_profiles']='1' + ) AS query_id_ +SELECT + name, + multiIf( + + + + + name = 'ExpressionTransform', elapsed_us >= 0.9e6 ? 1 : elapsed_us, + + + name = 'SourceFromSingleChunk', output_wait_elapsed_us >= 0.9e6 ? 1 : output_wait_elapsed_us, + + + input_wait_elapsed_us>=1e6 ? 1 : input_wait_elapsed_us) + elapsed, + input_rows, + input_bytes, + output_rows, + output_bytes +FROM system.processors_profile_log +WHERE query_id = query_id_ +ORDER BY name diff --git a/tests/ast_json_fixtures/shapes/c28304073b3ba939.json b/tests/ast_json_fixtures/shapes/c28304073b3ba939.json new file mode 100644 index 000000000000..0a7088992a85 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c28304073b3ba939.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "v" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "prewhere": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c28304073b3ba939.sql b/tests/ast_json_fixtures/shapes/c28304073b3ba939.sql new file mode 100644 index 000000000000..c39b4d9819e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c28304073b3ba939.sql @@ -0,0 +1 @@ +select v from test prewhere 1 diff --git a/tests/ast_json_fixtures/shapes/c289520ee705ca7a.json b/tests/ast_json_fixtures/shapes/c289520ee705ca7a.json new file mode 100644 index 000000000000..4c49b2242cfc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c289520ee705ca7a.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["SET DEFINER"], + "parameter": "test_user_03593_1" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_03593"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c289520ee705ca7a.sql b/tests/ast_json_fixtures/shapes/c289520ee705ca7a.sql new file mode 100644 index 000000000000..9eba24371f28 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c289520ee705ca7a.sql @@ -0,0 +1 @@ +GRANT SET DEFINER ON test_user_03593_1 TO test_user_03593 diff --git a/tests/ast_json_fixtures/shapes/c28ae3a9546dbd15.json b/tests/ast_json_fixtures/shapes/c28ae3a9546dbd15.json new file mode 100644 index 000000000000..35210b0d8c0c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c28ae3a9546dbd15.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "dictionary": true, + "elements": [ + { + "from_database": "dummy_db", + "from_table": "dict1", + "to_database": "test_01191", + "to_table": "dict" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c28ae3a9546dbd15.sql b/tests/ast_json_fixtures/shapes/c28ae3a9546dbd15.sql new file mode 100644 index 000000000000..26398a17725d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c28ae3a9546dbd15.sql @@ -0,0 +1 @@ +RENAME DICTIONARY dummy_db.dict1 TO test_01191.dict diff --git a/tests/ast_json_fixtures/shapes/c2997f88223c7173.json b/tests/ast_json_fixtures/shapes/c2997f88223c7173.json new file mode 100644 index 000000000000..fc2d8bea70b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2997f88223c7173.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "key", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "alias": "value", + "value_type": "String", + "value": "b" + } + ], + "group_by": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c2997f88223c7173.sql b/tests/ast_json_fixtures/shapes/c2997f88223c7173.sql new file mode 100644 index 000000000000..d6c86cb6427f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2997f88223c7173.sql @@ -0,0 +1 @@ +SELECT 'a' AS key, 'b' as value GROUP BY ignore(1) diff --git a/tests/ast_json_fixtures/shapes/c2a1ed63b517ddfe.json b/tests/ast_json_fixtures/shapes/c2a1ed63b517ddfe.json new file mode 100644 index 000000000000..472a175bf74a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2a1ed63b517ddfe.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Variant", + "arguments": [] + }, + "primary_key_specifier": true + } + ], + "primary_key_from_columns": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + } + ] + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Redis", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": ":" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c2a1ed63b517ddfe.sql b/tests/ast_json_fixtures/shapes/c2a1ed63b517ddfe.sql new file mode 100644 index 000000000000..3d4f72d9d53d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2a1ed63b517ddfe.sql @@ -0,0 +1 @@ +CREATE TABLE t0 (c0 Variant() PRIMARY KEY) ENGINE = Redis(':', 0, '') diff --git a/tests/ast_json_fixtures/shapes/c2b9bf2a6dba9f3c.json b/tests/ast_json_fixtures/shapes/c2b9bf2a6dba9f3c.json new file mode 100644 index 000000000000..78c0f022b6f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2b9bf2a6dba9f3c.json @@ -0,0 +1,135 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "3" + }, + { + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Function", + "name": "toUInt8", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c2b9bf2a6dba9f3c.sql b/tests/ast_json_fixtures/shapes/c2b9bf2a6dba9f3c.sql new file mode 100644 index 000000000000..77bfae9e884c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2b9bf2a6dba9f3c.sql @@ -0,0 +1 @@ +SELECT 1 AS x, x, (SELECT 2 AS x, x) FROM remote('127.0.0.{2,3}', system.one) WHERE (3, 4) IN (SELECT 3 AS x, toUInt8(x + 1)) diff --git a/tests/ast_json_fixtures/shapes/c2bc2efb14eba046.json b/tests/ast_json_fixtures/shapes/c2bc2efb14eba046.json new file mode 100644 index 000000000000..03f061182204 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2bc2efb14eba046.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "01856_test_function_2" + } +} diff --git a/tests/ast_json_fixtures/shapes/c2bc2efb14eba046.sql b/tests/ast_json_fixtures/shapes/c2bc2efb14eba046.sql new file mode 100644 index 000000000000..07c8a46dc1a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2bc2efb14eba046.sql @@ -0,0 +1 @@ +DROP FUNCTION 01856_test_function_2 diff --git a/tests/ast_json_fixtures/shapes/c2d704ce1436d33b.json b/tests/ast_json_fixtures/shapes/c2d704ce1436d33b.json new file mode 100644 index 000000000000..2d070cb680be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2d704ce1436d33b.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tp_1" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PROJECTION", + "clear_projection": true, + "projection": { + "type": "Identifier", + "name": "pp" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c2d704ce1436d33b.sql b/tests/ast_json_fixtures/shapes/c2d704ce1436d33b.sql new file mode 100644 index 000000000000..3913b60b530e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2d704ce1436d33b.sql @@ -0,0 +1 @@ +alter table tp_1 clear projection pp diff --git a/tests/ast_json_fixtures/shapes/c2f5f4a58e926624.json b/tests/ast_json_fixtures/shapes/c2f5f4a58e926624.json new file mode 100644 index 000000000000..e18856370ba8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2f5f4a58e926624.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "URL" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits_s3", + "database": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "URL" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c2f5f4a58e926624.sql b/tests/ast_json_fixtures/shapes/c2f5f4a58e926624.sql new file mode 100644 index 000000000000..382770e828fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c2f5f4a58e926624.sql @@ -0,0 +1 @@ +SELECT 1, URL, count() AS c FROM test.hits_s3 GROUP BY 1, URL ORDER BY c DESC LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/c3260cb353e6d22f.json b/tests/ast_json_fixtures/shapes/c3260cb353e6d22f.json new file mode 100644 index 000000000000..260ddc8d8725 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3260cb353e6d22f.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "text_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c3260cb353e6d22f.sql b/tests/ast_json_fixtures/shapes/c3260cb353e6d22f.sql new file mode 100644 index 000000000000..ee5c3aa43c23 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3260cb353e6d22f.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS text_log diff --git a/tests/ast_json_fixtures/shapes/c33933974e75bf83.json b/tests/ast_json_fixtures/shapes/c33933974e75bf83.json new file mode 100644 index 000000000000..6db85cce540a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c33933974e75bf83.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + }, + "as_table": "x" + } +} diff --git a/tests/ast_json_fixtures/shapes/c33933974e75bf83.sql b/tests/ast_json_fixtures/shapes/c33933974e75bf83.sql new file mode 100644 index 000000000000..dcaa50dd1ad2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c33933974e75bf83.sql @@ -0,0 +1 @@ +CREATE TABLE x_dist as x ENGINE = Distributed('test_cluster_two_shards', currentDatabase(), x) diff --git a/tests/ast_json_fixtures/shapes/c353dabbf43e84df.json b/tests/ast_json_fixtures/shapes/c353dabbf43e84df.json new file mode 100644 index 000000000000..3caf013e392e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c353dabbf43e84df.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "query_views_log" + }, + { + "table": "query_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c353dabbf43e84df.sql b/tests/ast_json_fixtures/shapes/c353dabbf43e84df.sql new file mode 100644 index 000000000000..7f9777e1d9e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c353dabbf43e84df.sql @@ -0,0 +1 @@ +system flush logs query_views_log, query_log diff --git a/tests/ast_json_fixtures/shapes/c3a9d545c5a7ba5a.json b/tests/ast_json_fixtures/shapes/c3a9d545c5a7ba5a.json new file mode 100644 index 000000000000..30e41e522ff6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3a9d545c5a7ba5a.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t1_all" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards_localhost" + }, + { + "type": "Identifier", + "name": "test_02115" + }, + { + "type": "Identifier", + "name": "t1_local" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "t1_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/c3a9d545c5a7ba5a.sql b/tests/ast_json_fixtures/shapes/c3a9d545c5a7ba5a.sql new file mode 100644 index 000000000000..f137ff96aa29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3a9d545c5a7ba5a.sql @@ -0,0 +1 @@ +create table t1_all as t1_local engine Distributed(test_cluster_two_shards_localhost, test_02115, t1_local, rand()) diff --git a/tests/ast_json_fixtures/shapes/c3c4ca6fcbe67a17.json b/tests/ast_json_fixtures/shapes/c3c4ca6fcbe67a17.json new file mode 100644 index 000000000000..73ddaf40b9f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3c4ca6fcbe67a17.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "map_test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "tags", + "data_type": { + "type": "DataType", + "name": "Map", + "arguments": [ + { + "type": "DataType", + "name": "String" + }, + { + "type": "DataType", + "name": "String" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "tags" + }, + "order_by": { + "type": "Identifier", + "name": "tags" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c3c4ca6fcbe67a17.sql b/tests/ast_json_fixtures/shapes/c3c4ca6fcbe67a17.sql new file mode 100644 index 000000000000..75e8d49fafac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3c4ca6fcbe67a17.sql @@ -0,0 +1 @@ +CREATE TABLE map_test(`tags` Map(String, String)) ENGINE = MergeTree PRIMARY KEY tags ORDER BY tags SETTINGS index_granularity = 8192 diff --git a/tests/ast_json_fixtures/shapes/c3e66a9c31f9ed0e.json b/tests/ast_json_fixtures/shapes/c3e66a9c31f9ed0e.json new file mode 100644 index 000000000000..e1d0e9ca95c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3e66a9c31f9ed0e.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["READ"], + "parameter": "S3" + }, + { + "access_types": ["WRITE"], + "parameter": "S3" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_03593"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c3e66a9c31f9ed0e.sql b/tests/ast_json_fixtures/shapes/c3e66a9c31f9ed0e.sql new file mode 100644 index 000000000000..4298dc58267b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3e66a9c31f9ed0e.sql @@ -0,0 +1 @@ +GRANT READ,WRITE ON S3 TO test_user_03593 diff --git a/tests/ast_json_fixtures/shapes/c3eb264f4c581eb6.json b/tests/ast_json_fixtures/shapes/c3eb264f4c581eb6.json new file mode 100644 index 000000000000..3b9bd00ffead --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3eb264f4c581eb6.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "minmax_compact" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_INDEX", + "clear_index": true, + "index": { + "type": "Identifier", + "name": "idx" + }, + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c3eb264f4c581eb6.sql b/tests/ast_json_fixtures/shapes/c3eb264f4c581eb6.sql new file mode 100644 index 000000000000..ad4b4dd29a07 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3eb264f4c581eb6.sql @@ -0,0 +1 @@ +ALTER TABLE minmax_compact CLEAR INDEX idx IN PARTITION 1 diff --git a/tests/ast_json_fixtures/shapes/c3eea227d5f578f1.json b/tests/ast_json_fixtures/shapes/c3eea227d5f578f1.json new file mode 100644 index 000000000000..bbad9ad48584 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3eea227d5f578f1.json @@ -0,0 +1,134 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "limit w\/ GROUP BY" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.{1,2}" + }, + { + "type": "Function", + "name": "view", + "arguments": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "number", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "count", + "arguments": [] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "DESC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "limit": "2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c3eea227d5f578f1.sql b/tests/ast_json_fixtures/shapes/c3eea227d5f578f1.sql new file mode 100644 index 000000000000..9380021f0f20 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3eea227d5f578f1.sql @@ -0,0 +1,13 @@ +SELECT + 'limit w/ GROUP BY', + count(), + number +FROM remote('127.{1,2}', view( + SELECT intDiv(number, 2) AS number + FROM numbers(10) +)) +GROUP BY number +ORDER BY + count() ASC, + number DESC +SETTINGS limit=2 diff --git a/tests/ast_json_fixtures/shapes/c3ff7c78d4697ae9.json b/tests/ast_json_fixtures/shapes/c3ff7c78d4697ae9.json new file mode 100644 index 000000000000..925c21a28753 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3ff7c78d4697ae9.json @@ -0,0 +1,143 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "X", + "name": "arraySort", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ttt01746" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2021-03-03" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c3ff7c78d4697ae9.sql b/tests/ast_json_fixtures/shapes/c3ff7c78d4697ae9.sql new file mode 100644 index 000000000000..8c27e7564193 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c3ff7c78d4697ae9.sql @@ -0,0 +1 @@ +SELECT arraySort(x -> x.2, [tuple('a', 10)]) AS X FROM ttt01746 PREWHERE d >= toDate('2021-03-03') - 2 ORDER BY n LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/c417db0dd5aff313.json b/tests/ast_json_fixtures/shapes/c417db0dd5aff313.json new file mode 100644 index 000000000000..bedb8c825c39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c417db0dd5aff313.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "copy_without_comment" + }, + "as_table": "base" + } +} diff --git a/tests/ast_json_fixtures/shapes/c417db0dd5aff313.sql b/tests/ast_json_fixtures/shapes/c417db0dd5aff313.sql new file mode 100644 index 000000000000..a20090be257c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c417db0dd5aff313.sql @@ -0,0 +1 @@ +CREATE TABLE copy_without_comment AS base diff --git a/tests/ast_json_fixtures/shapes/c429be0ceb22fc0b.json b/tests/ast_json_fixtures/shapes/c429be0ceb22fc0b.json new file mode 100644 index 000000000000..72c6244eb082 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c429be0ceb22fc0b.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "intersect" + }, + { + "type": "Function", + "name": "countSubstringsCaseInsensitiveUTF8", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "char", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "repeat", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "я" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "яЯ" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65" + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/c429be0ceb22fc0b.sql b/tests/ast_json_fixtures/shapes/c429be0ceb22fc0b.sql new file mode 100644 index 000000000000..b62568fa4b4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c429be0ceb22fc0b.sql @@ -0,0 +1 @@ +select 'intersect', countSubstringsCaseInsensitiveUTF8(concat(char(number), repeat('я', 8)), 'яЯ') from numbers(100) where number = 0x41 format CSV diff --git a/tests/ast_json_fixtures/shapes/c43aa586031aeb63.json b/tests/ast_json_fixtures/shapes/c43aa586031aeb63.json new file mode 100644 index 000000000000..f7761f60754b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c43aa586031aeb63.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "DISABLE FAILPOINT", + "fail_point_name": "replicated_commit_zk_fail_after_op" + } +} diff --git a/tests/ast_json_fixtures/shapes/c43aa586031aeb63.sql b/tests/ast_json_fixtures/shapes/c43aa586031aeb63.sql new file mode 100644 index 000000000000..815f1f50bf1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c43aa586031aeb63.sql @@ -0,0 +1 @@ +system disable failpoint replicated_commit_zk_fail_after_op diff --git a/tests/ast_json_fixtures/shapes/c43baa5ef2856470.json b/tests/ast_json_fixtures/shapes/c43baa5ef2856470.json new file mode 100644 index 000000000000..d0f287ba8ccf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c43baa5ef2856470.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "� �" + } + ] + } + ], + "format": "JSONCompactEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/c43baa5ef2856470.sql b/tests/ast_json_fixtures/shapes/c43baa5ef2856470.sql new file mode 100644 index 000000000000..33b5895e1447 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c43baa5ef2856470.sql @@ -0,0 +1 @@ +SELECT '\xED\x20\xA8' AS s FORMAT JSONCompactEachRow diff --git a/tests/ast_json_fixtures/shapes/c4561a64d78cef97.json b/tests/ast_json_fixtures/shapes/c4561a64d78cef97.json new file mode 100644 index 000000000000..f11a73e47bda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4561a64d78cef97.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "CreateWorkloadQuery", + "workload_name": { + "type": "Identifier", + "name": "another_root" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c4561a64d78cef97.sql b/tests/ast_json_fixtures/shapes/c4561a64d78cef97.sql new file mode 100644 index 000000000000..c4194b5d211d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4561a64d78cef97.sql @@ -0,0 +1 @@ +create workload another_root diff --git a/tests/ast_json_fixtures/shapes/c47f5e2ed56c5fbf.json b/tests/ast_json_fixtures/shapes/c47f5e2ed56c5fbf.json new file mode 100644 index 000000000000..167648b544b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c47f5e2ed56c5fbf.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "j", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "x", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "j" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "i" + }, + "order_by": { + "type": "Identifier", + "name": "i" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c47f5e2ed56c5fbf.sql b/tests/ast_json_fixtures/shapes/c47f5e2ed56c5fbf.sql new file mode 100644 index 000000000000..5d80506515ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c47f5e2ed56c5fbf.sql @@ -0,0 +1 @@ +create table t (i int, j int, projection x (select * order by j)) engine MergeTree partition by i order by i diff --git a/tests/ast_json_fixtures/shapes/c487cace43cd06cb.json b/tests/ast_json_fixtures/shapes/c487cace43cd06cb.json new file mode 100644 index 000000000000..7bb0acee13fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c487cace43cd06cb.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR UNCOMPRESSED CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/c487cace43cd06cb.sql b/tests/ast_json_fixtures/shapes/c487cace43cd06cb.sql new file mode 100644 index 000000000000..7c4467f08d49 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c487cace43cd06cb.sql @@ -0,0 +1 @@ +SYSTEM CLEAR UNCOMPRESSED CACHE diff --git a/tests/ast_json_fixtures/shapes/c493cfdb962e674a.json b/tests/ast_json_fixtures/shapes/c493cfdb962e674a.json new file mode 100644 index 000000000000..4d12f62001cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c493cfdb962e674a.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "metric_log" + }, + { + "table": "trace_log" + }, + { + "table": "query_log" + }, + { + "table": "query_thread_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c493cfdb962e674a.sql b/tests/ast_json_fixtures/shapes/c493cfdb962e674a.sql new file mode 100644 index 000000000000..16f65909eeb4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c493cfdb962e674a.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS metric_log, trace_log, query_log, query_thread_log diff --git a/tests/ast_json_fixtures/shapes/c49b289feaaea968.json b/tests/ast_json_fixtures/shapes/c49b289feaaea968.json new file mode 100644 index 000000000000..6c24b38aad86 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c49b289feaaea968.json @@ -0,0 +1,95 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "subdepartment", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "department" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "A" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "subdepartment" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "name" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c49b289feaaea968.sql b/tests/ast_json_fixtures/shapes/c49b289feaaea968.sql new file mode 100644 index 000000000000..a92dc67e80cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c49b289feaaea968.sql @@ -0,0 +1,6 @@ +WITH RECURSIVE subdepartment AS +( + + SELECT * FROM department WHERE name = 'A' +) +SELECT * FROM subdepartment ORDER BY name diff --git a/tests/ast_json_fixtures/shapes/c4b548a93234014a.json b/tests/ast_json_fixtures/shapes/c4b548a93234014a.json new file mode 100644 index 000000000000..69dbc044f126 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4b548a93234014a.json @@ -0,0 +1,126 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "map1", + "data_type": { + "type": "DataType", + "name": "Map", + "arguments": [ + { + "type": "DataType", + "name": "String" + }, + { + "type": "DataType", + "name": "String" + } + ] + } + }, + { + "type": "ColumnDeclaration", + "name": "map2", + "data_type": { + "type": "DataType", + "name": "Map", + "arguments": [ + { + "type": "DataType", + "name": "String" + }, + { + "type": "DataType", + "name": "String" + } + ] + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx_map1_key", + "expression": { + "type": "Function", + "name": "mapKeys", + "arguments": [ + { + "type": "Identifier", + "name": "map1" + } + ] + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + } + ] + }, + "granularity": 1 + }, + { + "type": "Index", + "name": "idx_map2_key", + "expression": { + "type": "Function", + "name": "mapKeys", + "arguments": [ + { + "type": "Identifier", + "name": "map2" + } + ] + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + } + ] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "id" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c4b548a93234014a.sql b/tests/ast_json_fixtures/shapes/c4b548a93234014a.sql new file mode 100644 index 000000000000..ce4805f5b23c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4b548a93234014a.sql @@ -0,0 +1,10 @@ +CREATE TABLE tab +( + id UInt32, + map1 Map(String, String), + map2 Map(String, String), + INDEX idx_map1_key mapKeys(map1) TYPE bloom_filter(0.01) GRANULARITY 1, + INDEX idx_map2_key mapKeys(map2) TYPE bloom_filter(0.01) GRANULARITY 1 +) +ENGINE = MergeTree +PRIMARY KEY(id) diff --git a/tests/ast_json_fixtures/shapes/c4c9cf3e514c4dee.json b/tests/ast_json_fixtures/shapes/c4c9cf3e514c4dee.json new file mode 100644 index 000000000000..fa86d7b595f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4c9cf3e514c4dee.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c4c9cf3e514c4dee.sql b/tests/ast_json_fixtures/shapes/c4c9cf3e514c4dee.sql new file mode 100644 index 000000000000..2a282779f1f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4c9cf3e514c4dee.sql @@ -0,0 +1 @@ +SELECT x, (SELECT 1 AS x) diff --git a/tests/ast_json_fixtures/shapes/c4d36d8f969ac176.json b/tests/ast_json_fixtures/shapes/c4d36d8f969ac176.json new file mode 100644 index 000000000000..864677fa75bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4d36d8f969ac176.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + }, + { + "type": "ColumnDeclaration", + "name": "z", + "data_type": { + "type": "DataType", + "name": "String" + }, + "default_specifier": "DEFAULT", + "default_expression": { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "partition_by": { + "type": "Identifier", + "name": "x" + }, + "order_by": { + "type": "Identifier", + "name": "x" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c4d36d8f969ac176.sql b/tests/ast_json_fixtures/shapes/c4d36d8f969ac176.sql new file mode 100644 index 000000000000..b81ea334073b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4d36d8f969ac176.sql @@ -0,0 +1 @@ +CREATE TABLE test (x UInt8, y UInt8, z String DEFAULT toString(x)) PARTITION BY x ORDER BY x diff --git a/tests/ast_json_fixtures/shapes/c4dde7d4ce812daf.json b/tests/ast_json_fixtures/shapes/c4dde7d4ce812daf.json new file mode 100644 index 000000000000..2b9125a20632 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4dde7d4ce812daf.json @@ -0,0 +1,140 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Identifier", + "name": "e" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "e" + } + ] + }, + { + "type": "Identifier", + "name": "f" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "f" + } + ] + }, + { + "type": "Identifier", + "name": "g" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "g" + } + ] + }, + { + "type": "Identifier", + "name": "h" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "h" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c4dde7d4ce812daf.sql b/tests/ast_json_fixtures/shapes/c4dde7d4ce812daf.sql new file mode 100644 index 000000000000..97be01a7d741 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4dde7d4ce812daf.sql @@ -0,0 +1 @@ +SELECT a, toTypeName(a), b, toTypeName(b), c, toTypeName(c), d, toTypeName(d), e, toTypeName(e), f, toTypeName(f), g, toTypeName(g), h, toTypeName(h) FROM test diff --git a/tests/ast_json_fixtures/shapes/c4f5e050ca1c4c3f.json b/tests/ast_json_fixtures/shapes/c4f5e050ca1c4c3f.json new file mode 100644 index 000000000000..744c004a30b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4f5e050ca1c4c3f.json @@ -0,0 +1,114 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "limit_with_ties": true, + "select": [ + { + "type": "Function", + "alias": "n", + "name": "toFloat32", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "source", + "value_type": "String", + "value": "original" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC", + "with_fill": true, + "fill_step": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c4f5e050ca1c4c3f.sql b/tests/ast_json_fixtures/shapes/c4f5e050ca1c4c3f.sql new file mode 100644 index 000000000000..84612dd3741a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c4f5e050ca1c4c3f.sql @@ -0,0 +1,7 @@ +SELECT + toFloat32(number % 10) AS n, + 'original' AS source +FROM numbers(10) +WHERE (number % 3) = 1 +ORDER BY n ASC WITH FILL STEP 1 +LIMIT 2 WITH TIES diff --git a/tests/ast_json_fixtures/shapes/c54b0a3fab97d44d.json b/tests/ast_json_fixtures/shapes/c54b0a3fab97d44d.json new file mode 100644 index 000000000000..d8a5f3190eaa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c54b0a3fab97d44d.json @@ -0,0 +1,237 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "ws_wh", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "ws1.ws_order_number", + "name_parts": ["ws1", "ws_order_number"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "ws1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "ws_order_number", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "ws_warehouse_sk", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "ws2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "ws_order_number", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "ws_warehouse_sk", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ws1.ws_order_number", + "name_parts": ["ws1", "ws_order_number"] + }, + { + "type": "Identifier", + "name": "ws2.ws_order_number", + "name_parts": ["ws2", "ws_order_number"] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ws1.ws_warehouse_sk", + "name_parts": ["ws1", "ws_warehouse_sk"] + }, + { + "type": "Identifier", + "name": "ws2.ws_warehouse_sk", + "name_parts": ["ws2", "ws_warehouse_sk"] + } + ] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "name": "COUNT", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "ws1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "ws_order_number", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ws1.ws_order_number", + "name_parts": ["ws1", "ws_order_number"] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "ws_order_number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ws_wh" + } + } + } + ] + } + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "join_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c54b0a3fab97d44d.sql b/tests/ast_json_fixtures/shapes/c54b0a3fab97d44d.sql new file mode 100644 index 000000000000..89ae4994fd9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c54b0a3fab97d44d.sql @@ -0,0 +1,27 @@ +WITH ws_wh AS + ( + SELECT + ws1.ws_order_number + FROM + ( + SELECT + 1 AS ws_order_number, + 1 AS ws_warehouse_sk + ) AS ws1, + ( + SELECT + 1 AS ws_order_number, + 2 AS ws_warehouse_sk + ) AS ws2 + WHERE (ws1.ws_order_number = ws2.ws_order_number) AND (ws1.ws_warehouse_sk != ws2.ws_warehouse_sk) + ) +SELECT COUNT() +FROM +( + SELECT 1 AS ws_order_number +) AS ws1 +WHERE (ws1.ws_order_number IN ( + SELECT ws_order_number + FROM ws_wh +)) +SETTINGS join_use_nulls=1 diff --git a/tests/ast_json_fixtures/shapes/c558fb370a0de222.json b/tests/ast_json_fixtures/shapes/c558fb370a0de222.json new file mode 100644 index 000000000000..710d30c7f820 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c558fb370a0de222.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "v" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_QUERY", + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "Null", + "value": null + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "src" + } + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c558fb370a0de222.sql b/tests/ast_json_fixtures/shapes/c558fb370a0de222.sql new file mode 100644 index 000000000000..c0a367381a5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c558fb370a0de222.sql @@ -0,0 +1 @@ +alter table v modify query select NULL as x from src diff --git a/tests/ast_json_fixtures/shapes/c55bc6509b84b84b.json b/tests/ast_json_fixtures/shapes/c55bc6509b84b84b.json new file mode 100644 index 000000000000..fb52262cf8bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c55bc6509b84b84b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "nonConstF32", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/c55bc6509b84b84b.sql b/tests/ast_json_fixtures/shapes/c55bc6509b84b84b.sql new file mode 100644 index 000000000000..b82d9ce48afd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c55bc6509b84b84b.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS nonConstF32 diff --git a/tests/ast_json_fixtures/shapes/c55f23eb756e61c7.json b/tests/ast_json_fixtures/shapes/c55f23eb756e61c7.json new file mode 100644 index 000000000000..2afc40f3d1da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c55f23eb756e61c7.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "tab" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "final": true + } +} diff --git a/tests/ast_json_fixtures/shapes/c55f23eb756e61c7.sql b/tests/ast_json_fixtures/shapes/c55f23eb756e61c7.sql new file mode 100644 index 000000000000..7a89763e7310 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c55f23eb756e61c7.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE tab FINAL SETTINGS mutations_sync = 2 diff --git a/tests/ast_json_fixtures/shapes/c562286bb8c59a14.json b/tests/ast_json_fixtures/shapes/c562286bb8c59a14.json new file mode 100644 index 000000000000..556b571365ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c562286bb8c59a14.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table4" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "Int64" + } + }, + { + "type": "ColumnDeclaration", + "name": "v", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "a", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "s" + } + ] + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 3 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "v" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c562286bb8c59a14.sql b/tests/ast_json_fixtures/shapes/c562286bb8c59a14.sql new file mode 100644 index 000000000000..f53dcc1a6307 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c562286bb8c59a14.sql @@ -0,0 +1,3 @@ +CREATE TABLE table4 (id Int64, v UInt64, s String, +INDEX a (id * 2, s) TYPE minmax GRANULARITY 3 +) ENGINE = MergeTree() PARTITION BY id % 10 ORDER BY v diff --git a/tests/ast_json_fixtures/shapes/c56ddfb956093c08.json b/tests/ast_json_fixtures/shapes/c56ddfb956093c08.json new file mode 100644 index 000000000000..64d37619b7d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c56ddfb956093c08.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c56ddfb956093c08.sql b/tests/ast_json_fixtures/shapes/c56ddfb956093c08.sql new file mode 100644 index 000000000000..7134c710a044 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c56ddfb956093c08.sql @@ -0,0 +1 @@ +CREATE USER u1_01292 SETTINGS readonly=1 diff --git a/tests/ast_json_fixtures/shapes/c589eb107af1cb20.json b/tests/ast_json_fixtures/shapes/c589eb107af1cb20.json new file mode 100644 index 000000000000..1576f559cc50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c589eb107af1cb20.json @@ -0,0 +1,103 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01 00:00:00" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/c589eb107af1cb20.sql b/tests/ast_json_fixtures/shapes/c589eb107af1cb20.sql new file mode 100644 index 000000000000..699cffcda36f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c589eb107af1cb20.sql @@ -0,0 +1 @@ +SELECT number, toString(number), range(number), toDate('2000-01-01') + number, toDateTime('2000-01-01 00:00:00') + number FROM system.numbers LIMIT 10 FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/c58dc9b19e665435.json b/tests/ast_json_fixtures/shapes/c58dc9b19e665435.json new file mode 100644 index 000000000000..303f5a135d21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c58dc9b19e665435.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + ], + "format": "PrettySpaceMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/c58dc9b19e665435.sql b/tests/ast_json_fixtures/shapes/c58dc9b19e665435.sql new file mode 100644 index 000000000000..3747b21b3395 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c58dc9b19e665435.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a FORMAT PrettySpaceMonoBlock diff --git a/tests/ast_json_fixtures/shapes/c5911636ff87ea38.json b/tests/ast_json_fixtures/shapes/c5911636ff87ea38.json new file mode 100644 index 000000000000..21f4792693ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c5911636ff87ea38.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "v_test1", + "to_table": "v_test11" + }, + { + "from_table": "v_test2", + "to_table": "v_test22" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c5911636ff87ea38.sql b/tests/ast_json_fixtures/shapes/c5911636ff87ea38.sql new file mode 100644 index 000000000000..5bf09113c2a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c5911636ff87ea38.sql @@ -0,0 +1 @@ +rename table v_test1 to v_test11, v_test2 to v_test22 diff --git a/tests/ast_json_fixtures/shapes/c598bbb4b146e1a7.json b/tests/ast_json_fixtures/shapes/c598bbb4b146e1a7.json new file mode 100644 index 000000000000..51f2053bd56b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c598bbb4b146e1a7.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateDictionaryQuery", + "database": { + "type": "Identifier", + "name": "db_01018" + }, + "table": { + "type": "Identifier", + "name": "dict1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c598bbb4b146e1a7.sql b/tests/ast_json_fixtures/shapes/c598bbb4b146e1a7.sql new file mode 100644 index 000000000000..ade664d29915 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c598bbb4b146e1a7.sql @@ -0,0 +1 @@ +SHOW CREATE DICTIONARY db_01018.dict1 diff --git a/tests/ast_json_fixtures/shapes/c5bda231ae31adc8.json b/tests/ast_json_fixtures/shapes/c5bda231ae31adc8.json new file mode 100644 index 000000000000..14eb1b14cb85 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c5bda231ae31adc8.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/c5bda231ae31adc8.sql b/tests/ast_json_fixtures/shapes/c5bda231ae31adc8.sql new file mode 100644 index 000000000000..42c2bfa5365c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c5bda231ae31adc8.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/c5c8e78c99312bae.json b/tests/ast_json_fixtures/shapes/c5c8e78c99312bae.json new file mode 100644 index 000000000000..cfe49711fc4e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c5c8e78c99312bae.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "replace_table": true, + "create_or_replace": true, + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "SummingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c5c8e78c99312bae.sql b/tests/ast_json_fixtures/shapes/c5c8e78c99312bae.sql new file mode 100644 index 000000000000..364b24289ae3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c5c8e78c99312bae.sql @@ -0,0 +1 @@ +CREATE OR REPLACE TABLE t0 (c0 Int) ENGINE = SummingMergeTree() ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/c5f923bc465344f6.json b/tests/ast_json_fixtures/shapes/c5f923bc465344f6.json new file mode 100644 index 000000000000..52e99fcd5b62 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c5f923bc465344f6.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["🙈 🙉 🙊"] + } +} diff --git a/tests/ast_json_fixtures/shapes/c5f923bc465344f6.sql b/tests/ast_json_fixtures/shapes/c5f923bc465344f6.sql new file mode 100644 index 000000000000..73b9921050f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c5f923bc465344f6.sql @@ -0,0 +1 @@ +drop user if exists "🙈 🙉 🙊" diff --git a/tests/ast_json_fixtures/shapes/c60060a32231ebc0.json b/tests/ast_json_fixtures/shapes/c60060a32231ebc0.json new file mode 100644 index 000000000000..34c69944c6a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c60060a32231ebc0.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "cluster": "test_shard_localhost", + "table": { + "type": "Identifier", + "name": "test_repl" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c60060a32231ebc0.sql b/tests/ast_json_fixtures/shapes/c60060a32231ebc0.sql new file mode 100644 index 000000000000..4a056333d3b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c60060a32231ebc0.sql @@ -0,0 +1 @@ +ATTACH TABLE test_repl ON CLUSTER test_shard_localhost diff --git a/tests/ast_json_fixtures/shapes/c623f40d0e63052d.json b/tests/ast_json_fixtures/shapes/c623f40d0e63052d.json new file mode 100644 index 000000000000..b7201f81fd44 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c623f40d0e63052d.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "tmp2" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Identifier", + "name": "n" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c623f40d0e63052d.sql b/tests/ast_json_fixtures/shapes/c623f40d0e63052d.sql new file mode 100644 index 000000000000..1a3954997678 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c623f40d0e63052d.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE tmp2 (n int) ORDER BY n diff --git a/tests/ast_json_fixtures/shapes/c632abcc2bd5316c.json b/tests/ast_json_fixtures/shapes/c632abcc2bd5316c.json new file mode 100644 index 000000000000..03e8733ec47d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c632abcc2bd5316c.json @@ -0,0 +1,129 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Identifier", + "name": "type_full" + }, + { + "type": "Identifier", + "name": "granularity" + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "data_compressed_bytes" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "data_uncompressed_bytes" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "75" + } + ] + }, + { + "type": "Identifier", + "name": "marks_bytes" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data_skipping_indices", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "text" + } + ] + } + ] + } + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/c632abcc2bd5316c.sql b/tests/ast_json_fixtures/shapes/c632abcc2bd5316c.sql new file mode 100644 index 000000000000..fc3c0c9fb726 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c632abcc2bd5316c.sql @@ -0,0 +1,11 @@ +SELECT + database, + table, + name, + type, + type_full, + granularity, + data_compressed_bytes > 100, + data_uncompressed_bytes > 75, + marks_bytes +FROM system.data_skipping_indices WHERE database = currentDatabase() AND type = 'text' FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/c636672913b2798c.json b/tests/ast_json_fixtures/shapes/c636672913b2798c.json new file mode 100644 index 000000000000..2fec3b4be5b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c636672913b2798c.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "k", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "order_by": { + "type": "Identifier", + "name": "k" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "dst_" + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c636672913b2798c.sql b/tests/ast_json_fixtures/shapes/c636672913b2798c.sql new file mode 100644 index 000000000000..6f7d1d1e7d7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c636672913b2798c.sql @@ -0,0 +1 @@ +CREATE TABLE t(k String) ORDER BY k as select 'dst_'||number from numbers(10) diff --git a/tests/ast_json_fixtures/shapes/c643ca972aea8756.json b/tests/ast_json_fixtures/shapes/c643ca972aea8756.json new file mode 100644 index 000000000000..4c93b1d060c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c643ca972aea8756.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "arr1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + { + "type": "Function", + "name": "arraySlice", + "arguments": [ + { + "type": "Identifier", + "name": "arr1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "array_functions" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c643ca972aea8756.sql b/tests/ast_json_fixtures/shapes/c643ca972aea8756.sql new file mode 100644 index 000000000000..da4404e2e9ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c643ca972aea8756.sql @@ -0,0 +1 @@ +select arr1, 2, 4, arraySlice(arr1, 2, 4) from array_functions diff --git a/tests/ast_json_fixtures/shapes/c64775e85b1ecd02.json b/tests/ast_json_fixtures/shapes/c64775e85b1ecd02.json new file mode 100644 index 000000000000..a68d27b9411f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c64775e85b1ecd02.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "labels", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "name" + }, + { + "type": "Identifier", + "name": "errors.name", + "name_parts": ["errors", "name"] + } + ] + }, + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Literal", + "alias": "name", + "value_type": "String", + "value": "ch_errors_total" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "errors", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/c64775e85b1ecd02.sql b/tests/ast_json_fixtures/shapes/c64775e85b1ecd02.sql new file mode 100644 index 000000000000..75f3e84c05ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c64775e85b1ecd02.sql @@ -0,0 +1,7 @@ +SELECT + map('name', errors.name) AS labels, + value, + 'ch_errors_total' AS name +FROM system.errors +LIMIT 1 +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/c64d5a5196357c9d.json b/tests/ast_json_fixtures/shapes/c64d5a5196357c9d.json new file mode 100644 index 000000000000..62caa9cee35d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c64d5a5196357c9d.json @@ -0,0 +1,153 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "result_rows" + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "result_bytes" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "lower", + "arguments": [ + { + "type": "Identifier", + "name": "query" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "%select count() > 0 from system.settings%" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryFinish" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "query_start_time" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c64d5a5196357c9d.sql b/tests/ast_json_fixtures/shapes/c64d5a5196357c9d.sql new file mode 100644 index 000000000000..ac0880ad790a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c64d5a5196357c9d.sql @@ -0,0 +1 @@ +select result_rows, result_bytes >= 8 from system.query_log where current_database = currentDatabase() AND event_date >= today() - 1 and lower(query) like '%select count() > 0 from system.settings%' and type = 'QueryFinish' order by query_start_time desc limit 1 diff --git a/tests/ast_json_fixtures/shapes/c65779e8ec722673.json b/tests/ast_json_fixtures/shapes/c65779e8ec722673.json new file mode 100644 index 000000000000..7a0d9e23c147 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c65779e8ec722673.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "alter": true, + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p2_01295", + "database": "db", + "table": "table" + } + ] + }, + "new_short_name": "p2_01295_renamed" + } +} diff --git a/tests/ast_json_fixtures/shapes/c65779e8ec722673.sql b/tests/ast_json_fixtures/shapes/c65779e8ec722673.sql new file mode 100644 index 000000000000..f440506529b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c65779e8ec722673.sql @@ -0,0 +1 @@ +ALTER ROW POLICY p2_01295 ON db.table RENAME TO 'p2_01295_renamed' diff --git a/tests/ast_json_fixtures/shapes/c66292cb8b55cdfe.json b/tests/ast_json_fixtures/shapes/c66292cb8b55cdfe.json new file mode 100644 index 000000000000..4d7bcc2f375f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c66292cb8b55cdfe.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "udf_preprocessor" + } +} diff --git a/tests/ast_json_fixtures/shapes/c66292cb8b55cdfe.sql b/tests/ast_json_fixtures/shapes/c66292cb8b55cdfe.sql new file mode 100644 index 000000000000..271930d986ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c66292cb8b55cdfe.sql @@ -0,0 +1 @@ +DROP FUNCTION udf_preprocessor diff --git a/tests/ast_json_fixtures/shapes/c675133e40866b35.json b/tests/ast_json_fixtures/shapes/c675133e40866b35.json new file mode 100644 index 000000000000..df2e153266ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c675133e40866b35.json @@ -0,0 +1,138 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "s", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "alias": "n", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers_mt", + "database": "system" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c675133e40866b35.sql b/tests/ast_json_fixtures/shapes/c675133e40866b35.sql new file mode 100644 index 000000000000..dbb73ae156c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c675133e40866b35.sql @@ -0,0 +1 @@ +SELECT concat(toString(number % 256 AS n), '') AS s, n, max(s) FROM system.numbers_mt GROUP BY s, n, n, n, n, n, n, n, n, n ORDER BY s, n diff --git a/tests/ast_json_fixtures/shapes/c693288994970780.json b/tests/ast_json_fixtures/shapes/c693288994970780.json new file mode 100644 index 000000000000..8cd443c635fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c693288994970780.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "UpdateQuery", + "table": { + "type": "Identifier", + "name": "mutation_table" + }, + "assignments": [ + { + "type": "Assignment", + "column": "dt", + "expression": { + "type": "Literal", + "value_type": "Null", + "value": null + } + } + ], + "predicate": { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c693288994970780.sql b/tests/ast_json_fixtures/shapes/c693288994970780.sql new file mode 100644 index 000000000000..1c251dbcdc82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c693288994970780.sql @@ -0,0 +1 @@ +update mutation_table set dt = null where name is not null diff --git a/tests/ast_json_fixtures/shapes/c697068070363541.json b/tests/ast_json_fixtures/shapes/c697068070363541.json new file mode 100644 index 000000000000..b8cbcab45fa3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c697068070363541.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN PIPELINE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "graph": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/c697068070363541.sql b/tests/ast_json_fixtures/shapes/c697068070363541.sql new file mode 100644 index 000000000000..e5a64c707566 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c697068070363541.sql @@ -0,0 +1 @@ +explain pipeline graph=1 select sum(1) from t1 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/c69ef70b1605406e.json b/tests/ast_json_fixtures/shapes/c69ef70b1605406e.json new file mode 100644 index 000000000000..888963872433 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c69ef70b1605406e.json @@ -0,0 +1,188 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "ty.number", + "name_parts": ["ty", "number"] + }, + { + "type": "Function", + "alias": "a", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sipHash64", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ty.number", + "name_parts": ["ty", "number"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Identifier", + "name": "tw.number", + "name_parts": ["tw", "number"] + }, + { + "type": "Function", + "alias": "b", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sipHash64", + "arguments": [ + { + "type": "Identifier", + "name": "tw.number", + "name_parts": ["tw", "number"] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "ty", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "RIGHT", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tw.number", + "name_parts": ["tw", "number"] + }, + { + "type": "Identifier", + "name": "ty.number", + "name_parts": ["ty", "number"] + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "tw", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c69ef70b1605406e.sql b/tests/ast_json_fixtures/shapes/c69ef70b1605406e.sql new file mode 100644 index 000000000000..e24bce9fc78f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c69ef70b1605406e.sql @@ -0,0 +1,6 @@ +SELECT ty.number, sipHash64(ty.number + 1) % 100 as a, tw.number, sipHash64(tw.number) % 100 as b +FROM numbers(1, 4) ty +RIGHT JOIN numbers(1, 4) tw +ON tw.number = ty.number + AND a <= b +ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/c6d7cbd18178b432.json b/tests/ast_json_fixtures/shapes/c6d7cbd18178b432.json new file mode 100644 index 000000000000..62ba5bbba397 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c6d7cbd18178b432.json @@ -0,0 +1,325 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "w", + "value_type": "UInt64", + "value": "4096" + }, + { + "type": "Literal", + "alias": "h", + "value_type": "UInt64", + "value": "4096" + }, + { + "type": "Function", + "alias": "pixels", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "w" + }, + { + "type": "Identifier", + "name": "h" + } + ] + }, + { + "type": "Function", + "alias": "num", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "coverage" + } + ] + }, + { + "type": "Function", + "alias": "idx", + "name": "intDiv", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "num" + }, + { + "type": "Function", + "name": "intDiv", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "32768" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "32768" + } + ] + }, + { + "type": "Identifier", + "name": "pixels" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "coord", + "name": "mortonDecode", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Identifier", + "name": "idx" + } + ] + }, + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "255" + }, + { + "type": "Function", + "alias": "r", + "name": "least", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "255" + }, + { + "type": "Function", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "test_name" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "g", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "255" + }, + { + "type": "Function", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "test_name" + } + ] + } + ] + }, + { + "type": "Function", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "test_name" + } + ] + } + ], + "window_definition": { + "type": "WindowDefinition" + } + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "r" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt8" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "g" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt8" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt8" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "coord" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "coord" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "w" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "coord" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "direction": "ASC", + "with_fill": true, + "fill_from": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "fill_to": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c6d7cbd18178b432.sql b/tests/ast_json_fixtures/shapes/c6d7cbd18178b432.sql new file mode 100644 index 000000000000..2495dc9461eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c6d7cbd18178b432.sql @@ -0,0 +1,13 @@ +WITH + 4096 AS w, 4096 AS h, w * h AS pixels, + arrayJoin(coverage) AS num, + num DIV (32768 * 32768 DIV pixels) AS idx, + mortonDecode(2, idx) AS coord, + 255 AS b, + least(255, uniq(test_name)) AS r, + 255 * uniq(test_name) / (max(uniq(test_name)) OVER ()) AS g +SELECT r::UInt8, g::UInt8, b::UInt8 +FROM test +GROUP BY coord +ORDER BY coord.2 * w + coord.1 +WITH FILL FROM 0 TO 10 diff --git a/tests/ast_json_fixtures/shapes/c6ec8583d1c435f4.json b/tests/ast_json_fixtures/shapes/c6ec8583d1c435f4.json new file mode 100644 index 000000000000..1a67568f9c9b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c6ec8583d1c435f4.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "dst" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition_ID", + "all": true + }, + "replace": false, + "from_table": "src" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c6ec8583d1c435f4.sql b/tests/ast_json_fixtures/shapes/c6ec8583d1c435f4.sql new file mode 100644 index 000000000000..d9288c0f34f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c6ec8583d1c435f4.sql @@ -0,0 +1 @@ +ALTER TABLE dst ATTACH PARTITION ALL FROM src diff --git a/tests/ast_json_fixtures/shapes/c6ee3c95bccac101.json b/tests/ast_json_fixtures/shapes/c6ee3c95bccac101.json new file mode 100644 index 000000000000..22a07b6ed7b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c6ee3c95bccac101.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "strings_whitespace" + } + } + } + ] + } + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/c6ee3c95bccac101.sql b/tests/ast_json_fixtures/shapes/c6ee3c95bccac101.sql new file mode 100644 index 000000000000..d0f3d7d8fd45 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c6ee3c95bccac101.sql @@ -0,0 +1 @@ +SELECT * FROM strings_whitespace FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/c6eea430387daae0.json b/tests/ast_json_fixtures/shapes/c6eea430387daae0.json new file mode 100644 index 000000000000..e0eb02a5222c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c6eea430387daae0.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "log1" + }, + "as_table": "log" + } +} diff --git a/tests/ast_json_fixtures/shapes/c6eea430387daae0.sql b/tests/ast_json_fixtures/shapes/c6eea430387daae0.sql new file mode 100644 index 000000000000..6a14cb1942ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c6eea430387daae0.sql @@ -0,0 +1 @@ +CREATE TABLE log1 AS log diff --git a/tests/ast_json_fixtures/shapes/c6f0d71396cab70f.json b/tests/ast_json_fixtures/shapes/c6f0d71396cab70f.json new file mode 100644 index 000000000000..c65bb8cab76e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c6f0d71396cab70f.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c6f0d71396cab70f.sql b/tests/ast_json_fixtures/shapes/c6f0d71396cab70f.sql new file mode 100644 index 000000000000..1d9acbd5ef0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c6f0d71396cab70f.sql @@ -0,0 +1 @@ +select * from x order by () settings max_threads = 1 diff --git a/tests/ast_json_fixtures/shapes/c718511e1d3b7f65.json b/tests/ast_json_fixtures/shapes/c718511e1d3b7f65.json new file mode 100644 index 000000000000..eff4529b5a1c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c718511e1d3b7f65.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Test select text + hasAnyTokens:" + }, + { + "type": "Identifier", + "name": "text" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "hasAnyTokens", + "arguments": [ + { + "type": "Identifier", + "name": "text" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "Alick" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c718511e1d3b7f65.sql b/tests/ast_json_fixtures/shapes/c718511e1d3b7f65.sql new file mode 100644 index 000000000000..ad9ff93e4e17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c718511e1d3b7f65.sql @@ -0,0 +1 @@ +SELECT 'Test select text + hasAnyTokens:', text FROM tab WHERE hasAnyTokens(text, ['Alick']) diff --git a/tests/ast_json_fixtures/shapes/c71aeff58539be08.json b/tests/ast_json_fixtures/shapes/c71aeff58539be08.json new file mode 100644 index 000000000000..a93d9a6354b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c71aeff58539be08.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "d1" + }, + { + "type": "Function", + "name": "dynamicType", + "arguments": [ + { + "type": "Identifier", + "name": "d1" + } + ] + }, + { + "type": "Identifier", + "name": "d2" + }, + { + "type": "Function", + "name": "dynamicType", + "arguments": [ + { + "type": "Identifier", + "name": "d2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_nested_dynamic" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c71aeff58539be08.sql b/tests/ast_json_fixtures/shapes/c71aeff58539be08.sql new file mode 100644 index 000000000000..55b2c238a012 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c71aeff58539be08.sql @@ -0,0 +1 @@ +SELECT d1, dynamicType(d1), d2, dynamicType(d2) FROM test_nested_dynamic diff --git a/tests/ast_json_fixtures/shapes/c71ef84bee999cfa.json b/tests/ast_json_fixtures/shapes/c71ef84bee999cfa.json new file mode 100644 index 000000000000..1ce62cc8523f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c71ef84bee999cfa.json @@ -0,0 +1,94 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_rows_to_read": "3" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c71ef84bee999cfa.sql b/tests/ast_json_fixtures/shapes/c71ef84bee999cfa.sql new file mode 100644 index 000000000000..d30db7c6e914 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c71ef84bee999cfa.sql @@ -0,0 +1 @@ +SELECT count() FROM test PREWHERE x >= 10 WHERE x < 11 AND y = 10 SETTINGS max_rows_to_read = 3 diff --git a/tests/ast_json_fixtures/shapes/c738a41baf5af5d9.json b/tests/ast_json_fixtures/shapes/c738a41baf5af5d9.json new file mode 100644 index 000000000000..5b36095c9277 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c738a41baf5af5d9.json @@ -0,0 +1,535 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "s.a", + "name_parts": ["s", "a"] + }, + { + "type": "Identifier", + "name": "s.b", + "name_parts": ["s", "b"] + }, + { + "type": "Function", + "alias": "dt1", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "s.dt1", + "name_parts": ["s", "dt1"] + } + ] + }, + { + "type": "Identifier", + "name": "s.c", + "name_parts": ["s", "c"] + }, + { + "type": "Identifier", + "name": "s.d", + "name_parts": ["s", "d"] + }, + { + "type": "Identifier", + "name": "s.f", + "name_parts": ["s", "f"] + }, + { + "type": "Identifier", + "name": "s.i", + "name_parts": ["s", "i"] + }, + { + "type": "Function", + "alias": "dt2", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "s.dt2", + "name_parts": ["s", "dt2"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "s", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4360430" + } + ] + }, + { + "type": "Function", + "alias": "b", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5681495" + } + ] + }, + { + "type": "Function", + "alias": "dt1", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-11-01 10:44:58" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Istanbul" + } + ] + }, + { + "type": "Literal", + "alias": "c", + "value_type": "String", + "value": "txt" + }, + { + "type": "Function", + "alias": "d", + "name": "toDecimal128", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "274.350000000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + }, + { + "type": "Function", + "alias": "f", + "name": "toDecimal128", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 268.97 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + }, + { + "type": "Function", + "alias": "i", + "name": "toDecimal128", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + }, + { + "type": "Function", + "alias": "dt2", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-11-02 00:00:00" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Istanbul" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4341757" + } + ] + }, + { + "type": "Function", + "alias": "b", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5657967" + } + ] + }, + { + "type": "Function", + "alias": "dt1", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-11-01 16:47:46" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Istanbul" + } + ] + }, + { + "type": "Literal", + "alias": "c", + "value_type": "String", + "value": "txt" + }, + { + "type": "Function", + "alias": "d", + "name": "toDecimal128", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "321.380000000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + }, + { + "type": "Function", + "alias": "f", + "name": "toDecimal128", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 315.08 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + }, + { + "type": "Function", + "alias": "i", + "name": "toDecimal128", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + }, + { + "type": "Function", + "alias": "dt2", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-11-02 00:00:00" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Istanbul" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4360430" + } + ] + }, + { + "type": "Function", + "alias": "b", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5681495" + } + ] + }, + { + "type": "Function", + "alias": "dt1", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-11-02 09:00:07" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Istanbul" + } + ] + }, + { + "type": "Literal", + "alias": "c", + "value_type": "String", + "value": "txt" + }, + { + "type": "Function", + "alias": "d", + "name": "toDecimal128", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "274.350000000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + }, + { + "type": "Function", + "alias": "f", + "name": "toDecimal128", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 268.97 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + }, + { + "type": "Function", + "alias": "i", + "name": "toDecimal128", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + }, + { + "type": "Function", + "alias": "dt2", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2018-11-02 00:00:00" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Istanbul" + } + ] + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "s.a", + "name_parts": ["s", "a"] + }, + { + "type": "Identifier", + "name": "s.b", + "name_parts": ["s", "b"] + }, + { + "type": "Identifier", + "name": "s.c", + "name_parts": ["s", "c"] + }, + { + "type": "Identifier", + "name": "s.d", + "name_parts": ["s", "d"] + }, + { + "type": "Identifier", + "name": "s.f", + "name_parts": ["s", "f"] + }, + { + "type": "Identifier", + "name": "s.i", + "name_parts": ["s", "i"] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s.a", + "name_parts": ["s", "a"] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s.b", + "name_parts": ["s", "b"] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s.c", + "name_parts": ["s", "c"] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s.d", + "name_parts": ["s", "d"] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s.f", + "name_parts": ["s", "f"] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s.i", + "name_parts": ["s", "i"] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c738a41baf5af5d9.sql b/tests/ast_json_fixtures/shapes/c738a41baf5af5d9.sql new file mode 100644 index 000000000000..25cb8939778a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c738a41baf5af5d9.sql @@ -0,0 +1,28 @@ +select s.a, s.b, max(s.dt1) dt1, s.c, s.d, s.f, s.i, max(s.dt2) dt2 from ( + select toUInt64(4360430) a + , toUInt64(5681495) b + , toDateTime('2018-11-01 10:44:58', 'Asia/Istanbul') dt1 + , 'txt' c + , toDecimal128('274.350000000000', 12) d + , toDecimal128(268.970000000000, 12) f + , toDecimal128(0.000000000000, 12) i + , toDateTime('2018-11-02 00:00:00', 'Asia/Istanbul') dt2 + union all + select toUInt64(4341757) a + , toUInt64(5657967) b + , toDateTime('2018-11-01 16:47:46', 'Asia/Istanbul') dt1 + , 'txt' c + , toDecimal128('321.380000000000', 12) d + , toDecimal128(315.080000000000, 12) f + , toDecimal128(0.000000000000, 12) i + , toDateTime('2018-11-02 00:00:00', 'Asia/Istanbul') dt2 + union all + select toUInt64(4360430) a + , toUInt64(5681495) b + , toDateTime('2018-11-02 09:00:07', 'Asia/Istanbul') dt1 + , 'txt' c + , toDecimal128('274.350000000000', 12) d + , toDecimal128(268.970000000000, 12) f + , toDecimal128(0.000000000000, 12) i + , toDateTime('2018-11-02 00:00:00', 'Asia/Istanbul') dt2 +) s group by s.a, s.b, s.c, s.d, s.f, s.i ORDER BY s.a, s.b, s.c, s.d, s.f, s.i diff --git a/tests/ast_json_fixtures/shapes/c74c1f045764c7ff.json b/tests/ast_json_fixtures/shapes/c74c1f045764c7ff.json new file mode 100644 index 000000000000..45a0e96884fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c74c1f045764c7ff.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c74c1f045764c7ff.sql b/tests/ast_json_fixtures/shapes/c74c1f045764c7ff.sql new file mode 100644 index 000000000000..fb1e7d60dce6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c74c1f045764c7ff.sql @@ -0,0 +1 @@ +SELECT DISTINCT ON (a) * FROM t1 diff --git a/tests/ast_json_fixtures/shapes/c773c0e9d94de475.json b/tests/ast_json_fixtures/shapes/c773c0e9d94de475.json new file mode 100644 index 000000000000..4b7b55c0eeca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c773c0e9d94de475.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ], + "format": "Pretty" + } +} diff --git a/tests/ast_json_fixtures/shapes/c773c0e9d94de475.sql b/tests/ast_json_fixtures/shapes/c773c0e9d94de475.sql new file mode 100644 index 000000000000..3214e76d8be6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c773c0e9d94de475.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) FORMAT Pretty diff --git a/tests/ast_json_fixtures/shapes/c7763a67c9dc5110.json b/tests/ast_json_fixtures/shapes/c7763a67c9dc5110.json new file mode 100644 index 000000000000..36cd7952b5e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c7763a67c9dc5110.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "y" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "_03914.parquet" + } + ] + } + ] + } + } + } + ] + }, + "prewhere": { + "type": "Identifier", + "name": "x" + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "50" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c7763a67c9dc5110.sql b/tests/ast_json_fixtures/shapes/c7763a67c9dc5110.sql new file mode 100644 index 000000000000..5ef8d294d24d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c7763a67c9dc5110.sql @@ -0,0 +1 @@ +select sum(y) from file(currentDatabase() || '_03914.parquet') prewhere x where y >= 50 diff --git a/tests/ast_json_fixtures/shapes/c7790903c17dd61a.json b/tests/ast_json_fixtures/shapes/c7790903c17dd61a.json new file mode 100644 index 000000000000..1f8d6568aecb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c7790903c17dd61a.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01148_atomic", + "from_table": "rmt4", + "to_database": "test_01148_atomic", + "to_table": "rmt3" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c7790903c17dd61a.sql b/tests/ast_json_fixtures/shapes/c7790903c17dd61a.sql new file mode 100644 index 000000000000..dcdd3ba8f312 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c7790903c17dd61a.sql @@ -0,0 +1 @@ +RENAME TABLE test_01148_atomic.rmt4 to test_01148_atomic.rmt3 diff --git a/tests/ast_json_fixtures/shapes/c7a39a930752a4c9.json b/tests/ast_json_fixtures/shapes/c7a39a930752a4c9.json new file mode 100644 index 000000000000..a870156f3124 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c7a39a930752a4c9.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "test", + "value_type": "UInt64", + "value": "0" + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "test", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_global_with_statement": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c7a39a930752a4c9.sql b/tests/ast_json_fixtures/shapes/c7a39a930752a4c9.sql new file mode 100644 index 000000000000..338eb30e6ffd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c7a39a930752a4c9.sql @@ -0,0 +1,7 @@ +WITH 0 AS test +SELECT * +FROM +( + SELECT 1 AS test +) +SETTINGS enable_global_with_statement = 1 diff --git a/tests/ast_json_fixtures/shapes/c7bda089b472a5a9.json b/tests/ast_json_fixtures/shapes/c7bda089b472a5a9.json new file mode 100644 index 000000000000..e200f40fa1c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c7bda089b472a5a9.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "c", + "name": "anySimpleState", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c7bda089b472a5a9.sql b/tests/ast_json_fixtures/shapes/c7bda089b472a5a9.sql new file mode 100644 index 000000000000..a390689cf0b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c7bda089b472a5a9.sql @@ -0,0 +1 @@ +with anySimpleState(number) as c select toTypeName(c), c from numbers(1) diff --git a/tests/ast_json_fixtures/shapes/c7e5279525cea68d.json b/tests/ast_json_fixtures/shapes/c7e5279525cea68d.json new file mode 100644 index 000000000000..c17faddf3475 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c7e5279525cea68d.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mem" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "as_table": "log1" + } +} diff --git a/tests/ast_json_fixtures/shapes/c7e5279525cea68d.sql b/tests/ast_json_fixtures/shapes/c7e5279525cea68d.sql new file mode 100644 index 000000000000..360a0e2b5cd6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c7e5279525cea68d.sql @@ -0,0 +1 @@ +CREATE TABLE mem AS log1 ENGINE=Memory diff --git a/tests/ast_json_fixtures/shapes/c804530e2de2311c.json b/tests/ast_json_fixtures/shapes/c804530e2de2311c.json new file mode 100644 index 000000000000..c2204f014d65 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c804530e2de2311c.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/c804530e2de2311c.sql b/tests/ast_json_fixtures/shapes/c804530e2de2311c.sql new file mode 100644 index 000000000000..63de04308eb3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c804530e2de2311c.sql @@ -0,0 +1 @@ +DROP ROLE r1_01293 diff --git a/tests/ast_json_fixtures/shapes/c80997d703ae5505.json b/tests/ast_json_fixtures/shapes/c80997d703ae5505.json new file mode 100644 index 000000000000..a91ac02e8722 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c80997d703ae5505.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "WAIT VIEW", + "table": { + "type": "Identifier", + "name": "03221_rmv" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c80997d703ae5505.sql b/tests/ast_json_fixtures/shapes/c80997d703ae5505.sql new file mode 100644 index 000000000000..523ea98e9239 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c80997d703ae5505.sql @@ -0,0 +1 @@ +SYSTEM WAIT VIEW 03221_rmv diff --git a/tests/ast_json_fixtures/shapes/c80cd802589707a4.json b/tests/ast_json_fixtures/shapes/c80cd802589707a4.json new file mode 100644 index 000000000000..3d4ad42f91f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c80cd802589707a4.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distr2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "shard2" + }, + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + ] + } + }, + "as_table": "shard2" + } +} diff --git a/tests/ast_json_fixtures/shapes/c80cd802589707a4.sql b/tests/ast_json_fixtures/shapes/c80cd802589707a4.sql new file mode 100644 index 000000000000..3cc132d72af0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c80cd802589707a4.sql @@ -0,0 +1 @@ +create table distr2 as shard2 engine Distributed (test_cluster_two_shards_localhost, currentDatabase(), shard2, cityHash64(id)) diff --git a/tests/ast_json_fixtures/shapes/c8122ca7e323fbd7.json b/tests/ast_json_fixtures/shapes/c8122ca7e323fbd7.json new file mode 100644 index 000000000000..7a2090ccf7bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c8122ca7e323fbd7.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "merge", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^numbers\\d+$" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c8122ca7e323fbd7.sql b/tests/ast_json_fixtures/shapes/c8122ca7e323fbd7.sql new file mode 100644 index 000000000000..647f3e509eea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c8122ca7e323fbd7.sql @@ -0,0 +1 @@ +SELECT DISTINCT count() FROM merge(currentDatabase(), '^numbers\\d+$') GROUP BY number diff --git a/tests/ast_json_fixtures/shapes/c84cd6eb4197b5d9.json b/tests/ast_json_fixtures/shapes/c84cd6eb4197b5d9.json new file mode 100644 index 000000000000..7d6fb9f5105f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c84cd6eb4197b5d9.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test", + "from_table": "hits", + "to_database": "test", + "to_table": "hits_tmp" + }, + { + "from_database": "test", + "from_table": "hits_tmp", + "to_database": "test", + "to_table": "hits" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c84cd6eb4197b5d9.sql b/tests/ast_json_fixtures/shapes/c84cd6eb4197b5d9.sql new file mode 100644 index 000000000000..6c38796056fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c84cd6eb4197b5d9.sql @@ -0,0 +1 @@ +RENAME TABLE test.hits TO test.hits_tmp, test.hits_tmp TO test.hits diff --git a/tests/ast_json_fixtures/shapes/c863476a5a0fcf9d.json b/tests/ast_json_fixtures/shapes/c863476a5a0fcf9d.json new file mode 100644 index 000000000000..41970d086642 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c863476a5a0fcf9d.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "table_keeper_map_02525" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "KeeperMap", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "\/test02525" + } + ] + } + ] + }, + "primary_key": { + "type": "Identifier", + "name": "key" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c863476a5a0fcf9d.sql b/tests/ast_json_fixtures/shapes/c863476a5a0fcf9d.sql new file mode 100644 index 000000000000..8bca65b5c466 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c863476a5a0fcf9d.sql @@ -0,0 +1,6 @@ +CREATE TEMPORARY TABLE table_keeper_map_02525 +( + key String, + value UInt32 +) Engine=KeeperMap('/' || currentDatabase() || '/test02525') +PRIMARY KEY(key) diff --git a/tests/ast_json_fixtures/shapes/c880918a3d84f9f9.json b/tests/ast_json_fixtures/shapes/c880918a3d84f9f9.json new file mode 100644 index 000000000000..68285faf262c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c880918a3d84f9f9.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c880918a3d84f9f9.sql b/tests/ast_json_fixtures/shapes/c880918a3d84f9f9.sql new file mode 100644 index 000000000000..77dbf9d349ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c880918a3d84f9f9.sql @@ -0,0 +1 @@ +SELECT 1 AS x, x, x + 1 diff --git a/tests/ast_json_fixtures/shapes/c88388436dec3cb9.json b/tests/ast_json_fixtures/shapes/c88388436dec3cb9.json new file mode 100644 index 000000000000..715d735416f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c88388436dec3cb9.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "distinct_in_order" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "10", + "max_threads": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c88388436dec3cb9.sql b/tests/ast_json_fixtures/shapes/c88388436dec3cb9.sql new file mode 100644 index 000000000000..ca1c433940a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c88388436dec3cb9.sql @@ -0,0 +1 @@ +select distinct a from distinct_in_order settings max_block_size=10, max_threads=1 diff --git a/tests/ast_json_fixtures/shapes/c901d39dcc2924c3.json b/tests/ast_json_fixtures/shapes/c901d39dcc2924c3.json new file mode 100644 index 000000000000..2886d6a7cef7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c901d39dcc2924c3.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01292", "r2_01292"] + }, + "grantees": { + "type": "RolesOrUsersSet", + "names": ["u2_01292", "u3_01292", "u4_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c901d39dcc2924c3.sql b/tests/ast_json_fixtures/shapes/c901d39dcc2924c3.sql new file mode 100644 index 000000000000..1946d2dda6dc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c901d39dcc2924c3.sql @@ -0,0 +1 @@ +GRANT r1_01292, r2_01292 TO u2_01292, u3_01292, u4_01292 diff --git a/tests/ast_json_fixtures/shapes/c90f7f986725b409.json b/tests/ast_json_fixtures/shapes/c90f7f986725b409.json new file mode 100644 index 000000000000..3a105b666f13 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c90f7f986725b409.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowIndexes", + "table": "tbl" + } +} diff --git a/tests/ast_json_fixtures/shapes/c90f7f986725b409.sql b/tests/ast_json_fixtures/shapes/c90f7f986725b409.sql new file mode 100644 index 000000000000..ee82d8db6e30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c90f7f986725b409.sql @@ -0,0 +1 @@ +SHOW KEYS FROM tbl diff --git a/tests/ast_json_fixtures/shapes/c911edcdc749a645.json b/tests/ast_json_fixtures/shapes/c911edcdc749a645.json new file mode 100644 index 000000000000..17c2793a9497 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c911edcdc749a645.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "clusterAllReplicas", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + }, + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/c911edcdc749a645.sql b/tests/ast_json_fixtures/shapes/c911edcdc749a645.sql new file mode 100644 index 000000000000..6a9f744cd06c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c911edcdc749a645.sql @@ -0,0 +1 @@ +insert into function clusterAllReplicas(test_cluster_two_shards, currentDatabase(), data, rand()) values (2) diff --git a/tests/ast_json_fixtures/shapes/c92fecaeebaee530.json b/tests/ast_json_fixtures/shapes/c92fecaeebaee530.json new file mode 100644 index 000000000000..3543b4398ec0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c92fecaeebaee530.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 100000000 + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_bytes_ratio_before_external_sort": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/c92fecaeebaee530.sql b/tests/ast_json_fixtures/shapes/c92fecaeebaee530.sql new file mode 100644 index 000000000000..03a284fe6d5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c92fecaeebaee530.sql @@ -0,0 +1 @@ +select number from numbers(100e6) order by number format Null settings max_bytes_ratio_before_external_sort=1 diff --git a/tests/ast_json_fixtures/shapes/c93235cb344f0d3c.json b/tests/ast_json_fixtures/shapes/c93235cb344f0d3c.json new file mode 100644 index 000000000000..52b0d7e51ae9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c93235cb344f0d3c.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r8_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "value": "5000000", + "min_value": "4000000", + "max_value": "6000000", + "writability": "CONST" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c93235cb344f0d3c.sql b/tests/ast_json_fixtures/shapes/c93235cb344f0d3c.sql new file mode 100644 index 000000000000..800b104866bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c93235cb344f0d3c.sql @@ -0,0 +1 @@ +CREATE ROLE r8_01293 SETTINGS max_memory_usage=5000000 MIN 4000000 MAX 6000000 CONST diff --git a/tests/ast_json_fixtures/shapes/c93dcde3dfdb4910.json b/tests/ast_json_fixtures/shapes/c93dcde3dfdb4910.json new file mode 100644 index 000000000000..f810836c17fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c93dcde3dfdb4910.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "03710" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1", + "max_block_size": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c93dcde3dfdb4910.sql b/tests/ast_json_fixtures/shapes/c93dcde3dfdb4910.sql new file mode 100644 index 000000000000..dfceac3d17c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c93dcde3dfdb4910.sql @@ -0,0 +1 @@ +SELECT '03710', c FROM tab SETTINGS use_query_cache = 1, max_block_size = 1 diff --git a/tests/ast_json_fixtures/shapes/c94b962780fb012e.json b/tests/ast_json_fixtures/shapes/c94b962780fb012e.json new file mode 100644 index 000000000000..539acac853a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c94b962780fb012e.json @@ -0,0 +1,195 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "v1.id", + "name_parts": ["v1", "id"] + }, + { + "type": "Identifier", + "name": "v2.id", + "name_parts": ["v2", "id"] + }, + { + "type": "Function", + "name": "L1Distance", + "arguments": [ + { + "type": "Identifier", + "name": "v1.v", + "name_parts": ["v1", "v"] + }, + { + "type": "Identifier", + "name": "v2.v", + "name_parts": ["v2", "v"] + } + ] + }, + { + "type": "Function", + "name": "LinfDistance", + "arguments": [ + { + "type": "Identifier", + "name": "v1.v", + "name_parts": ["v1", "v"] + }, + { + "type": "Identifier", + "name": "v2.v", + "name_parts": ["v2", "v"] + } + ] + }, + { + "type": "Function", + "name": "LpDistance", + "arguments": [ + { + "type": "Identifier", + "name": "v1.v", + "name_parts": ["v1", "v"] + }, + { + "type": "Identifier", + "name": "v2.v", + "name_parts": ["v2", "v"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "v1.v", + "name_parts": ["v1", "v"] + }, + { + "type": "Identifier", + "name": "v2.v", + "name_parts": ["v2", "v"] + } + ] + }, + { + "type": "Function", + "name": "L2SquaredDistance", + "arguments": [ + { + "type": "Identifier", + "name": "v1.v", + "name_parts": ["v1", "v"] + }, + { + "type": "Identifier", + "name": "v2.v", + "name_parts": ["v2", "v"] + } + ] + }, + { + "type": "Function", + "name": "cosineDistance", + "arguments": [ + { + "type": "Identifier", + "name": "v1.v", + "name_parts": ["v1", "v"] + }, + { + "type": "Identifier", + "name": "v2.v", + "name_parts": ["v2", "v"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "v1", + "name": "vec2d" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "v2", + "name": "vec2d" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "v1.v", + "name_parts": ["v1", "v"] + } + ] + }, + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "v2.v", + "name_parts": ["v2", "v"] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c94b962780fb012e.sql b/tests/ast_json_fixtures/shapes/c94b962780fb012e.sql new file mode 100644 index 000000000000..55390717d022 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c94b962780fb012e.sql @@ -0,0 +1,12 @@ +SELECT + v1.id, + v2.id, + L1Distance(v1.v, v2.v), + LinfDistance(v1.v, v2.v), + LpDistance(v1.v, v2.v, 3), + L2Distance(v1.v, v2.v), + L2SquaredDistance(v1.v, v2.v), + cosineDistance(v1.v, v2.v) +FROM vec2d v1, vec2d v2 +WHERE length(v1.v) == length(v2.v) +ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/c95a296acbb8df69.json b/tests/ast_json_fixtures/shapes/c95a296acbb8df69.json new file mode 100644 index 000000000000..d63a514c2e14 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c95a296acbb8df69.json @@ -0,0 +1,56 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "key", + "name": "a" + } + ], + "select": [ + { + "type": "Identifier", + "alias": "k1", + "name": "key" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c95a296acbb8df69.sql b/tests/ast_json_fixtures/shapes/c95a296acbb8df69.sql new file mode 100644 index 000000000000..7bd698976725 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c95a296acbb8df69.sql @@ -0,0 +1 @@ +WITH a as key SELECT key as k1 FROM test GROUP BY key ORDER BY key diff --git a/tests/ast_json_fixtures/shapes/c966a6d0efc302a9.json b/tests/ast_json_fixtures/shapes/c966a6d0efc302a9.json new file mode 100644 index 000000000000..626551df2f20 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c966a6d0efc302a9.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "DropIndexQuery", + "table": { + "type": "Identifier", + "name": "t_index" + }, + "if_exists": true, + "index_name": { + "type": "Identifier", + "name": "i_a" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c966a6d0efc302a9.sql b/tests/ast_json_fixtures/shapes/c966a6d0efc302a9.sql new file mode 100644 index 000000000000..7a3743542f17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c966a6d0efc302a9.sql @@ -0,0 +1 @@ +drop index if exists i_a on t_index diff --git a/tests/ast_json_fixtures/shapes/c96f20f89736e76c.json b/tests/ast_json_fixtures/shapes/c96f20f89736e76c.json new file mode 100644 index 000000000000..4f9c0ccf5717 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c96f20f89736e76c.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01292", "r2_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/c96f20f89736e76c.sql b/tests/ast_json_fixtures/shapes/c96f20f89736e76c.sql new file mode 100644 index 000000000000..e0ca36a54493 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c96f20f89736e76c.sql @@ -0,0 +1 @@ +DROP ROLE r1_01292, r2_01292 diff --git a/tests/ast_json_fixtures/shapes/c9781b2dab7e6a94.json b/tests/ast_json_fixtures/shapes/c9781b2dab7e6a94.json new file mode 100644 index 000000000000..5a81607d124d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c9781b2dab7e6a94.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/c9781b2dab7e6a94.sql b/tests/ast_json_fixtures/shapes/c9781b2dab7e6a94.sql new file mode 100644 index 000000000000..4d5df18dde74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c9781b2dab7e6a94.sql @@ -0,0 +1 @@ +SELECT k, count() FROM (SELECT number % 5 AS k FROM system.numbers LIMIT 100) GROUP BY k WITH TOTALS ORDER BY k FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/c97e3b2d96253d5e.json b/tests/ast_json_fixtures/shapes/c97e3b2d96253d5e.json new file mode 100644 index 000000000000..bc777b4ddd7a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c97e3b2d96253d5e.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_desc_subcolumns" + } + }, + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/c97e3b2d96253d5e.sql b/tests/ast_json_fixtures/shapes/c97e3b2d96253d5e.sql new file mode 100644 index 000000000000..57eae722dbe6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c97e3b2d96253d5e.sql @@ -0,0 +1 @@ +DESCRIBE TABLE t_desc_subcolumns FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/c982df03e3041d74.json b/tests/ast_json_fixtures/shapes/c982df03e3041d74.json new file mode 100644 index 000000000000..60814dccd7e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c982df03e3041d74.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Function", + "name": "repeat", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "200" + } + ] + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data_01513" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/c982df03e3041d74.sql b/tests/ast_json_fixtures/shapes/c982df03e3041d74.sql new file mode 100644 index 000000000000..3f97a02c0eb9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c982df03e3041d74.sql @@ -0,0 +1 @@ +select key, groupArray(repeat('a', 200)), count() from data_01513 group by key with totals format Null settings optimize_aggregation_in_order=1 diff --git a/tests/ast_json_fixtures/shapes/c98868212bd9eebd.json b/tests/ast_json_fixtures/shapes/c98868212bd9eebd.json new file mode 100644 index 000000000000..3befa16b2bd9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c98868212bd9eebd.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "log_remote" + }, + "as_table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.1" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "log" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/c98868212bd9eebd.sql b/tests/ast_json_fixtures/shapes/c98868212bd9eebd.sql new file mode 100644 index 000000000000..3b92b47f9012 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c98868212bd9eebd.sql @@ -0,0 +1 @@ +create table log_remote as remote('127.1', currentDatabase(), log) diff --git a/tests/ast_json_fixtures/shapes/c9b424d64372ae83.json b/tests/ast_json_fixtures/shapes/c9b424d64372ae83.json new file mode 100644 index 000000000000..7678dcedf9d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c9b424d64372ae83.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "b" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "analyzer_compatibility_join_using_top_level_identifier": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/c9b424d64372ae83.sql b/tests/ast_json_fixtures/shapes/c9b424d64372ae83.sql new file mode 100644 index 000000000000..bd517ae2b9c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c9b424d64372ae83.sql @@ -0,0 +1 @@ +SELECT 1 AS b FROM t1 JOIN t2 USING b SETTINGS analyzer_compatibility_join_using_top_level_identifier = 1 diff --git a/tests/ast_json_fixtures/shapes/c9e63a083b60dc80.json b/tests/ast_json_fixtures/shapes/c9e63a083b60dc80.json new file mode 100644 index 000000000000..6e1723bb65bf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c9e63a083b60dc80.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t3" + }, + "as_table": "dict" + } +} diff --git a/tests/ast_json_fixtures/shapes/c9e63a083b60dc80.sql b/tests/ast_json_fixtures/shapes/c9e63a083b60dc80.sql new file mode 100644 index 000000000000..53b0070fbda2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/c9e63a083b60dc80.sql @@ -0,0 +1 @@ +CREATE TABLE t3 AS dict diff --git a/tests/ast_json_fixtures/shapes/ca12a150b7177e61.json b/tests/ast_json_fixtures/shapes/ca12a150b7177e61.json new file mode 100644 index 000000000000..d9eb6adf5889 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca12a150b7177e61.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p6_01295", + "database": "db", + "table": "table" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r1_01295"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ca12a150b7177e61.sql b/tests/ast_json_fixtures/shapes/ca12a150b7177e61.sql new file mode 100644 index 000000000000..097c5fc58a25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca12a150b7177e61.sql @@ -0,0 +1 @@ +CREATE POLICY p6_01295 ON db.table TO ALL EXCEPT r1_01295 diff --git a/tests/ast_json_fixtures/shapes/ca53d28c9ee5b7fa.json b/tests/ast_json_fixtures/shapes/ca53d28c9ee5b7fa.json new file mode 100644 index 000000000000..10c153ccf1ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca53d28c9ee5b7fa.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "if_not_exists": true, + "is_ordinary_view": true, + "table": { + "type": "Identifier", + "name": "tview_basic" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ca53d28c9ee5b7fa.sql b/tests/ast_json_fixtures/shapes/ca53d28c9ee5b7fa.sql new file mode 100644 index 000000000000..ef19b4cd09d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca53d28c9ee5b7fa.sql @@ -0,0 +1 @@ +CREATE TEMPORARY VIEW IF NOT EXISTS tview_basic AS SELECT 0 diff --git a/tests/ast_json_fixtures/shapes/ca6c9437b8ed378c.json b/tests/ast_json_fixtures/shapes/ca6c9437b8ed378c.json new file mode 100644 index 000000000000..9211fa02a04e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca6c9437b8ed378c.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "minmax_compact" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_INDEX", + "index": { + "type": "Identifier", + "name": "idx" + }, + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ca6c9437b8ed378c.sql b/tests/ast_json_fixtures/shapes/ca6c9437b8ed378c.sql new file mode 100644 index 000000000000..1bd8f511567c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca6c9437b8ed378c.sql @@ -0,0 +1 @@ +ALTER TABLE minmax_compact MATERIALIZE INDEX idx IN PARTITION 1 diff --git a/tests/ast_json_fixtures/shapes/ca7879a58165252c.json b/tests/ast_json_fixtures/shapes/ca7879a58165252c.json new file mode 100644 index 000000000000..0b01bec0002c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca7879a58165252c.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "ip_range", + "name": "IPv4CIDRToRange", + "arguments": [ + { + "type": "Identifier", + "name": "ip" + }, + { + "type": "Identifier", + "name": "cidr" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "ip" + }, + { + "type": "Identifier", + "name": "cidr" + }, + { + "type": "Function", + "name": "IPv4NumToString", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "arguments": [ + { + "type": "Identifier", + "name": "ip_range" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "ip_range" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ipv4_range" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ca7879a58165252c.sql b/tests/ast_json_fixtures/shapes/ca7879a58165252c.sql new file mode 100644 index 000000000000..25ae265db2d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca7879a58165252c.sql @@ -0,0 +1 @@ +WITH IPv4CIDRToRange(ip, cidr) as ip_range SELECT ip, cidr, IPv4NumToString(tupleElement(ip_range, 1)), ip_range FROM ipv4_range diff --git a/tests/ast_json_fixtures/shapes/ca937bfeebad77c9.json b/tests/ast_json_fixtures/shapes/ca937bfeebad77c9.json new file mode 100644 index 000000000000..13fa0d97b28e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca937bfeebad77c9.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedColumnsListMatcher", + "qualifier": { + "type": "Identifier", + "name": "test_table" + }, + "columns": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ca937bfeebad77c9.sql b/tests/ast_json_fixtures/shapes/ca937bfeebad77c9.sql new file mode 100644 index 000000000000..06f48aa97de6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca937bfeebad77c9.sql @@ -0,0 +1 @@ +SELECT test_table.COLUMNS(id) FROM test_table diff --git a/tests/ast_json_fixtures/shapes/ca993e3a6fe2cd43.json b/tests/ast_json_fixtures/shapes/ca993e3a6fe2cd43.json new file mode 100644 index 000000000000..43dff63fd1ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca993e3a6fe2cd43.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ca993e3a6fe2cd43.sql b/tests/ast_json_fixtures/shapes/ca993e3a6fe2cd43.sql new file mode 100644 index 000000000000..f55e242b3647 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca993e3a6fe2cd43.sql @@ -0,0 +1 @@ +SELECT s != '' FROM test LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/ca99f0a88099301f.json b/tests/ast_json_fixtures/shapes/ca99f0a88099301f.json new file mode 100644 index 000000000000..ad69140da60f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca99f0a88099301f.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "� �" + } + ] + } + ], + "format": "JSONCompactColumns" + } +} diff --git a/tests/ast_json_fixtures/shapes/ca99f0a88099301f.sql b/tests/ast_json_fixtures/shapes/ca99f0a88099301f.sql new file mode 100644 index 000000000000..c1dfc2942653 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca99f0a88099301f.sql @@ -0,0 +1 @@ +SELECT '\xED\x20\xA8' AS s FORMAT JSONCompactColumns diff --git a/tests/ast_json_fixtures/shapes/ca9cdf3e9722647b.json b/tests/ast_json_fixtures/shapes/ca9cdf3e9722647b.json new file mode 100644 index 000000000000..573541ac9702 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca9cdf3e9722647b.json @@ -0,0 +1 @@ +0 diff --git a/tests/ast_json_fixtures/shapes/ca9cdf3e9722647b.sql b/tests/ast_json_fixtures/shapes/ca9cdf3e9722647b.sql new file mode 100644 index 000000000000..d86a96ea7fe0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ca9cdf3e9722647b.sql @@ -0,0 +1 @@ +Customers | project FirstName,LastName,Occupation,Education | where Education !in ('Bachelors','High School') diff --git a/tests/ast_json_fixtures/shapes/cab221452e7dcca2.json b/tests/ast_json_fixtures/shapes/cab221452e7dcca2.json new file mode 100644 index 000000000000..3d7bc94fb935 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cab221452e7dcca2.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "RawWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/cab221452e7dcca2.sql b/tests/ast_json_fixtures/shapes/cab221452e7dcca2.sql new file mode 100644 index 000000000000..d54b7e881179 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cab221452e7dcca2.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT RawWithNames diff --git a/tests/ast_json_fixtures/shapes/cab66ced0aaa7bd1.json b/tests/ast_json_fixtures/shapes/cab66ced0aaa7bd1.json new file mode 100644 index 000000000000..90c423bbebfb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cab66ced0aaa7bd1.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test", + "from_table": "hits", + "to_database": "default", + "to_table": "hits" + }, + { + "from_database": "test", + "from_table": "visits", + "to_database": "test", + "to_table": "hits" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cab66ced0aaa7bd1.sql b/tests/ast_json_fixtures/shapes/cab66ced0aaa7bd1.sql new file mode 100644 index 000000000000..fc1106558af0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cab66ced0aaa7bd1.sql @@ -0,0 +1 @@ +RENAME TABLE test.hits TO default.hits, test.visits TO test.hits diff --git a/tests/ast_json_fixtures/shapes/cac202f19ffe0117.json b/tests/ast_json_fixtures/shapes/cac202f19ffe0117.json new file mode 100644 index 000000000000..8f6402db7a35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cac202f19ffe0117.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "mt_pk" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cac202f19ffe0117.sql b/tests/ast_json_fixtures/shapes/cac202f19ffe0117.sql new file mode 100644 index 000000000000..bdd1f83131b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cac202f19ffe0117.sql @@ -0,0 +1 @@ +SELECT x FROM mt_pk ORDER BY x ASC LIMIT 1000000, 1 diff --git a/tests/ast_json_fixtures/shapes/cad4192747b1d109.json b/tests/ast_json_fixtures/shapes/cad4192747b1d109.json new file mode 100644 index 000000000000..a9f4d70c048b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cad4192747b1d109.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "KillQueryQuery", + "kill_type": "QUERY", + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "3-857d-4a57-9ee0-3c7da5d60a90" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": true + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cad4192747b1d109.sql b/tests/ast_json_fixtures/shapes/cad4192747b1d109.sql new file mode 100644 index 000000000000..27ec29f32e74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cad4192747b1d109.sql @@ -0,0 +1 @@ +KILL QUERY WHERE query_id='3-857d-4a57-9ee0-3c7da5d60a90' SETTINGS use_query_cache = true diff --git a/tests/ast_json_fixtures/shapes/cae94bbbe70ddf3f.json b/tests/ast_json_fixtures/shapes/cae94bbbe70ddf3f.json new file mode 100644 index 000000000000..2ba0b7db1c81 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cae94bbbe70ddf3f.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "if_not_exists": true, + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "row_policy", + "table": "table_with_dot_column" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "today", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "30" + } + ] + } + ] + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cae94bbbe70ddf3f.sql b/tests/ast_json_fixtures/shapes/cae94bbbe70ddf3f.sql new file mode 100644 index 000000000000..58470095ddeb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cae94bbbe70ddf3f.sql @@ -0,0 +1 @@ +CREATE ROW POLICY IF NOT EXISTS row_policy ON table_with_dot_column USING toDate(date) >= today() - 30 TO ALL diff --git a/tests/ast_json_fixtures/shapes/caed257266a666d9.json b/tests/ast_json_fixtures/shapes/caed257266a666d9.json new file mode 100644 index 000000000000..52c8d6595187 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/caed257266a666d9.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/caed257266a666d9.sql b/tests/ast_json_fixtures/shapes/caed257266a666d9.sql new file mode 100644 index 000000000000..92a0918a1da9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/caed257266a666d9.sql @@ -0,0 +1 @@ +SELECT DISTINCT 'a' diff --git a/tests/ast_json_fixtures/shapes/cb0de7b4d88bebb9.json b/tests/ast_json_fixtures/shapes/cb0de7b4d88bebb9.json new file mode 100644 index 000000000000..6b98eb352fed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb0de7b4d88bebb9.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UUID" + } + }, + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "id" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cb0de7b4d88bebb9.sql b/tests/ast_json_fixtures/shapes/cb0de7b4d88bebb9.sql new file mode 100644 index 000000000000..b0ad9c182d9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb0de7b4d88bebb9.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS t +( + id UUID, + d DateTime +) +ENGINE = MergeTree +PARTITION BY toDate(d) +ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/cb4f71a12f765513.json b/tests/ast_json_fixtures/shapes/cb4f71a12f765513.json new file mode 100644 index 000000000000..eb8628caa5e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb4f71a12f765513.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "rank", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + }, + "final": true + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + } + ] + } + } + ], + "format": "null" + } +} diff --git a/tests/ast_json_fixtures/shapes/cb4f71a12f765513.sql b/tests/ast_json_fixtures/shapes/cb4f71a12f765513.sql new file mode 100644 index 000000000000..6d6b4585b1b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb4f71a12f765513.sql @@ -0,0 +1 @@ +SELECT rank() OVER () FROM t0 FINAL WHERE t0.c0 > 0.1 FORMAT null diff --git a/tests/ast_json_fixtures/shapes/cb51c668554d3861.json b/tests/ast_json_fixtures/shapes/cb51c668554d3861.json new file mode 100644 index 000000000000..7170f313aa39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb51c668554d3861.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "123qwe" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/cb51c668554d3861.sql b/tests/ast_json_fixtures/shapes/cb51c668554d3861.sql new file mode 100644 index 000000000000..dae5e6f7349d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb51c668554d3861.sql @@ -0,0 +1 @@ +ALTER USER u1_01292 IDENTIFIED BY '123qwe' diff --git a/tests/ast_json_fixtures/shapes/cb6ae75bff3360f3.json b/tests/ast_json_fixtures/shapes/cb6ae75bff3360f3.json new file mode 100644 index 000000000000..19278c9a04a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb6ae75bff3360f3.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "full_duplicates" + }, + "deduplicate": true, + "deduplicate_by_columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Asterisk", + "transformers": [ + { + "type": "ColumnsExceptTransformer", + "columns": [ + { + "type": "Identifier", + "name": "pk" + } + ] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cb6ae75bff3360f3.sql b/tests/ast_json_fixtures/shapes/cb6ae75bff3360f3.sql new file mode 100644 index 000000000000..0856bcb0684d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb6ae75bff3360f3.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE full_duplicates DEDUPLICATE BY * EXCEPT(pk) diff --git a/tests/ast_json_fixtures/shapes/cb77ab99bc8164c8.json b/tests/ast_json_fixtures/shapes/cb77ab99bc8164c8.json new file mode 100644 index 000000000000..3b21dd307844 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb77ab99bc8164c8.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01270" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01270" + }, + { + "type": "Identifier", + "name": "key" + } + ] + } + }, + "as_table": "data_01270" + } +} diff --git a/tests/ast_json_fixtures/shapes/cb77ab99bc8164c8.sql b/tests/ast_json_fixtures/shapes/cb77ab99bc8164c8.sql new file mode 100644 index 000000000000..a7a83bfbea2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb77ab99bc8164c8.sql @@ -0,0 +1 @@ +create table dist_01270 as data_01270 Engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01270, key) diff --git a/tests/ast_json_fixtures/shapes/cb94d0db65f5dfca.json b/tests/ast_json_fixtures/shapes/cb94d0db65f5dfca.json new file mode 100644 index 000000000000..2f47e311096f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb94d0db65f5dfca.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "partition_all" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition_ID", + "all": true + }, + "move_destination_type": "TABLE", + "to_table": "partition_all2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cb94d0db65f5dfca.sql b/tests/ast_json_fixtures/shapes/cb94d0db65f5dfca.sql new file mode 100644 index 000000000000..3f20eccea17b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb94d0db65f5dfca.sql @@ -0,0 +1 @@ +ALTER TABLE partition_all MOVE PARTITION ALL TO TABLE partition_all2 diff --git a/tests/ast_json_fixtures/shapes/cb95c2a50f8118fb.json b/tests/ast_json_fixtures/shapes/cb95c2a50f8118fb.json new file mode 100644 index 000000000000..f9bddde75f77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb95c2a50f8118fb.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "replace_access": true, + "access_rights": [ + { + "access_types": [] + }, + { + "access_types": ["SELECT"], + "database": "db9", + "table": "tb3" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cb95c2a50f8118fb.sql b/tests/ast_json_fixtures/shapes/cb95c2a50f8118fb.sql new file mode 100644 index 000000000000..a8d6c841c565 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cb95c2a50f8118fb.sql @@ -0,0 +1 @@ +GRANT NONE ON *.*, SELECT on db9.tb3 TO test_user_01999 WITH REPLACE OPTION diff --git a/tests/ast_json_fixtures/shapes/cbb594aa2103500b.json b/tests/ast_json_fixtures/shapes/cbb594aa2103500b.json new file mode 100644 index 000000000000..d0dc377e3df6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cbb594aa2103500b.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02148_test_function_nested" + } +} diff --git a/tests/ast_json_fixtures/shapes/cbb594aa2103500b.sql b/tests/ast_json_fixtures/shapes/cbb594aa2103500b.sql new file mode 100644 index 000000000000..0bd112b7c95d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cbb594aa2103500b.sql @@ -0,0 +1 @@ +DROP FUNCTION 02148_test_function_nested diff --git a/tests/ast_json_fixtures/shapes/cbbe0c25e2b19b80.json b/tests/ast_json_fixtures/shapes/cbbe0c25e2b19b80.json new file mode 100644 index 000000000000..ee501e566a67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cbbe0c25e2b19b80.json @@ -0,0 +1,115 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "start", + "value_type": "UInt64", + "value": "1734955380" + }, + { + "type": "Literal", + "alias": "end", + "value_type": "UInt64", + "value": "1734955680" + }, + { + "type": "Literal", + "alias": "step", + "value_type": "UInt64", + "value": "15" + }, + { + "type": "Literal", + "alias": "staleness", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Function", + "alias": "grid", + "name": "timeSeriesRange", + "arguments": [ + { + "type": "Identifier", + "name": "start" + }, + { + "type": "Identifier", + "name": "end" + }, + { + "type": "Identifier", + "name": "step" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "arrayZip", + "arguments": [ + { + "type": "Identifier", + "name": "grid" + }, + { + "type": "Function", + "name": "timeSeriesResampleToGridWithStaleness", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + }, + { + "type": "Identifier", + "name": "value" + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start" + }, + { + "type": "Identifier", + "name": "end" + }, + { + "type": "Identifier", + "name": "step" + }, + { + "type": "Identifier", + "name": "staleness" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ts_raw_data" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cbbe0c25e2b19b80.sql b/tests/ast_json_fixtures/shapes/cbbe0c25e2b19b80.sql new file mode 100644 index 000000000000..4951e3156872 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cbbe0c25e2b19b80.sql @@ -0,0 +1,4 @@ +WITH + 1734955380 AS start, 1734955680 AS end, 15 AS step, 0 AS staleness, + timeSeriesRange(start, end, step) as grid +SELECT arrayZip(grid, timeSeriesResampleToGridWithStaleness(start, end, step, staleness)(timestamp, value)) FROM ts_raw_data diff --git a/tests/ast_json_fixtures/shapes/cbdd86faa275d308.json b/tests/ast_json_fixtures/shapes/cbdd86faa275d308.json new file mode 100644 index 000000000000..61249c20df24 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cbdd86faa275d308.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q14_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/cbdd86faa275d308.sql b/tests/ast_json_fixtures/shapes/cbdd86faa275d308.sql new file mode 100644 index 000000000000..436c6fa0ff69 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cbdd86faa275d308.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q14_01297 diff --git a/tests/ast_json_fixtures/shapes/cbe67210e3956491.json b/tests/ast_json_fixtures/shapes/cbe67210e3956491.json new file mode 100644 index 000000000000..e30e04f7b373 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cbe67210e3956491.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "replace_table": true, + "create_or_replace": true, + "database": { + "type": "Identifier", + "name": "test_01915_db" + }, + "table": { + "type": "Identifier", + "name": "test_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "db", + "value": { + "type": "Literal", + "value_type": "String", + "value": "test_01915_db" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "test_source_table_1" + } + } + ] + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "direct", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cbe67210e3956491.sql b/tests/ast_json_fixtures/shapes/cbe67210e3956491.sql new file mode 100644 index 000000000000..c9860c1e770b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cbe67210e3956491.sql @@ -0,0 +1,8 @@ +CREATE OR REPLACE DICTIONARY test_01915_db.test_dictionary +( + id UInt64, + value String +) +PRIMARY KEY id +LAYOUT(DIRECT()) +SOURCE(CLICKHOUSE(DB 'test_01915_db' TABLE 'test_source_table_1')) diff --git a/tests/ast_json_fixtures/shapes/cbfa9c5ab68a7dea.json b/tests/ast_json_fixtures/shapes/cbfa9c5ab68a7dea.json new file mode 100644 index 000000000000..e6d9c4685e2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cbfa9c5ab68a7dea.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "res", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "3" + }, + { + "value_type": "UInt64", + "value": "4" + }, + { + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "TabSeparatedWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/cbfa9c5ab68a7dea.sql b/tests/ast_json_fixtures/shapes/cbfa9c5ab68a7dea.sql new file mode 100644 index 000000000000..88083f3b5c32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cbfa9c5ab68a7dea.sql @@ -0,0 +1 @@ +SELECT number % 2 ? [1, 2] : [3, 4, 5] AS res FROM system.numbers LIMIT 10 FORMAT TabSeparatedWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/cc16f51d2853fe62.json b/tests/ast_json_fixtures/shapes/cc16f51d2853fe62.json new file mode 100644 index 000000000000..c5df0c3cc261 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cc16f51d2853fe62.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "test_view" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "Rows", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "MaxHitTime", + "data_type": { + "type": "DataType", + "name": "DateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "America\/Los_Angeles" + } + ] + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "Rows", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "alias": "MaxHitTime", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "UTCEventTime" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cc16f51d2853fe62.sql b/tests/ast_json_fixtures/shapes/cc16f51d2853fe62.sql new file mode 100644 index 000000000000..757a0dbfa28b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cc16f51d2853fe62.sql @@ -0,0 +1 @@ +CREATE MATERIALIZED VIEW test_view (Rows UInt64, MaxHitTime DateTime('America/Los_Angeles')) AS SELECT count() AS Rows, max(UTCEventTime) AS MaxHitTime FROM test_table diff --git a/tests/ast_json_fixtures/shapes/cc7b700ddf4e0131.json b/tests/ast_json_fixtures/shapes/cc7b700ddf4e0131.json new file mode 100644 index 000000000000..10e47f989054 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cc7b700ddf4e0131.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PARTITION", + "detach": true, + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cc7b700ddf4e0131.sql b/tests/ast_json_fixtures/shapes/cc7b700ddf4e0131.sql new file mode 100644 index 000000000000..c5c43f37589f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cc7b700ddf4e0131.sql @@ -0,0 +1 @@ +alter table t detach partition 1 diff --git a/tests/ast_json_fixtures/shapes/ccac8fd3b7fe5db8.json b/tests/ast_json_fixtures/shapes/ccac8fd3b7fe5db8.json new file mode 100644 index 000000000000..e3b684d793c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ccac8fd3b7fe5db8.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "anyLast", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ccac8fd3b7fe5db8.sql b/tests/ast_json_fixtures/shapes/ccac8fd3b7fe5db8.sql new file mode 100644 index 000000000000..be1b1743d6a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ccac8fd3b7fe5db8.sql @@ -0,0 +1 @@ +SELECT anyLast(number) FROM numbers(1) GROUP BY number WITH ROLLUP WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/cce9bd8b8d24466b.json b/tests/ast_json_fixtures/shapes/cce9bd8b8d24466b.json new file mode 100644 index 000000000000..e3cb48e8e885 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cce9bd8b8d24466b.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "rmt1" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "1" + } + }, + "move_destination_type": "TABLE", + "to_table": "rmt2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cce9bd8b8d24466b.sql b/tests/ast_json_fixtures/shapes/cce9bd8b8d24466b.sql new file mode 100644 index 000000000000..750aeb0364ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cce9bd8b8d24466b.sql @@ -0,0 +1 @@ +alter table rmt1 move partition id '1' to table rmt2 diff --git a/tests/ast_json_fixtures/shapes/ccfba5994c3772ef.json b/tests/ast_json_fixtures/shapes/ccfba5994c3772ef.json new file mode 100644 index 000000000000..4828e7b7561b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ccfba5994c3772ef.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_b" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "0" + } + }, + "replace": true, + "from_table": "test_a" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ccfba5994c3772ef.sql b/tests/ast_json_fixtures/shapes/ccfba5994c3772ef.sql new file mode 100644 index 000000000000..943cc268066b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ccfba5994c3772ef.sql @@ -0,0 +1 @@ +ALTER TABLE test_b REPLACE PARTITION '0' FROM test_a diff --git a/tests/ast_json_fixtures/shapes/cd2fa99233f5cd32.json b/tests/ast_json_fixtures/shapes/cd2fa99233f5cd32.json new file mode 100644 index 000000000000..208964b929c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd2fa99233f5cd32.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + }, + "aliases": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "b" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cd2fa99233f5cd32.sql b/tests/ast_json_fixtures/shapes/cd2fa99233f5cd32.sql new file mode 100644 index 000000000000..0a4348c25a61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd2fa99233f5cd32.sql @@ -0,0 +1,5 @@ +WITH t (a) AS ( + SELECT 1, 2 +) +SELECT b +FROM t diff --git a/tests/ast_json_fixtures/shapes/cd35b50b75b0b6b5.json b/tests/ast_json_fixtures/shapes/cd35b50b75b0b6b5.json new file mode 100644 index 000000000000..4d7d8a9c6b67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd35b50b75b0b6b5.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q1_01297", "q2_01297", "q3_01297", "q4_01297", "q5_01297", "q6_01297", "q7_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/cd35b50b75b0b6b5.sql b/tests/ast_json_fixtures/shapes/cd35b50b75b0b6b5.sql new file mode 100644 index 000000000000..50dcd90e3c81 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd35b50b75b0b6b5.sql @@ -0,0 +1 @@ +DROP QUOTA q1_01297, q2_01297, q3_01297, q4_01297, q5_01297, q6_01297, q7_01297 diff --git a/tests/ast_json_fixtures/shapes/cd3647c7625ec6af.json b/tests/ast_json_fixtures/shapes/cd3647c7625ec6af.json new file mode 100644 index 000000000000..5318c31c76c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd3647c7625ec6af.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "mergetree_00588" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "where": { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%l%" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "s" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cd3647c7625ec6af.sql b/tests/ast_json_fixtures/shapes/cd3647c7625ec6af.sql new file mode 100644 index 000000000000..17a8ca4521cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd3647c7625ec6af.sql @@ -0,0 +1 @@ +SELECT * FROM mergetree_00588 PREWHERE x = 1 WHERE s LIKE '%l%' ORDER BY x, s diff --git a/tests/ast_json_fixtures/shapes/cd3bb4cc6d1c915e.json b/tests/ast_json_fixtures/shapes/cd3bb4cc6d1c915e.json new file mode 100644 index 000000000000..fb541fb3cd8f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd3bb4cc6d1c915e.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_alter_atomic" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Literal", + "value_type": "Bool", + "value": true + }, + "assignments": [ + { + "type": "Assignment", + "column": "c0", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + }, + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "column": { + "type": "Identifier", + "name": "c0" + }, + "rename_to": { + "type": "Identifier", + "name": "c1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cd3bb4cc6d1c915e.sql b/tests/ast_json_fixtures/shapes/cd3bb4cc6d1c915e.sql new file mode 100644 index 000000000000..e6e5a2115ce8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd3bb4cc6d1c915e.sql @@ -0,0 +1 @@ +ALTER TABLE test_alter_atomic UPDATE c0 = 1 WHERE true, RENAME COLUMN c0 TO c1 diff --git a/tests/ast_json_fixtures/shapes/cd40030d385efbd1.json b/tests/ast_json_fixtures/shapes/cd40030d385efbd1.json new file mode 100644 index 000000000000..c95600fb6fe4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd40030d385efbd1.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Identifier", + "name": "02453_data.jsonl", + "name_parts": ["02453_data", "jsonl"] + }, + { + "type": "Identifier", + "name": "TSV" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cd40030d385efbd1.sql b/tests/ast_json_fixtures/shapes/cd40030d385efbd1.sql new file mode 100644 index 000000000000..b07ce0fd3392 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd40030d385efbd1.sql @@ -0,0 +1 @@ +insert into function file(02453_data.jsonl, TSV) select 1 settings engine_file_truncate_on_insert=1 diff --git a/tests/ast_json_fixtures/shapes/cd648377325dd9db.json b/tests/ast_json_fixtures/shapes/cd648377325dd9db.json new file mode 100644 index 000000000000..1422f85688cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd648377325dd9db.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "cluster", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "dist_01247" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "distributed_group_by_no_merge": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cd648377325dd9db.sql b/tests/ast_json_fixtures/shapes/cd648377325dd9db.sql new file mode 100644 index 000000000000..0316a43cfa10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd648377325dd9db.sql @@ -0,0 +1 @@ +select count(), * from cluster(test_cluster_two_shards, currentDatabase(), dist_01247) group by number order by number settings distributed_group_by_no_merge=1 diff --git a/tests/ast_json_fixtures/shapes/cd79913642ab5f72.json b/tests/ast_json_fixtures/shapes/cd79913642ab5f72.json new file mode 100644 index 000000000000..174a9f84abab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd79913642ab5f72.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cd79913642ab5f72.sql b/tests/ast_json_fixtures/shapes/cd79913642ab5f72.sql new file mode 100644 index 000000000000..aadcd3589ae5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd79913642ab5f72.sql @@ -0,0 +1 @@ +SELECT (SELECT 1) diff --git a/tests/ast_json_fixtures/shapes/cd7f39dcec2083b3.json b/tests/ast_json_fixtures/shapes/cd7f39dcec2083b3.json new file mode 100644 index 000000000000..3bae625e9856 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd7f39dcec2083b3.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "original_mv", + "to_table": "new_mv" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cd7f39dcec2083b3.sql b/tests/ast_json_fixtures/shapes/cd7f39dcec2083b3.sql new file mode 100644 index 000000000000..4b76a81503e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd7f39dcec2083b3.sql @@ -0,0 +1 @@ +RENAME TABLE original_mv TO new_mv diff --git a/tests/ast_json_fixtures/shapes/cd9813860f69d290.json b/tests/ast_json_fixtures/shapes/cd9813860f69d290.json new file mode 100644 index 000000000000..5e9ebf418492 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd9813860f69d290.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "NO_PASSWORD", + "arguments": [] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/cd9813860f69d290.sql b/tests/ast_json_fixtures/shapes/cd9813860f69d290.sql new file mode 100644 index 000000000000..344c10187c43 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd9813860f69d290.sql @@ -0,0 +1 @@ +CREATE USER u1_01292 NOT IDENTIFIED diff --git a/tests/ast_json_fixtures/shapes/cd9bfaa7265d7ed0.json b/tests/ast_json_fixtures/shapes/cd9bfaa7265d7ed0.json new file mode 100644 index 000000000000..ec3a45879d6a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd9bfaa7265d7ed0.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "is_populate": true, + "table": { + "type": "Identifier", + "name": "rview" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c0", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "File", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "CSV" + } + ] + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cd9bfaa7265d7ed0.sql b/tests/ast_json_fixtures/shapes/cd9bfaa7265d7ed0.sql new file mode 100644 index 000000000000..87819ed4fde2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cd9bfaa7265d7ed0.sql @@ -0,0 +1 @@ +CREATE MATERIALIZED VIEW rview ENGINE = File(CSV) POPULATE AS SELECT 1 AS c0 diff --git a/tests/ast_json_fixtures/shapes/cda4b7fe10feb912.json b/tests/ast_json_fixtures/shapes/cda4b7fe10feb912.json new file mode 100644 index 000000000000..bd1dfe05043c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cda4b7fe10feb912.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "min_number", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "having": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "min_number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cda4b7fe10feb912.sql b/tests/ast_json_fixtures/shapes/cda4b7fe10feb912.sql new file mode 100644 index 000000000000..a4443aa6764f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cda4b7fe10feb912.sql @@ -0,0 +1 @@ +SELECT min(number) as min_number FROM numbers(10) GROUP BY number HAVING 1 ORDER BY min_number diff --git a/tests/ast_json_fixtures/shapes/cda7ddcb840b842d.json b/tests/ast_json_fixtures/shapes/cda7ddcb840b842d.json new file mode 100644 index 000000000000..27edbe15cd13 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cda7ddcb840b842d.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cda7ddcb840b842d.sql b/tests/ast_json_fixtures/shapes/cda7ddcb840b842d.sql new file mode 100644 index 000000000000..02719057351f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cda7ddcb840b842d.sql @@ -0,0 +1 @@ +SELECT *, n = x, n - x FROM t WHERE n % 1000 = 0 ORDER BY n diff --git a/tests/ast_json_fixtures/shapes/cda8c128bcbd55e3.json b/tests/ast_json_fixtures/shapes/cda8c128bcbd55e3.json new file mode 100644 index 000000000000..79d0973e4352 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cda8c128bcbd55e3.json @@ -0,0 +1,427 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "count", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "id2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "cte", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tbl" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "joinGet", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".join_engine" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "v" + }, + { + "type": "Identifier", + "name": "id1" + }, + { + "type": "Identifier", + "name": "id2" + } + ] + }, + { + "type": "Identifier", + "name": "tbl.v", + "name_parts": ["tbl", "v"] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "e", + "name": "tbl" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "joinGet", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".join_engine" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "v" + }, + { + "type": "Identifier", + "name": "id1" + }, + { + "type": "Identifier", + "name": "id2" + } + ] + }, + { + "type": "Identifier", + "name": "e.v", + "name_parts": ["e", "v"] + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id2" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tbl" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "joinGet", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".join_engine" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "v" + }, + { + "type": "Identifier", + "name": "id1" + }, + { + "type": "Identifier", + "name": "id2" + } + ] + }, + { + "type": "Identifier", + "name": "tbl.v", + "name_parts": ["tbl", "v"] + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "count", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "id2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tbl" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "joinGet", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".join_engine" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "v" + }, + { + "type": "Identifier", + "name": "id1" + }, + { + "type": "Identifier", + "name": "id2" + } + ] + }, + { + "type": "Identifier", + "name": "tbl.v", + "name_parts": ["tbl", "v"] + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cda8c128bcbd55e3.sql b/tests/ast_json_fixtures/shapes/cda8c128bcbd55e3.sql new file mode 100644 index 000000000000..8851ba781f59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cda8c128bcbd55e3.sql @@ -0,0 +1,30 @@ +SELECT uniq(id2) AS count +FROM +( + WITH cte AS + ( + SELECT id2 + FROM tbl + WHERE joinGet(currentDatabase() || '.join_engine', 'v', id1, id2) = tbl.v + ) + SELECT * + FROM tbl AS e + WHERE joinGet(currentDatabase() || '.join_engine', 'v', id1, id2) = e.v +) +WHERE id2 IN ( + SELECT id2 + FROM + ( + SELECT id2 + FROM tbl + WHERE joinGet(currentDatabase() || '.join_engine', 'v', id1, id2) = tbl.v + ) +) +UNION ALL +SELECT uniq(id2) AS count +FROM +( + SELECT id2 + FROM tbl + WHERE joinGet(currentDatabase() || '.join_engine', 'v', id1, id2) = tbl.v +) diff --git a/tests/ast_json_fixtures/shapes/cdc98c12ebc64837.json b/tests/ast_json_fixtures/shapes/cdc98c12ebc64837.json new file mode 100644 index 000000000000..52bcf755c374 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cdc98c12ebc64837.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "DISABLE FAILPOINT", + "fail_point_name": "prefetched_reader_pool_failpoint" + } +} diff --git a/tests/ast_json_fixtures/shapes/cdc98c12ebc64837.sql b/tests/ast_json_fixtures/shapes/cdc98c12ebc64837.sql new file mode 100644 index 000000000000..b43ab16be922 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cdc98c12ebc64837.sql @@ -0,0 +1 @@ +SYSTEM DISABLE FAILPOINT prefetched_reader_pool_failpoint diff --git a/tests/ast_json_fixtures/shapes/cdd1ce028df43dcf.json b/tests/ast_json_fixtures/shapes/cdd1ce028df43dcf.json new file mode 100644 index 000000000000..e727f20bf2ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cdd1ce028df43dcf.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "a1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "hash_key", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "partition_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Identifier", + "name": "hash_key" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cdd1ce028df43dcf.sql b/tests/ast_json_fixtures/shapes/cdd1ce028df43dcf.sql new file mode 100644 index 000000000000..7bf962c934d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cdd1ce028df43dcf.sql @@ -0,0 +1 @@ +create table a1 (i int, hash_key int) partition by (i, hash_key) diff --git a/tests/ast_json_fixtures/shapes/cdd792b926ece6a6.json b/tests/ast_json_fixtures/shapes/cdd792b926ece6a6.json new file mode 100644 index 000000000000..9e72b5470f79 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cdd792b926ece6a6.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition" + } + } + ], + "where": { + "type": "Literal", + "value_type": "Null", + "value": null + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cdd792b926ece6a6.sql b/tests/ast_json_fixtures/shapes/cdd792b926ece6a6.sql new file mode 100644 index 000000000000..78a3414a1b8e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cdd792b926ece6a6.sql @@ -0,0 +1 @@ +select count() over () where null diff --git a/tests/ast_json_fixtures/shapes/cde7db0b71fd8442.json b/tests/ast_json_fixtures/shapes/cde7db0b71fd8442.json new file mode 100644 index 000000000000..f297c8d9cac5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cde7db0b71fd8442.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "reference_vec", + "value_type": "Array", + "value": [ + { + "value_type": "Float64", + "value": 0 + }, + { + "value_type": "Float64", + "value": 2 + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab_bf16" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "L2Distance", + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cde7db0b71fd8442.sql b/tests/ast_json_fixtures/shapes/cde7db0b71fd8442.sql new file mode 100644 index 000000000000..e681b7cad2dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cde7db0b71fd8442.sql @@ -0,0 +1,5 @@ +WITH [0.0, 2.0] AS reference_vec +SELECT id, L2Distance(vec, reference_vec) +FROM tab_bf16 +ORDER BY L2Distance(vec, reference_vec) +LIMIT 4 diff --git a/tests/ast_json_fixtures/shapes/ce7ecb0a0393abe9.json b/tests/ast_json_fixtures/shapes/ce7ecb0a0393abe9.json new file mode 100644 index 000000000000..51bebf9cd9fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ce7ecb0a0393abe9.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ce7ecb0a0393abe9.sql b/tests/ast_json_fixtures/shapes/ce7ecb0a0393abe9.sql new file mode 100644 index 000000000000..ff4bae5ba45a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ce7ecb0a0393abe9.sql @@ -0,0 +1 @@ +SELECT x FROM a diff --git a/tests/ast_json_fixtures/shapes/ce9436155826fe73.json b/tests/ast_json_fixtures/shapes/ce9436155826fe73.json new file mode 100644 index 000000000000..f2af88623953 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ce9436155826fe73.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test", + "from_table": "hits", + "to_database": "test", + "to_table": "hits2" + }, + { + "from_database": "test", + "from_table": "hits2", + "to_database": "test", + "to_table": "hits3" + }, + { + "from_database": "test", + "from_table": "hits3", + "to_database": "test", + "to_table": "hits4" + }, + { + "from_database": "test", + "from_table": "hits4", + "to_database": "test", + "to_table": "hits5" + }, + { + "from_database": "test", + "from_table": "hits5", + "to_database": "test", + "to_table": "hits6" + }, + { + "from_database": "test", + "from_table": "hits6", + "to_database": "test", + "to_table": "hits7" + }, + { + "from_database": "test", + "from_table": "hits7", + "to_database": "test", + "to_table": "hits8" + }, + { + "from_database": "test", + "from_table": "hits8", + "to_database": "test", + "to_table": "hits9" + }, + { + "from_database": "test", + "from_table": "hits9", + "to_database": "test", + "to_table": "hits10" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ce9436155826fe73.sql b/tests/ast_json_fixtures/shapes/ce9436155826fe73.sql new file mode 100644 index 000000000000..a9159be4873e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ce9436155826fe73.sql @@ -0,0 +1 @@ +RENAME TABLE test.hits TO test.hits2, test.hits2 TO test.hits3, test.hits3 TO test.hits4, test.hits4 TO test.hits5, test.hits5 TO test.hits6, test.hits6 TO test.hits7, test.hits7 TO test.hits8, test.hits8 TO test.hits9, test.hits9 TO test.hits10 diff --git a/tests/ast_json_fixtures/shapes/ce95a764837f8a47.json b/tests/ast_json_fixtures/shapes/ce95a764837f8a47.json new file mode 100644 index 000000000000..1fab36f92554 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ce95a764837f8a47.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "y", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "t" + }, + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "alias": "x", + "value_type": "String", + "value": "rue" + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "String", + "value": "true" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ce95a764837f8a47.sql b/tests/ast_json_fixtures/shapes/ce95a764837f8a47.sql new file mode 100644 index 000000000000..39ee1570278b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ce95a764837f8a47.sql @@ -0,0 +1,4 @@ +with + ('t' || x) as y, + 'rue' as x +select 1 from tab where y = 'true' settings enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/ceb15efa9a69ea44.json b/tests/ast_json_fixtures/shapes/ceb15efa9a69ea44.json new file mode 100644 index 000000000000..f451ff8811e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ceb15efa9a69ea44.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "function_name": { + "type": "Identifier", + "name": "02181_invalid_lambda" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "arguments": [] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ceb15efa9a69ea44.sql b/tests/ast_json_fixtures/shapes/ceb15efa9a69ea44.sql new file mode 100644 index 000000000000..5c81444dcd35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ceb15efa9a69ea44.sql @@ -0,0 +1 @@ +CREATE FUNCTION 02181_invalid_lambda AS lambda() diff --git a/tests/ast_json_fixtures/shapes/cefb9c71a7ad3f75.json b/tests/ast_json_fixtures/shapes/cefb9c71a7ad3f75.json new file mode 100644 index 000000000000..12575f247121 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cefb9c71a7ad3f75.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t1_local" + }, + "cluster": "test_shard_localhost", + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "partition2" + } + }, + "move_destination_type": "TABLE", + "to_table": "t2_local" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cefb9c71a7ad3f75.sql b/tests/ast_json_fixtures/shapes/cefb9c71a7ad3f75.sql new file mode 100644 index 000000000000..6e906d506366 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cefb9c71a7ad3f75.sql @@ -0,0 +1 @@ +ALTER TABLE t1_local ON CLUSTER test_shard_localhost MOVE PARTITION 'partition2' TO TABLE t2_local diff --git a/tests/ast_json_fixtures/shapes/cf078bd5b5ca0eae.json b/tests/ast_json_fixtures/shapes/cf078bd5b5ca0eae.json new file mode 100644 index 000000000000..ee22220eef8c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf078bd5b5ca0eae.json @@ -0,0 +1,132 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_all": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "l.number", + "name_parts": ["l", "number"] + }, + { + "type": "Function", + "alias": "mod3", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "r.number", + "name_parts": ["r", "number"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "r.number", + "name_parts": ["r", "number"] + } + ] + }, + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "l.number", + "name_parts": ["l", "number"] + } + ] + }, + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "mod3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "l", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l.number", + "name_parts": ["l", "number"] + }, + { + "type": "Identifier", + "name": "r.number", + "name_parts": ["r", "number"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "r", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cf078bd5b5ca0eae.sql b/tests/ast_json_fixtures/shapes/cf078bd5b5ca0eae.sql new file mode 100644 index 000000000000..2f1dcd2b69e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf078bd5b5ca0eae.sql @@ -0,0 +1,4 @@ +SELECT l.number, r.number % 3 AS mod3, sum(r.number), + grouping(l.number), grouping(mod3) +FROM numbers(1) l JOIN numbers(2) r ON l.number < r.number +GROUP BY ALL WITH CUBE diff --git a/tests/ast_json_fixtures/shapes/cf07c7967793ecb8.json b/tests/ast_json_fixtures/shapes/cf07c7967793ecb8.json new file mode 100644 index 000000000000..ab4e21adb347 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf07c7967793ecb8.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q5_01297"], + "key_type": "CLIENT_KEY_OR_USER_NAME" + } +} diff --git a/tests/ast_json_fixtures/shapes/cf07c7967793ecb8.sql b/tests/ast_json_fixtures/shapes/cf07c7967793ecb8.sql new file mode 100644 index 000000000000..a04b9d0ff95e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf07c7967793ecb8.sql @@ -0,0 +1 @@ +CREATE QUOTA q5_01297 KEY BY client_key, user_name diff --git a/tests/ast_json_fixtures/shapes/cf12e83183a86b83.json b/tests/ast_json_fixtures/shapes/cf12e83183a86b83.json new file mode 100644 index 000000000000..39da7ed268d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf12e83183a86b83.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "value2" + } + ] + }, + { + "type": "Identifier", + "name": "value2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "rdb.key", + "name_parts": ["rdb", "key"] + }, + { + "type": "Identifier", + "name": "t2.k", + "name_parts": ["t2", "k"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "rdb" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "join_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cf12e83183a86b83.sql b/tests/ast_json_fixtures/shapes/cf12e83183a86b83.sql new file mode 100644 index 000000000000..4fd1b6dd9cb0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf12e83183a86b83.sql @@ -0,0 +1 @@ +SELECT k, key, toTypeName(value2), value2 FROM t2 LEFT JOIN rdb ON rdb.key == t2.k ORDER BY k SETTINGS join_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/cf17f9308ef4d27d.json b/tests/ast_json_fixtures/shapes/cf17f9308ef4d27d.json new file mode 100644 index 000000000000..34168f4161e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf17f9308ef4d27d.json @@ -0,0 +1,126 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Literal", + "alias": "p", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "alias": "actual", + "name": "geohashEncode", + "arguments": [ + { + "type": "Identifier", + "name": "longitude" + }, + { + "type": "Identifier", + "name": "latitude" + }, + { + "type": "Identifier", + "name": "p" + } + ] + }, + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "actual" + }, + { + "type": "Identifier", + "name": "encoded" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Ok" + }, + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "expected: " + }, + { + "type": "Identifier", + "name": "encoded" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "geohash_test_data" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "encoded" + } + ] + }, + { + "type": "Identifier", + "name": "p" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cf17f9308ef4d27d.sql b/tests/ast_json_fixtures/shapes/cf17f9308ef4d27d.sql new file mode 100644 index 000000000000..be069083ed11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf17f9308ef4d27d.sql @@ -0,0 +1 @@ +select 1 as p, geohashEncode(longitude, latitude, p) as actual, if(actual = encoded, 'Ok', concat('expected: ', encoded)) from geohash_test_data WHERE length(encoded) = p order by all diff --git a/tests/ast_json_fixtures/shapes/cf181285d705185d.json b/tests/ast_json_fixtures/shapes/cf181285d705185d.json new file mode 100644 index 000000000000..1c52b4c31ed0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf181285d705185d.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "rmt3" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PARTITION", + "part": true, + "partition": { + "type": "Literal", + "value_type": "String", + "value": "all_1_1_0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cf181285d705185d.sql b/tests/ast_json_fixtures/shapes/cf181285d705185d.sql new file mode 100644 index 000000000000..cbe90557dcaa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf181285d705185d.sql @@ -0,0 +1 @@ +alter table rmt3 drop part 'all_1_1_0' diff --git a/tests/ast_json_fixtures/shapes/cf1c12d3e6fe6e12.json b/tests/ast_json_fixtures/shapes/cf1c12d3e6fe6e12.json new file mode 100644 index 000000000000..e615ea09836f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf1c12d3e6fe6e12.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "DetachQuery", + "kind": "DETACH", + "database": { + "type": "Identifier", + "name": "db_01018" + }, + "table": { + "type": "Identifier", + "name": "dict1" + }, + "is_dictionary": true + } +} diff --git a/tests/ast_json_fixtures/shapes/cf1c12d3e6fe6e12.sql b/tests/ast_json_fixtures/shapes/cf1c12d3e6fe6e12.sql new file mode 100644 index 000000000000..08af3349218c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf1c12d3e6fe6e12.sql @@ -0,0 +1 @@ +DETACH DICTIONARY db_01018.dict1 diff --git a/tests/ast_json_fixtures/shapes/cf1cde69e616652a.json b/tests/ast_json_fixtures/shapes/cf1cde69e616652a.json new file mode 100644 index 000000000000..37df2f41944c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf1cde69e616652a.json @@ -0,0 +1,114 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "res", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tup" + }, + { + "type": "Identifier", + "name": "tup" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_02833" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cf1cde69e616652a.sql b/tests/ast_json_fixtures/shapes/cf1cde69e616652a.sql new file mode 100644 index 000000000000..27ad3665b7d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf1cde69e616652a.sql @@ -0,0 +1,2 @@ +WITH (tup || tup) AS res +SELECT res, res.1, res.2, res.3, res.4 FROM t_02833 diff --git a/tests/ast_json_fixtures/shapes/cf319e1866c5e294.json b/tests/ast_json_fixtures/shapes/cf319e1866c5e294.json new file mode 100644 index 000000000000..f97b0033c341 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf319e1866c5e294.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "alter": true, + "names": ["r1_01293"], + "alter_settings": { + "type": "AlterSettingsProfileElements", + "add_settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "1" + } + ] + }, + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cf319e1866c5e294.sql b/tests/ast_json_fixtures/shapes/cf319e1866c5e294.sql new file mode 100644 index 000000000000..7729ab7932db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf319e1866c5e294.sql @@ -0,0 +1 @@ +ALTER ROLE r1_01293 SETTINGS readonly=1 diff --git a/tests/ast_json_fixtures/shapes/cf36f93f9acecb96.json b/tests/ast_json_fixtures/shapes/cf36f93f9acecb96.json new file mode 100644 index 000000000000..e464db0f48a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf36f93f9acecb96.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "distinct_in_order" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "read_in_order_two_level_merge_threshold": "0", + "optimize_read_in_order": "1", + "max_threads": "2" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cf36f93f9acecb96.sql b/tests/ast_json_fixtures/shapes/cf36f93f9acecb96.sql new file mode 100644 index 000000000000..4ac86c01e3fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf36f93f9acecb96.sql @@ -0,0 +1,6 @@ +SELECT DISTINCT a +FROM distinct_in_order +ORDER BY a ASC +SETTINGS read_in_order_two_level_merge_threshold = 0, +optimize_read_in_order = 1, +max_threads = 2 diff --git a/tests/ast_json_fixtures/shapes/cf539886a851d1f0.json b/tests/ast_json_fixtures/shapes/cf539886a851d1f0.json new file mode 100644 index 000000000000..96d3e3c73816 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf539886a851d1f0.json @@ -0,0 +1,141 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "full_duplicates" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "pk", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "sk", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "val", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "partition_key", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "mat", + "data_type": { + "type": "DataType", + "name": "UInt32" + }, + "default_specifier": "MATERIALIZED", + "default_expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "12345" + } + }, + { + "type": "ColumnDeclaration", + "name": "alias", + "data_type": { + "type": "DataType", + "name": "UInt32" + }, + "default_specifier": "ALIAS", + "default_expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "pk" + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "partition_key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "primary_key": { + "type": "Identifier", + "name": "pk" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "pk" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "sk" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/cf539886a851d1f0.sql b/tests/ast_json_fixtures/shapes/cf539886a851d1f0.sql new file mode 100644 index 000000000000..d4dcbc839908 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf539886a851d1f0.sql @@ -0,0 +1,6 @@ +CREATE TABLE full_duplicates ( + pk Int32, sk Int32, val UInt32, partition_key UInt32, mat UInt32 MATERIALIZED 12345, alias UInt32 ALIAS 2, + PRIMARY KEY (pk) +) ENGINE=MergeTree +PARTITION BY (partition_key + 1) +ORDER BY (pk, toString(sk * 10)) diff --git a/tests/ast_json_fixtures/shapes/cf6cc7b114bb5ebe.json b/tests/ast_json_fixtures/shapes/cf6cc7b114bb5ebe.json new file mode 100644 index 000000000000..6369368ddaf3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf6cc7b114bb5ebe.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "database": true, + "elements": [ + { + "from_database": "test_01155_atomic", + "to_database": "test_01155_ordinary" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cf6cc7b114bb5ebe.sql b/tests/ast_json_fixtures/shapes/cf6cc7b114bb5ebe.sql new file mode 100644 index 000000000000..1739d3a589ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cf6cc7b114bb5ebe.sql @@ -0,0 +1 @@ +RENAME DATABASE test_01155_atomic TO test_01155_ordinary diff --git a/tests/ast_json_fixtures/shapes/cfc0178f43a9d1ef.json b/tests/ast_json_fixtures/shapes/cfc0178f43a9d1ef.json new file mode 100644 index 000000000000..12510db9814d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cfc0178f43a9d1ef.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_COMMENT", + "comment": { + "type": "Literal", + "value_type": "String", + "value": "World" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cfc0178f43a9d1ef.sql b/tests/ast_json_fixtures/shapes/cfc0178f43a9d1ef.sql new file mode 100644 index 000000000000..6ec280b41530 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cfc0178f43a9d1ef.sql @@ -0,0 +1 @@ +ALTER TABLE t MODIFY COMMENT 'World' diff --git a/tests/ast_json_fixtures/shapes/cfea247a6c6f0af4.json b/tests/ast_json_fixtures/shapes/cfea247a6c6f0af4.json new file mode 100644 index 000000000000..f87b1c4801cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cfea247a6c6f0af4.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "s", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Привет, World" + } + ] + } + ], + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "hell%" + } + ] + }, + { + "type": "Function", + "name": "ilike", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%привет%" + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "world%" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_or_like_chain": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cfea247a6c6f0af4.sql b/tests/ast_json_fixtures/shapes/cfea247a6c6f0af4.sql new file mode 100644 index 000000000000..c7e18d5ee8c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cfea247a6c6f0af4.sql @@ -0,0 +1 @@ +SELECT materialize('Привет, World') AS s WHERE (s LIKE 'hell%') OR (s ILIKE '%привет%') OR (s LIKE 'world%') SETTINGS optimize_or_like_chain = 0 diff --git a/tests/ast_json_fixtures/shapes/cff65a95af937ff2.json b/tests/ast_json_fixtures/shapes/cff65a95af937ff2.json new file mode 100644 index 000000000000..1f11c6f0ef0e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cff65a95af937ff2.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "alias": "k", + "value_type": "String", + "value": "Hello" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "999990" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + "settings": { + "type": "Settings", + "changes": { + "max_bytes_before_external_sort": "1000000", + "max_bytes_ratio_before_external_sort": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/cff65a95af937ff2.sql b/tests/ast_json_fixtures/shapes/cff65a95af937ff2.sql new file mode 100644 index 000000000000..313216b3e2b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/cff65a95af937ff2.sql @@ -0,0 +1 @@ +SELECT number, 'Hello' AS k FROM (SELECT number FROM system.numbers LIMIT 1000000) ORDER BY number LIMIT 999990, 100 SETTINGS max_bytes_before_external_sort = 1000000, max_bytes_ratio_before_external_sort = 0 diff --git a/tests/ast_json_fixtures/shapes/d000addfc701515c.json b/tests/ast_json_fixtures/shapes/d000addfc701515c.json new file mode 100644 index 000000000000..0a4fbeb3ccc6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d000addfc701515c.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_cluster" + }, + "as_table_function": { + "type": "Function", + "name": "cluster", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_one_shard_three_replicas_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "test" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d000addfc701515c.sql b/tests/ast_json_fixtures/shapes/d000addfc701515c.sql new file mode 100644 index 000000000000..8046302407ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d000addfc701515c.sql @@ -0,0 +1 @@ +create table test_cluster as cluster(test_cluster_one_shard_three_replicas_localhost, currentDatabase(), 'test') diff --git a/tests/ast_json_fixtures/shapes/d00ceb3027e517b1.json b/tests/ast_json_fixtures/shapes/d00ceb3027e517b1.json new file mode 100644 index 000000000000..1d8a57b590d9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d00ceb3027e517b1.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ShowGrantsQuery", + "for_roles": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d00ceb3027e517b1.sql b/tests/ast_json_fixtures/shapes/d00ceb3027e517b1.sql new file mode 100644 index 000000000000..fd791e5f0d45 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d00ceb3027e517b1.sql @@ -0,0 +1 @@ +SHOW GRANTS FOR test_user_01999 diff --git a/tests/ast_json_fixtures/shapes/d0130385f813b53c.json b/tests/ast_json_fixtures/shapes/d0130385f813b53c.json new file mode 100644 index 000000000000..7356f4f3973a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0130385f813b53c.json @@ -0,0 +1,193 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "Test" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "String1" + }, + { + "type": "Identifier", + "name": "String2" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "String1" + }, + { + "type": "Identifier", + "name": "String2" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192", + "index_granularity_bytes": "10Mi", + "add_minmax_index_for_numeric_columns": "0" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "String1", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "String1_" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "String2", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "String2_" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "String3", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "String3_" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "String4", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "String4_" + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d0130385f813b53c.sql b/tests/ast_json_fixtures/shapes/d0130385f813b53c.sql new file mode 100644 index 000000000000..77fc1a73b095 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0130385f813b53c.sql @@ -0,0 +1,12 @@ +CREATE TABLE Test +ENGINE = MergeTree() +PRIMARY KEY (String1,String2) +ORDER BY (String1,String2) +SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi', add_minmax_index_for_numeric_columns=0 +AS +SELECT + 'String1_' || toString(number) as String1, + 'String2_' || toString(number) as String2, + 'String3_' || toString(number) as String3, + 'String4_' || toString(number%4) as String4 +FROM numbers(1) diff --git a/tests/ast_json_fixtures/shapes/d01a403cd18eab43.json b/tests/ast_json_fixtures/shapes/d01a403cd18eab43.json new file mode 100644 index 000000000000..6ad754504c53 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d01a403cd18eab43.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r1_01295"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d01a403cd18eab43.sql b/tests/ast_json_fixtures/shapes/d01a403cd18eab43.sql new file mode 100644 index 000000000000..6569a7e84f54 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d01a403cd18eab43.sql @@ -0,0 +1 @@ +DROP ROLE r1_01295 diff --git a/tests/ast_json_fixtures/shapes/d01b280df90d125e.json b/tests/ast_json_fixtures/shapes/d01b280df90d125e.json new file mode 100644 index 000000000000..e3104be3cc4f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d01b280df90d125e.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_DISTINCT", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d01b280df90d125e.sql b/tests/ast_json_fixtures/shapes/d01b280df90d125e.sql new file mode 100644 index 000000000000..ab34d35c2c3d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d01b280df90d125e.sql @@ -0,0 +1,6 @@ +EXPLAIN SYNTAX +SELECT 1 +UNION ALL +SELECT 1 +UNION DISTINCT +SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/d02a43cc2f31a318.json b/tests/ast_json_fixtures/shapes/d02a43cc2f31a318.json new file mode 100644 index 000000000000..f3b83990f346 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d02a43cc2f31a318.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "dst" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + "replace": true, + "from_table": "dst" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d02a43cc2f31a318.sql b/tests/ast_json_fixtures/shapes/d02a43cc2f31a318.sql new file mode 100644 index 000000000000..54af4f129f08 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d02a43cc2f31a318.sql @@ -0,0 +1 @@ +ALTER TABLE dst REPLACE PARTITION 1 FROM dst diff --git a/tests/ast_json_fixtures/shapes/d038523ea4669931.json b/tests/ast_json_fixtures/shapes/d038523ea4669931.json new file mode 100644 index 000000000000..e062db6eeb94 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d038523ea4669931.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q3_01297"], + "limits": [ + { + "duration_sec": "7200", + "max": { + "ERRORS": "10" + } + }, + { + "duration_sec": "3600", + "max": { + "QUERIES": "70" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d038523ea4669931.sql b/tests/ast_json_fixtures/shapes/d038523ea4669931.sql new file mode 100644 index 000000000000..d7a0e946f01d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d038523ea4669931.sql @@ -0,0 +1 @@ +ALTER QUOTA q3_01297 FOR INTERVAL 2 HOUR MAX errors = 10, FOR INTERVAL 1 HOUR MAX queries = 70 diff --git a/tests/ast_json_fixtures/shapes/d0394131a253da61.json b/tests/ast_json_fixtures/shapes/d0394131a253da61.json new file mode 100644 index 000000000000..08396047161d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0394131a253da61.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "move_partition_to_oneself" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "move_destination_type": "TABLE", + "to_table": "move_partition_to_oneself" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d0394131a253da61.sql b/tests/ast_json_fixtures/shapes/d0394131a253da61.sql new file mode 100644 index 000000000000..619a928aa421 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0394131a253da61.sql @@ -0,0 +1 @@ +ALTER TABLE move_partition_to_oneself MOVE PARTITION tuple() TO TABLE move_partition_to_oneself diff --git a/tests/ast_json_fixtures/shapes/d04c6a2bba841f01.json b/tests/ast_json_fixtures/shapes/d04c6a2bba841f01.json new file mode 100644 index 000000000000..3d562e382ba2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d04c6a2bba841f01.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + } + ], + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "2" + } + ], + "select": [ + { + "type": "Identifier", + "alias": "y", + "name": "x" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d04c6a2bba841f01.sql b/tests/ast_json_fixtures/shapes/d04c6a2bba841f01.sql new file mode 100644 index 000000000000..753c3a71f79b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d04c6a2bba841f01.sql @@ -0,0 +1 @@ +with 1 as x select *, x from (with 2 as x select x as y) diff --git a/tests/ast_json_fixtures/shapes/d06264d0a63ccb55.json b/tests/ast_json_fixtures/shapes/d06264d0a63ccb55.json new file mode 100644 index 000000000000..c94c6a2f4daa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d06264d0a63ccb55.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "alias": "str", + "value_type": "String", + "value": "Hello" + }, + { + "type": "Function", + "alias": "arr", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + } + ], + "format": "JSONObjectEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/d06264d0a63ccb55.sql b/tests/ast_json_fixtures/shapes/d06264d0a63ccb55.sql new file mode 100644 index 000000000000..a6f6a97f6c99 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d06264d0a63ccb55.sql @@ -0,0 +1 @@ +select number, 'Hello' as str, range(number) as arr from numbers(3) format JSONObjectEachRow diff --git a/tests/ast_json_fixtures/shapes/d07cc796cc9da10c.json b/tests/ast_json_fixtures/shapes/d07cc796cc9da10c.json new file mode 100644 index 000000000000..d55e8b4ee97d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d07cc796cc9da10c.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d07cc796cc9da10c.sql b/tests/ast_json_fixtures/shapes/d07cc796cc9da10c.sql new file mode 100644 index 000000000000..99b9ccd8af3d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d07cc796cc9da10c.sql @@ -0,0 +1 @@ +DROP USER u1_01292 diff --git a/tests/ast_json_fixtures/shapes/d09a39aa7aeeb4c9.json b/tests/ast_json_fixtures/shapes/d09a39aa7aeeb4c9.json new file mode 100644 index 000000000000..09ae09ab6efd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d09a39aa7aeeb4c9.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "limit_with_ties": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d09a39aa7aeeb4c9.sql b/tests/ast_json_fixtures/shapes/d09a39aa7aeeb4c9.sql new file mode 100644 index 000000000000..d3bd0e9591ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d09a39aa7aeeb4c9.sql @@ -0,0 +1 @@ +SELECT DISTINCT TOP 1 WITH TIES * FROM t0 ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/d0b9d1b62ea7608f.json b/tests/ast_json_fixtures/shapes/d0b9d1b62ea7608f.json new file mode 100644 index 000000000000..6d927f88b933 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0b9d1b62ea7608f.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02484_plusthreemonths" + } +} diff --git a/tests/ast_json_fixtures/shapes/d0b9d1b62ea7608f.sql b/tests/ast_json_fixtures/shapes/d0b9d1b62ea7608f.sql new file mode 100644 index 000000000000..a48636f76b01 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0b9d1b62ea7608f.sql @@ -0,0 +1 @@ +DROP FUNCTION 02484_plusthreemonths diff --git a/tests/ast_json_fixtures/shapes/d0c72c9bc0fc7a70.json b/tests/ast_json_fixtures/shapes/d0c72c9bc0fc7a70.json new file mode 100644 index 000000000000..0e648381a6e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0c72c9bc0fc7a70.json @@ -0,0 +1,196 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "begin", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Literal", + "alias": "end", + "value_type": "UInt64", + "value": "200" + }, + { + "type": "Literal", + "alias": "step_sec", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "alias": "staleness_sec", + "value_type": "UInt64", + "value": "15" + }, + { + "type": "Function", + "alias": "begin_ts", + "name": "CAST", + "arguments": [ + { + "type": "Identifier", + "name": "begin" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime('UTC')" + } + ] + }, + { + "type": "Function", + "alias": "end_ts", + "name": "CAST", + "arguments": [ + { + "type": "Identifier", + "name": "end" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime('UTC')" + } + ] + }, + { + "type": "Function", + "alias": "grid", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "begin" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "end" + }, + { + "type": "Identifier", + "name": "step_sec" + } + ] + }, + { + "type": "Identifier", + "name": "step_sec" + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "e", + "name": "arrayZip", + "arguments": [ + { + "type": "Identifier", + "name": "grid" + }, + { + "type": "Function", + "name": "timeSeriesResampleToGridWithStaleness", + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(6, 'UTC')" + } + ] + }, + { + "type": "Identifier", + "name": "value" + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "begin_ts" + }, + { + "type": "Identifier", + "name": "end_ts" + }, + { + "type": "Identifier", + "name": "step_sec" + }, + { + "type": "Identifier", + "name": "staleness_sec" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "clusterAllReplicas", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "ts_data" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_parallel_replicas": "1", + "max_parallel_replicas": "3", + "parallel_replicas_for_non_replicated_merge_tree": "1", + "prefer_localhost_replica": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d0c72c9bc0fc7a70.sql b/tests/ast_json_fixtures/shapes/d0c72c9bc0fc7a70.sql new file mode 100644 index 000000000000..30f0bc1bd966 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0c72c9bc0fc7a70.sql @@ -0,0 +1,14 @@ +WITH + 100 as begin, + 200 as end, + 10 as step_sec, + 15 as staleness_sec, + CAST(begin as DateTime('UTC')) as begin_ts, + CAST(end as DateTime('UTC')) as end_ts, + range(begin, end+step_sec, step_sec) as grid +SELECT + arrayZip( + grid, + timeSeriesResampleToGridWithStaleness(begin_ts, end_ts, step_sec, staleness_sec)(timestamp::DateTime64(6, 'UTC'), value) + ) as e +FROM clusterAllReplicas('test_shard_localhost', currentDatabase(), ts_data) SETTINGS enable_parallel_replicas=1, max_parallel_replicas=3, parallel_replicas_for_non_replicated_merge_tree=1, prefer_localhost_replica = 0 diff --git a/tests/ast_json_fixtures/shapes/d0ca0efcfba9c320.json b/tests/ast_json_fixtures/shapes/d0ca0efcfba9c320.json new file mode 100644 index 000000000000..35999373487a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0ca0efcfba9c320.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "z" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "z" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d0ca0efcfba9c320.sql b/tests/ast_json_fixtures/shapes/d0ca0efcfba9c320.sql new file mode 100644 index 000000000000..82b5d4677a61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0ca0efcfba9c320.sql @@ -0,0 +1 @@ +SELECT DISTINCT x, z FROM tab WHERE x IN (1, 2) AND z < 5 diff --git a/tests/ast_json_fixtures/shapes/d0f0f79fb1d01dd9.json b/tests/ast_json_fixtures/shapes/d0f0f79fb1d01dd9.json new file mode 100644 index 000000000000..105d492350d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0f0f79fb1d01dd9.json @@ -0,0 +1,219 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "TraficSourceID" + }, + { + "type": "Identifier", + "name": "SearchEngineID" + }, + { + "type": "Identifier", + "name": "AdvEngineID" + }, + { + "type": "Function", + "alias": "Src", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "SearchEngineID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "AdvEngineID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "Referer" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Identifier", + "alias": "Dst", + "name": "URL" + }, + { + "type": "Function", + "alias": "PageViews", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits_s3", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "62" + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "EventDate" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2013-07-01" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "EventDate" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2013-07-31" + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Refresh" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "TraficSourceID" + }, + { + "type": "Identifier", + "name": "SearchEngineID" + }, + { + "type": "Identifier", + "name": "AdvEngineID" + }, + { + "type": "Identifier", + "name": "Src" + }, + { + "type": "Identifier", + "name": "Dst" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "PageViews" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "TraficSourceID" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d0f0f79fb1d01dd9.sql b/tests/ast_json_fixtures/shapes/d0f0f79fb1d01dd9.sql new file mode 100644 index 000000000000..ca3f52d688c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0f0f79fb1d01dd9.sql @@ -0,0 +1 @@ +SELECT TraficSourceID, SearchEngineID, AdvEngineID, ((SearchEngineID = 0 AND AdvEngineID = 0) ? Referer : '') AS Src, URL AS Dst, count() AS PageViews FROM test.hits_s3 WHERE CounterID = 62 AND EventDate >= '2013-07-01' AND EventDate <= '2013-07-31' AND NOT Refresh GROUP BY TraficSourceID, SearchEngineID, AdvEngineID, Src, Dst ORDER BY PageViews, TraficSourceID DESC LIMIT 1000 diff --git a/tests/ast_json_fixtures/shapes/d0f21d3257d02df8.json b/tests/ast_json_fixtures/shapes/d0f21d3257d02df8.json new file mode 100644 index 000000000000..1b5a7dab574c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0f21d3257d02df8.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d0f21d3257d02df8.sql b/tests/ast_json_fixtures/shapes/d0f21d3257d02df8.sql new file mode 100644 index 000000000000..399578828f7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d0f21d3257d02df8.sql @@ -0,0 +1 @@ +SELECT x FROM t GROUP BY x WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/d10692b8c4bc305e.json b/tests/ast_json_fixtures/shapes/d10692b8c4bc305e.json new file mode 100644 index 000000000000..1e8b1bb995a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d10692b8c4bc305e.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d10692b8c4bc305e.sql b/tests/ast_json_fixtures/shapes/d10692b8c4bc305e.sql new file mode 100644 index 000000000000..e003268f427c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d10692b8c4bc305e.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number with totals order by number limit 1 diff --git a/tests/ast_json_fixtures/shapes/d11c89450cccfdca.json b/tests/ast_json_fixtures/shapes/d11c89450cccfdca.json new file mode 100644 index 000000000000..eadb025c34c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d11c89450cccfdca.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/d11c89450cccfdca.sql b/tests/ast_json_fixtures/shapes/d11c89450cccfdca.sql new file mode 100644 index 000000000000..963d38621cda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d11c89450cccfdca.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/d13996d0aeb99f97.json b/tests/ast_json_fixtures/shapes/d13996d0aeb99f97.json new file mode 100644 index 000000000000..8d46baf5abb7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d13996d0aeb99f97.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "t0", + "name": "tupleElement", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "t0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_functions_to_subcolumns_alias" + } + } + } + ] + } + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/d13996d0aeb99f97.sql b/tests/ast_json_fixtures/shapes/d13996d0aeb99f97.sql new file mode 100644 index 000000000000..3656ee6751f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d13996d0aeb99f97.sql @@ -0,0 +1 @@ +SELECT tupleElement(t, 1) as t0, t0 FROM t_functions_to_subcolumns_alias FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/d14354e9764d25a5.json b/tests/ast_json_fixtures/shapes/d14354e9764d25a5.json new file mode 100644 index 000000000000..496b82d30b1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d14354e9764d25a5.json @@ -0,0 +1,104 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "n10" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "current_database", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "03596_parquet_prewhere_page_skip_bug.parquet" + } + ] + } + ] + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "131" + }, + { + "value_type": "UInt64", + "value": "174" + }, + { + "value_type": "UInt64", + "value": "175" + }, + { + "value_type": "UInt64", + "value": "176" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "input_format_parquet_page_filter_push_down": "0", + "input_format_parquet_filter_push_down": "0", + "input_format_parquet_bloom_filter_push_down": "0", + "input_format_parquet_max_block_size": "10" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d14354e9764d25a5.sql b/tests/ast_json_fixtures/shapes/d14354e9764d25a5.sql new file mode 100644 index 000000000000..dc2af184e884 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d14354e9764d25a5.sql @@ -0,0 +1 @@ +select n10 from file(current_database() ||'03596_parquet_prewhere_page_skip_bug.parquet') prewhere n in (131, 174, 175, 176) order by all settings input_format_parquet_page_filter_push_down=0, input_format_parquet_filter_push_down=0, input_format_parquet_bloom_filter_push_down=0, input_format_parquet_max_block_size=10 diff --git a/tests/ast_json_fixtures/shapes/d149c9733cc6e4e4.json b/tests/ast_json_fixtures/shapes/d149c9733cc6e4e4.json new file mode 100644 index 000000000000..e861c2e2c3e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d149c9733cc6e4e4.json @@ -0,0 +1,202 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "table_uuid_", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "uuid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tables", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "data_02491" + } + ] + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table_uuid" + }, + { + "type": "Function", + "name": "toUUIDOrDefault", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "event_type" + }, + { + "type": "Identifier", + "name": "merge_reason" + }, + { + "type": "Identifier", + "name": "part_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "part_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "data_02491" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table_uuid" + }, + { + "type": "Identifier", + "name": "table_uuid_" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time_microseconds" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d149c9733cc6e4e4.sql b/tests/ast_json_fixtures/shapes/d149c9733cc6e4e4.sql new file mode 100644 index 000000000000..6c1fc36a7cb7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d149c9733cc6e4e4.sql @@ -0,0 +1,12 @@ +with (select uuid from system.tables where database = currentDatabase() and table = 'data_02491') as table_uuid_ +select + table_uuid != toUUIDOrDefault(Null), + event_type, + merge_reason, + part_name +from system.part_log +where + database = currentDatabase() and + table = 'data_02491' and + table_uuid = table_uuid_ +order by event_time_microseconds diff --git a/tests/ast_json_fixtures/shapes/d14a17ca9d5eb0e6.json b/tests/ast_json_fixtures/shapes/d14a17ca9d5eb0e6.json new file mode 100644 index 000000000000..1220d4967e92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d14a17ca9d5eb0e6.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "throwIf", + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Literal", + "value_type": "String", + "value": "one" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "column_modify_test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/d14a17ca9d5eb0e6.sql b/tests/ast_json_fixtures/shapes/d14a17ca9d5eb0e6.sql new file mode 100644 index 000000000000..20a0e8186881 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d14a17ca9d5eb0e6.sql @@ -0,0 +1 @@ +SELECT *, throwIf(val <> 'one') FROM column_modify_test WHERE id = 1 FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/d14aae1f1b7fd35a.json b/tests/ast_json_fixtures/shapes/d14aae1f1b7fd35a.json new file mode 100644 index 000000000000..3bab438f24e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d14aae1f1b7fd35a.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "l", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "arr" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "prewhere_column_missing" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d14aae1f1b7fd35a.sql b/tests/ast_json_fixtures/shapes/d14aae1f1b7fd35a.sql new file mode 100644 index 000000000000..d9d9e3803003 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d14aae1f1b7fd35a.sql @@ -0,0 +1 @@ +select *, length(arr) as l from prewhere_column_missing where l = 0 diff --git a/tests/ast_json_fixtures/shapes/d1621bed59416db1.json b/tests/ast_json_fixtures/shapes/d1621bed59416db1.json new file mode 100644 index 000000000000..ab4ea8309874 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d1621bed59416db1.json @@ -0,0 +1,133 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "alias": "val", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "val" + } + ] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d1621bed59416db1.sql b/tests/ast_json_fixtures/shapes/d1621bed59416db1.sql new file mode 100644 index 000000000000..5f2f500e796f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d1621bed59416db1.sql @@ -0,0 +1,5 @@ +SELECT number, number % 2, sum(number) AS val +FROM numbers(10) +GROUP BY CUBE(number, number % 2) WITH TOTALS +ORDER BY (number, number % 2, val) +SETTINGS group_by_use_nulls=1 diff --git a/tests/ast_json_fixtures/shapes/d162afcff23915ed.json b/tests/ast_json_fixtures/shapes/d162afcff23915ed.json new file mode 100644 index 000000000000..70c9e160d41f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d162afcff23915ed.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "String", + "value": "payload" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2000000" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "03772_temporary_files_codec\/sort", + "temporary_files_codec": "LZ4" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/d162afcff23915ed.sql b/tests/ast_json_fixtures/shapes/d162afcff23915ed.sql new file mode 100644 index 000000000000..e897bb66ec43 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d162afcff23915ed.sql @@ -0,0 +1,3 @@ +SELECT * FROM (SELECT number, 'payload' FROM numbers(2_000_000)) ORDER BY number +SETTINGS log_comment='03772_temporary_files_codec/sort', temporary_files_codec = 'LZ4' +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/d1904e2b6d722115.json b/tests/ast_json_fixtures/shapes/d1904e2b6d722115.json new file mode 100644 index 000000000000..cc87aebeee38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d1904e2b6d722115.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "UserID" + }, + { + "type": "Function", + "name": "COUNT", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "UserID" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "COUNT", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "query_15" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/d1904e2b6d722115.sql b/tests/ast_json_fixtures/shapes/d1904e2b6d722115.sql new file mode 100644 index 000000000000..b60c8874b5a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d1904e2b6d722115.sql @@ -0,0 +1 @@ +SELECT UserID, COUNT(*) FROM test.hits GROUP BY UserID ORDER BY COUNT(*) DESC LIMIT 10 FORMAT Null SETTINGS log_comment='query_15' diff --git a/tests/ast_json_fixtures/shapes/d19436e7be7690cb.json b/tests/ast_json_fixtures/shapes/d19436e7be7690cb.json new file mode 100644 index 000000000000..326eb342a966 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d19436e7be7690cb.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "03271_parametrized_v_expl" + } +} diff --git a/tests/ast_json_fixtures/shapes/d19436e7be7690cb.sql b/tests/ast_json_fixtures/shapes/d19436e7be7690cb.sql new file mode 100644 index 000000000000..45ddaf9946fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d19436e7be7690cb.sql @@ -0,0 +1 @@ +SHOW COLUMNS IN 03271_parametrized_v_expl diff --git a/tests/ast_json_fixtures/shapes/d1e17ddf4b45ab7e.json b/tests/ast_json_fixtures/shapes/d1e17ddf4b45ab7e.json new file mode 100644 index 000000000000..5d01efb1b72a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d1e17ddf4b45ab7e.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "expr", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIntervalSecond", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Function", + "name": "toIntervalSecond", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "expr" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "expr" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d1e17ddf4b45ab7e.sql b/tests/ast_json_fixtures/shapes/d1e17ddf4b45ab7e.sql new file mode 100644 index 000000000000..2b97807fb76e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d1e17ddf4b45ab7e.sql @@ -0,0 +1 @@ +WITH INTERVAL 1 SECOND + tuple(INTERVAL 1 SECOND) as expr SELECT expr, toTypeName(expr) diff --git a/tests/ast_json_fixtures/shapes/d1edcd774cb3a127.json b/tests/ast_json_fixtures/shapes/d1edcd774cb3a127.json new file mode 100644 index 000000000000..0a04ba34e8b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d1edcd774cb3a127.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "x", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2018-01-01" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2018-01-02" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "x" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d1edcd774cb3a127.sql b/tests/ast_json_fixtures/shapes/d1edcd774cb3a127.sql new file mode 100644 index 000000000000..1715efbe1262 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d1edcd774cb3a127.sql @@ -0,0 +1,4 @@ +WITH (d < '2018-01-01') AND (d < '2018-01-02') AS x +SELECT 1 +FROM t +WHERE x diff --git a/tests/ast_json_fixtures/shapes/d20a14e8f5bf34db.json b/tests/ast_json_fixtures/shapes/d20a14e8f5bf34db.json new file mode 100644 index 000000000000..c3a72a851a2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d20a14e8f5bf34db.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "SetRoleQuery", + "kind": "SET_DEFAULT_ROLE", + "roles": { + "type": "RolesOrUsersSet", + "all": true, + "except_names": ["r1_01292"] + }, + "to_users": { + "type": "RolesOrUsersSet", + "names": ["u5_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d20a14e8f5bf34db.sql b/tests/ast_json_fixtures/shapes/d20a14e8f5bf34db.sql new file mode 100644 index 000000000000..22df145a5fb2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d20a14e8f5bf34db.sql @@ -0,0 +1 @@ +SET DEFAULT ROLE ALL EXCEPT r1_01292 TO u5_01292 diff --git a/tests/ast_json_fixtures/shapes/d234b8e24519448b.json b/tests/ast_json_fixtures/shapes/d234b8e24519448b.json new file mode 100644 index 000000000000..b6ad9935813f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d234b8e24519448b.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "null_in__fuzz_6" + } + } + } + ] + }, + "prewhere": { + "type": "Literal", + "value_type": "UInt64", + "value": "71" + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Identifier", + "name": "test_set" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d234b8e24519448b.sql b/tests/ast_json_fixtures/shapes/d234b8e24519448b.sql new file mode 100644 index 000000000000..e38d7036918e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d234b8e24519448b.sql @@ -0,0 +1 @@ +SELECT count() = 1 FROM null_in__fuzz_6 PREWHERE 71 WHERE i IN (test_set) diff --git a/tests/ast_json_fixtures/shapes/d252ccd358834fa2.json b/tests/ast_json_fixtures/shapes/d252ccd358834fa2.json new file mode 100644 index 000000000000..948dfcb91eb3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d252ccd358834fa2.json @@ -0,0 +1,89 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "total_rows" + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "total_bytes" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tables", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "dict" + } + ] + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/d252ccd358834fa2.sql b/tests/ast_json_fixtures/shapes/d252ccd358834fa2.sql new file mode 100644 index 000000000000..1ed25f8e2635 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d252ccd358834fa2.sql @@ -0,0 +1 @@ +SELECT total_rows, total_bytes > 0 FROM system.tables WHERE database = currentDatabase() AND name = 'dict' FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/d273da867be6d19b.json b/tests/ast_json_fixtures/shapes/d273da867be6d19b.json new file mode 100644 index 000000000000..1c9a82e10345 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d273da867be6d19b.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "fuzzQuery", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "SELECT 1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "500" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8956" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ], + "format": "TSVWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/d273da867be6d19b.sql b/tests/ast_json_fixtures/shapes/d273da867be6d19b.sql new file mode 100644 index 000000000000..65bdb6f78d4f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d273da867be6d19b.sql @@ -0,0 +1 @@ +SELECT * FROM fuzzQuery('SELECT 1', 500, 8956) LIMIT 0 FORMAT TSVWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/d2786bcc3a7b9fda.json b/tests/ast_json_fixtures/shapes/d2786bcc3a7b9fda.json new file mode 100644 index 000000000000..4bf56a81dbce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2786bcc3a7b9fda.json @@ -0,0 +1,151 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "flt", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "shardNum", + "arguments": [] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "name": "shardNum", + "arguments": [] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1..3}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "flt" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d2786bcc3a7b9fda.sql b/tests/ast_json_fixtures/shapes/d2786bcc3a7b9fda.sql new file mode 100644 index 000000000000..954511b156bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2786bcc3a7b9fda.sql @@ -0,0 +1,7 @@ +WITH flt AS ( + SELECT number FROM numbers(10) WHERE number = shardNum() +) +SELECT shardNum(), number +FROM remote('127.0.0.{1..3}', numbers(100)) +WHERE number IN (flt) +ORDER BY 1, 2 diff --git a/tests/ast_json_fixtures/shapes/d27b8a1e9a44b627.json b/tests/ast_json_fixtures/shapes/d27b8a1e9a44b627.json new file mode 100644 index 000000000000..06a08bbe0332 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d27b8a1e9a44b627.json @@ -0,0 +1,136 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "globalIn", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d27b8a1e9a44b627.sql b/tests/ast_json_fixtures/shapes/d27b8a1e9a44b627.sql new file mode 100644 index 000000000000..a1f03101f95b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d27b8a1e9a44b627.sql @@ -0,0 +1 @@ +select sum(number) from remote('127.0.0.{2,3}', numbers(2)) where number global in (select sum(number) from numbers(2) group by number with totals) group by number with totals order by number diff --git a/tests/ast_json_fixtures/shapes/d2a432098124c579.json b/tests/ast_json_fixtures/shapes/d2a432098124c579.json new file mode 100644 index 000000000000..cb6f1438850f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2a432098124c579.json @@ -0,0 +1,117 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "alias": "key", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "count", + "nulls_action": "IGNORE NULLS", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d2a432098124c579.sql b/tests/ast_json_fixtures/shapes/d2a432098124c579.sql new file mode 100644 index 000000000000..92970e107fe5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2a432098124c579.sql @@ -0,0 +1 @@ +SELECT number % 2 AS key, count(materialize(5)) IGNORE NULLS FROM numbers(10) WHERE toLowCardinality(toLowCardinality(materialize(2))) GROUP BY key WITH CUBE WITH TOTALS QUALIFY key = 0 diff --git a/tests/ast_json_fixtures/shapes/d2b3e00c36a99624.json b/tests/ast_json_fixtures/shapes/d2b3e00c36a99624.json new file mode 100644 index 000000000000..6903aac17bec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2b3e00c36a99624.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1" + } + }, + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/d2b3e00c36a99624.sql b/tests/ast_json_fixtures/shapes/d2b3e00c36a99624.sql new file mode 100644 index 000000000000..ac2229bf1195 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2b3e00c36a99624.sql @@ -0,0 +1 @@ +SELECT toUInt64(42) FORMAT Vertical SETTINGS use_query_cache = 1 diff --git a/tests/ast_json_fixtures/shapes/d2c5756f8a63499e.json b/tests/ast_json_fixtures/shapes/d2c5756f8a63499e.json new file mode 100644 index 000000000000..7fb3d24ee2f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2c5756f8a63499e.json @@ -0,0 +1,130 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "proj" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "date", + "data_type": { + "type": "DataType", + "name": "Date" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "maxdate", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "date" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2012-10-24" + } + ] + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 100 + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d2c5756f8a63499e.sql b/tests/ast_json_fixtures/shapes/d2c5756f8a63499e.sql new file mode 100644 index 000000000000..7e5154b64866 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2c5756f8a63499e.sql @@ -0,0 +1 @@ +CREATE TABLE proj(date Date, PROJECTION maxdate( SELECT max(date) GROUP BY date )) ENGINE = MergeTree ORDER BY tuple() as select toDate('2012-10-24')-number%100 from numbers(1e2) diff --git a/tests/ast_json_fixtures/shapes/d2c99efcf51bef1a.json b/tests/ast_json_fixtures/shapes/d2c99efcf51bef1a.json new file mode 100644 index 000000000000..0c124b253b8e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2c99efcf51bef1a.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "alter": true, + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p1_01295", + "database": "db", + "table": "table" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet", + "names": ["u1_01295"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d2c99efcf51bef1a.sql b/tests/ast_json_fixtures/shapes/d2c99efcf51bef1a.sql new file mode 100644 index 000000000000..3f121ea92b34 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2c99efcf51bef1a.sql @@ -0,0 +1 @@ +ALTER POLICY p1_01295 ON db.table TO u1_01295 diff --git a/tests/ast_json_fixtures/shapes/d2ca93ad60e4ad73.json b/tests/ast_json_fixtures/shapes/d2ca93ad60e4ad73.json new file mode 100644 index 000000000000..b723738b44a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2ca93ad60e4ad73.json @@ -0,0 +1,109 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "246" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + }, + "format": "TabSeparatedWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/d2ca93ad60e4ad73.sql b/tests/ast_json_fixtures/shapes/d2ca93ad60e4ad73.sql new file mode 100644 index 000000000000..f698d060c761 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2ca93ad60e4ad73.sql @@ -0,0 +1 @@ +SELECT number * 246 + 10 AS n, toDate('2000-01-01') + n AS d, (n, d) AS tuple FROM system.numbers LIMIT 1 FORMAT TabSeparatedWithNamesAndTypes SETTINGS enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/d2ce088d83d9906e.json b/tests/ast_json_fixtures/shapes/d2ce088d83d9906e.json new file mode 100644 index 000000000000..409531ee43f8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2ce088d83d9906e.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "CreateIndexQuery", + "table": { + "type": "Identifier", + "name": "tab2" + }, + "unique": true, + "index_name": { + "type": "Identifier", + "name": "idx_tab2_0" + }, + "index_declaration": { + "type": "Index", + "name": "idx_tab2_0", + "expression": { + "type": "Identifier", + "name": "col1" + }, + "granularity": 1 + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d2ce088d83d9906e.sql b/tests/ast_json_fixtures/shapes/d2ce088d83d9906e.sql new file mode 100644 index 000000000000..2e4499b35b30 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2ce088d83d9906e.sql @@ -0,0 +1 @@ +CREATE UNIQUE INDEX idx_tab2_0 ON tab2 (col1) diff --git a/tests/ast_json_fixtures/shapes/d2d0a072c5d7e028.json b/tests/ast_json_fixtures/shapes/d2d0a072c5d7e028.json new file mode 100644 index 000000000000..592dfe90b9ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2d0a072c5d7e028.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q9_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d2d0a072c5d7e028.sql b/tests/ast_json_fixtures/shapes/d2d0a072c5d7e028.sql new file mode 100644 index 000000000000..1e8a5d0bd4b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2d0a072c5d7e028.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q9_01297 diff --git a/tests/ast_json_fixtures/shapes/d2d800921a6ab12a.json b/tests/ast_json_fixtures/shapes/d2d800921a6ab12a.json new file mode 100644 index 000000000000..e67ecdd6efe9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2d800921a6ab12a.json @@ -0,0 +1,361 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "cte", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tbl" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "joinGet", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".join_engine" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "v" + }, + { + "type": "Identifier", + "name": "id1" + }, + { + "type": "Identifier", + "name": "id2" + } + ] + }, + { + "type": "Identifier", + "name": "tbl.v", + "name_parts": ["tbl", "v"] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "alias": "count", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "id2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "e", + "name": "tbl" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "joinGet", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".join_engine" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "v" + }, + { + "type": "Identifier", + "name": "id1" + }, + { + "type": "Identifier", + "name": "id2" + } + ] + }, + { + "type": "Identifier", + "name": "e.v", + "name_parts": ["e", "v"] + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id2" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "cte" + } + } + } + ] + } + } + ] + } + } + ] + } + }, + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "cte", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tbl" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "joinGet", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".join_engine" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "v" + }, + { + "type": "Identifier", + "name": "id1" + }, + { + "type": "Identifier", + "name": "id2" + } + ] + }, + { + "type": "Identifier", + "name": "tbl.v", + "name_parts": ["tbl", "v"] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "alias": "count", + "name": "uniq", + "arguments": [ + { + "type": "Identifier", + "name": "id2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "cte" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d2d800921a6ab12a.sql b/tests/ast_json_fixtures/shapes/d2d800921a6ab12a.sql new file mode 100644 index 000000000000..4fae69ff567b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2d800921a6ab12a.sql @@ -0,0 +1,24 @@ +WITH cte AS + ( + SELECT id2 + FROM tbl + WHERE joinGet(currentDatabase() || '.join_engine', 'v', id1, id2) = tbl.v + ) +SELECT uniq(id2) AS count +FROM +( + + + + + SELECT * + FROM tbl AS e + WHERE joinGet(currentDatabase() || '.join_engine', 'v', id1, id2) = e.v +) +WHERE id2 IN ( + SELECT id2 + FROM cte +) +UNION ALL +SELECT uniq(id2) AS count +FROM cte diff --git a/tests/ast_json_fixtures/shapes/d2e251b0965f2217.json b/tests/ast_json_fixtures/shapes/d2e251b0965f2217.json new file mode 100644 index 000000000000..c2fa631f6419 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2e251b0965f2217.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["test_role_01999"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d2e251b0965f2217.sql b/tests/ast_json_fixtures/shapes/d2e251b0965f2217.sql new file mode 100644 index 000000000000..1fe5471ffcb6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2e251b0965f2217.sql @@ -0,0 +1 @@ +CREATE role test_role_01999 diff --git a/tests/ast_json_fixtures/shapes/d2e5ccde6c90088d.json b/tests/ast_json_fixtures/shapes/d2e5ccde6c90088d.json new file mode 100644 index 000000000000..fe1b1bffc47e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2e5ccde6c90088d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["u2_01292@%.myhost.com"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d2e5ccde6c90088d.sql b/tests/ast_json_fixtures/shapes/d2e5ccde6c90088d.sql new file mode 100644 index 000000000000..f9e1d66b37b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d2e5ccde6c90088d.sql @@ -0,0 +1 @@ +SHOW CREATE USER 'u2_01292@%.myhost.com' diff --git a/tests/ast_json_fixtures/shapes/d304d4685d59a435.json b/tests/ast_json_fixtures/shapes/d304d4685d59a435.json new file mode 100644 index 000000000000..0fa109085de8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d304d4685d59a435.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r1_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d304d4685d59a435.sql b/tests/ast_json_fixtures/shapes/d304d4685d59a435.sql new file mode 100644 index 000000000000..0655ec7b7715 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d304d4685d59a435.sql @@ -0,0 +1 @@ +CREATE ROLE r1_01297 diff --git a/tests/ast_json_fixtures/shapes/d317a6fe3eeb96ac.json b/tests/ast_json_fixtures/shapes/d317a6fe3eeb96ac.json new file mode 100644 index 000000000000..0cb9bac7e783 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d317a6fe3eeb96ac.json @@ -0,0 +1,41 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000000" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/d317a6fe3eeb96ac.sql b/tests/ast_json_fixtures/shapes/d317a6fe3eeb96ac.sql new file mode 100644 index 000000000000..ee3ac83c4ae8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d317a6fe3eeb96ac.sql @@ -0,0 +1 @@ +SELECT 1_000_000_000 as a FROM system.numbers LIMIT 2 FORMAT PrettySpace diff --git a/tests/ast_json_fixtures/shapes/d31d6f133a14eed1.json b/tests/ast_json_fixtures/shapes/d31d6f133a14eed1.json new file mode 100644 index 000000000000..c1be74668446 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d31d6f133a14eed1.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "03591_rp", + "table": "03591_test" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "current_user": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d31d6f133a14eed1.sql b/tests/ast_json_fixtures/shapes/d31d6f133a14eed1.sql new file mode 100644 index 000000000000..756e205453b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d31d6f133a14eed1.sql @@ -0,0 +1 @@ +CREATE ROW POLICY 03591_rp ON 03591_test USING b=2 TO CURRENT_USER diff --git a/tests/ast_json_fixtures/shapes/d33889a490b98fd6.json b/tests/ast_json_fixtures/shapes/d33889a490b98fd6.json new file mode 100644 index 000000000000..4f6f0c5f6b59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d33889a490b98fd6.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q5_01297"], + "limits": [ + { + "duration_sec": "31556952", + "randomize_interval": true, + "max": { + "QUERIES": "100", + "ERRORS": "11" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d33889a490b98fd6.sql b/tests/ast_json_fixtures/shapes/d33889a490b98fd6.sql new file mode 100644 index 000000000000..c525e6d1ef55 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d33889a490b98fd6.sql @@ -0,0 +1 @@ +CREATE QUOTA q5_01297 FOR RANDOMIZED INTERVAL 1 YEAR MAX errors = 11, MAX queries = 100 diff --git a/tests/ast_json_fixtures/shapes/d3409a6cd6033a16.json b/tests/ast_json_fixtures/shapes/d3409a6cd6033a16.json new file mode 100644 index 000000000000..cd5d2dd2835d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3409a6cd6033a16.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "alias": "x", + "name": "toBool", + "arguments": [ + { + "type": "Function", + "name": "sin", + "arguments": [ + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "number", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "having": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "sin", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_optimize_predicate_expression": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d3409a6cd6033a16.sql b/tests/ast_json_fixtures/shapes/d3409a6cd6033a16.sql new file mode 100644 index 000000000000..dcac4648488c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3409a6cd6033a16.sql @@ -0,0 +1,9 @@ +SELECT toBool(sin(SUM(number))) AS x +FROM +( + SELECT 1 AS number +) +GROUP BY number +HAVING 1 AND sin(1) +ORDER BY ALL +SETTINGS enable_optimize_predicate_expression = 0 diff --git a/tests/ast_json_fixtures/shapes/d354e9786e8cfd07.json b/tests/ast_json_fixtures/shapes/d354e9786e8cfd07.json new file mode 100644 index 000000000000..64b29c72a890 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d354e9786e8cfd07.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "d", + "name": "toDecimal128", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 42.42 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_json_quote_decimals": "1" + } + }, + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/d354e9786e8cfd07.sql b/tests/ast_json_fixtures/shapes/d354e9786e8cfd07.sql new file mode 100644 index 000000000000..80b122f5ad7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d354e9786e8cfd07.sql @@ -0,0 +1 @@ +select toDecimal128(42.42, 5) as d format JSONEachRow settings output_format_json_quote_decimals=1 diff --git a/tests/ast_json_fixtures/shapes/d360334dfaf51cff.json b/tests/ast_json_fixtures/shapes/d360334dfaf51cff.json new file mode 100644 index 000000000000..3b28a9fbc9f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d360334dfaf51cff.json @@ -0,0 +1,95 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "alias": "d", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test02313" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d360334dfaf51cff.sql b/tests/ast_json_fixtures/shapes/d360334dfaf51cff.sql new file mode 100644 index 000000000000..430e29e1888a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d360334dfaf51cff.sql @@ -0,0 +1,5 @@ +SELECT + count() as d, a, b, c +FROM test02313 +GROUP BY CUBE(a, b, c) +ORDER BY d, a, b, c diff --git a/tests/ast_json_fixtures/shapes/d369ee4a924a2914.json b/tests/ast_json_fixtures/shapes/d369ee4a924a2914.json new file mode 100644 index 000000000000..9fb74c78325a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d369ee4a924a2914.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "_02268_data.jsonl" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "TSV" + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d369ee4a924a2914.sql b/tests/ast_json_fixtures/shapes/d369ee4a924a2914.sql new file mode 100644 index 000000000000..8166aae4a51a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d369ee4a924a2914.sql @@ -0,0 +1 @@ +insert into function file(currentDatabase() || '_02268_data.jsonl', 'TSV') select 1 diff --git a/tests/ast_json_fixtures/shapes/d36d5d4593e3b068.json b/tests/ast_json_fixtures/shapes/d36d5d4593e3b068.json new file mode 100644 index 000000000000..91d1df54e23e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d36d5d4593e3b068.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q8_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d36d5d4593e3b068.sql b/tests/ast_json_fixtures/shapes/d36d5d4593e3b068.sql new file mode 100644 index 000000000000..8f582a503890 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d36d5d4593e3b068.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q8_01297 diff --git a/tests/ast_json_fixtures/shapes/d3761d474da3238e.json b/tests/ast_json_fixtures/shapes/d3761d474da3238e.json new file mode 100644 index 000000000000..b9356bde143e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3761d474da3238e.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "udf" + } +} diff --git a/tests/ast_json_fixtures/shapes/d3761d474da3238e.sql b/tests/ast_json_fixtures/shapes/d3761d474da3238e.sql new file mode 100644 index 000000000000..3a7ed3829c09 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3761d474da3238e.sql @@ -0,0 +1 @@ +DROP FUNCTION udf diff --git a/tests/ast_json_fixtures/shapes/d398847afeb7ab0c.json b/tests/ast_json_fixtures/shapes/d398847afeb7ab0c.json new file mode 100644 index 000000000000..0b8078678c29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d398847afeb7ab0c.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "date" + }, + { + "type": "Function", + "name": "argMax", + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Identifier", + "name": "clicks" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lc" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "date" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d398847afeb7ab0c.sql b/tests/ast_json_fixtures/shapes/d398847afeb7ab0c.sql new file mode 100644 index 000000000000..444ee7e38dbd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d398847afeb7ab0c.sql @@ -0,0 +1 @@ +SELECT date, argMax(name, clicks) FROM lc GROUP BY date diff --git a/tests/ast_json_fixtures/shapes/d39d148aa775e08f.json b/tests/ast_json_fixtures/shapes/d39d148aa775e08f.json new file mode 100644 index 000000000000..3bcf4ba08a50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d39d148aa775e08f.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "d" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d39d148aa775e08f.sql b/tests/ast_json_fixtures/shapes/d39d148aa775e08f.sql new file mode 100644 index 000000000000..a81670958061 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d39d148aa775e08f.sql @@ -0,0 +1 @@ +select * from test group by d diff --git a/tests/ast_json_fixtures/shapes/d3a1e1670b75311b.json b/tests/ast_json_fixtures/shapes/d3a1e1670b75311b.json new file mode 100644 index 000000000000..a835f37b0f35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3a1e1670b75311b.json @@ -0,0 +1,132 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "alias": "val", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "val" + } + ] + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d3a1e1670b75311b.sql b/tests/ast_json_fixtures/shapes/d3a1e1670b75311b.sql new file mode 100644 index 000000000000..6f9c024566d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3a1e1670b75311b.sql @@ -0,0 +1,5 @@ +SELECT number, number % 2, sum(number) AS val +FROM numbers(10) +GROUP BY ROLLUP(number, number % 2) +ORDER BY (number, number % 2, val) +SETTINGS group_by_use_nulls=0 diff --git a/tests/ast_json_fixtures/shapes/d3b51f8fba3377fa.json b/tests/ast_json_fixtures/shapes/d3b51f8fba3377fa.json new file mode 100644 index 000000000000..f056159282ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3b51f8fba3377fa.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateTableQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "t_proj" + }, + "format": "TSVRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/d3b51f8fba3377fa.sql b/tests/ast_json_fixtures/shapes/d3b51f8fba3377fa.sql new file mode 100644 index 000000000000..71636316dfc7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3b51f8fba3377fa.sql @@ -0,0 +1 @@ +SHOW CREATE TEMPORARY TABLE t_proj FORMAT TSVRaw diff --git a/tests/ast_json_fixtures/shapes/d3c437baef727143.json b/tests/ast_json_fixtures/shapes/d3c437baef727143.json new file mode 100644 index 000000000000..722699fc67e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3c437baef727143.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "D" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "C" + }, + { + "type": "Identifier", + "name": "E" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "C" + }, + { + "type": "Identifier", + "name": "E" + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d3c437baef727143.sql b/tests/ast_json_fixtures/shapes/d3c437baef727143.sql new file mode 100644 index 000000000000..1a36bbc0741f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3c437baef727143.sql @@ -0,0 +1 @@ +SELECT * FROM x WHERE (D AND 5) OR ((C AND E) AND (C AND E)) ORDER BY ALL LIMIT 3 diff --git a/tests/ast_json_fixtures/shapes/d3c600cd7b24f764.json b/tests/ast_json_fixtures/shapes/d3c600cd7b24f764.json new file mode 100644 index 000000000000..83c04e84d8f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3c600cd7b24f764.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "u.uid", + "name_parts": ["u", "uid"] + }, + { + "type": "Identifier", + "name": "u.name", + "name_parts": ["u", "name"] + }, + { + "type": "Identifier", + "name": "u.gid", + "name_parts": ["u", "gid"] + }, + { + "type": "Identifier", + "name": "u.gname", + "name_parts": ["u", "gname"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "u", + "name": "users" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "using": [ + { + "type": "Identifier", + "name": "gid" + }, + { + "type": "Identifier", + "name": "gname" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "g", + "name": "groups" + } + } + } + ] + } + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/d3c600cd7b24f764.sql b/tests/ast_json_fixtures/shapes/d3c600cd7b24f764.sql new file mode 100644 index 000000000000..664f991c84f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3c600cd7b24f764.sql @@ -0,0 +1,3 @@ +SELECT u.uid, u.name, u.gid, u.gname +FROM users u left join groups g using gid, gname +format PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/d3d1d7931aee1a8e.json b/tests/ast_json_fixtures/shapes/d3d1d7931aee1a8e.json new file mode 100644 index 000000000000..2f0ccba9fb31 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3d1d7931aee1a8e.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_table": "t4", + "to_table": "t2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d3d1d7931aee1a8e.sql b/tests/ast_json_fixtures/shapes/d3d1d7931aee1a8e.sql new file mode 100644 index 000000000000..33ba9cd92eed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3d1d7931aee1a8e.sql @@ -0,0 +1 @@ +EXCHANGE TABLES t4 AND t2 diff --git a/tests/ast_json_fixtures/shapes/d3e9c3af026d8371.json b/tests/ast_json_fixtures/shapes/d3e9c3af026d8371.json new file mode 100644 index 000000000000..4f2e4f7a61ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3e9c3af026d8371.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TSVRawWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/d3e9c3af026d8371.sql b/tests/ast_json_fixtures/shapes/d3e9c3af026d8371.sql new file mode 100644 index 000000000000..2105d1a8df05 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d3e9c3af026d8371.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TSVRawWithNames diff --git a/tests/ast_json_fixtures/shapes/d40e7bda058fa790.json b/tests/ast_json_fixtures/shapes/d40e7bda058fa790.json new file mode 100644 index 000000000000..5eea1819fbfb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d40e7bda058fa790.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PROJECTION", + "projection": { + "type": "Identifier", + "name": "d_order" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d40e7bda058fa790.sql b/tests/ast_json_fixtures/shapes/d40e7bda058fa790.sql new file mode 100644 index 000000000000..6b4e6e2218c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d40e7bda058fa790.sql @@ -0,0 +1 @@ +ALTER TABLE test DROP PROJECTION d_order SETTINGS mutations_sync = 2 diff --git a/tests/ast_json_fixtures/shapes/d4292b61355c4b3d.json b/tests/ast_json_fixtures/shapes/d4292b61355c4b3d.json new file mode 100644 index 000000000000..77432aeaaffc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4292b61355c4b3d.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Identifier", + "name": "arrays_02735.parquet", + "name_parts": ["arrays_02735", "parquet"] + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "arrays_02735" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d4292b61355c4b3d.sql b/tests/ast_json_fixtures/shapes/d4292b61355c4b3d.sql new file mode 100644 index 000000000000..1868c7c42595 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4292b61355c4b3d.sql @@ -0,0 +1 @@ +insert into function file(arrays_02735.parquet) select * from arrays_02735 diff --git a/tests/ast_json_fixtures/shapes/d42c9509cf23b07d.json b/tests/ast_json_fixtures/shapes/d42c9509cf23b07d.json new file mode 100644 index 000000000000..dcff555a9e47 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d42c9509cf23b07d.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "nonConstF32" + } +} diff --git a/tests/ast_json_fixtures/shapes/d42c9509cf23b07d.sql b/tests/ast_json_fixtures/shapes/d42c9509cf23b07d.sql new file mode 100644 index 000000000000..fc0a3abfd831 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d42c9509cf23b07d.sql @@ -0,0 +1 @@ +DROP FUNCTION nonConstF32 diff --git a/tests/ast_json_fixtures/shapes/d430c5ba632ca8fe.json b/tests/ast_json_fixtures/shapes/d430c5ba632ca8fe.json new file mode 100644 index 000000000000..f8a20fbf9f95 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d430c5ba632ca8fe.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pk" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d430c5ba632ca8fe.sql b/tests/ast_json_fixtures/shapes/d430c5ba632ca8fe.sql new file mode 100644 index 000000000000..7387ec660cf9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d430c5ba632ca8fe.sql @@ -0,0 +1 @@ +SELECT * FROM pk WHERE x = 1 ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/d45539bdc5fc867f.json b/tests/ast_json_fixtures/shapes/d45539bdc5fc867f.json new file mode 100644 index 000000000000..ee1be34ee390 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d45539bdc5fc867f.json @@ -0,0 +1,156 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x.A", + "name_parts": ["x", "A"] + }, + { + "type": "Identifier", + "name": "y.A", + "name_parts": ["y", "A"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x.B", + "name_parts": ["x", "B"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x.A", + "name_parts": ["x", "A"] + }, + { + "type": "Identifier", + "name": "y.A", + "name_parts": ["y", "A"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y.C", + "name_parts": ["y", "C"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "y" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_extract_common_expressions": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d45539bdc5fc867f.sql b/tests/ast_json_fixtures/shapes/d45539bdc5fc867f.sql new file mode 100644 index 000000000000..774b17a9b0b9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d45539bdc5fc867f.sql @@ -0,0 +1 @@ +SELECT * FROM x INNER JOIN y ON ((x.A = y.A ) AND x.B = 1) OR ((x.A = y.A) AND y.C = 1) ORDER BY ALL LIMIT 10 SETTINGS optimize_extract_common_expressions = 0 diff --git a/tests/ast_json_fixtures/shapes/d4768442a4714c77.json b/tests/ast_json_fixtures/shapes/d4768442a4714c77.json new file mode 100644 index 000000000000..a92fd748983a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4768442a4714c77.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "minmax_idx" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_INDEX", + "index_declaration": { + "type": "Index", + "name": "idx3", + "expression": { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "u64" + }, + { + "type": "Identifier", + "name": "i32" + } + ] + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 10 + }, + "index": { + "type": "Identifier", + "name": "idx1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d4768442a4714c77.sql b/tests/ast_json_fixtures/shapes/d4768442a4714c77.sql new file mode 100644 index 000000000000..bd035c0b0553 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4768442a4714c77.sql @@ -0,0 +1 @@ +ALTER TABLE minmax_idx ADD INDEX idx3 u64 - i32 TYPE minmax GRANULARITY 10 AFTER idx1 diff --git a/tests/ast_json_fixtures/shapes/d47a9edfbe23d1ad.json b/tests/ast_json_fixtures/shapes/d47a9edfbe23d1ad.json new file mode 100644 index 000000000000..23ff8a788927 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d47a9edfbe23d1ad.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN", + "query": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_DISTINCT", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d47a9edfbe23d1ad.sql b/tests/ast_json_fixtures/shapes/d47a9edfbe23d1ad.sql new file mode 100644 index 000000000000..ad4ed8b612ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d47a9edfbe23d1ad.sql @@ -0,0 +1 @@ +EXPLAIN SELECT 1 UNION SELECT 1 UNION DISTINCT SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/d49dd947b7bc6bcd.json b/tests/ast_json_fixtures/shapes/d49dd947b7bc6bcd.json new file mode 100644 index 000000000000..c238bf30f658 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d49dd947b7bc6bcd.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "tmp2" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Log", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d49dd947b7bc6bcd.sql b/tests/ast_json_fixtures/shapes/d49dd947b7bc6bcd.sql new file mode 100644 index 000000000000..4cdb45aa83f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d49dd947b7bc6bcd.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE tmp2 (n int) ENGINE=Log diff --git a/tests/ast_json_fixtures/shapes/d4a0419262763e35.json b/tests/ast_json_fixtures/shapes/d4a0419262763e35.json new file mode 100644 index 000000000000..38d53b2fa73d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4a0419262763e35.json @@ -0,0 +1,128 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "time", + "name": "formatDateTime", + "arguments": [ + { + "type": "Function", + "name": "toStartOfInterval", + "arguments": [ + { + "type": "Identifier", + "name": "collectorReceiptTime" + }, + { + "type": "Function", + "name": "toIntervalHour", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "%Y-%m-%d %H" + } + ] + }, + { + "type": "Function", + "alias": "count", + "name": "COUNT", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "log" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "collectorReceiptTime" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2025-01-01 00:00:00" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "collectorReceiptTime" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2025-01-01 23:59:59" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "time" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "time" + }, + "direction": "DESC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_optimize_projection": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d4a0419262763e35.sql b/tests/ast_json_fixtures/shapes/d4a0419262763e35.sql new file mode 100644 index 000000000000..a016e0a5ee2b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4a0419262763e35.sql @@ -0,0 +1,8 @@ +SELECT + formatDateTime(toStartOfInterval(collectorReceiptTime, toIntervalHour(1)), '%Y-%m-%d %H') AS time, + COUNT() AS count +FROM log +WHERE (collectorReceiptTime >= '2025-01-01 00:00:00') AND (collectorReceiptTime <= '2025-01-01 23:59:59') +GROUP BY time +ORDER BY time DESC +SETTINGS force_optimize_projection = 1 diff --git a/tests/ast_json_fixtures/shapes/d4a73ff6166e42bf.json b/tests/ast_json_fixtures/shapes/d4a73ff6166e42bf.json new file mode 100644 index 000000000000..4aa2465cc796 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4a73ff6166e42bf.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "optimize_trivial_count_query" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "adaptive_table" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_trivial_count_query": "1" + } + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/d4a73ff6166e42bf.sql b/tests/ast_json_fixtures/shapes/d4a73ff6166e42bf.sql new file mode 100644 index 000000000000..33094fa4a6af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4a73ff6166e42bf.sql @@ -0,0 +1,3 @@ +SELECT 'optimize_trivial_count_query', count() FROM adaptive_table SETTINGS + optimize_trivial_count_query=1 +FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/d4afc147824def39.json b/tests/ast_json_fixtures/shapes/d4afc147824def39.json new file mode 100644 index 000000000000..f112dd0d1e4e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4afc147824def39.json @@ -0,0 +1,114 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "t", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1509138000" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "300" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "h", + "name": "toHour", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Kolkata" + } + ] + }, + { + "type": "Function", + "alias": "h_start", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "toStartOfHour", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Kolkata" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Asia\/Kolkata" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d4afc147824def39.sql b/tests/ast_json_fixtures/shapes/d4afc147824def39.sql new file mode 100644 index 000000000000..ff43b50b49fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4afc147824def39.sql @@ -0,0 +1 @@ +WITH toDateTime(1509138000) + number * 300 AS t SELECT toHour(t, 'Asia/Kolkata') AS h, toString(toStartOfHour(t, 'Asia/Kolkata'), 'Asia/Kolkata') AS h_start FROM system.numbers LIMIT 12 diff --git a/tests/ast_json_fixtures/shapes/d4b2379988991aff.json b/tests/ast_json_fixtures/shapes/d4b2379988991aff.json new file mode 100644 index 000000000000..842c613b255a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4b2379988991aff.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "extremes": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d4b2379988991aff.sql b/tests/ast_json_fixtures/shapes/d4b2379988991aff.sql new file mode 100644 index 000000000000..bf46c02c08de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4b2379988991aff.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number limit 1 settings extremes=1 diff --git a/tests/ast_json_fixtures/shapes/d4b297b9fe42c90c.json b/tests/ast_json_fixtures/shapes/d4b297b9fe42c90c.json new file mode 100644 index 000000000000..90be5ca7cf38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4b297b9fe42c90c.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "03710" + }, + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": "1", + "max_block_size": "1" + } + }, + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/d4b297b9fe42c90c.sql b/tests/ast_json_fixtures/shapes/d4b297b9fe42c90c.sql new file mode 100644 index 000000000000..fc749ec3f094 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4b297b9fe42c90c.sql @@ -0,0 +1 @@ +SELECT '03710', c FROM tab FORMAT TSV SETTINGS use_query_cache = 1, max_block_size = 1 diff --git a/tests/ast_json_fixtures/shapes/d4bff747b4ffee54.json b/tests/ast_json_fixtures/shapes/d4bff747b4ffee54.json new file mode 100644 index 000000000000..618b59781141 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4bff747b4ffee54.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "START DISTRIBUTED SENDS", + "table": { + "type": "Identifier", + "name": "dist_01293" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d4bff747b4ffee54.sql b/tests/ast_json_fixtures/shapes/d4bff747b4ffee54.sql new file mode 100644 index 000000000000..f75de13fe239 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4bff747b4ffee54.sql @@ -0,0 +1 @@ +system start distributed sends dist_01293 diff --git a/tests/ast_json_fixtures/shapes/d4c9af1688cc3650.json b/tests/ast_json_fixtures/shapes/d4c9af1688cc3650.json new file mode 100644 index 000000000000..2946e1d0eaad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4c9af1688cc3650.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r1_01292", "r2_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d4c9af1688cc3650.sql b/tests/ast_json_fixtures/shapes/d4c9af1688cc3650.sql new file mode 100644 index 000000000000..040d997ae3ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4c9af1688cc3650.sql @@ -0,0 +1 @@ +CREATE ROLE r1_01292, r2_01292 diff --git a/tests/ast_json_fixtures/shapes/d4fffd84d519b4de.json b/tests/ast_json_fixtures/shapes/d4fffd84d519b4de.json new file mode 100644 index 000000000000..fe996702ebcf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4fffd84d519b4de.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "left_table" + }, + "as_table": "dest_table" + } +} diff --git a/tests/ast_json_fixtures/shapes/d4fffd84d519b4de.sql b/tests/ast_json_fixtures/shapes/d4fffd84d519b4de.sql new file mode 100644 index 000000000000..d2b51caa9736 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d4fffd84d519b4de.sql @@ -0,0 +1 @@ +create table left_table as dest_table diff --git a/tests/ast_json_fixtures/shapes/d50ee5b4be36a49e.json b/tests/ast_json_fixtures/shapes/d50ee5b4be36a49e.json new file mode 100644 index 000000000000..b6266aaf25b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d50ee5b4be36a49e.json @@ -0,0 +1,177 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "FileOpen" + } + ] + }, + { + "type": "Identifier", + "name": "read_rows" + }, + { + "type": "Function", + "name": "arraySort", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "splitByChar", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "." + }, + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "columns" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryFinish" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%SELECT sum(b) FROM t_index_hint%" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time_microseconds" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d50ee5b4be36a49e.sql b/tests/ast_json_fixtures/shapes/d50ee5b4be36a49e.sql new file mode 100644 index 000000000000..78f90186002b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d50ee5b4be36a49e.sql @@ -0,0 +1,9 @@ +SELECT + ProfileEvents['FileOpen'], + read_rows, + arraySort(arrayMap(x -> splitByChar('.', x)[-1], columns)) +FROM system.query_log +WHERE type = 'QueryFinish' + AND current_database = currentDatabase() + AND query LIKE '%SELECT sum(b) FROM t_index_hint%' +ORDER BY event_time_microseconds diff --git a/tests/ast_json_fixtures/shapes/d513304a9ae73015.json b/tests/ast_json_fixtures/shapes/d513304a9ae73015.json new file mode 100644 index 000000000000..3b5929cadace --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d513304a9ae73015.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r8_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d513304a9ae73015.sql b/tests/ast_json_fixtures/shapes/d513304a9ae73015.sql new file mode 100644 index 000000000000..c303d6518e2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d513304a9ae73015.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r8_01293 diff --git a/tests/ast_json_fixtures/shapes/d514ed816dd25bda.json b/tests/ast_json_fixtures/shapes/d514ed816dd25bda.json new file mode 100644 index 000000000000..130179a18dfc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d514ed816dd25bda.json @@ -0,0 +1,120 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "String", + "value": "7" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d514ed816dd25bda.sql b/tests/ast_json_fixtures/shapes/d514ed816dd25bda.sql new file mode 100644 index 000000000000..613e7ef342d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d514ed816dd25bda.sql @@ -0,0 +1,6 @@ +WITH RECURSIVE t AS ( + SELECT '7' AS n +UNION ALL + SELECT n+1 FROM t WHERE n < 10 +) +SELECT n, toTypeName(n) FROM t diff --git a/tests/ast_json_fixtures/shapes/d55029b02937ea5f.json b/tests/ast_json_fixtures/shapes/d55029b02937ea5f.json new file mode 100644 index 000000000000..606acc2b1580 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d55029b02937ea5f.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowIndexes", + "table": "'", + "database": "'" + } +} diff --git a/tests/ast_json_fixtures/shapes/d55029b02937ea5f.sql b/tests/ast_json_fixtures/shapes/d55029b02937ea5f.sql new file mode 100644 index 000000000000..83d5a719bf5d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d55029b02937ea5f.sql @@ -0,0 +1 @@ +SHOW INDEX FROM `'`.`'` diff --git a/tests/ast_json_fixtures/shapes/d55a95ae563ca9ae.json b/tests/ast_json_fixtures/shapes/d55a95ae563ca9ae.json new file mode 100644 index 000000000000..34e7c16e4097 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d55a95ae563ca9ae.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "UserID" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "audience_local" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Date" + }, + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2019-07-25" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Release" + }, + { + "type": "Literal", + "value_type": "String", + "value": "17.11.0.542" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d55a95ae563ca9ae.sql b/tests/ast_json_fixtures/shapes/d55a95ae563ca9ae.sql new file mode 100644 index 000000000000..b551bb240a22 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d55a95ae563ca9ae.sql @@ -0,0 +1,3 @@ +SELECT DISTINCT UserID +FROM audience_local +PREWHERE Date = toDate('2019-07-25') AND Release = '17.11.0.542' diff --git a/tests/ast_json_fixtures/shapes/d568f897e5229c6c.json b/tests/ast_json_fixtures/shapes/d568f897e5229c6c.json new file mode 100644 index 000000000000..a7473a2aca9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d568f897e5229c6c.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t1" + }, + "as_table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.1" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d568f897e5229c6c.sql b/tests/ast_json_fixtures/shapes/d568f897e5229c6c.sql new file mode 100644 index 000000000000..6f41ed6e6278 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d568f897e5229c6c.sql @@ -0,0 +1 @@ +CREATE TABLE t1 AS remote('127.0.0.1', system.one) diff --git a/tests/ast_json_fixtures/shapes/d57999fffc3c9342.json b/tests/ast_json_fixtures/shapes/d57999fffc3c9342.json new file mode 100644 index 000000000000..b55e64b5e0f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d57999fffc3c9342.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u2_01292", + "host_pattern": "%.myhost.com" + } + ] + }, + "hosts": { + "any_host": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d57999fffc3c9342.sql b/tests/ast_json_fixtures/shapes/d57999fffc3c9342.sql new file mode 100644 index 000000000000..566550902139 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d57999fffc3c9342.sql @@ -0,0 +1 @@ +ALTER USER u2_01292@'%.myhost.com' HOST ANY diff --git a/tests/ast_json_fixtures/shapes/d5bd7096589e0b9e.json b/tests/ast_json_fixtures/shapes/d5bd7096589e0b9e.json new file mode 100644 index 000000000000..fab1b912acad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d5bd7096589e0b9e.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s4_01294"], + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["u1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d5bd7096589e0b9e.sql b/tests/ast_json_fixtures/shapes/d5bd7096589e0b9e.sql new file mode 100644 index 000000000000..2a98964655c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d5bd7096589e0b9e.sql @@ -0,0 +1 @@ +CREATE PROFILE s4_01294 TO u1_01294 diff --git a/tests/ast_json_fixtures/shapes/d5c5561d93be37ce.json b/tests/ast_json_fixtures/shapes/d5c5561d93be37ce.json new file mode 100644 index 000000000000..4ea7385b3a33 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d5c5561d93be37ce.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "i0", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Identifier", + "name": "c0" + } + ] + }, + "index_type": { + "type": "Function", + "name": "hypothesis", + "arguments": [] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_suspicious_indices": "1" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d5c5561d93be37ce.sql b/tests/ast_json_fixtures/shapes/d5c5561d93be37ce.sql new file mode 100644 index 000000000000..7cd403011ec6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d5c5561d93be37ce.sql @@ -0,0 +1 @@ +CREATE TABLE t0 (c0 Int, INDEX i0 (c0, c0) TYPE hypothesis) ENGINE = MergeTree() ORDER BY tuple() SETTINGS allow_suspicious_indices = 1 diff --git a/tests/ast_json_fixtures/shapes/d607371df78cd2bd.json b/tests/ast_json_fixtures/shapes/d607371df78cd2bd.json new file mode 100644 index 000000000000..f9794c75158b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d607371df78cd2bd.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toYear", + "arguments": [ + { + "type": "Identifier", + "name": "col_date" + } + ] + }, + { + "type": "Identifier", + "name": "col_date32" + }, + { + "type": "Function", + "name": "toYear", + "arguments": [ + { + "type": "Identifier", + "name": "col_datetime" + } + ] + }, + { + "type": "Function", + "name": "toYear", + "arguments": [ + { + "type": "Identifier", + "name": "col_datetime32" + } + ] + }, + { + "type": "Identifier", + "name": "col_datetime64" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "my_table" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d607371df78cd2bd.sql b/tests/ast_json_fixtures/shapes/d607371df78cd2bd.sql new file mode 100644 index 000000000000..2dca85d81109 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d607371df78cd2bd.sql @@ -0,0 +1 @@ +SELECT toYear(col_date), col_date32, toYear(col_datetime), toYear(col_datetime32), col_datetime64 FROM my_table diff --git a/tests/ast_json_fixtures/shapes/d623aaf81c8cce15.json b/tests/ast_json_fixtures/shapes/d623aaf81c8cce15.json new file mode 100644 index 000000000000..bb9213143130 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d623aaf81c8cce15.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s1_01294", "s2_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "value": "5000000" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d623aaf81c8cce15.sql b/tests/ast_json_fixtures/shapes/d623aaf81c8cce15.sql new file mode 100644 index 000000000000..42752467cd68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d623aaf81c8cce15.sql @@ -0,0 +1 @@ +CREATE PROFILE s1_01294, s2_01294 SETTINGS max_memory_usage=5000000 diff --git a/tests/ast_json_fixtures/shapes/d628fa7ed9b03d6e.json b/tests/ast_json_fixtures/shapes/d628fa7ed9b03d6e.json new file mode 100644 index 000000000000..f06fc081c6af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d628fa7ed9b03d6e.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "format", + "arguments": [ + { + "type": "Identifier", + "name": "CSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1,2,3" + } + ] + } + }, + "settings": { + "type": "Settings", + "changes": { + "column_names_for_schema_inference": "a, b, a" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d628fa7ed9b03d6e.sql b/tests/ast_json_fixtures/shapes/d628fa7ed9b03d6e.sql new file mode 100644 index 000000000000..86b6ab0b1861 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d628fa7ed9b03d6e.sql @@ -0,0 +1 @@ +desc format(CSV, '1,2,3') settings column_names_for_schema_inference='a, b, a' diff --git a/tests/ast_json_fixtures/shapes/d63365f0dd32de58.json b/tests/ast_json_fixtures/shapes/d63365f0dd32de58.json new file mode 100644 index 000000000000..f229b7095ebb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d63365f0dd32de58.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "q1" + }, + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table1" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d63365f0dd32de58.sql b/tests/ast_json_fixtures/shapes/d63365f0dd32de58.sql new file mode 100644 index 000000000000..49e2f70b7183 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d63365f0dd32de58.sql @@ -0,0 +1 @@ +SELECT 'q1', x FROM table1 ORDER BY all diff --git a/tests/ast_json_fixtures/shapes/d638f437fcdec0cf.json b/tests/ast_json_fixtures/shapes/d638f437fcdec0cf.json new file mode 100644 index 000000000000..3d5a83b1705a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d638f437fcdec0cf.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "part_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d638f437fcdec0cf.sql b/tests/ast_json_fixtures/shapes/d638f437fcdec0cf.sql new file mode 100644 index 000000000000..1e3243a9d254 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d638f437fcdec0cf.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS part_log diff --git a/tests/ast_json_fixtures/shapes/d6501071ef9bdf7d.json b/tests/ast_json_fixtures/shapes/d6501071ef9bdf7d.json new file mode 100644 index 000000000000..42f290c3ab77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6501071ef9bdf7d.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "dst_00753" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "x" + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "String" + } + } + }, + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "z", + "data_type": { + "type": "DataType", + "name": "String" + }, + "default_specifier": "DEFAULT", + "default_expression": { + "type": "Literal", + "value_type": "String", + "value": "DEFZ" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d6501071ef9bdf7d.sql b/tests/ast_json_fixtures/shapes/d6501071ef9bdf7d.sql new file mode 100644 index 000000000000..9cdbcbcaf8d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6501071ef9bdf7d.sql @@ -0,0 +1 @@ +ALTER TABLE dst_00753 DROP COLUMN x, MODIFY COLUMN y String, ADD COLUMN z String DEFAULT 'DEFZ' diff --git a/tests/ast_json_fixtures/shapes/d65a60fadc218431.json b/tests/ast_json_fixtures/shapes/d65a60fadc218431.json new file mode 100644 index 000000000000..ad80ae07cf43 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d65a60fadc218431.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "SLEEP #2 TEST" + }, + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.001 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/d65a60fadc218431.sql b/tests/ast_json_fixtures/shapes/d65a60fadc218431.sql new file mode 100644 index 000000000000..f8b9c486238a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d65a60fadc218431.sql @@ -0,0 +1 @@ +SELECT 'SLEEP #2 TEST', sleep(0.001) FROM numbers(2) FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/d66133fac85b4559.json b/tests/ast_json_fixtures/shapes/d66133fac85b4559.json new file mode 100644 index 000000000000..a46341c17edc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d66133fac85b4559.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "having": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d66133fac85b4559.sql b/tests/ast_json_fixtures/shapes/d66133fac85b4559.sql new file mode 100644 index 000000000000..da382e58e567 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d66133fac85b4559.sql @@ -0,0 +1 @@ +SELECT 1 HAVING 1 diff --git a/tests/ast_json_fixtures/shapes/d667791cded56b93.json b/tests/ast_json_fixtures/shapes/d667791cded56b93.json new file mode 100644 index 000000000000..5bc49dc61bce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d667791cded56b93.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_alter_mixed" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "x" + } + }, + { + "type": "AlterCommand", + "command_type": "COMMENT_COLUMN", + "if_exists": true, + "column": { + "type": "Identifier", + "name": "x" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "test comment" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d667791cded56b93.sql b/tests/ast_json_fixtures/shapes/d667791cded56b93.sql new file mode 100644 index 000000000000..a4558aceae45 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d667791cded56b93.sql @@ -0,0 +1 @@ +ALTER TABLE test_alter_mixed DROP COLUMN x, COMMENT COLUMN IF EXISTS x 'test comment' diff --git a/tests/ast_json_fixtures/shapes/d670a4c061f07533.json b/tests/ast_json_fixtures/shapes/d670a4c061f07533.json new file mode 100644 index 000000000000..e2eb432b1ae9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d670a4c061f07533.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_1603_rename_bug_ordinary", + "from_table": "bar", + "to_database": "test_1603_rename_bug_ordinary", + "to_table": "foo" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d670a4c061f07533.sql b/tests/ast_json_fixtures/shapes/d670a4c061f07533.sql new file mode 100644 index 000000000000..ea071fff41bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d670a4c061f07533.sql @@ -0,0 +1 @@ +rename table test_1603_rename_bug_ordinary.bar to test_1603_rename_bug_ordinary.foo diff --git a/tests/ast_json_fixtures/shapes/d67f84ed77669572.json b/tests/ast_json_fixtures/shapes/d67f84ed77669572.json new file mode 100644 index 000000000000..de56fbdb4919 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d67f84ed77669572.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tmp_table_01818" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "ClickHouse" + } + }, + "move_destination_type": "TABLE", + "to_table": "main_table_01818" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d67f84ed77669572.sql b/tests/ast_json_fixtures/shapes/d67f84ed77669572.sql new file mode 100644 index 000000000000..4c44c8bd57fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d67f84ed77669572.sql @@ -0,0 +1 @@ +ALTER TABLE tmp_table_01818 MOVE PARTITION 'ClickHouse' TO TABLE main_table_01818 diff --git a/tests/ast_json_fixtures/shapes/d6a642f42a04ee19.json b/tests/ast_json_fixtures/shapes/d6a642f42a04ee19.json new file mode 100644 index 000000000000..33ee65894fda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6a642f42a04ee19.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Function", + "alias": "m", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_inter_02233" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "n" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC", + "with_fill": true + } + ], + "interpolate": [ + { + "type": "InterpolateElement", + "column": "m", + "expr": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "m" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d6a642f42a04ee19.sql b/tests/ast_json_fixtures/shapes/d6a642f42a04ee19.sql new file mode 100644 index 000000000000..531781640192 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6a642f42a04ee19.sql @@ -0,0 +1 @@ +SELECT n, count() AS m FROM t_inter_02233 GROUP BY n ORDER BY n WITH FILL INTERPOLATE ( m AS m + 1 ) diff --git a/tests/ast_json_fixtures/shapes/d6c61205b59935c3.json b/tests/ast_json_fixtures/shapes/d6c61205b59935c3.json new file mode 100644 index 000000000000..dd4c672bc237 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6c61205b59935c3.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "hello", + "name": "number" + }, + { + "type": "Function", + "alias": "world", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Identifier", + "name": "world" + } + ] + }, + { + "type": "Function", + "alias": "sometimes_nulls", + "name": "nullIf", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "5" + } + } + } + ], + "format": "PrettySpaceNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/d6c61205b59935c3.sql b/tests/ast_json_fixtures/shapes/d6c61205b59935c3.sql new file mode 100644 index 000000000000..7c81ba5a7568 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6c61205b59935c3.sql @@ -0,0 +1 @@ +SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 10 SETTINGS max_block_size = 5 FORMAT PrettySpaceNoEscapes diff --git a/tests/ast_json_fixtures/shapes/d6c9b19c7e45fbf1.json b/tests/ast_json_fixtures/shapes/d6c9b19c7e45fbf1.json new file mode 100644 index 000000000000..697915bba5f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6c9b19c7e45fbf1.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01755" + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "settings": { + "type": "Settings", + "changes": { + "enable_early_constant_folding": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d6c9b19c7e45fbf1.sql b/tests/ast_json_fixtures/shapes/d6c9b19c7e45fbf1.sql new file mode 100644 index 000000000000..e212129a7f7d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6c9b19c7e45fbf1.sql @@ -0,0 +1 @@ +select * from dist_01755 where 1 settings enable_early_constant_folding = 0 diff --git a/tests/ast_json_fixtures/shapes/d6e56fbea9f4a96b.json b/tests/ast_json_fixtures/shapes/d6e56fbea9f4a96b.json new file mode 100644 index 000000000000..baeb59957c0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6e56fbea9f4a96b.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_shard_num" + } + ] + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "_shard_num" + } + ], + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_correlated_subqueries": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d6e56fbea9f4a96b.sql b/tests/ast_json_fixtures/shapes/d6e56fbea9f4a96b.sql new file mode 100644 index 000000000000..f8241c9a5d82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6e56fbea9f4a96b.sql @@ -0,0 +1 @@ +SELECT (SELECT _shard_num) FROM t1 GROUP BY _shard_num SETTINGS allow_experimental_correlated_subqueries = 1 diff --git a/tests/ast_json_fixtures/shapes/d6f108fb6e95da79.json b/tests/ast_json_fixtures/shapes/d6f108fb6e95da79.json new file mode 100644 index 000000000000..57f5fb2caf4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6f108fb6e95da79.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q16_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d6f108fb6e95da79.sql b/tests/ast_json_fixtures/shapes/d6f108fb6e95da79.sql new file mode 100644 index 000000000000..0f49e4dd523d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6f108fb6e95da79.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q16_01297 diff --git a/tests/ast_json_fixtures/shapes/d6f11efabccb1dd9.json b/tests/ast_json_fixtures/shapes/d6f11efabccb1dd9.json new file mode 100644 index 000000000000..b670a1e7d8fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6f11efabccb1dd9.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "full_duplicates" + }, + "final": true, + "deduplicate": true, + "deduplicate_by_columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Asterisk" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d6f11efabccb1dd9.sql b/tests/ast_json_fixtures/shapes/d6f11efabccb1dd9.sql new file mode 100644 index 000000000000..a896a083b62a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d6f11efabccb1dd9.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE full_duplicates FINAL DEDUPLICATE BY * diff --git a/tests/ast_json_fixtures/shapes/d7109eeb8d92c938.json b/tests/ast_json_fixtures/shapes/d7109eeb8d92c938.json new file mode 100644 index 000000000000..b7809bd284d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7109eeb8d92c938.json @@ -0,0 +1,147 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "t2", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "x" + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 10000 + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "t1.s", + "name_parts": ["t1", "s"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "substr", + "arguments": [ + { + "type": "Identifier", + "name": "t1.s", + "name_parts": ["t1", "s"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "t2.s", + "name_parts": ["t2", "s"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "Float64", + "value": 100000 + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "32", + "max_memory_usage": "2Gi", + "join_algorithm": "parallel_hash", + "min_joined_block_size_bytes": "1Mi" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/d7109eeb8d92c938.sql b/tests/ast_json_fixtures/shapes/d7109eeb8d92c938.sql new file mode 100644 index 000000000000..5c3db1eaf29e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7109eeb8d92c938.sql @@ -0,0 +1,13 @@ +WITH t2 AS + ( + SELECT + 'x' AS s, + number + FROM numbers_mt(10000.) + ) +SELECT t1.s +FROM t AS t1 +INNER JOIN t2 ON substr(t1.s, 1, 1) = t2.s +LIMIT 1e5 +SETTINGS max_threads = 32, max_memory_usage = '2Gi', join_algorithm = 'parallel_hash', min_joined_block_size_bytes = '1Mi' +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/d7249ecdfabbe1f8.json b/tests/ast_json_fixtures/shapes/d7249ecdfabbe1f8.json new file mode 100644 index 000000000000..be576deaa7a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7249ecdfabbe1f8.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "alias": "ratio", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "in" + }, + { + "type": "Identifier", + "name": "out" + } + ] + }, + { + "type": "Function", + "alias": "count_rows_w", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Asterisk" + } + ], + "window_name": "w" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "error_win_func" + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "frame_type": "ROWS", + "frame_begin": { + "type": "Current", + "preceding": true + }, + "frame_end": { + "type": "Offset", + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + } + } + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "k" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d7249ecdfabbe1f8.sql b/tests/ast_json_fixtures/shapes/d7249ecdfabbe1f8.sql new file mode 100644 index 000000000000..184e97ba3285 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7249ecdfabbe1f8.sql @@ -0,0 +1,10 @@ +SELECT + k, + in / out AS ratio, + count(*) OVER w AS count_rows_w +FROM error_win_func +WINDOW + w AS (ROWS BETWEEN CURRENT ROW AND 3 FOLLOWING) +ORDER BY ALL +LIMIT 1 BY + k diff --git a/tests/ast_json_fixtures/shapes/d72940b48f545681.json b/tests/ast_json_fixtures/shapes/d72940b48f545681.json new file mode 100644 index 000000000000..db593e251ad0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d72940b48f545681.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_atomic", + "from_table": "dst", + "to_database": "test_01155_ordinary", + "to_table": "dst" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d72940b48f545681.sql b/tests/ast_json_fixtures/shapes/d72940b48f545681.sql new file mode 100644 index 000000000000..9509561b2ba8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d72940b48f545681.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_atomic.dst TO test_01155_ordinary.dst diff --git a/tests/ast_json_fixtures/shapes/d72ac680797e4241.json b/tests/ast_json_fixtures/shapes/d72ac680797e4241.json new file mode 100644 index 000000000000..170c3aaedca5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d72ac680797e4241.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "$alias$name$", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/d72ac680797e4241.sql b/tests/ast_json_fixtures/shapes/d72ac680797e4241.sql new file mode 100644 index 000000000000..f07651eee052 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d72ac680797e4241.sql @@ -0,0 +1 @@ +SELECT 1 AS $alias$name$ FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/d734d54156cfb7be.json b/tests/ast_json_fixtures/shapes/d734d54156cfb7be.json new file mode 100644 index 000000000000..90e1d7eb032f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d734d54156cfb7be.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "users" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "uid", + "data_type": { + "type": "DataType", + "name": "Int16" + } + }, + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "DateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "UTC" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "uid" + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "uid" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "merge_with_ttl_timeout": "0", + "min_bytes_for_wide_part": "0", + "vertical_merge_algorithm_min_rows_to_activate": "0", + "vertical_merge_algorithm_min_columns_to_activate": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d734d54156cfb7be.sql b/tests/ast_json_fixtures/shapes/d734d54156cfb7be.sql new file mode 100644 index 000000000000..ed9afe17ddd3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d734d54156cfb7be.sql @@ -0,0 +1,3 @@ +CREATE TABLE users (uid Int16, d DateTime('UTC')) +ENGINE = MergeTree ORDER BY uid TTL d + INTERVAL 1 MONTH WHERE uid = 1 +SETTINGS merge_with_ttl_timeout = 0, min_bytes_for_wide_part = 0, vertical_merge_algorithm_min_rows_to_activate = 0, vertical_merge_algorithm_min_columns_to_activate = 0 diff --git a/tests/ast_json_fixtures/shapes/d73893959bb7673e.json b/tests/ast_json_fixtures/shapes/d73893959bb7673e.json new file mode 100644 index 000000000000..6b39888d29fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d73893959bb7673e.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowGrantsQuery", + "for_roles": { + "type": "RolesOrUsersSet", + "current_user": true + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/d73893959bb7673e.sql b/tests/ast_json_fixtures/shapes/d73893959bb7673e.sql new file mode 100644 index 000000000000..14e87fe4c0a8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d73893959bb7673e.sql @@ -0,0 +1 @@ +SHOW GRANTS FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/d739e8c8849b18ad.json b/tests/ast_json_fixtures/shapes/d739e8c8849b18ad.json new file mode 100644 index 000000000000..fcc70a2ab891 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d739e8c8849b18ad.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "sqllt", + "table": "table" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["sqllt_user"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d739e8c8849b18ad.sql b/tests/ast_json_fixtures/shapes/d739e8c8849b18ad.sql new file mode 100644 index 000000000000..afa4a8021dbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d739e8c8849b18ad.sql @@ -0,0 +1 @@ +GRANT SELECT ON sqllt.table TO sqllt_user diff --git a/tests/ast_json_fixtures/shapes/d73c0e50ed7fb6cd.json b/tests/ast_json_fixtures/shapes/d73c0e50ed7fb6cd.json new file mode 100644 index 000000000000..1591335d3222 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d73c0e50ed7fb6cd.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "{}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "JSON" + } + ] + } + ], + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x.^`c0`", + "name_parts": ["x", "^`c0`"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d73c0e50ed7fb6cd.sql b/tests/ast_json_fixtures/shapes/d73c0e50ed7fb6cd.sql new file mode 100644 index 000000000000..2d11dc416c60 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d73c0e50ed7fb6cd.sql @@ -0,0 +1 @@ +SELECT '{}'::JSON x QUALIFY x.^c0 = 1 diff --git a/tests/ast_json_fixtures/shapes/d7545819e6b0d60b.json b/tests/ast_json_fixtures/shapes/d7545819e6b0d60b.json new file mode 100644 index 000000000000..f082a199d916 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7545819e6b0d60b.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/d7545819e6b0d60b.sql b/tests/ast_json_fixtures/shapes/d7545819e6b0d60b.sql new file mode 100644 index 000000000000..aaf9232ffe29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7545819e6b0d60b.sql @@ -0,0 +1 @@ +select * from test limit 1 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/d7736821bc0eca35.json b/tests/ast_json_fixtures/shapes/d7736821bc0eca35.json new file mode 100644 index 000000000000..423b86bb6511 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7736821bc0eca35.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "uuid": "00000000-0000-0000-0000-000000003541", + "table": { + "type": "Identifier", + "name": "no_insertable" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "Int" + }, + "default_specifier": "MATERIALIZED", + "default_expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d7736821bc0eca35.sql b/tests/ast_json_fixtures/shapes/d7736821bc0eca35.sql new file mode 100644 index 000000000000..e8c8bd141bae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7736821bc0eca35.sql @@ -0,0 +1 @@ +ATTACH TABLE no_insertable UUID '00000000-0000-0000-0000-000000003541' (a Int MATERIALIZED 1) Engine=Memory diff --git a/tests/ast_json_fixtures/shapes/d77d768fd2f259aa.json b/tests/ast_json_fixtures/shapes/d77d768fd2f259aa.json new file mode 100644 index 000000000000..b515e8f8228b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d77d768fd2f259aa.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH ASYNC INSERT QUEUE", + "tables": [ + { + "table": "03732_table" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d77d768fd2f259aa.sql b/tests/ast_json_fixtures/shapes/d77d768fd2f259aa.sql new file mode 100644 index 000000000000..bd7112604462 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d77d768fd2f259aa.sql @@ -0,0 +1 @@ +system flush async insert queue 03732_table diff --git a/tests/ast_json_fixtures/shapes/d7b117e124f2080f.json b/tests/ast_json_fixtures/shapes/d7b117e124f2080f.json new file mode 100644 index 000000000000..5487f249087c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7b117e124f2080f.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q2_01297"], + "new_name": "q2_01297_renamed" + } +} diff --git a/tests/ast_json_fixtures/shapes/d7b117e124f2080f.sql b/tests/ast_json_fixtures/shapes/d7b117e124f2080f.sql new file mode 100644 index 000000000000..0fb4706979f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7b117e124f2080f.sql @@ -0,0 +1 @@ +ALTER QUOTA q2_01297 RENAME TO 'q2_01297_renamed' diff --git a/tests/ast_json_fixtures/shapes/d7c2de774ed48de2.json b/tests/ast_json_fixtures/shapes/d7c2de774ed48de2.json new file mode 100644 index 000000000000..4dc19c493332 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7c2de774ed48de2.json @@ -0,0 +1,110 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "recursive_cte", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recursive_cte" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "n" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recursive_cte" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d7c2de774ed48de2.sql b/tests/ast_json_fixtures/shapes/d7c2de774ed48de2.sql new file mode 100644 index 000000000000..b5941f069bb6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7c2de774ed48de2.sql @@ -0,0 +1,2 @@ +WITH RECURSIVE recursive_cte AS (SELECT 1 AS n UNION ALL SELECT n + 1 FROM recursive_cte WHERE n < 10) +SELECT n FROM recursive_cte diff --git a/tests/ast_json_fixtures/shapes/d7c97f1dfe016da3.json b/tests/ast_json_fixtures/shapes/d7c97f1dfe016da3.json new file mode 100644 index 000000000000..ae0c1e27f121 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7c97f1dfe016da3.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/d7c97f1dfe016da3.sql b/tests/ast_json_fixtures/shapes/d7c97f1dfe016da3.sql new file mode 100644 index 000000000000..d0074fb5f768 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7c97f1dfe016da3.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) ORDER BY number FORMAT PrettyNoEscapes diff --git a/tests/ast_json_fixtures/shapes/d7cd91826db65cba.json b/tests/ast_json_fixtures/shapes/d7cd91826db65cba.json new file mode 100644 index 000000000000..8a133510c094 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7cd91826db65cba.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "test", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d7cd91826db65cba.sql b/tests/ast_json_fixtures/shapes/d7cd91826db65cba.sql new file mode 100644 index 000000000000..d51f6e484de8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7cd91826db65cba.sql @@ -0,0 +1,9 @@ +WITH + test AS ( + SELECT + *, + count() OVER () AS c + FROM numbers(10) + ) +SELECT * FROM test +ORDER BY toString(number) diff --git a/tests/ast_json_fixtures/shapes/d7d42f993e3fa11e.json b/tests/ast_json_fixtures/shapes/d7d42f993e3fa11e.json new file mode 100644 index 000000000000..2cb67bf4dd9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7d42f993e3fa11e.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01292", "r2_01292"] + }, + "grantees": { + "type": "RolesOrUsersSet", + "names": ["u1_01292", "u2_01292", "u3_01292", "u4_01292", "u5_01292", "u6_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d7d42f993e3fa11e.sql b/tests/ast_json_fixtures/shapes/d7d42f993e3fa11e.sql new file mode 100644 index 000000000000..a16e556d0070 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7d42f993e3fa11e.sql @@ -0,0 +1 @@ +GRANT r1_01292, r2_01292 TO u1_01292, u2_01292, u3_01292, u4_01292, u5_01292, u6_01292 diff --git a/tests/ast_json_fixtures/shapes/d7ee8df775b0aafa.json b/tests/ast_json_fixtures/shapes/d7ee8df775b0aafa.json new file mode 100644 index 000000000000..26a4d3ff99b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7ee8df775b0aafa.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + }, + "format": "TSVRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/d7ee8df775b0aafa.sql b/tests/ast_json_fixtures/shapes/d7ee8df775b0aafa.sql new file mode 100644 index 000000000000..543845e38979 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d7ee8df775b0aafa.sql @@ -0,0 +1 @@ +desc test format TSVRaw diff --git a/tests/ast_json_fixtures/shapes/d81ec2cdecf06e88.json b/tests/ast_json_fixtures/shapes/d81ec2cdecf06e88.json new file mode 100644 index 000000000000..cee34329957e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d81ec2cdecf06e88.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "SLEEP #6 TEST" + }, + { + "type": "Function", + "name": "sleepEachRow", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.001 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "sleep_view" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/d81ec2cdecf06e88.sql b/tests/ast_json_fixtures/shapes/d81ec2cdecf06e88.sql new file mode 100644 index 000000000000..7ce114ae6f5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d81ec2cdecf06e88.sql @@ -0,0 +1 @@ +SELECT 'SLEEP #6 TEST', sleepEachRow(0.001) FROM sleep_view LIMIT 10 FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/d837d5170975903e.json b/tests/ast_json_fixtures/shapes/d837d5170975903e.json new file mode 100644 index 000000000000..37f4f922e118 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d837d5170975903e.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "result_overflow_mode": "break", + "max_block_size": "1" + } + } + } + ], + "format": "PrettySpaceNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/d837d5170975903e.sql b/tests/ast_json_fixtures/shapes/d837d5170975903e.sql new file mode 100644 index 000000000000..26e6ced4896e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d837d5170975903e.sql @@ -0,0 +1 @@ +select * from numbers(10) SETTINGS result_overflow_mode = 'break', max_block_size = 1 FORMAT PrettySpaceNoEscapes diff --git a/tests/ast_json_fixtures/shapes/d84341f00c60c68c.json b/tests/ast_json_fixtures/shapes/d84341f00c60c68c.json new file mode 100644 index 000000000000..2885b28dd314 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d84341f00c60c68c.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "d0" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "null", + "elements": [] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 1 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d84341f00c60c68c.sql b/tests/ast_json_fixtures/shapes/d84341f00c60c68c.sql new file mode 100644 index 000000000000..8a71e437e2ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d84341f00c60c68c.sql @@ -0,0 +1 @@ +CREATE DICTIONARY d0 (c0 Int) PRIMARY KEY (c0) SOURCE(NULL()) LAYOUT(FLAT()) LIFETIME(1) diff --git a/tests/ast_json_fixtures/shapes/d847c1ebc492d57c.json b/tests/ast_json_fixtures/shapes/d847c1ebc492d57c.json new file mode 100644 index 000000000000..2392f0a0e3b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d847c1ebc492d57c.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q8_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d847c1ebc492d57c.sql b/tests/ast_json_fixtures/shapes/d847c1ebc492d57c.sql new file mode 100644 index 000000000000..95adf7c1e165 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d847c1ebc492d57c.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q8_01297 diff --git a/tests/ast_json_fixtures/shapes/d849a1aa57c641f1.json b/tests/ast_json_fixtures/shapes/d849a1aa57c641f1.json new file mode 100644 index 000000000000..dbb8fb5b98b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d849a1aa57c641f1.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["sqllt_quota"], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/d849a1aa57c641f1.sql b/tests/ast_json_fixtures/shapes/d849a1aa57c641f1.sql new file mode 100644 index 000000000000..98ed6912d725 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d849a1aa57c641f1.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA sqllt_quota FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/d84d16a6f4aa9df0.json b/tests/ast_json_fixtures/shapes/d84d16a6f4aa9df0.json new file mode 100644 index 000000000000..dcd21087059f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d84d16a6f4aa9df0.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "exp2", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "exp10", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test" + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "64" + } + ] + } + } + } + ] + } + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/d84d16a6f4aa9df0.sql b/tests/ast_json_fixtures/shapes/d84d16a6f4aa9df0.sql new file mode 100644 index 000000000000..70ce5d7d84cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d84d16a6f4aa9df0.sql @@ -0,0 +1 @@ +SELECT exp2(number), exp10(number), 'test'||number FROM numbers(64) FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/d84f98c16755d4a4.json b/tests/ast_json_fixtures/shapes/d84f98c16755d4a4.json new file mode 100644 index 000000000000..574a59ea2b2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d84f98c16755d4a4.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "x1" + } + ] + }, + { + "type": "Identifier", + "name": "x2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d84f98c16755d4a4.sql b/tests/ast_json_fixtures/shapes/d84f98c16755d4a4.sql new file mode 100644 index 000000000000..be360a96888e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d84f98c16755d4a4.sql @@ -0,0 +1 @@ +select max(x1), x2 from test group by 1, 2 diff --git a/tests/ast_json_fixtures/shapes/d860367a86113528.json b/tests/ast_json_fixtures/shapes/d860367a86113528.json new file mode 100644 index 000000000000..98f82314b630 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d860367a86113528.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_desc_subcolumns" + } + }, + "settings": { + "type": "Settings", + "changes": { + "describe_include_subcolumns": "1" + } + }, + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/d860367a86113528.sql b/tests/ast_json_fixtures/shapes/d860367a86113528.sql new file mode 100644 index 000000000000..072865ee55b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d860367a86113528.sql @@ -0,0 +1,2 @@ +DESCRIBE TABLE t_desc_subcolumns FORMAT PrettyCompactNoEscapes +SETTINGS describe_include_subcolumns = 1 diff --git a/tests/ast_json_fixtures/shapes/d86ad69563394ba8.json b/tests/ast_json_fixtures/shapes/d86ad69563394ba8.json new file mode 100644 index 000000000000..17f92cf96bd5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d86ad69563394ba8.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "y", + "data_type": { + "type": "DataType", + "name": "int" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d86ad69563394ba8.sql b/tests/ast_json_fixtures/shapes/d86ad69563394ba8.sql new file mode 100644 index 000000000000..e91cca9889d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d86ad69563394ba8.sql @@ -0,0 +1 @@ +ALTER TABLE t ADD COLUMN y int diff --git a/tests/ast_json_fixtures/shapes/d8768bc91249af05.json b/tests/ast_json_fixtures/shapes/d8768bc91249af05.json new file mode 100644 index 000000000000..98ad38afd1d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8768bc91249af05.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "trunc" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ATTACH_PARTITION", + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d8768bc91249af05.sql b/tests/ast_json_fixtures/shapes/d8768bc91249af05.sql new file mode 100644 index 000000000000..5a9c71487f4f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8768bc91249af05.sql @@ -0,0 +1 @@ +alter table trunc attach partition id '0' diff --git a/tests/ast_json_fixtures/shapes/d897e294df90534d.json b/tests/ast_json_fixtures/shapes/d897e294df90534d.json new file mode 100644 index 000000000000..21ac03d86f34 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d897e294df90534d.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "uuid": "00000000-0000-0000-0000-000000001601", + "database": { + "type": "Identifier", + "name": "test1601_detach_permanently_atomic" + }, + "table": { + "type": "Identifier", + "name": "test_name_reuse" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "number", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d897e294df90534d.sql b/tests/ast_json_fixtures/shapes/d897e294df90534d.sql new file mode 100644 index 000000000000..376d26d0d395 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d897e294df90534d.sql @@ -0,0 +1 @@ +ATTACH TABLE test1601_detach_permanently_atomic.test_name_reuse UUID '00000000-0000-0000-0000-000000001601' (`number` UInt64 ) ENGINE = MergeTree ORDER BY tuple() SETTINGS index_granularity = 8192 diff --git a/tests/ast_json_fixtures/shapes/d8ac9f8ce72a6a5d.json b/tests/ast_json_fixtures/shapes/d8ac9f8ce72a6a5d.json new file mode 100644 index 000000000000..2b7fbeffeaf4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8ac9f8ce72a6a5d.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH ASYNC INSERT QUEUE", + "tables": [ + { + "table": "test" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d8ac9f8ce72a6a5d.sql b/tests/ast_json_fixtures/shapes/d8ac9f8ce72a6a5d.sql new file mode 100644 index 000000000000..b9fb29b1d253 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8ac9f8ce72a6a5d.sql @@ -0,0 +1 @@ +SYSTEM FLUSH ASYNC INSERT QUEUE test diff --git a/tests/ast_json_fixtures/shapes/d8c8098eba6932e2.json b/tests/ast_json_fixtures/shapes/d8c8098eba6932e2.json new file mode 100644 index 000000000000..691cd06c2465 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8c8098eba6932e2.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_primary_key": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d8c8098eba6932e2.sql b/tests/ast_json_fixtures/shapes/d8c8098eba6932e2.sql new file mode 100644 index 000000000000..53cb17cf4cb5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8c8098eba6932e2.sql @@ -0,0 +1,8 @@ +SELECT + k, + count() +FROM t1 +WHERE k > 0 +GROUP BY k +ORDER BY k +SETTINGS force_primary_key = 1 diff --git a/tests/ast_json_fixtures/shapes/d8d640a54014f69f.json b/tests/ast_json_fixtures/shapes/d8d640a54014f69f.json new file mode 100644 index 000000000000..4ddf2897929b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8d640a54014f69f.json @@ -0,0 +1,161 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "246" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "arrayStringConcat", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reinterpretAsString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/d8d640a54014f69f.sql b/tests/ast_json_fixtures/shapes/d8d640a54014f69f.sql new file mode 100644 index 000000000000..e57fff5e3357 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8d640a54014f69f.sql @@ -0,0 +1 @@ +SELECT number * 246 + 10 AS n, toDate('2000-01-01') + n AS d, range(n) AS arr, arrayStringConcat(arrayMap(x -> reinterpretAsString(x), arr)) AS s, (n, d) AS tuple FROM system.numbers LIMIT 2 FORMAT JSON diff --git a/tests/ast_json_fixtures/shapes/d8dc11cc753c8f8b.json b/tests/ast_json_fixtures/shapes/d8dc11cc753c8f8b.json new file mode 100644 index 000000000000..74b20f570c3e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8dc11cc753c8f8b.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "START PULLING REPLICATION LOG", + "table": { + "type": "Identifier", + "name": "t1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d8dc11cc753c8f8b.sql b/tests/ast_json_fixtures/shapes/d8dc11cc753c8f8b.sql new file mode 100644 index 000000000000..174fcce3aeac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8dc11cc753c8f8b.sql @@ -0,0 +1 @@ +SYSTEM START PULLING REPLICATION LOG t1 diff --git a/tests/ast_json_fixtures/shapes/d8e7c0335541508d.json b/tests/ast_json_fixtures/shapes/d8e7c0335541508d.json new file mode 100644 index 000000000000..2e2f7f2a42a2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8e7c0335541508d.json @@ -0,0 +1,254 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "e2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "alias": "e2", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.y", + "name_parts": ["t1", "y"] + }, + { + "type": "Identifier", + "name": "t2.y", + "name_parts": ["t2", "y"] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.y", + "name_parts": ["t1", "y"] + } + ] + }, + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.y", + "name_parts": ["t2", "y"] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "COALESCE", + "arguments": [ + { + "type": "Identifier", + "name": "t1.x", + "name_parts": ["t1", "x"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.x", + "name_parts": ["t1", "x"] + }, + { + "type": "Identifier", + "name": "t2.x", + "name_parts": ["t2", "x"] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.x", + "name_parts": ["t2", "x"] + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.x", + "name_parts": ["t1", "x"] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.x", + "name_parts": ["t1", "x"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.x", + "name_parts": ["t2", "x"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d8e7c0335541508d.sql b/tests/ast_json_fixtures/shapes/d8e7c0335541508d.sql new file mode 100644 index 000000000000..603267fb5318 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8e7c0335541508d.sql @@ -0,0 +1,7 @@ +SELECT *, e2 FROM t1 FULL OUTER JOIN t2 +ON ( + (((t1.y = t2.y) OR ((t1.y IS NULL) AND (t2.y IS NULL))) AND (COALESCE(t1.x, 0) != 2)) + OR (((t1.x = t2.x)) AND ((t2.x IS NOT NULL) AND (t1.x IS NOT NULL))) + AS e2 +) AND (t1.x = 1) AND (t2.x = 1) +ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/d8fa0bd7fbc6b53e.json b/tests/ast_json_fixtures/shapes/d8fa0bd7fbc6b53e.json new file mode 100644 index 000000000000..0a4a28cd2424 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8fa0bd7fbc6b53e.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "bb", + "name": "b" + } + ], + "select": [ + { + "type": "Identifier", + "name": "bb" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + } + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d8fa0bd7fbc6b53e.sql b/tests/ast_json_fixtures/shapes/d8fa0bd7fbc6b53e.sql new file mode 100644 index 000000000000..80fbb3efedaa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d8fa0bd7fbc6b53e.sql @@ -0,0 +1 @@ +WITH b AS bb SELECT bb FROM t2 WHERE a IN (SELECT a FROM t1) diff --git a/tests/ast_json_fixtures/shapes/d915f0c392d7c2d1.json b/tests/ast_json_fixtures/shapes/d915f0c392d7c2d1.json new file mode 100644 index 000000000000..4d88504dd292 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d915f0c392d7c2d1.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "tlb" + }, + "columns": [ + { + "type": "Identifier", + "name": "k" + } + ], + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d915f0c392d7c2d1.sql b/tests/ast_json_fixtures/shapes/d915f0c392d7c2d1.sql new file mode 100644 index 000000000000..fb9cfbee9019 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d915f0c392d7c2d1.sql @@ -0,0 +1 @@ +INSERT INTO tlb (k) SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/d933720035130b9f.json b/tests/ast_json_fixtures/shapes/d933720035130b9f.json new file mode 100644 index 000000000000..857236b02e2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d933720035130b9f.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "a8x" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "min_bytes_for_wide_part": "0" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/d933720035130b9f.sql b/tests/ast_json_fixtures/shapes/d933720035130b9f.sql new file mode 100644 index 000000000000..ab199ac26008 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d933720035130b9f.sql @@ -0,0 +1 @@ +create table a8x ENGINE = MergeTree ORDER BY tuple() settings min_bytes_for_wide_part=0 as SELECT number FROM system.numbers limit 100 diff --git a/tests/ast_json_fixtures/shapes/d95426a08148c1bf.json b/tests/ast_json_fixtures/shapes/d95426a08148c1bf.json new file mode 100644 index 000000000000..b9f45becf7c8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d95426a08148c1bf.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "data" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_INDEX", + "index": { + "type": "Identifier", + "name": "idx" + }, + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d95426a08148c1bf.sql b/tests/ast_json_fixtures/shapes/d95426a08148c1bf.sql new file mode 100644 index 000000000000..d4f440111b0a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d95426a08148c1bf.sql @@ -0,0 +1 @@ +ALTER TABLE data MATERIALIZE INDEX idx IN PARTITION ID '1' diff --git a/tests/ast_json_fixtures/shapes/d95ce7c5c633f247.json b/tests/ast_json_fixtures/shapes/d95ce7c5c633f247.json new file mode 100644 index 000000000000..cc0f62eed31c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d95ce7c5c633f247.json @@ -0,0 +1,126 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t1" + } + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t2" + } + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t3" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "table1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table1.a", + "name_parts": ["table1", "a"] + }, + { + "type": "Identifier", + "name": "table2.a", + "name_parts": ["table2", "a"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "table2" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table2.b", + "name_parts": ["table2", "b"] + }, + { + "type": "Identifier", + "name": "table3.b", + "name_parts": ["table3", "b"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t3", + "name": "table3" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.a", + "name_parts": ["t1", "a"] + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/d95ce7c5c633f247.sql b/tests/ast_json_fixtures/shapes/d95ce7c5c633f247.sql new file mode 100644 index 000000000000..54b33d5fbc2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d95ce7c5c633f247.sql @@ -0,0 +1,6 @@ +select t1.*, t2.*, t3.* +from table1 as t1 +join table2 as t2 on table1.a = table2.a +join table3 as t3 on table2.b = table3.b +ORDER BY t1.a +FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/d97cc8496d70adfd.json b/tests/ast_json_fixtures/shapes/d97cc8496d70adfd.json new file mode 100644 index 000000000000..33131b7a0576 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d97cc8496d70adfd.json @@ -0,0 +1,106 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "k", + "name": "number" + }, + { + "type": "Function", + "alias": "v1", + "name": "repeat", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + }, + { + "type": "Function", + "alias": "v2", + "name": "repeat", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "12" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 3000000 + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "Float64", + "value": 400000 + }, + "settings": { + "type": "Settings", + "changes": { + "remerge_sort_lowered_memory_bytes_ratio": 1.9 + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/d97cc8496d70adfd.sql b/tests/ast_json_fixtures/shapes/d97cc8496d70adfd.sql new file mode 100644 index 000000000000..1a9e6678b61e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d97cc8496d70adfd.sql @@ -0,0 +1 @@ +select number k, repeat(toString(number), 11) v1, repeat(toString(number), 12) v2 from numbers(3e6) order by k limit 400e3 settings remerge_sort_lowered_memory_bytes_ratio=1.9 format Null diff --git a/tests/ast_json_fixtures/shapes/d9811d2be3e6e9e7.json b/tests/ast_json_fixtures/shapes/d9811d2be3e6e9e7.json new file mode 100644 index 000000000000..e36834a6f06f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d9811d2be3e6e9e7.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s1_01418"] + } +} diff --git a/tests/ast_json_fixtures/shapes/d9811d2be3e6e9e7.sql b/tests/ast_json_fixtures/shapes/d9811d2be3e6e9e7.sql new file mode 100644 index 000000000000..1276c078c771 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d9811d2be3e6e9e7.sql @@ -0,0 +1 @@ +SHOW CREATE SETTINGS PROFILE s1_01418 diff --git a/tests/ast_json_fixtures/shapes/d9bcad7304ac934b.json b/tests/ast_json_fixtures/shapes/d9bcad7304ac934b.json new file mode 100644 index 000000000000..26481651f59e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d9bcad7304ac934b.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "i" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d9bcad7304ac934b.sql b/tests/ast_json_fixtures/shapes/d9bcad7304ac934b.sql new file mode 100644 index 000000000000..9fa5fb43e657 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d9bcad7304ac934b.sql @@ -0,0 +1 @@ +SELECT * FROM test ORDER BY i LIMIT 20 OFFSET 10*10 diff --git a/tests/ast_json_fixtures/shapes/d9dea02618a7a9e5.json b/tests/ast_json_fixtures/shapes/d9dea02618a7a9e5.json new file mode 100644 index 000000000000..5573c39ab44f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d9dea02618a7a9e5.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q5_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "QUERY_SELECTS": "12000000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d9dea02618a7a9e5.sql b/tests/ast_json_fixtures/shapes/d9dea02618a7a9e5.sql new file mode 100644 index 000000000000..2c318f3522c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d9dea02618a7a9e5.sql @@ -0,0 +1 @@ +CREATE QUOTA q5_01297 FOR INTERVAL 1 MINUTE MAX query_selects = '12G' diff --git a/tests/ast_json_fixtures/shapes/d9e00b894192be5b.json b/tests/ast_json_fixtures/shapes/d9e00b894192be5b.json new file mode 100644 index 000000000000..5f77bb874005 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d9e00b894192be5b.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Identifier", + "name": "ints" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "ints" + } + ] + }, + { + "type": "Identifier", + "name": "int_ints" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "int_ints" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_byte_size_complex_array" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d9e00b894192be5b.sql b/tests/ast_json_fixtures/shapes/d9e00b894192be5b.sql new file mode 100644 index 000000000000..dd8aa7367150 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d9e00b894192be5b.sql @@ -0,0 +1 @@ +select key, byteSize(*), ints, byteSize(ints), int_ints, byteSize(int_ints) from test_byte_size_complex_array order by key diff --git a/tests/ast_json_fixtures/shapes/d9f6f3adec73a2fc.json b/tests/ast_json_fixtures/shapes/d9f6f3adec73a2fc.json new file mode 100644 index 000000000000..2e41b3c847e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d9f6f3adec73a2fc.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_src" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MOVE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + }, + "move_destination_type": "TABLE", + "to_table": "t_dst" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/d9f6f3adec73a2fc.sql b/tests/ast_json_fixtures/shapes/d9f6f3adec73a2fc.sql new file mode 100644 index 000000000000..9813a805a0cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/d9f6f3adec73a2fc.sql @@ -0,0 +1 @@ +ALTER TABLE t_src MOVE PARTITION 1 TO TABLE t_dst diff --git a/tests/ast_json_fixtures/shapes/da36c3977d1944b1.json b/tests/ast_json_fixtures/shapes/da36c3977d1944b1.json new file mode 100644 index 000000000000..adb1fb4a6865 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/da36c3977d1944b1.json @@ -0,0 +1,106 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "offset", + "name": "number" + }, + { + "type": "Function", + "alias": "length", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "Hello" + }, + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Function", + "name": "bin", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "length" + } + ] + }, + { + "type": "Function", + "name": "bin", + "arguments": [ + { + "type": "Function", + "name": "bitSlice", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "length" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/da36c3977d1944b1.sql b/tests/ast_json_fixtures/shapes/da36c3977d1944b1.sql new file mode 100644 index 000000000000..5f0f9e23170c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/da36c3977d1944b1.sql @@ -0,0 +1 @@ +select number as offset, -number as length, 'Hello' as s, subString(bin(s), offset , length), bin(bitSlice(s, offset, length)) from numbers(16) diff --git a/tests/ast_json_fixtures/shapes/da5c7acf79d76510.json b/tests/ast_json_fixtures/shapes/da5c7acf79d76510.json new file mode 100644 index 000000000000..3318cbcea5e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/da5c7acf79d76510.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02099_lambda_function" + } +} diff --git a/tests/ast_json_fixtures/shapes/da5c7acf79d76510.sql b/tests/ast_json_fixtures/shapes/da5c7acf79d76510.sql new file mode 100644 index 000000000000..44fcf8e1241c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/da5c7acf79d76510.sql @@ -0,0 +1 @@ +DROP FUNCTION 02099_lambda_function diff --git a/tests/ast_json_fixtures/shapes/da5f01678bcfa66a.json b/tests/ast_json_fixtures/shapes/da5f01678bcfa66a.json new file mode 100644 index 000000000000..09207f6701bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/da5f01678bcfa66a.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "other_table_1" + }, + "as_table": "mv_with_storage" + } +} diff --git a/tests/ast_json_fixtures/shapes/da5f01678bcfa66a.sql b/tests/ast_json_fixtures/shapes/da5f01678bcfa66a.sql new file mode 100644 index 000000000000..9783eeb53bc2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/da5f01678bcfa66a.sql @@ -0,0 +1 @@ +CREATE TABLE other_table_1 AS mv_with_storage diff --git a/tests/ast_json_fixtures/shapes/da744e8cf67b614f.json b/tests/ast_json_fixtures/shapes/da744e8cf67b614f.json new file mode 100644 index 000000000000..401bcf18a377 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/da744e8cf67b614f.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "group_by_null_key" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "c1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/da744e8cf67b614f.sql b/tests/ast_json_fixtures/shapes/da744e8cf67b614f.sql new file mode 100644 index 000000000000..e17e176b7f1a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/da744e8cf67b614f.sql @@ -0,0 +1 @@ +select c1, count(*) from group_by_null_key group by ROLLUP(c1) diff --git a/tests/ast_json_fixtures/shapes/daace3bdd7d912d5.json b/tests/ast_json_fixtures/shapes/daace3bdd7d912d5.json new file mode 100644 index 000000000000..3fd34ec80368 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/daace3bdd7d912d5.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toUnixTimestamp", + "arguments": [ + { + "type": "Identifier", + "name": "v1" + } + ] + }, + { + "type": "Identifier", + "name": "v2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab1" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "v1" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "settings": { + "type": "Settings", + "changes": { + "use_top_k_dynamic_filtering": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/daace3bdd7d912d5.sql b/tests/ast_json_fixtures/shapes/daace3bdd7d912d5.sql new file mode 100644 index 000000000000..ac3c4b33dfd6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/daace3bdd7d912d5.sql @@ -0,0 +1 @@ +SELECT toUnixTimestamp(v1), v2 FROM tab1 ORDER BY v1 ASC LIMIT 5 SETTINGS use_top_k_dynamic_filtering=1 diff --git a/tests/ast_json_fixtures/shapes/daad9b2d238eb135.json b/tests/ast_json_fixtures/shapes/daad9b2d238eb135.json new file mode 100644 index 000000000000..3a2b0d973dc3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/daad9b2d238eb135.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_INDEX", + "index_declaration": { + "type": "Index", + "name": "idx", + "expression": { + "type": "Identifier", + "name": "vec" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/daad9b2d238eb135.sql b/tests/ast_json_fixtures/shapes/daad9b2d238eb135.sql new file mode 100644 index 000000000000..74551671bee1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/daad9b2d238eb135.sql @@ -0,0 +1 @@ +ALTER TABLE tab ADD INDEX idx(vec) TYPE minmax diff --git a/tests/ast_json_fixtures/shapes/dab06196f0964330.json b/tests/ast_json_fixtures/shapes/dab06196f0964330.json new file mode 100644 index 000000000000..e8e1e32e07b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dab06196f0964330.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tbl" + }, + "settings": { + "type": "Settings", + "changes": { + "allow_suspicious_indices": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "id2", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_ORDER_BY", + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id1" + }, + { + "type": "Identifier", + "name": "id2" + }, + { + "type": "Identifier", + "name": "id2" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dab06196f0964330.sql b/tests/ast_json_fixtures/shapes/dab06196f0964330.sql new file mode 100644 index 000000000000..297eb49b03cd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dab06196f0964330.sql @@ -0,0 +1 @@ +ALTER TABLE tbl ADD COLUMN `id2` UInt32, MODIFY ORDER BY (id1, id2, id2) SETTINGS allow_suspicious_indices = 1 diff --git a/tests/ast_json_fixtures/shapes/dacdd7d1ecd9b911.json b/tests/ast_json_fixtures/shapes/dacdd7d1ecd9b911.json new file mode 100644 index 000000000000..1fbc831ac088 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dacdd7d1ecd9b911.json @@ -0,0 +1,175 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "res", + "name": "minSampleSizeConversion", + "arguments": [ + { + "type": "Identifier", + "name": "p1" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.8 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.05 + } + ] + } + ], + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "conversion Float64 1" + }, + { + "type": "Function", + "name": "roundBankers", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "roundBankers", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "roundBankers", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "minimum_sample_size_conversion" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "roundBankers", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dacdd7d1ecd9b911.sql b/tests/ast_json_fixtures/shapes/dacdd7d1ecd9b911.sql new file mode 100644 index 000000000000..f569bf60359d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dacdd7d1ecd9b911.sql @@ -0,0 +1 @@ +WITH minSampleSizeConversion(p1, 0.01, 0.8, 0.05) AS res SELECT 'conversion Float64 1', roundBankers(res.1, 2), roundBankers(res.2, 2), roundBankers(res.3, 2) FROM minimum_sample_size_conversion ORDER BY roundBankers(res.1, 2) diff --git a/tests/ast_json_fixtures/shapes/dad062aaaba21f58.json b/tests/ast_json_fixtures/shapes/dad062aaaba21f58.json new file mode 100644 index 000000000000..8ed874892646 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dad062aaaba21f58.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "A" + }, + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/dad062aaaba21f58.sql b/tests/ast_json_fixtures/shapes/dad062aaaba21f58.sql new file mode 100644 index 000000000000..a2e376fa59b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dad062aaaba21f58.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS A diff --git a/tests/ast_json_fixtures/shapes/dae62253a4920967.json b/tests/ast_json_fixtures/shapes/dae62253a4920967.json new file mode 100644 index 000000000000..d8d6700f418f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dae62253a4920967.json @@ -0,0 +1,137 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "_row_number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "\/03727_prewhere_intermediate_columns.parquet" + } + ] + } + ] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "input_format_parquet_allow_missing_columns": "0", + "optimize_move_to_prewhere": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dae62253a4920967.sql b/tests/ast_json_fixtures/shapes/dae62253a4920967.sql new file mode 100644 index 000000000000..9dc5b2423ca2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dae62253a4920967.sql @@ -0,0 +1 @@ +SELECT DISTINCT x, _row_number FROM file(toNullable(concat(currentDatabase(), '/03727_prewhere_intermediate_columns.parquet'))) WHERE (x < 60) OR (x < 100) ORDER BY (x < 60), x SETTINGS input_format_parquet_allow_missing_columns=0, optimize_move_to_prewhere=1 diff --git a/tests/ast_json_fixtures/shapes/daf594752cc482cb.json b/tests/ast_json_fixtures/shapes/daf594752cc482cb.json new file mode 100644 index 000000000000..cf11681766b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/daf594752cc482cb.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TSVRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/daf594752cc482cb.sql b/tests/ast_json_fixtures/shapes/daf594752cc482cb.sql new file mode 100644 index 000000000000..0b628a857e40 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/daf594752cc482cb.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TSVRaw diff --git a/tests/ast_json_fixtures/shapes/db04cf44cef8bcda.json b/tests/ast_json_fixtures/shapes/db04cf44cef8bcda.json new file mode 100644 index 000000000000..26ecce2d7cfa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db04cf44cef8bcda.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_table" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/db04cf44cef8bcda.sql b/tests/ast_json_fixtures/shapes/db04cf44cef8bcda.sql new file mode 100644 index 000000000000..f3b8d41b8ad1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db04cf44cef8bcda.sql @@ -0,0 +1 @@ +SELECT _table SETTINGS enable_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/db087d63ad474adf.json b/tests/ast_json_fixtures/shapes/db087d63ad474adf.json new file mode 100644 index 000000000000..48d57550c7db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db087d63ad474adf.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "getSetting", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "max_block_size" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "3" + } + }, + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/db087d63ad474adf.sql b/tests/ast_json_fixtures/shapes/db087d63ad474adf.sql new file mode 100644 index 000000000000..0ce2efacdf04 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db087d63ad474adf.sql @@ -0,0 +1 @@ +SELECT getSetting('max_block_size') FORMAT TSV SETTINGS max_block_size = 3 diff --git a/tests/ast_json_fixtures/shapes/db118d02f2d20b78.json b/tests/ast_json_fixtures/shapes/db118d02f2d20b78.json new file mode 100644 index 000000000000..14b355c08aad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db118d02f2d20b78.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "a", + "name": "toStartOfHour", + "arguments": [ + { + "type": "Identifier", + "name": "ts" + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "v", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "agg" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ts" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2021-12-06 22:00:00" + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "toStartOfHour", + "arguments": [ + { + "type": "Identifier", + "name": "ts" + } + ] + }, + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "v" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/db118d02f2d20b78.sql b/tests/ast_json_fixtures/shapes/db118d02f2d20b78.sql new file mode 100644 index 000000000000..979768cc1ba6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db118d02f2d20b78.sql @@ -0,0 +1 @@ +WITH toStartOfHour(ts) AS a SELECT sum(value) v FROM agg WHERE ts > '2021-12-06 22:00:00' GROUP BY toStartOfHour(ts), a ORDER BY v LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/db20264e39e820f2.json b/tests/ast_json_fixtures/shapes/db20264e39e820f2.json new file mode 100644 index 000000000000..454e3164556a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db20264e39e820f2.json @@ -0,0 +1,106 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "offset", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Identifier", + "alias": "length", + "name": "number" + }, + { + "type": "Literal", + "alias": "s", + "value_type": "String", + "value": "Hello" + }, + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Function", + "name": "bin", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "length" + } + ] + }, + { + "type": "Function", + "name": "bin", + "arguments": [ + { + "type": "Function", + "name": "bitSlice", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Identifier", + "name": "offset" + }, + { + "type": "Identifier", + "name": "length" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/db20264e39e820f2.sql b/tests/ast_json_fixtures/shapes/db20264e39e820f2.sql new file mode 100644 index 000000000000..ac60de538d7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db20264e39e820f2.sql @@ -0,0 +1 @@ +select -number as offset, number as length, 'Hello' as s, subString(bin(s), offset , length), bin(bitSlice(s, offset, length)) from numbers(16) diff --git a/tests/ast_json_fixtures/shapes/db238e737d532948.json b/tests/ast_json_fixtures/shapes/db238e737d532948.json new file mode 100644 index 000000000000..056ced783881 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db238e737d532948.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/db238e737d532948.sql b/tests/ast_json_fixtures/shapes/db238e737d532948.sql new file mode 100644 index 000000000000..4bdf96993462 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db238e737d532948.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/db261d44f389c9d0.json b/tests/ast_json_fixtures/shapes/db261d44f389c9d0.json new file mode 100644 index 000000000000..d32af747b776 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db261d44f389c9d0.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "foo_00234" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/db261d44f389c9d0.sql b/tests/ast_json_fixtures/shapes/db261d44f389c9d0.sql new file mode 100644 index 000000000000..c2bdb19f2be2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db261d44f389c9d0.sql @@ -0,0 +1 @@ +CREATE TABLE IF NOT EXISTS foo_00234(id UInt64) Engine=MergeTree ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/db67351cadf80826.json b/tests/ast_json_fixtures/shapes/db67351cadf80826.json new file mode 100644 index 000000000000..a85107db11da --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db67351cadf80826.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "S", + "value_type": "String", + "value": "2020-02-05 14:34:12.333" + }, + { + "type": "Function", + "alias": "DT64", + "name": "toDateTime64", + "arguments": [ + { + "type": "Identifier", + "name": "S" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "DT64" + }, + { + "type": "Identifier", + "name": "S" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/db67351cadf80826.sql b/tests/ast_json_fixtures/shapes/db67351cadf80826.sql new file mode 100644 index 000000000000..cbafe8f68edf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db67351cadf80826.sql @@ -0,0 +1 @@ +WITH '2020-02-05 14:34:12.333' as S, toDateTime64(S, 3) as DT64 SELECT * WHERE DT64 < S diff --git a/tests/ast_json_fixtures/shapes/db6cd8d75ad2f0b1.json b/tests/ast_json_fixtures/shapes/db6cd8d75ad2f0b1.json new file mode 100644 index 000000000000..529cb1b523af --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db6cd8d75ad2f0b1.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["无名氏 "] + } +} diff --git a/tests/ast_json_fixtures/shapes/db6cd8d75ad2f0b1.sql b/tests/ast_json_fixtures/shapes/db6cd8d75ad2f0b1.sql new file mode 100644 index 000000000000..7734eb0b274d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db6cd8d75ad2f0b1.sql @@ -0,0 +1 @@ +drop user "无名氏 " diff --git a/tests/ast_json_fixtures/shapes/db74a259e11540d7.json b/tests/ast_json_fixtures/shapes/db74a259e11540d7.json new file mode 100644 index 000000000000..15efd30b09d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db74a259e11540d7.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ], + "select": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/db74a259e11540d7.sql b/tests/ast_json_fixtures/shapes/db74a259e11540d7.sql new file mode 100644 index 000000000000..7f4f2d5c28ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db74a259e11540d7.sql @@ -0,0 +1 @@ +WITH 1 AS a SELECT (SELECT a) diff --git a/tests/ast_json_fixtures/shapes/db783f37e5b64ff6.json b/tests/ast_json_fixtures/shapes/db783f37e5b64ff6.json new file mode 100644 index 000000000000..c6fc54370c7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db783f37e5b64ff6.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "strictness": "ANY", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "alias277.number", + "name_parts": ["alias277", "number"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "alias277", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "102400" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "join_algorithm": "parallel_hash" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/db783f37e5b64ff6.sql b/tests/ast_json_fixtures/shapes/db783f37e5b64ff6.sql new file mode 100644 index 000000000000..442efa509430 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db783f37e5b64ff6.sql @@ -0,0 +1,8 @@ +SELECT + number, + number +FROM system.numbers +ANY INNER JOIN system.numbers AS alias277 ON number = alias277.number +LIMIT 102400 +FORMAT `Null` +SETTINGS join_algorithm = 'parallel_hash' diff --git a/tests/ast_json_fixtures/shapes/db8c89c71dfc130b.json b/tests/ast_json_fixtures/shapes/db8c89c71dfc130b.json new file mode 100644 index 000000000000..2b253e6f47ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db8c89c71dfc130b.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_alter_if_exists" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "column": { + "type": "Identifier", + "name": "c0" + } + }, + { + "type": "AlterCommand", + "command_type": "DROP_COLUMN", + "if_exists": true, + "column": { + "type": "Identifier", + "name": "c0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/db8c89c71dfc130b.sql b/tests/ast_json_fixtures/shapes/db8c89c71dfc130b.sql new file mode 100644 index 000000000000..7bc1e07e3942 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/db8c89c71dfc130b.sql @@ -0,0 +1 @@ +ALTER TABLE test_alter_if_exists DROP COLUMN c0, DROP COLUMN IF EXISTS c0 diff --git a/tests/ast_json_fixtures/shapes/dba4bd84b0d8205a.json b/tests/ast_json_fixtures/shapes/dba4bd84b0d8205a.json new file mode 100644 index 000000000000..5f2cf63582f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dba4bd84b0d8205a.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "prd_bid_events_simple_no_partition" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "date", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "2025-11-01" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "type" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "ad_request" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dba4bd84b0d8205a.sql b/tests/ast_json_fixtures/shapes/dba4bd84b0d8205a.sql new file mode 100644 index 000000000000..5a8f502e8603 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dba4bd84b0d8205a.sql @@ -0,0 +1,7 @@ +SELECT + type, + count() +FROM prd_bid_events_simple_no_partition +WHERE date(timestamp) = '2025-11-01' +GROUP BY type +HAVING type = 'ad_request' diff --git a/tests/ast_json_fixtures/shapes/dbdc66026bdf2cd2.json b/tests/ast_json_fixtures/shapes/dbdc66026bdf2cd2.json new file mode 100644 index 000000000000..15f341d72554 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dbdc66026bdf2cd2.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "DeleteQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dbdc66026bdf2cd2.sql b/tests/ast_json_fixtures/shapes/dbdc66026bdf2cd2.sql new file mode 100644 index 000000000000..1bdce2156b67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dbdc66026bdf2cd2.sql @@ -0,0 +1 @@ +DELETE FROM t0 WHERE c0 = 1 diff --git a/tests/ast_json_fixtures/shapes/dbdc7ab42514acc1.json b/tests/ast_json_fixtures/shapes/dbdc7ab42514acc1.json new file mode 100644 index 000000000000..c2f0627a74cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dbdc7ab42514acc1.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r7_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "writability": "WRITABLE" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dbdc7ab42514acc1.sql b/tests/ast_json_fixtures/shapes/dbdc7ab42514acc1.sql new file mode 100644 index 000000000000..6aa9a4f1cb1f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dbdc7ab42514acc1.sql @@ -0,0 +1 @@ +CREATE ROLE r7_01293 SETTINGS max_memory_usage WRITABLE diff --git a/tests/ast_json_fixtures/shapes/dbdfe79aea1c277f.json b/tests/ast_json_fixtures/shapes/dbdfe79aea1c277f.json new file mode 100644 index 000000000000..11589d4804e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dbdfe79aea1c277f.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["DROP"], + "database": "sqllt", + "table": "view" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["sqllt_user"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dbdfe79aea1c277f.sql b/tests/ast_json_fixtures/shapes/dbdfe79aea1c277f.sql new file mode 100644 index 000000000000..d3776f55cf06 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dbdfe79aea1c277f.sql @@ -0,0 +1 @@ +GRANT DROP ON sqllt.view TO sqllt_user diff --git a/tests/ast_json_fixtures/shapes/dbe48f7216a34109.json b/tests/ast_json_fixtures/shapes/dbe48f7216a34109.json new file mode 100644 index 000000000000..97125e731499 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dbe48f7216a34109.json @@ -0,0 +1,287 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "e1", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2022-01-30" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Date" + } + ] + }, + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "e2", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2022-01-30" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Date" + } + ] + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "e3", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2022-01-30" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Date" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "e4", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2022-01-30" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Date" + } + ] + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "toIntervalMonth", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e1" + }, + { + "type": "Identifier", + "name": "e2" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e2" + }, + { + "type": "Identifier", + "name": "e3" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e3" + }, + { + "type": "Identifier", + "name": "e4" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "e1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dbe48f7216a34109.sql b/tests/ast_json_fixtures/shapes/dbe48f7216a34109.sql new file mode 100644 index 000000000000..39cefab199c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dbe48f7216a34109.sql @@ -0,0 +1,5 @@ +WITH '2022-01-30'::Date + INTERVAL 1 DAY + INTERVAL 1 MONTH AS e1, + '2022-01-30'::Date + (INTERVAL 1 DAY + INTERVAL 1 MONTH) AS e2, + '2022-01-30'::Date + (INTERVAL 1 DAY, INTERVAL 1 MONTH) AS e3, + '2022-01-30'::Date + INTERVAL '1 DAY 1 MONTH' AS e4 +SELECT e1 == e2 AND e2 == e3 AND e3 == e4, e1 diff --git a/tests/ast_json_fixtures/shapes/dbefea5828c7659f.json b/tests/ast_json_fixtures/shapes/dbefea5828c7659f.json new file mode 100644 index 000000000000..69d7d4ea4942 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dbefea5828c7659f.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "SYNC REPLICA", + "table": { + "type": "Identifier", + "name": "rmt1" + }, + "sync_replica_mode": "STRICT" + } +} diff --git a/tests/ast_json_fixtures/shapes/dbefea5828c7659f.sql b/tests/ast_json_fixtures/shapes/dbefea5828c7659f.sql new file mode 100644 index 000000000000..a8efec140bc2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dbefea5828c7659f.sql @@ -0,0 +1 @@ +system sync replica rmt1 strict diff --git a/tests/ast_json_fixtures/shapes/dc059f438d23ac65.json b/tests/ast_json_fixtures/shapes/dc059f438d23ac65.json new file mode 100644 index 000000000000..554eccf0d3eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc059f438d23ac65.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SYSTEM", + "system_type": "CLEAR FORMAT SCHEMA CACHE" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dc059f438d23ac65.sql b/tests/ast_json_fixtures/shapes/dc059f438d23ac65.sql new file mode 100644 index 000000000000..854d34776456 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc059f438d23ac65.sql @@ -0,0 +1 @@ +EXPLAIN SYNTAX SYSTEM CLEAR FORMAT SCHEMA CACHE diff --git a/tests/ast_json_fixtures/shapes/dc197b032a711bc3.json b/tests/ast_json_fixtures/shapes/dc197b032a711bc3.json new file mode 100644 index 000000000000..2199fd06fd5d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc197b032a711bc3.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "having": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dc197b032a711bc3.sql b/tests/ast_json_fixtures/shapes/dc197b032a711bc3.sql new file mode 100644 index 000000000000..3b53df78e1c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc197b032a711bc3.sql @@ -0,0 +1 @@ +SELECT 'x' FROM numbers(2) GROUP BY number WITH TOTALS HAVING count(number)<0 diff --git a/tests/ast_json_fixtures/shapes/dc368bb3c9c628ea.json b/tests/ast_json_fixtures/shapes/dc368bb3c9c628ea.json new file mode 100644 index 000000000000..ac3e4796ae66 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc368bb3c9c628ea.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "STOP REPLICATION QUEUES", + "table": { + "type": "Identifier", + "name": "checksums_r2" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dc368bb3c9c628ea.sql b/tests/ast_json_fixtures/shapes/dc368bb3c9c628ea.sql new file mode 100644 index 000000000000..49ba3a9bdef8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc368bb3c9c628ea.sql @@ -0,0 +1 @@ +SYSTEM STOP REPLICATION QUEUES checksums_r2 diff --git a/tests/ast_json_fixtures/shapes/dc3cab89e0293cc8.json b/tests/ast_json_fixtures/shapes/dc3cab89e0293cc8.json new file mode 100644 index 000000000000..4852d300ebf7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc3cab89e0293cc8.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "unknown_function" + } +} diff --git a/tests/ast_json_fixtures/shapes/dc3cab89e0293cc8.sql b/tests/ast_json_fixtures/shapes/dc3cab89e0293cc8.sql new file mode 100644 index 000000000000..7369e0656099 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc3cab89e0293cc8.sql @@ -0,0 +1 @@ +DROP FUNCTION unknown_function diff --git a/tests/ast_json_fixtures/shapes/dc4ff41457c22159.json b/tests/ast_json_fixtures/shapes/dc4ff41457c22159.json new file mode 100644 index 000000000000..0489f3d5060a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc4ff41457c22159.json @@ -0,0 +1,437 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "44" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "pk_block_union" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "44" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "DESC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dc4ff41457c22159.sql b/tests/ast_json_fixtures/shapes/dc4ff41457c22159.sql new file mode 100644 index 000000000000..8ef13e2585a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc4ff41457c22159.sql @@ -0,0 +1 @@ +SELECT cityHash64(1, (x = 3) AND (y = 44), '0', 1, 1, 1, 1, 1, 1, 1, toLowCardinality(1), 1, 1, 1, 1, 1, toNullable(toUInt256(1)), 1, 1, 1, toUInt128(1), 1, toLowCardinality(toUInt128(1)), 1, 1), cityHash64('0', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, toUInt128(1), 1, 1, toLowCardinality(1), 1, 1, toLowCardinality(1), toLowCardinality(1), 1, 1, 1, 1, 1), * FROM pk_block_union WHERE (x = 3) AND (y = 44) ORDER BY ALL DESC diff --git a/tests/ast_json_fixtures/shapes/dc6dde77049ad3d1.json b/tests/ast_json_fixtures/shapes/dc6dde77049ad3d1.json new file mode 100644 index 000000000000..e9566c2092ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc6dde77049ad3d1.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "hosts": { + "any_host": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dc6dde77049ad3d1.sql b/tests/ast_json_fixtures/shapes/dc6dde77049ad3d1.sql new file mode 100644 index 000000000000..8797c2a33c70 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc6dde77049ad3d1.sql @@ -0,0 +1 @@ +CREATE USER u1_01292 HOST ANY diff --git a/tests/ast_json_fixtures/shapes/dc893a20edf6526f.json b/tests/ast_json_fixtures/shapes/dc893a20edf6526f.json new file mode 100644 index 000000000000..339a18503c63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc893a20edf6526f.json @@ -0,0 +1,116 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "is_materialized_view": true, + "uuid": "e15f3ab5-6cae-4df3-b879-f40deafd82c2", + "table": { + "type": "Identifier", + "name": "mv" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "n2", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Function", + "alias": "n2", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "src" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "n" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dc893a20edf6526f.sql b/tests/ast_json_fixtures/shapes/dc893a20edf6526f.sql new file mode 100644 index 000000000000..d4e2146a0e0a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dc893a20edf6526f.sql @@ -0,0 +1 @@ +ATTACH MATERIALIZED VIEW mv UUID 'e15f3ab5-6cae-4df3-b879-f40deafd82c2' (n Int32, n2 Int64) ENGINE = MergeTree PARTITION BY n % 10 ORDER BY n AS SELECT n, n * n AS n2 FROM src diff --git a/tests/ast_json_fixtures/shapes/dca613039ae70e4f.json b/tests/ast_json_fixtures/shapes/dca613039ae70e4f.json new file mode 100644 index 000000000000..03cbf9529fb6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dca613039ae70e4f.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "uid" + }, + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "age" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "name": "arrayUniq", + "arguments": [ + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Identifier", + "name": "ts" + } + ] + } + ] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "age" + } + ] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "ts" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "users" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "ExpressionList" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dca613039ae70e4f.sql b/tests/ast_json_fixtures/shapes/dca613039ae70e4f.sql new file mode 100644 index 000000000000..05e3e7a80514 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dca613039ae70e4f.sql @@ -0,0 +1,14 @@ +select + uid, name + ,sum(age) + ,count() + ,arrayUniq(groupArray(ts)) + ,max(age) + ,max(ts) +from users +group by grouping sets +( + (*), + () +) +ORDER BY ALL diff --git a/tests/ast_json_fixtures/shapes/dcb61dea03d1a109.json b/tests/ast_json_fixtures/shapes/dcb61dea03d1a109.json new file mode 100644 index 000000000000..f1d14c445b99 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dcb61dea03d1a109.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q13_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "EXECUTION_TIME": "12000000000000000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dcb61dea03d1a109.sql b/tests/ast_json_fixtures/shapes/dcb61dea03d1a109.sql new file mode 100644 index 000000000000..88c73e0f7a10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dcb61dea03d1a109.sql @@ -0,0 +1 @@ +CREATE QUOTA q13_01297 FOR INTERVAL 1 MINUTE MAX execution_time = '12G' diff --git a/tests/ast_json_fixtures/shapes/dcdb6de0c407c12a.json b/tests/ast_json_fixtures/shapes/dcdb6de0c407c12a.json new file mode 100644 index 000000000000..4d51049ff749 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dcdb6de0c407c12a.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "named_tuples" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "File", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "JSONEachRow" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "output_format_json_named_tuples_as_objects": "1" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "c", + "name": "CAST", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple(a int, b int)" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dcdb6de0c407c12a.sql b/tests/ast_json_fixtures/shapes/dcdb6de0c407c12a.sql new file mode 100644 index 000000000000..1c03b9e5d784 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dcdb6de0c407c12a.sql @@ -0,0 +1,4 @@ +create table named_tuples engine File(JSONEachRow) + settings output_format_json_named_tuples_as_objects = 1 + as select cast(tuple(number, number * 2), 'Tuple(a int, b int)') c + from numbers(3) diff --git a/tests/ast_json_fixtures/shapes/dce4ba3508720ff1.json b/tests/ast_json_fixtures/shapes/dce4ba3508720ff1.json new file mode 100644 index 000000000000..f9fcea0c603f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dce4ba3508720ff1.json @@ -0,0 +1,123 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "hex", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "uniqState", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "x", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dce4ba3508720ff1.sql b/tests/ast_json_fixtures/shapes/dce4ba3508720ff1.sql new file mode 100644 index 000000000000..cc611ee7735d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dce4ba3508720ff1.sql @@ -0,0 +1 @@ +SELECT DISTINCT hex(toString(uniqState(x))) FROM (SELECT materialize(1) AS k, toNullable(1) AS x FROM numbers(1)) GROUP BY k WITH TOTALS ORDER BY k diff --git a/tests/ast_json_fixtures/shapes/dcef91983225e4cc.json b/tests/ast_json_fixtures/shapes/dcef91983225e4cc.json new file mode 100644 index 000000000000..8f53a1af33a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dcef91983225e4cc.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "parent_window_name": "w" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dcef91983225e4cc.sql b/tests/ast_json_fixtures/shapes/dcef91983225e4cc.sql new file mode 100644 index 000000000000..f7c1adb8f882 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dcef91983225e4cc.sql @@ -0,0 +1 @@ +select count() over (w) from numbers(1) window w as () diff --git a/tests/ast_json_fixtures/shapes/dcfe1e0d6d89de1c.json b/tests/ast_json_fixtures/shapes/dcfe1e0d6d89de1c.json new file mode 100644 index 000000000000..36b335af3665 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dcfe1e0d6d89de1c.json @@ -0,0 +1,111 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t" + } + }, + { + "type": "Identifier", + "name": "s.a", + "name_parts": ["s", "a"] + }, + { + "type": "Identifier", + "name": "s.b", + "name_parts": ["s", "b"] + }, + { + "type": "Identifier", + "name": "s.c", + "name_parts": ["s", "c"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.a", + "name_parts": ["s", "a"] + }, + { + "type": "Identifier", + "name": "t.a", + "name_parts": ["t", "a"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.b", + "name_parts": ["s", "b"] + }, + { + "type": "Identifier", + "name": "t.b", + "name_parts": ["t", "b"] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "s" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "join_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dcfe1e0d6d89de1c.sql b/tests/ast_json_fixtures/shapes/dcfe1e0d6d89de1c.sql new file mode 100644 index 000000000000..b7671cf0e3ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dcfe1e0d6d89de1c.sql @@ -0,0 +1 @@ +select t.*, s.a, s.b, s.c from t left join s on (s.a = t.a and s.b = t.b) SETTINGS join_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/dd06a79d19490c04.json b/tests/ast_json_fixtures/shapes/dd06a79d19490c04.json new file mode 100644 index 000000000000..cad365d4126b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd06a79d19490c04.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "source" + }, + "cluster": "test_shard_localhost", + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_SETTING", + "settings_changes": { + "type": "Settings", + "changes": { + "ttl_only_drop_parts": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dd06a79d19490c04.sql b/tests/ast_json_fixtures/shapes/dd06a79d19490c04.sql new file mode 100644 index 000000000000..5ebfd752a067 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd06a79d19490c04.sql @@ -0,0 +1 @@ +alter table source on cluster test_shard_localhost MODIFY SETTING ttl_only_drop_parts = 1 diff --git a/tests/ast_json_fixtures/shapes/dd15de97acc855b5.json b/tests/ast_json_fixtures/shapes/dd15de97acc855b5.json new file mode 100644 index 000000000000..a3a217fecd48 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd15de97acc855b5.json @@ -0,0 +1,93 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "m" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "key" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "b" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ID" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dd15de97acc855b5.sql b/tests/ast_json_fixtures/shapes/dd15de97acc855b5.sql new file mode 100644 index 000000000000..e43e7f786d78 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd15de97acc855b5.sql @@ -0,0 +1 @@ +SELECT * FROM m INNER JOIN b USING(key) WHERE ID = 1 HAVING ID = 1 ORDER BY ID diff --git a/tests/ast_json_fixtures/shapes/dd246440444eae29.json b/tests/ast_json_fixtures/shapes/dd246440444eae29.json new file mode 100644 index 000000000000..13660341e1f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd246440444eae29.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "alias": "category", + "name": "tupleElement", + "arguments": [ + { + "type": "Identifier", + "name": "data" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_nullable_tuples" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "arguments": [ + { + "type": "Identifier", + "name": "data" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "category" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dd246440444eae29.sql b/tests/ast_json_fixtures/shapes/dd246440444eae29.sql new file mode 100644 index 000000000000..c93ddad5b83b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd246440444eae29.sql @@ -0,0 +1,4 @@ +SELECT DISTINCT tupleElement(data, 2) as category +FROM test_nullable_tuples +WHERE tupleElement(data, 2) IS NOT NULL +ORDER BY category diff --git a/tests/ast_json_fixtures/shapes/dd3005646aa7ce76.json b/tests/ast_json_fixtures/shapes/dd3005646aa7ce76.json new file mode 100644 index 000000000000..dc3cdf30400d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd3005646aa7ce76.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "s3", + "arguments": [ + { + "type": "Identifier", + "name": "s3_conn" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "filename" + }, + { + "type": "Literal", + "value_type": "String", + "value": "::03215_archive.csv" + } + ] + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dd3005646aa7ce76.sql b/tests/ast_json_fixtures/shapes/dd3005646aa7ce76.sql new file mode 100644 index 000000000000..3f93f49585c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd3005646aa7ce76.sql @@ -0,0 +1 @@ +INSERT INTO FUNCTION s3(s3_conn, filename='::03215_archive.csv') SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/dd540031740cdd86.json b/tests/ast_json_fixtures/shapes/dd540031740cdd86.json new file mode 100644 index 000000000000..9ac68a2fabab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd540031740cdd86.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q3_01297"], + "key_type": "NONE", + "limits": [ + { + "duration_sec": "3600", + "drop": true + } + ], + "roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dd540031740cdd86.sql b/tests/ast_json_fixtures/shapes/dd540031740cdd86.sql new file mode 100644 index 000000000000..5df76b27e836 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd540031740cdd86.sql @@ -0,0 +1 @@ +CREATE QUOTA q3_01297 FOR INTERVAL 1 HOUR NO LIMITS NOT KEYED TO NONE diff --git a/tests/ast_json_fixtures/shapes/dd7694876128c1e1.json b/tests/ast_json_fixtures/shapes/dd7694876128c1e1.json new file mode 100644 index 000000000000..c47b66fb34e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd7694876128c1e1.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "current_database", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "03630_parquet_bool_bug.parquet" + } + ] + }, + { + "type": "Identifier", + "name": "Parquet" + }, + { + "type": "Literal", + "value_type": "String", + "value": "tags Array(Bool)" + } + ] + }, + "format": "Values", + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dd7694876128c1e1.sql b/tests/ast_json_fixtures/shapes/dd7694876128c1e1.sql new file mode 100644 index 000000000000..1e399d130ab9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd7694876128c1e1.sql @@ -0,0 +1 @@ +insert into function file(current_database() ||'03630_parquet_bool_bug.parquet', Parquet, 'tags Array(Bool)') settings engine_file_truncate_on_insert=1 values ([false,false,false,false,false,false,false,false]), ([true,true,true,true,true,true,true,true]) diff --git a/tests/ast_json_fixtures/shapes/dd899af4a1f111dc.json b/tests/ast_json_fixtures/shapes/dd899af4a1f111dc.json new file mode 100644 index 000000000000..1895e0b6e7ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd899af4a1f111dc.json @@ -0,0 +1,138 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table_for_rename" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "date", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "value1", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "value2", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "value3", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "constraints": [ + { + "type": "Constraint", + "name": "cs_value1", + "constraint_type": "CHECK", + "expression": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toInt64", + "arguments": [ + { + "type": "Identifier", + "name": "value1" + } + ] + }, + { + "type": "Function", + "name": "toInt64", + "arguments": [ + { + "type": "Identifier", + "name": "value2" + } + ] + } + ] + } + }, + { + "type": "Constraint", + "name": "cs_value2", + "constraint_type": "CHECK", + "expression": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toInt64", + "arguments": [ + { + "type": "Identifier", + "name": "value2" + } + ] + }, + { + "type": "Function", + "name": "toInt64", + "arguments": [ + { + "type": "Identifier", + "name": "value3" + } + ] + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "date" + }, + "order_by": { + "type": "Identifier", + "name": "key" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dd899af4a1f111dc.sql b/tests/ast_json_fixtures/shapes/dd899af4a1f111dc.sql new file mode 100644 index 000000000000..1c36338fb784 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd899af4a1f111dc.sql @@ -0,0 +1,13 @@ +CREATE TABLE table_for_rename +( + date Date, + key UInt64, + value1 String, + value2 String, + value3 String, + CONSTRAINT cs_value1 CHECK toInt64(value1) < toInt64(value2), + CONSTRAINT cs_value2 CHECK toInt64(value2) < toInt64(value3) +) +ENGINE = MergeTree() +PARTITION BY date +ORDER BY key diff --git a/tests/ast_json_fixtures/shapes/dd8b8b0d35e97682.json b/tests/ast_json_fixtures/shapes/dd8b8b0d35e97682.json new file mode 100644 index 000000000000..7c9956e1d144 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd8b8b0d35e97682.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dd8b8b0d35e97682.sql b/tests/ast_json_fixtures/shapes/dd8b8b0d35e97682.sql new file mode 100644 index 000000000000..20185eaf1a56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dd8b8b0d35e97682.sql @@ -0,0 +1 @@ +SELECT count() FROM t diff --git a/tests/ast_json_fixtures/shapes/ddabed284c504f61.json b/tests/ast_json_fixtures/shapes/ddabed284c504f61.json new file mode 100644 index 000000000000..2a1bcdff3444 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ddabed284c504f61.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "test3" + }, + "as_table": "test" + } +} diff --git a/tests/ast_json_fixtures/shapes/ddabed284c504f61.sql b/tests/ast_json_fixtures/shapes/ddabed284c504f61.sql new file mode 100644 index 000000000000..3be62584dd38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ddabed284c504f61.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE test3 AS test diff --git a/tests/ast_json_fixtures/shapes/ddbb0bc983b422e8.json b/tests/ast_json_fixtures/shapes/ddbb0bc983b422e8.json new file mode 100644 index 000000000000..450bbc05c322 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ddbb0bc983b422e8.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "test_repl" + }, + "cluster": "test_shard_localhost", + "if_exists": true, + "sync": true + } +} diff --git a/tests/ast_json_fixtures/shapes/ddbb0bc983b422e8.sql b/tests/ast_json_fixtures/shapes/ddbb0bc983b422e8.sql new file mode 100644 index 000000000000..353fd3da801d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ddbb0bc983b422e8.sql @@ -0,0 +1 @@ +DROP TABLE IF EXISTS test_repl ON CLUSTER test_shard_localhost NO DELAY diff --git a/tests/ast_json_fixtures/shapes/ddbc06c3a11b0f9e.json b/tests/ast_json_fixtures/shapes/ddbc06c3a11b0f9e.json new file mode 100644 index 000000000000..86d16a7e63d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ddbc06c3a11b0f9e.json @@ -0,0 +1,335 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "String", + "value": "25.6" + }, + { + "value_type": "String", + "value": "-0.02" + }, + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "String", + "value": "10485.76" + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "-922337203.6854775808" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1023" + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": null + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "String", + "value": "-1" + }, + { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65536" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/ddbc06c3a11b0f9e.sql b/tests/ast_json_fixtures/shapes/ddbc06c3a11b0f9e.sql new file mode 100644 index 000000000000..b3b5b3bcd91f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ddbc06c3a11b0f9e.sql @@ -0,0 +1 @@ +SELECT [NULL, '25.6', '-0.02', NULL], [NULL], 1024, [NULL, '10485.76', NULL, NULL], [NULL, '-922337203.6854775808', toNullable(NULL)], [NULL] FROM (SELECT [multiIf((number % 1023) = -inf, toString(number), NULL)], NULL, '-1', multiIf((number % NULL) = NULL, toString(number), ''), [NULL, NULL], multiIf((number % NULL) = 65536, toString(number), '') AS s FROM system.numbers) LIMIT 1024 format Null diff --git a/tests/ast_json_fixtures/shapes/dddfdd948f24eaed.json b/tests/ast_json_fixtures/shapes/dddfdd948f24eaed.json new file mode 100644 index 000000000000..7f1c627d41b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dddfdd948f24eaed.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02148_test_function", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/dddfdd948f24eaed.sql b/tests/ast_json_fixtures/shapes/dddfdd948f24eaed.sql new file mode 100644 index 000000000000..3ccad8d15bf0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dddfdd948f24eaed.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02148_test_function diff --git a/tests/ast_json_fixtures/shapes/dde1e8b933701c8a.json b/tests/ast_json_fixtures/shapes/dde1e8b933701c8a.json new file mode 100644 index 000000000000..9a44b7383d9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dde1e8b933701c8a.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_display_footer_column_names": "0" + } + }, + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/dde1e8b933701c8a.sql b/tests/ast_json_fixtures/shapes/dde1e8b933701c8a.sql new file mode 100644 index 000000000000..7c95cb40cc17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dde1e8b933701c8a.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettyCompact SETTINGS output_format_pretty_display_footer_column_names=0 diff --git a/tests/ast_json_fixtures/shapes/de02102857c0f9a5.json b/tests/ast_json_fixtures/shapes/de02102857c0f9a5.json new file mode 100644 index 000000000000..41066d716b86 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de02102857c0f9a5.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "mt" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "UPDATE", + "partition": { + "type": "Partition_ID", + "id": { + "type": "Literal", + "value_type": "String", + "value": "1" + } + }, + "predicate": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "assignments": [ + { + "type": "Assignment", + "column": "n", + "expression": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Function", + "name": "notIn", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "m" + } + ] + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/de02102857c0f9a5.sql b/tests/ast_json_fixtures/shapes/de02102857c0f9a5.sql new file mode 100644 index 000000000000..a8ac107d1ef0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de02102857c0f9a5.sql @@ -0,0 +1 @@ +alter table mt update n = n + (n not in m) in partition id '1' where 1 settings mutations_sync=1 diff --git a/tests/ast_json_fixtures/shapes/de0c70f1172957d4.json b/tests/ast_json_fixtures/shapes/de0c70f1172957d4.json new file mode 100644 index 000000000000..36a234952f7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de0c70f1172957d4.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "a" + }, + "settings": { + "type": "Settings", + "changes": { + "alter_sync": "2", + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_INDEX", + "if_exists": true, + "index": { + "type": "Identifier", + "name": "some_index" + } + }, + { + "type": "AlterCommand", + "command_type": "MODIFY_COLUMN", + "column_declaration": { + "type": "ColumnDeclaration", + "name": "y" + }, + "remove_property": "MATERIALIZED" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/de0c70f1172957d4.sql b/tests/ast_json_fixtures/shapes/de0c70f1172957d4.sql new file mode 100644 index 000000000000..014b6b0eed2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de0c70f1172957d4.sql @@ -0,0 +1,4 @@ +ALTER TABLE a + DROP INDEX IF EXISTS some_index, + MODIFY COLUMN y REMOVE MATERIALIZED +SETTINGS alter_sync = 2, mutations_sync = 2 diff --git a/tests/ast_json_fixtures/shapes/de15738f4a88ea9f.json b/tests/ast_json_fixtures/shapes/de15738f4a88ea9f.json new file mode 100644 index 000000000000..b7150af62f50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de15738f4a88ea9f.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tp" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PROJECTION", + "projection": { + "type": "Identifier", + "name": "p" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/de15738f4a88ea9f.sql b/tests/ast_json_fixtures/shapes/de15738f4a88ea9f.sql new file mode 100644 index 000000000000..c33dc9301851 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de15738f4a88ea9f.sql @@ -0,0 +1 @@ +alter table tp drop projection p diff --git a/tests/ast_json_fixtures/shapes/de180d9c53ff017e.json b/tests/ast_json_fixtures/shapes/de180d9c53ff017e.json new file mode 100644 index 000000000000..82bfaade355f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de180d9c53ff017e.json @@ -0,0 +1,239 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "0" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Identifier", + "name": "js2.s", + "name_parts": ["js2", "s"] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "js1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "k", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "js1.k", + "name_parts": ["js1", "k"] + }, + { + "type": "Identifier", + "name": "js2.k", + "name_parts": ["js2", "k"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "js2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483647" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "-0.0000000001" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + }, + { + "type": "Function", + "alias": "s", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "Float64", + "value": null + }, + "direction": "DESC", + "nulls_first": true + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "js1.k", + "name_parts": ["js1", "k"] + }, + "direction": "ASC", + "nulls_first": false + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "js2.k", + "name_parts": ["js2", "k"] + }, + "direction": "ASC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/de180d9c53ff017e.sql b/tests/ast_json_fixtures/shapes/de180d9c53ff017e.sql new file mode 100644 index 000000000000..7c7bfd2df884 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de180d9c53ff017e.sql @@ -0,0 +1,22 @@ +SELECT + '0', + toTypeName(materialize(js2.s)) +FROM +( + SELECT number AS k + FROM numbers(100) +) AS js1 +FULL OUTER JOIN +( + SELECT + toLowCardinality(2147483647 + 256) AS k, + '-0.0000000001', + 1024, + toString(number + 10) AS s + FROM numbers(1024) +) AS js2 ON js1.k = js2.k +ORDER BY + inf DESC NULLS FIRST, + js1.k ASC NULLS LAST, + js2.k ASC +FORMAT `Null` diff --git a/tests/ast_json_fixtures/shapes/de21d2fce2afb28a.json b/tests/ast_json_fixtures/shapes/de21d2fce2afb28a.json new file mode 100644 index 000000000000..653e481170dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de21d2fce2afb28a.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDateTime64", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 123.345 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "ABCD" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/de21d2fce2afb28a.sql b/tests/ast_json_fixtures/shapes/de21d2fce2afb28a.sql new file mode 100644 index 000000000000..961d530f9202 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de21d2fce2afb28a.sql @@ -0,0 +1 @@ +SELECT * WHERE toDateTime64(123.345, 3) == 'ABCD' diff --git a/tests/ast_json_fixtures/shapes/de384f27bfe839c8.json b/tests/ast_json_fixtures/shapes/de384f27bfe839c8.json new file mode 100644 index 000000000000..3cd22d4e0e14 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de384f27bfe839c8.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q13_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/de384f27bfe839c8.sql b/tests/ast_json_fixtures/shapes/de384f27bfe839c8.sql new file mode 100644 index 000000000000..16cae63594db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de384f27bfe839c8.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q13_01297 diff --git a/tests/ast_json_fixtures/shapes/de38dcf5ecaed14d.json b/tests/ast_json_fixtures/shapes/de38dcf5ecaed14d.json new file mode 100644 index 000000000000..6b60603eca3a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de38dcf5ecaed14d.json @@ -0,0 +1,195 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Function", + "alias": "qt", + "name": "quantileTiming", + "arguments": [ + { + "type": "Identifier", + "name": "SendTiming" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + } + ] + }, + { + "type": "Function", + "alias": "qe", + "name": "least", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "30000" + }, + { + "type": "Function", + "name": "quantileExact", + "arguments": [ + { + "type": "Identifier", + "name": "SendTiming" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + } + ] + } + ] + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "alias": "rounded_diff", + "name": "round", + "arguments": [ + { + "type": "Function", + "alias": "diff", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "abs", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "qt" + }, + { + "type": "Identifier", + "name": "qe" + } + ] + } + ] + }, + { + "type": "Function", + "name": "greatest", + "arguments": [ + { + "type": "Identifier", + "name": "qt" + }, + { + "type": "Identifier", + "name": "qe" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "SendTiming" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "CounterID" + } + ], + "having": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "diff" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "diff" + }, + "direction": "DESC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/de38dcf5ecaed14d.sql b/tests/ast_json_fixtures/shapes/de38dcf5ecaed14d.sql new file mode 100644 index 000000000000..9db136299a0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de38dcf5ecaed14d.sql @@ -0,0 +1 @@ +SELECT CounterID, quantileTiming(0.5)(SendTiming) AS qt, least(30000, quantileExact(0.5)(SendTiming)) AS qe, count() AS c, round(abs(qt - qe) / greatest(qt, qe) AS diff, 3) AS rounded_diff FROM test.hits WHERE SendTiming != -1 GROUP BY CounterID HAVING diff != 0 ORDER BY diff DESC SETTINGS optimize_aggregation_in_order = 1 diff --git a/tests/ast_json_fixtures/shapes/de553a9faa0a58a6.json b/tests/ast_json_fixtures/shapes/de553a9faa0a58a6.json new file mode 100644 index 000000000000..0d78df5aacc6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de553a9faa0a58a6.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "START MOVES", + "database": { + "type": "Identifier", + "name": "sqllt" + }, + "table": { + "type": "Identifier", + "name": "table" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/de553a9faa0a58a6.sql b/tests/ast_json_fixtures/shapes/de553a9faa0a58a6.sql new file mode 100644 index 000000000000..2bf6f83ffa63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de553a9faa0a58a6.sql @@ -0,0 +1 @@ +SYSTEM START MOVES sqllt.table diff --git a/tests/ast_json_fixtures/shapes/de6733e68b0916c3.json b/tests/ast_json_fixtures/shapes/de6733e68b0916c3.json new file mode 100644 index 000000000000..4d1238fc23f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de6733e68b0916c3.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "dictionary": true, + "elements": [ + { + "from_database": "test_01191", + "from_table": "dict", + "to_database": "dummy_db", + "to_table": "dict1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/de6733e68b0916c3.sql b/tests/ast_json_fixtures/shapes/de6733e68b0916c3.sql new file mode 100644 index 000000000000..1c27a1d0aa87 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de6733e68b0916c3.sql @@ -0,0 +1 @@ +RENAME DICTIONARY test_01191.dict TO dummy_db.dict1 diff --git a/tests/ast_json_fixtures/shapes/de7a8fb3b4c19fb8.json b/tests/ast_json_fixtures/shapes/de7a8fb3b4c19fb8.json new file mode 100644 index 000000000000..67f4d87abf9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de7a8fb3b4c19fb8.json @@ -0,0 +1,110 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "lagInFrame", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ], + "window_name": "w" + }, + { + "type": "Function", + "name": "lagInFrame", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "window_name": "w" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/de7a8fb3b4c19fb8.sql b/tests/ast_json_fixtures/shapes/de7a8fb3b4c19fb8.sql new file mode 100644 index 000000000000..14f8e3351464 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/de7a8fb3b4c19fb8.sql @@ -0,0 +1,5 @@ +select number, + lagInFrame(toNullable(number), 2, null) over w, + lagInFrame(number, 2, 1) over w +from numbers(10) +window w as (order by number) diff --git a/tests/ast_json_fixtures/shapes/deaad1723fdb5c57.json b/tests/ast_json_fixtures/shapes/deaad1723fdb5c57.json new file mode 100644 index 000000000000..15ba1500649d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/deaad1723fdb5c57.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "cast2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/clickhouse\/tables\/{database}\/test_00643\/cast" + }, + { + "type": "Literal", + "value_type": "String", + "value": "r2" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "e" + } + }, + "as_table": "cast1" + } +} diff --git a/tests/ast_json_fixtures/shapes/deaad1723fdb5c57.sql b/tests/ast_json_fixtures/shapes/deaad1723fdb5c57.sql new file mode 100644 index 000000000000..5c4b82c2980c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/deaad1723fdb5c57.sql @@ -0,0 +1 @@ +CREATE TABLE cast2 AS cast1 ENGINE = ReplicatedMergeTree('/clickhouse/tables/{database}/test_00643/cast', 'r2') ORDER BY e diff --git a/tests/ast_json_fixtures/shapes/deb0b408d5aafdb8.json b/tests/ast_json_fixtures/shapes/deb0b408d5aafdb8.json new file mode 100644 index 000000000000..5f48dfb311d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/deb0b408d5aafdb8.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "if_not_exists": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/deb0b408d5aafdb8.sql b/tests/ast_json_fixtures/shapes/deb0b408d5aafdb8.sql new file mode 100644 index 000000000000..d785be4b3b17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/deb0b408d5aafdb8.sql @@ -0,0 +1 @@ +CREATE USER IF NOT EXISTS u1_01292 diff --git a/tests/ast_json_fixtures/shapes/decb9f03d7f0a87d.json b/tests/ast_json_fixtures/shapes/decb9f03d7f0a87d.json new file mode 100644 index 000000000000..24e13069ba23 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/decb9f03d7f0a87d.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "myName", + "name": "dummy" + } + ], + "select": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "myName" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/decb9f03d7f0a87d.sql b/tests/ast_json_fixtures/shapes/decb9f03d7f0a87d.sql new file mode 100644 index 000000000000..32e6f2e66551 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/decb9f03d7f0a87d.sql @@ -0,0 +1 @@ +WITH dummy AS myName SELECT myName + 1 FROM system.one diff --git a/tests/ast_json_fixtures/shapes/dee3233a9402538a.json b/tests/ast_json_fixtures/shapes/dee3233a9402538a.json new file mode 100644 index 000000000000..e29833ddb5dc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dee3233a9402538a.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + "sample_by": { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dee3233a9402538a.sql b/tests/ast_json_fixtures/shapes/dee3233a9402538a.sql new file mode 100644 index 000000000000..4c0bb9170c07 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dee3233a9402538a.sql @@ -0,0 +1 @@ +CREATE TABLE t (x String) ENGINE = MergeTree ORDER BY cityHash64(x) SAMPLE BY cityHash64(x) diff --git a/tests/ast_json_fixtures/shapes/def3a6c26cc8dfc8.json b/tests/ast_json_fixtures/shapes/def3a6c26cc8dfc8.json new file mode 100644 index 000000000000..e4c60d1905c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/def3a6c26cc8dfc8.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "ratio_of_defaults_for_sparse_serialization": "0", + "serialization_info_version": "with_types", + "nullable_serialization_version": "allow_sparse" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/def3a6c26cc8dfc8.sql b/tests/ast_json_fixtures/shapes/def3a6c26cc8dfc8.sql new file mode 100644 index 000000000000..85d166d31f56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/def3a6c26cc8dfc8.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE test (x UInt64, PRIMARY KEY ()) ENGINE = MergeTree SETTINGS ratio_of_defaults_for_sparse_serialization = 0, serialization_info_version = 'with_types', nullable_serialization_version = 'allow_sparse' diff --git a/tests/ast_json_fixtures/shapes/df0b679eefb0f28d.json b/tests/ast_json_fixtures/shapes/df0b679eefb0f28d.json new file mode 100644 index 000000000000..6a26e464a4c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/df0b679eefb0f28d.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distributed_tf" + }, + "as_table_function": { + "type": "Function", + "name": "cluster", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test" + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + }, + { + "type": "Literal", + "value_type": "String", + "value": "shard_localhost" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "buf" + }, + { + "type": "Literal", + "value_type": "String", + "value": "fer" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/df0b679eefb0f28d.sql b/tests/ast_json_fixtures/shapes/df0b679eefb0f28d.sql new file mode 100644 index 000000000000..9c144c4fb090 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/df0b679eefb0f28d.sql @@ -0,0 +1 @@ +CREATE TABLE distributed_tf as cluster('test' || '_' || 'shard_localhost', '', 'buf' || 'fer') diff --git a/tests/ast_json_fixtures/shapes/df31f141f11a0154.json b/tests/ast_json_fixtures/shapes/df31f141f11a0154.json new file mode 100644 index 000000000000..d5d35ec6a64d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/df31f141f11a0154.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "String", + "value": "!#$%&(*+,-.\/:<=>?@[^`{|}~" + } + ] + } + ], + "format": "Markdown" + } +} diff --git a/tests/ast_json_fixtures/shapes/df31f141f11a0154.sql b/tests/ast_json_fixtures/shapes/df31f141f11a0154.sql new file mode 100644 index 000000000000..8e45ee8ce08c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/df31f141f11a0154.sql @@ -0,0 +1 @@ +SELECT '!#$%&(*+,-./:<=>?@[^`{|}~' AS a FORMAT Markdown diff --git a/tests/ast_json_fixtures/shapes/df3e2cf509dea71f.json b/tests/ast_json_fixtures/shapes/df3e2cf509dea71f.json new file mode 100644 index 000000000000..c15dd5a220ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/df3e2cf509dea71f.json @@ -0,0 +1,127 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "strictness": "ALL", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.key", + "name_parts": ["t1", "key"] + }, + { + "type": "Identifier", + "name": "t2.key", + "name_parts": ["t2", "key"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "prewhere": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.key", + "name_parts": ["t2", "key"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/df3e2cf509dea71f.sql b/tests/ast_json_fixtures/shapes/df3e2cf509dea71f.sql new file mode 100644 index 000000000000..240aa3725f1d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/df3e2cf509dea71f.sql @@ -0,0 +1 @@ +SELECT materialize([NULL]), [], 100, count(materialize(NULL)) FROM t1 ALL INNER JOIN t2 ON t1.key = t2.key PREWHERE 10 WHERE t2.key != 0 WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/df5c887f3e12b656.json b/tests/ast_json_fixtures/shapes/df5c887f3e12b656.json new file mode 100644 index 000000000000..69915c3111b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/df5c887f3e12b656.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q2_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "EXECUTION_TIME": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/df5c887f3e12b656.sql b/tests/ast_json_fixtures/shapes/df5c887f3e12b656.sql new file mode 100644 index 000000000000..7a9784e687b6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/df5c887f3e12b656.sql @@ -0,0 +1 @@ +CREATE QUOTA q2_01297 FOR INTERVAL 1 MINUTE MAX execution_time = '0' diff --git a/tests/ast_json_fixtures/shapes/dfacd87a2e464c53.json b/tests/ast_json_fixtures/shapes/dfacd87a2e464c53.json new file mode 100644 index 000000000000..a2817f85aa46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dfacd87a2e464c53.json @@ -0,0 +1,176 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/01650_drop_part_and_deduplication_partitioned_table\/blocks\/" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + }, + { + "type": "Identifier", + "name": "k1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Asterisk" + }, + { + "type": "Literal", + "value_type": "String", + "value": "127.{1,2}" + }, + { + "type": "Function", + "name": "view", + "arguments": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Literal", + "alias": "k1", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65535" + }, + { + "type": "Literal", + "alias": "k2", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "v", + "value_type": "UInt64", + "value": "3" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "cityHash64", + "arguments": [ + { + "type": "Identifier", + "name": "k1" + } + ] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "having": { + "type": "Function", + "name": "equals", + "arguments": [ + { + "type": "Identifier", + "name": "k1" + }, + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + } + ] + } + } + ] + } + ] + } + ] + }, + "final": true + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dfacd87a2e464c53.sql b/tests/ast_json_fixtures/shapes/dfacd87a2e464c53.sql new file mode 100644 index 000000000000..f242bedec433 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dfacd87a2e464c53.sql @@ -0,0 +1,5 @@ +SELECT DISTINCT '/01650_drop_part_and_deduplication_partitioned_table/blocks/', 60, k1 +FROM remote(*, '127.{1,2}', view(SELECT 1 AS k1, 65535, 2 AS k2, 3 AS v +FROM numbers(2, cityHash64(k1)) +WHERE toLowCardinality(60) GROUP BY GROUPING SETS ((toLowCardinality(2))) +HAVING equals(k1, toNullable(60)))) FINAL diff --git a/tests/ast_json_fixtures/shapes/dfbf8cfcd3b394ee.json b/tests/ast_json_fixtures/shapes/dfbf8cfcd3b394ee.json new file mode 100644 index 000000000000..524bf7fc8d29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dfbf8cfcd3b394ee.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "v" + }, + { + "type": "Function", + "name": "variantElement", + "arguments": [ + { + "type": "Identifier", + "name": "v" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Bool" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "format", + "arguments": [ + { + "type": "Identifier", + "name": "CSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "v Variant(String, Bool)" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\\N\ntruee\ntrue" + } + ] + } + } + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/dfbf8cfcd3b394ee.sql b/tests/ast_json_fixtures/shapes/dfbf8cfcd3b394ee.sql new file mode 100644 index 000000000000..23db932c961a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dfbf8cfcd3b394ee.sql @@ -0,0 +1 @@ +select v, variantElement(v, 'Bool') from format(CSV, 'v Variant(String, Bool)', '\\N\ntruee\ntrue') format CSV diff --git a/tests/ast_json_fixtures/shapes/dfc12d1b9cee13d8.json b/tests/ast_json_fixtures/shapes/dfc12d1b9cee13d8.json new file mode 100644 index 000000000000..15d00179f124 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dfc12d1b9cee13d8.json @@ -0,0 +1,161 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "246" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "arrayStringConcat", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reinterpretAsString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/dfc12d1b9cee13d8.sql b/tests/ast_json_fixtures/shapes/dfc12d1b9cee13d8.sql new file mode 100644 index 000000000000..544a7c25ba32 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dfc12d1b9cee13d8.sql @@ -0,0 +1 @@ +SELECT number * 246 + 10 AS n, toDate('2000-01-01') + n AS d, range(n) AS arr, arrayStringConcat(arrayMap(x -> reinterpretAsString(x), arr)) AS s, (n, d) AS tuple FROM system.numbers LIMIT 2 FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/dfe01192dd651415.json b/tests/ast_json_fixtures/shapes/dfe01192dd651415.json new file mode 100644 index 000000000000..f44c8cdcfc95 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dfe01192dd651415.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "alter": true, + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p1_01296", + "table": "table" + }, + { + "short_name": "p2_01296", + "table": "table" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/dfe01192dd651415.sql b/tests/ast_json_fixtures/shapes/dfe01192dd651415.sql new file mode 100644 index 000000000000..31aac0b3620f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dfe01192dd651415.sql @@ -0,0 +1 @@ +ALTER POLICY p1_01296, p2_01296 ON table TO ALL diff --git a/tests/ast_json_fixtures/shapes/dffee0a934ee28ad.json b/tests/ast_json_fixtures/shapes/dffee0a934ee28ad.json new file mode 100644 index 000000000000..b26f5abeed16 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dffee0a934ee28ad.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_const_name_size": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/dffee0a934ee28ad.sql b/tests/ast_json_fixtures/shapes/dffee0a934ee28ad.sql new file mode 100644 index 000000000000..da765e0d6f10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/dffee0a934ee28ad.sql @@ -0,0 +1 @@ +SELECT c0 FROM t1 LIMIT 10 SETTINGS optimize_const_name_size = 1 diff --git a/tests/ast_json_fixtures/shapes/e01bd7e043c90fea.json b/tests/ast_json_fixtures/shapes/e01bd7e043c90fea.json new file mode 100644 index 000000000000..6594e9c6ddfd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e01bd7e043c90fea.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "dictionary": true, + "elements": [ + { + "from_table": "test_dict", + "to_table": "test_dict_2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e01bd7e043c90fea.sql b/tests/ast_json_fixtures/shapes/e01bd7e043c90fea.sql new file mode 100644 index 000000000000..117ff7d8aa0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e01bd7e043c90fea.sql @@ -0,0 +1 @@ +EXCHANGE DICTIONARIES test_dict AND test_dict_2 diff --git a/tests/ast_json_fixtures/shapes/e03f58bb330df257.json b/tests/ast_json_fixtures/shapes/e03f58bb330df257.json new file mode 100644 index 000000000000..9b310531d35a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e03f58bb330df257.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "d" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "dt" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e03f58bb330df257.sql b/tests/ast_json_fixtures/shapes/e03f58bb330df257.sql new file mode 100644 index 000000000000..1b49fe3145ab --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e03f58bb330df257.sql @@ -0,0 +1 @@ +select count() from d group by toDate(dt) diff --git a/tests/ast_json_fixtures/shapes/e03f6c66dcb6f42c.json b/tests/ast_json_fixtures/shapes/e03f6c66dcb6f42c.json new file mode 100644 index 000000000000..21c6d7c05dd7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e03f6c66dcb6f42c.json @@ -0,0 +1,157 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Function", + "alias": "async", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "BackgroundLoadingMarksTasks" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "alias": "sync", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "MarksTasksFromCache" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_kind" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Select" + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryStart" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time_microseconds" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/e03f6c66dcb6f42c.sql b/tests/ast_json_fixtures/shapes/e03f6c66dcb6f42c.sql new file mode 100644 index 000000000000..a689250e3d78 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e03f6c66dcb6f42c.sql @@ -0,0 +1,5 @@ +select query, ProfileEvents['BackgroundLoadingMarksTasks']>0 async, ProfileEvents['MarksTasksFromCache']>0 sync +from system.query_log +where current_database = currentDatabase() and query_kind = 'Select' and type != 'QueryStart' +order by event_time_microseconds +format Vertical diff --git a/tests/ast_json_fixtures/shapes/e04695e4ccae4979.json b/tests/ast_json_fixtures/shapes/e04695e4ccae4979.json new file mode 100644 index 000000000000..bfdddd5f54e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e04695e4ccae4979.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_atomic", + "from_table": "mv2", + "to_database": "test_01155_ordinary", + "to_table": "mv2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e04695e4ccae4979.sql b/tests/ast_json_fixtures/shapes/e04695e4ccae4979.sql new file mode 100644 index 000000000000..d015226091c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e04695e4ccae4979.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_atomic.mv2 TO test_01155_ordinary.mv2 diff --git a/tests/ast_json_fixtures/shapes/e05cb8b294a5e5bb.json b/tests/ast_json_fixtures/shapes/e05cb8b294a5e5bb.json new file mode 100644 index 000000000000..081ef2c6ce14 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e05cb8b294a5e5bb.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "test_02327" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "name", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "VALUES", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "Vasya" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Petya" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e05cb8b294a5e5bb.sql b/tests/ast_json_fixtures/shapes/e05cb8b294a5e5bb.sql new file mode 100644 index 000000000000..efc4807baff3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e05cb8b294a5e5bb.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE test_02327 (name String) AS SELECT * FROM VALUES(('Vasya'), ('Petya')) diff --git a/tests/ast_json_fixtures/shapes/e07bff6c3b95b668.json b/tests/ast_json_fixtures/shapes/e07bff6c3b95b668.json new file mode 100644 index 000000000000..a40b5181cd46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e07bff6c3b95b668.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "RELOAD DICTIONARY", + "table": { + "type": "Identifier", + "name": "d1" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e07bff6c3b95b668.sql b/tests/ast_json_fixtures/shapes/e07bff6c3b95b668.sql new file mode 100644 index 000000000000..ebab8e4151f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e07bff6c3b95b668.sql @@ -0,0 +1 @@ +SYSTEM RELOAD DICTIONARY d1 diff --git a/tests/ast_json_fixtures/shapes/e09655e8be487b38.json b/tests/ast_json_fixtures/shapes/e09655e8be487b38.json new file mode 100644 index 000000000000..e98c48808d7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e09655e8be487b38.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data_01279" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/e09655e8be487b38.sql b/tests/ast_json_fixtures/shapes/e09655e8be487b38.sql new file mode 100644 index 000000000000..d18e84336f91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e09655e8be487b38.sql @@ -0,0 +1 @@ +select * from data_01279 group by key format Null diff --git a/tests/ast_json_fixtures/shapes/e0a5724adf4ae67c.json b/tests/ast_json_fixtures/shapes/e0a5724adf4ae67c.json new file mode 100644 index 000000000000..1f47fa575870 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0a5724adf4ae67c.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Function", + "name": "arrayWithConstant", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + }, + { + "type": "Identifier", + "name": "value" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "args" + } + } + } + ] + } + } + ], + "format": "NULL" + } +} diff --git a/tests/ast_json_fixtures/shapes/e0a5724adf4ae67c.sql b/tests/ast_json_fixtures/shapes/e0a5724adf4ae67c.sql new file mode 100644 index 000000000000..9864832927a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0a5724adf4ae67c.sql @@ -0,0 +1 @@ +SELECT length(arrayWithConstant(1000000, value)) FROM args FORMAT NULL diff --git a/tests/ast_json_fixtures/shapes/e0b2d54fcfecff67.json b/tests/ast_json_fixtures/shapes/e0b2d54fcfecff67.json new file mode 100644 index 000000000000..514c375c41d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0b2d54fcfecff67.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02484_plusone" + } +} diff --git a/tests/ast_json_fixtures/shapes/e0b2d54fcfecff67.sql b/tests/ast_json_fixtures/shapes/e0b2d54fcfecff67.sql new file mode 100644 index 000000000000..9e550118ead4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0b2d54fcfecff67.sql @@ -0,0 +1 @@ +DROP FUNCTION 02484_plusone diff --git a/tests/ast_json_fixtures/shapes/e0b68df6bec4b5cf.json b/tests/ast_json_fixtures/shapes/e0b68df6bec4b5cf.json new file mode 100644 index 000000000000..c37ccbac8921 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0b68df6bec4b5cf.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROW POLICY", + "row_policy_names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "rp", + "table": "t" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e0b68df6bec4b5cf.sql b/tests/ast_json_fixtures/shapes/e0b68df6bec4b5cf.sql new file mode 100644 index 000000000000..c9ae71dbe7ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0b68df6bec4b5cf.sql @@ -0,0 +1 @@ +DROP ROW POLICY rp ON t diff --git a/tests/ast_json_fixtures/shapes/e0da161d4a9bf488.json b/tests/ast_json_fixtures/shapes/e0da161d4a9bf488.json new file mode 100644 index 000000000000..16153702110f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0da161d4a9bf488.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "t_a", + "name": "t.a", + "name_parts": ["t", "a"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.a", + "name_parts": ["s", "a"] + }, + { + "type": "Identifier", + "name": "t_a" + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "s" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t.a", + "name_parts": ["t", "a"] + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/e0da161d4a9bf488.sql b/tests/ast_json_fixtures/shapes/e0da161d4a9bf488.sql new file mode 100644 index 000000000000..bf101625bcd4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0da161d4a9bf488.sql @@ -0,0 +1,4 @@ +select t.a as t_a from t +left join s on s.a = t_a +order by t.a +format PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/e0e061eef2ed3972.json b/tests/ast_json_fixtures/shapes/e0e061eef2ed3972.json new file mode 100644 index 000000000000..82488f6d7d7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0e061eef2ed3972.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e0e061eef2ed3972.sql b/tests/ast_json_fixtures/shapes/e0e061eef2ed3972.sql new file mode 100644 index 000000000000..bbea3b38bcb2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0e061eef2ed3972.sql @@ -0,0 +1 @@ +SELECT count() FROM system.one WHERE 0 diff --git a/tests/ast_json_fixtures/shapes/e0e37bc201379935.json b/tests/ast_json_fixtures/shapes/e0e37bc201379935.json new file mode 100644 index 000000000000..82a30a08cf8a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0e37bc201379935.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "ttl" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toDayOfMonth", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "a" + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e0e37bc201379935.sql b/tests/ast_json_fixtures/shapes/e0e37bc201379935.sql new file mode 100644 index 000000000000..1d6c4f601170 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0e37bc201379935.sql @@ -0,0 +1 @@ +create table ttl (d Date, a Int) engine = MergeTree order by a partition by toDayOfMonth(d) ttl d + interval 1 day diff --git a/tests/ast_json_fixtures/shapes/e0e39ebeabe1256e.json b/tests/ast_json_fixtures/shapes/e0e39ebeabe1256e.json new file mode 100644 index 000000000000..6ed64c6b6a11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0e39ebeabe1256e.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "meta_source_req_uuid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "bug_14144" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "meta_source_type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "missing" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "meta_source_req_uuid" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e0e39ebeabe1256e.sql b/tests/ast_json_fixtures/shapes/e0e39ebeabe1256e.sql new file mode 100644 index 000000000000..6dae5ab85684 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0e39ebeabe1256e.sql @@ -0,0 +1,4 @@ +SELECT DISTINCT meta_source_req_uuid +FROM bug_14144 +WHERE meta_source_type = 'missing' +ORDER BY meta_source_req_uuid ASC diff --git a/tests/ast_json_fixtures/shapes/e0e4c0ea3f948c9f.json b/tests/ast_json_fixtures/shapes/e0e4c0ea3f948c9f.json new file mode 100644 index 000000000000..7a85892e40f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0e4c0ea3f948c9f.json @@ -0,0 +1,113 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "random_filename" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + }, + { + "type": "Literal", + "value_type": "String", + "value": "MsgPack" + }, + { + "type": "Literal", + "value_type": "String", + "value": "c0 Int32, c1 Tuple()" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "tuple", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "engine_file_truncate_on_insert": "1" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e0e4c0ea3f948c9f.sql b/tests/ast_json_fixtures/shapes/e0e4c0ea3f948c9f.sql new file mode 100644 index 000000000000..c8a482a1fff8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0e4c0ea3f948c9f.sql @@ -0,0 +1,2 @@ +INSERT INTO FUNCTION file((SELECT name FROM random_filename LIMIT 1), 'MsgPack', 'c0 Int32, c1 Tuple()') +SELECT 1, tuple() FROM numbers(5) SETTINGS engine_file_truncate_on_insert = 1 diff --git a/tests/ast_json_fixtures/shapes/e0ead8c110c6f8f2.json b/tests/ast_json_fixtures/shapes/e0ead8c110c6f8f2.json new file mode 100644 index 000000000000..741d463324d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0ead8c110c6f8f2.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e0ead8c110c6f8f2.sql b/tests/ast_json_fixtures/shapes/e0ead8c110c6f8f2.sql new file mode 100644 index 000000000000..c408b24f2999 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e0ead8c110c6f8f2.sql @@ -0,0 +1 @@ +CREATE TABLE t (x UInt8, PROJECTION p (SELECT x GROUP BY x)) ENGINE = MergeTree ORDER BY () diff --git a/tests/ast_json_fixtures/shapes/e1089bd96a62f412.json b/tests/ast_json_fixtures/shapes/e1089bd96a62f412.json new file mode 100644 index 000000000000..482e0422d043 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1089bd96a62f412.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_path" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "url", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "http:\/\/127.0.0.1:8123?query=select+{1,2}+as+x+format+TSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "TSV" + } + ] + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e1089bd96a62f412.sql b/tests/ast_json_fixtures/shapes/e1089bd96a62f412.sql new file mode 100644 index 000000000000..4cea988b939b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1089bd96a62f412.sql @@ -0,0 +1 @@ +SELECT _path FROM url('http://127.0.0.1:8123?query=select+{1,2}+as+x+format+TSV', 'TSV') WHERE 0 diff --git a/tests/ast_json_fixtures/shapes/e127781a7c6c6ab8.json b/tests/ast_json_fixtures/shapes/e127781a7c6c6ab8.json new file mode 100644 index 000000000000..b08c7a8ecfe7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e127781a7c6c6ab8.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "uid" + }, + { + "type": "Identifier", + "name": "date" + }, + { + "type": "Function", + "alias": "res", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2021-03-24" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table_3" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "res" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "uid" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "date" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_parallel_replicas": "1", + "max_parallel_replicas": "3", + "cluster_for_parallel_replicas": "test_cluster_one_shard_three_replicas_localhost", + "parallel_replicas_local_plan": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e127781a7c6c6ab8.sql b/tests/ast_json_fixtures/shapes/e127781a7c6c6ab8.sql new file mode 100644 index 000000000000..94504ecdf8a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e127781a7c6c6ab8.sql @@ -0,0 +1,10 @@ +SELECT + uid, + date, + toDate(date) = toDate('2021-03-24') AS res +FROM table_3 +WHERE res = 1 +ORDER BY + uid ASC, + date ASC +SETTINGS enable_parallel_replicas = 1, max_parallel_replicas = 3, cluster_for_parallel_replicas = 'test_cluster_one_shard_three_replicas_localhost', parallel_replicas_local_plan = 1 diff --git a/tests/ast_json_fixtures/shapes/e135f05c53cb3c49.json b/tests/ast_json_fixtures/shapes/e135f05c53cb3c49.json new file mode 100644 index 000000000000..6799a706e694 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e135f05c53cb3c49.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "sleepEachRow", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/e135f05c53cb3c49.sql b/tests/ast_json_fixtures/shapes/e135f05c53cb3c49.sql new file mode 100644 index 000000000000..7d8e5817e0a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e135f05c53cb3c49.sql @@ -0,0 +1 @@ +SELECT number from numbers(10) where sleepEachRow(1) Format Null diff --git a/tests/ast_json_fixtures/shapes/e13663851c3e8249.json b/tests/ast_json_fixtures/shapes/e13663851c3e8249.json new file mode 100644 index 000000000000..c5f3552e7874 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e13663851c3e8249.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Identifier", + "name": "comment" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "columns", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "check_query_comment_column" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/e13663851c3e8249.sql b/tests/ast_json_fixtures/shapes/e13663851c3e8249.sql new file mode 100644 index 000000000000..91e35786fe59 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e13663851c3e8249.sql @@ -0,0 +1,4 @@ +SELECT table, name, comment +FROM system.columns +WHERE table = 'check_query_comment_column' AND database = currentDatabase() +FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/e14d90365735bca0.json b/tests/ast_json_fixtures/shapes/e14d90365735bca0.json new file mode 100644 index 000000000000..f8abcb1a25e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e14d90365735bca0.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t_subcolumns_dist" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "t_subcolumns_local" + } + ] + } + }, + "as_table": "t_subcolumns_local" + } +} diff --git a/tests/ast_json_fixtures/shapes/e14d90365735bca0.sql b/tests/ast_json_fixtures/shapes/e14d90365735bca0.sql new file mode 100644 index 000000000000..2c7fb4206c35 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e14d90365735bca0.sql @@ -0,0 +1 @@ +CREATE TABLE t_subcolumns_dist AS t_subcolumns_local ENGINE = Distributed(test_cluster_two_shards, currentDatabase(), t_subcolumns_local) diff --git a/tests/ast_json_fixtures/shapes/e173569ed58573c1.json b/tests/ast_json_fixtures/shapes/e173569ed58573c1.json new file mode 100644 index 000000000000..630f1150cdfe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e173569ed58573c1.json @@ -0,0 +1,154 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "alias": "i0", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "alias": "u0", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "alias": "ip", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775807" + } + ] + }, + { + "type": "Function", + "alias": "in", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775808" + } + ] + }, + { + "type": "Function", + "alias": "up", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "18446744073709551615" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "i0" + }, + { + "type": "Identifier", + "name": "u0" + }, + { + "type": "Identifier", + "name": "ip" + }, + { + "type": "Identifier", + "name": "in" + }, + { + "type": "Identifier", + "name": "up" + }, + { + "type": "Identifier", + "name": "arr" + }, + { + "type": "Identifier", + "name": "tuple" + } + ] + } + ], + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/e173569ed58573c1.sql b/tests/ast_json_fixtures/shapes/e173569ed58573c1.sql new file mode 100644 index 000000000000..0d1e5f32e359 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e173569ed58573c1.sql @@ -0,0 +1 @@ +SELECT toInt64(0) as i0, toUInt64(0) as u0, toInt64(9223372036854775807) as ip, toInt64(-9223372036854775808) as in, toUInt64(18446744073709551615) as up, [toInt64(0)] as arr, (toUInt64(0), toUInt64(0)) as tuple GROUP BY i0, u0, ip, in, up, arr, tuple WITH TOTALS FORMAT JSON diff --git a/tests/ast_json_fixtures/shapes/e176bf6b294d007a.json b/tests/ast_json_fixtures/shapes/e176bf6b294d007a.json new file mode 100644 index 000000000000..44443112c5dd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e176bf6b294d007a.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH ASYNC INSERT QUEUE", + "tables": [ + { + "table": "table1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e176bf6b294d007a.sql b/tests/ast_json_fixtures/shapes/e176bf6b294d007a.sql new file mode 100644 index 000000000000..790500537e39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e176bf6b294d007a.sql @@ -0,0 +1 @@ +SYSTEM FLUSH ASYNC INSERT QUEUE table1 diff --git a/tests/ast_json_fixtures/shapes/e180c53b56d25ac1.json b/tests/ast_json_fixtures/shapes/e180c53b56d25ac1.json new file mode 100644 index 000000000000..8a297d07810f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e180c53b56d25ac1.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "_path", + "name": "replaceRegexpAll", + "arguments": [ + { + "type": "Identifier", + "name": "_path" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\/[0-9]+\\.csv" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\/.csv" + } + ] + }, + { + "type": "Identifier", + "name": "counter" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_03363_csv" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "counter" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "counter" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e180c53b56d25ac1.sql b/tests/ast_json_fixtures/shapes/e180c53b56d25ac1.sql new file mode 100644 index 000000000000..b494508a7cc3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e180c53b56d25ac1.sql @@ -0,0 +1 @@ +select distinct on (counter) replaceRegexpAll(_path, '/[0-9]+\\.csv', '/.csv') AS _path, counter from t_03363_csv order by counter diff --git a/tests/ast_json_fixtures/shapes/e1864ee63b7be4fb.json b/tests/ast_json_fixtures/shapes/e1864ee63b7be4fb.json new file mode 100644 index 000000000000..7ba4deb3fa0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1864ee63b7be4fb.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "hits_buffer" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Buffer", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "current_database", + "arguments": [] + }, + { + "type": "Identifier", + "name": "hits_dst" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "600" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "600" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000000" + } + ] + } + }, + "as_table": "hits_dst" + } +} diff --git a/tests/ast_json_fixtures/shapes/e1864ee63b7be4fb.sql b/tests/ast_json_fixtures/shapes/e1864ee63b7be4fb.sql new file mode 100644 index 000000000000..50413178f71f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1864ee63b7be4fb.sql @@ -0,0 +1 @@ +CREATE TABLE hits_buffer AS hits_dst ENGINE = Buffer(current_database(), hits_dst, 8, 600, 600, 1000000, 1000000, 100000000, 1000000000) diff --git a/tests/ast_json_fixtures/shapes/e19753c34e1a3ed5.json b/tests/ast_json_fixtures/shapes/e19753c34e1a3ed5.json new file mode 100644 index 000000000000..843844438fc9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e19753c34e1a3ed5.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "t0", + "to_table": "t1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e19753c34e1a3ed5.sql b/tests/ast_json_fixtures/shapes/e19753c34e1a3ed5.sql new file mode 100644 index 000000000000..6bd0c20eb60a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e19753c34e1a3ed5.sql @@ -0,0 +1 @@ +RENAME TABLE t0 TO t1 diff --git a/tests/ast_json_fixtures/shapes/e19e651986870dbb.json b/tests/ast_json_fixtures/shapes/e19e651986870dbb.json new file mode 100644 index 000000000000..87b4923f1d73 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e19e651986870dbb.json @@ -0,0 +1,97 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "compound_value", + "name": "CAST", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Tuple (value UInt64)" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "test_table" + }, + "transformers": [ + { + "type": "ColumnsApplyTransformer", + "lambda": { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "compound_value" + } + } + ] + }, + "lambda_arg": "x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e19e651986870dbb.sql b/tests/ast_json_fixtures/shapes/e19e651986870dbb.sql new file mode 100644 index 000000000000..3596612eee5f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e19e651986870dbb.sql @@ -0,0 +1 @@ +WITH cast(tuple(1), 'Tuple (value UInt64)') AS compound_value SELECT id, test_table.* APPLY x -> compound_value.* FROM test_table diff --git a/tests/ast_json_fixtures/shapes/e1afc385cd1e63c7.json b/tests/ast_json_fixtures/shapes/e1afc385cd1e63c7.json new file mode 100644 index 000000000000..e3c9dd3e87d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1afc385cd1e63c7.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["READ"], + "parameter": "REMOTE" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_03727"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e1afc385cd1e63c7.sql b/tests/ast_json_fixtures/shapes/e1afc385cd1e63c7.sql new file mode 100644 index 000000000000..4ce607acf4b4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1afc385cd1e63c7.sql @@ -0,0 +1 @@ +GRANT READ ON REMOTE to test_03727 diff --git a/tests/ast_json_fixtures/shapes/e1d103c0df9e3f4d.json b/tests/ast_json_fixtures/shapes/e1d103c0df9e3f4d.json new file mode 100644 index 000000000000..a9f343cb94ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1d103c0df9e3f4d.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "DropQuery", + "kind": "DROP", + "table": { + "type": "Identifier", + "name": "test_compact_map" + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/e1d103c0df9e3f4d.sql b/tests/ast_json_fixtures/shapes/e1d103c0df9e3f4d.sql new file mode 100644 index 000000000000..ce5e8893bfa3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1d103c0df9e3f4d.sql @@ -0,0 +1 @@ +drop table test_compact_map format Null diff --git a/tests/ast_json_fixtures/shapes/e1eec9e766578168.json b/tests/ast_json_fixtures/shapes/e1eec9e766578168.json new file mode 100644 index 000000000000..6993c48c1207 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1eec9e766578168.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_clone_as": true, + "table": { + "type": "Identifier", + "name": "clone_as_foo_merge_tree" + }, + "as_table": "foo_merge_tree" + } +} diff --git a/tests/ast_json_fixtures/shapes/e1eec9e766578168.sql b/tests/ast_json_fixtures/shapes/e1eec9e766578168.sql new file mode 100644 index 000000000000..76f2315ec641 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1eec9e766578168.sql @@ -0,0 +1 @@ +CREATE TABLE clone_as_foo_merge_tree CLONE AS foo_merge_tree diff --git a/tests/ast_json_fixtures/shapes/e1ef8a0a9ea52b73.json b/tests/ast_json_fixtures/shapes/e1ef8a0a9ea52b73.json new file mode 100644 index 000000000000..b3edc9a4442d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1ef8a0a9ea52b73.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01643" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01643" + }, + { + "type": "Identifier", + "name": "key" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "fsync_after_insert": "1", + "fsync_directories": "1" + } + } + }, + "as_table": "data_01643" + } +} diff --git a/tests/ast_json_fixtures/shapes/e1ef8a0a9ea52b73.sql b/tests/ast_json_fixtures/shapes/e1ef8a0a9ea52b73.sql new file mode 100644 index 000000000000..0617aecb4479 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e1ef8a0a9ea52b73.sql @@ -0,0 +1 @@ +create table dist_01643 as data_01643 engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01643, key) settings fsync_after_insert=1, fsync_directories=1 diff --git a/tests/ast_json_fixtures/shapes/e26c21669cb74edb.json b/tests/ast_json_fixtures/shapes/e26c21669cb74edb.json new file mode 100644 index 000000000000..9b94fd297642 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e26c21669cb74edb.json @@ -0,0 +1,116 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "is_materialized_view": true, + "uuid": "3bd68e3c-2693-4352-ad66-a66eba9e345e", + "table": { + "type": "Identifier", + "name": "mv" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "n2", + "data_type": { + "type": "DataType", + "name": "Int64" + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Function", + "alias": "n2", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "src" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "n" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e26c21669cb74edb.sql b/tests/ast_json_fixtures/shapes/e26c21669cb74edb.sql new file mode 100644 index 000000000000..b72f4899aed8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e26c21669cb74edb.sql @@ -0,0 +1 @@ +ATTACH MATERIALIZED VIEW mv UUID '3bd68e3c-2693-4352-ad66-a66eba9e345e' TO INNER UUID '3bd68e3c-2693-4352-ad66-a66eba9e345e' (n Int32, n2 Int64) ENGINE = MergeTree PARTITION BY n % 10 ORDER BY n AS SELECT n, n * n AS n2 FROM src diff --git a/tests/ast_json_fixtures/shapes/e27d7c31b7cb0d15.json b/tests/ast_json_fixtures/shapes/e27d7c31b7cb0d15.json new file mode 100644 index 000000000000..4a8bcdeb673a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e27d7c31b7cb0d15.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + } + } + ], + "format": "PrettyMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/e27d7c31b7cb0d15.sql b/tests/ast_json_fixtures/shapes/e27d7c31b7cb0d15.sql new file mode 100644 index 000000000000..426e7be54456 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e27d7c31b7cb0d15.sql @@ -0,0 +1 @@ +SELECT * FROM t0 FORMAT PrettyMonoBlock diff --git a/tests/ast_json_fixtures/shapes/e2bf971baaaac100.json b/tests/ast_json_fixtures/shapes/e2bf971baaaac100.json new file mode 100644 index 000000000000..973e060a3982 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2bf971baaaac100.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["test_user_02867"] + } +} diff --git a/tests/ast_json_fixtures/shapes/e2bf971baaaac100.sql b/tests/ast_json_fixtures/shapes/e2bf971baaaac100.sql new file mode 100644 index 000000000000..b7623a739251 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2bf971baaaac100.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS test_user_02867 diff --git a/tests/ast_json_fixtures/shapes/e2d4cb3acfafdf37.json b/tests/ast_json_fixtures/shapes/e2d4cb3acfafdf37.json new file mode 100644 index 000000000000..1b14a1ce3600 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2d4cb3acfafdf37.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "replicated_table_detach_all1" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "FETCH_PARTITION", + "partition": { + "type": "Partition_ID", + "all": true + }, + "from": "\/clickhouse\/tables\/test_00753_{database}\/replicated_table_detach_all1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e2d4cb3acfafdf37.sql b/tests/ast_json_fixtures/shapes/e2d4cb3acfafdf37.sql new file mode 100644 index 000000000000..3b45e566d154 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2d4cb3acfafdf37.sql @@ -0,0 +1 @@ +ALTER TABLE replicated_table_detach_all1 FETCH PARTITION ALL FROM '/clickhouse/tables/test_00753_{database}/replicated_table_detach_all1' diff --git a/tests/ast_json_fixtures/shapes/e2d98712573ed9cd.json b/tests/ast_json_fixtures/shapes/e2d98712573ed9cd.json new file mode 100644 index 000000000000..3281fb9d8d02 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2d98712573ed9cd.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "hello" + }, + { + "type": "Function", + "name": "untuple", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Asterisk", + "transformers": [ + { + "type": "ColumnsExceptTransformer", + "columns": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "world" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "c", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e2d98712573ed9cd.sql b/tests/ast_json_fixtures/shapes/e2d98712573ed9cd.sql new file mode 100644 index 000000000000..750c5fb3bfea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2d98712573ed9cd.sql @@ -0,0 +1 @@ +select 'hello', untuple((* except (b),)), 'world' from (select 1 a, 2 b, 3 c) diff --git a/tests/ast_json_fixtures/shapes/e2e39693e270449c.json b/tests/ast_json_fixtures/shapes/e2e39693e270449c.json new file mode 100644 index 000000000000..ac16cbd96d69 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2e39693e270449c.json @@ -0,0 +1,190 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "start", + "value_type": "UInt64", + "value": "1734955380" + }, + { + "type": "Literal", + "alias": "end", + "value_type": "UInt64", + "value": "1734955680" + }, + { + "type": "Literal", + "alias": "step", + "value_type": "UInt64", + "value": "15" + }, + { + "type": "Literal", + "alias": "window", + "value_type": "UInt64", + "value": "300" + }, + { + "type": "Literal", + "alias": "predict_offset", + "value_type": "UInt64", + "value": "60" + }, + { + "type": "Function", + "alias": "grid", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "start" + }, + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "end" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "step" + } + ] + } + ], + "select": [ + { + "type": "Function", + "alias": "changes_5m", + "name": "arrayZip", + "arguments": [ + { + "type": "Identifier", + "name": "grid" + }, + { + "type": "Function", + "name": "timeSeriesChangesToGrid", + "arguments": [ + { + "type": "Function", + "name": "toUnixTimestamp", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + { + "type": "Identifier", + "name": "value" + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start" + }, + { + "type": "Identifier", + "name": "end" + }, + { + "type": "Identifier", + "name": "step" + }, + { + "type": "Identifier", + "name": "window" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "resets_5m", + "name": "arrayZip", + "arguments": [ + { + "type": "Identifier", + "name": "grid" + }, + { + "type": "Function", + "name": "timeSeriesResetsToGrid", + "arguments": [ + { + "type": "Function", + "name": "toUnixTimestamp", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + { + "type": "Identifier", + "name": "value" + } + ], + "parameters": [ + { + "type": "Identifier", + "name": "start" + }, + { + "type": "Identifier", + "name": "end" + }, + { + "type": "Identifier", + "name": "step" + }, + { + "type": "Identifier", + "name": "window" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ts_raw_data" + } + } + } + ] + } + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/e2e39693e270449c.sql b/tests/ast_json_fixtures/shapes/e2e39693e270449c.sql new file mode 100644 index 000000000000..748222c9fb11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2e39693e270449c.sql @@ -0,0 +1,7 @@ +WITH + 1734955380 AS start, 1734955680 AS end, 15 AS step, 300 AS window, 60 as predict_offset, + range(start, end + 1, step) as grid +SELECT + arrayZip(grid, timeSeriesChangesToGrid(start, end, step, window)(toUnixTimestamp(timestamp), value)) as changes_5m, + arrayZip(grid, timeSeriesResetsToGrid(start, end, step, window)(toUnixTimestamp(timestamp), value)) as resets_5m +FROM ts_raw_data FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/e2eae5d0ecef5a71.json b/tests/ast_json_fixtures/shapes/e2eae5d0ecef5a71.json new file mode 100644 index 000000000000..c0e1f3686036 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2eae5d0ecef5a71.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q1_01297", "q2_01297", "q3_01297", "q4_01297", "q5_01297", "q6_01297", "q7_01297", "q8_01297", "q9_01297", "q10_01297", "q11_01297", "q12_01297", "q13_01297", "q14_01297", "q15_01297", "q16_01297", "q17_01297", "q18_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/e2eae5d0ecef5a71.sql b/tests/ast_json_fixtures/shapes/e2eae5d0ecef5a71.sql new file mode 100644 index 000000000000..84a57a140af6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2eae5d0ecef5a71.sql @@ -0,0 +1,2 @@ +DROP QUOTA IF EXISTS q1_01297, q2_01297, q3_01297, q4_01297, q5_01297, q6_01297, q7_01297, q8_01297, q9_01297, +q10_01297, q11_01297, q12_01297, q13_01297, q14_01297, q15_01297, q16_01297, q17_01297,q18_01297 diff --git a/tests/ast_json_fixtures/shapes/e2f35da3295589d7.json b/tests/ast_json_fixtures/shapes/e2f35da3295589d7.json new file mode 100644 index 000000000000..d81efda4ac0b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2f35da3295589d7.json @@ -0,0 +1,75 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_block_mismatch_sk2" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + }, + "primary_key": { + "type": "Identifier", + "name": "a" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e2f35da3295589d7.sql b/tests/ast_json_fixtures/shapes/e2f35da3295589d7.sql new file mode 100644 index 000000000000..23abbc9654a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e2f35da3295589d7.sql @@ -0,0 +1,9 @@ +CREATE TABLE test_block_mismatch_sk2 +( + a UInt32, + b DateTime +) +ENGINE = ReplacingMergeTree +PARTITION BY toYYYYMM(b) +PRIMARY KEY (a) +ORDER BY (a, toDate(b)) diff --git a/tests/ast_json_fixtures/shapes/e30b859f07b61149.json b/tests/ast_json_fixtures/shapes/e30b859f07b61149.json new file mode 100644 index 000000000000..b913ef933950 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e30b859f07b61149.json @@ -0,0 +1,32 @@ +{ + "version": 2, + "ast": { + "type": "DescribeQuery", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "format", + "arguments": [ + { + "type": "Identifier", + "name": "JSONEachRow" + }, + { + "type": "Literal", + "value_type": "String", + "value": "{\"id\" : 1, \"age\" : 25, \"name\" : \"Josh\", \"status\" : null, \"hobbies\" : [\"football\", \"cooking\"]}" + } + ] + } + }, + "settings": { + "type": "Settings", + "changes": { + "schema_inference_hints": "age LowCardinality(UInt8), status Nullable(String)", + "allow_suspicious_low_cardinality_types": "1" + } + }, + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/e30b859f07b61149.sql b/tests/ast_json_fixtures/shapes/e30b859f07b61149.sql new file mode 100644 index 000000000000..0e4d8823ab2f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e30b859f07b61149.sql @@ -0,0 +1 @@ +DESC format(JSONEachRow, '{"id" : 1, "age" : 25, "name" : "Josh", "status" : null, "hobbies" : ["football", "cooking"]}') FORMAT CSV SETTINGS schema_inference_hints = 'age LowCardinality(UInt8), status Nullable(String)', allow_suspicious_low_cardinality_types=1 diff --git a/tests/ast_json_fixtures/shapes/e31019300dc77a80.json b/tests/ast_json_fixtures/shapes/e31019300dc77a80.json new file mode 100644 index 000000000000..edc9cde0fe7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e31019300dc77a80.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "_data_02318.tsv" + } + ] + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e31019300dc77a80.sql b/tests/ast_json_fixtures/shapes/e31019300dc77a80.sql new file mode 100644 index 000000000000..0e4181b6a7e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e31019300dc77a80.sql @@ -0,0 +1 @@ +insert into function file(currentDatabase() || '_data_02318.tsv') select * from numbers(10) diff --git a/tests/ast_json_fixtures/shapes/e32d76ef45e66780.json b/tests/ast_json_fixtures/shapes/e32d76ef45e66780.json new file mode 100644 index 000000000000..fa898bf4a149 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e32d76ef45e66780.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "like": "%", + "not_like": true, + "case_insensitive_like": true + } +} diff --git a/tests/ast_json_fixtures/shapes/e32d76ef45e66780.sql b/tests/ast_json_fixtures/shapes/e32d76ef45e66780.sql new file mode 100644 index 000000000000..40384e92e7b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e32d76ef45e66780.sql @@ -0,0 +1 @@ +SHOW TABLES NOT ILIKE '%' diff --git a/tests/ast_json_fixtures/shapes/e33644cf40f8abfc.json b/tests/ast_json_fixtures/shapes/e33644cf40f8abfc.json new file mode 100644 index 000000000000..40d11383dddc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e33644cf40f8abfc.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_remove_sample_by" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REMOVE_SAMPLE_BY" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e33644cf40f8abfc.sql b/tests/ast_json_fixtures/shapes/e33644cf40f8abfc.sql new file mode 100644 index 000000000000..8c345095fab2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e33644cf40f8abfc.sql @@ -0,0 +1 @@ +ALTER TABLE t_remove_sample_by REMOVE SAMPLE BY diff --git a/tests/ast_json_fixtures/shapes/e33f5268edf7c237.json b/tests/ast_json_fixtures/shapes/e33f5268edf7c237.json new file mode 100644 index 000000000000..ac1a22099808 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e33f5268edf7c237.json @@ -0,0 +1,117 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "having": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e33f5268edf7c237.sql b/tests/ast_json_fixtures/shapes/e33f5268edf7c237.sql new file mode 100644 index 000000000000..2b44f11338a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e33f5268edf7c237.sql @@ -0,0 +1,8 @@ +SELECT + number, + countIf(1, number > 0) +FROM numbers(10) +GROUP BY number +HAVING (count() <= 10) AND 1 +ORDER BY number ASC +SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/e349b1cc0bb66a8a.json b/tests/ast_json_fixtures/shapes/e349b1cc0bb66a8a.json new file mode 100644 index 000000000000..d9a785c05462 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e349b1cc0bb66a8a.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_00612" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_00612" + }, + { + "type": "Function", + "name": "rand", + "arguments": [] + } + ] + } + }, + "as_table": "data_00612" + } +} diff --git a/tests/ast_json_fixtures/shapes/e349b1cc0bb66a8a.sql b/tests/ast_json_fixtures/shapes/e349b1cc0bb66a8a.sql new file mode 100644 index 000000000000..0fe9790495d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e349b1cc0bb66a8a.sql @@ -0,0 +1 @@ +CREATE TABLE dist_00612 AS data_00612 ENGINE = Distributed(test_shard_localhost, currentDatabase(), data_00612, rand()) diff --git a/tests/ast_json_fixtures/shapes/e3562e39496a0b9f.json b/tests/ast_json_fixtures/shapes/e3562e39496a0b9f.json new file mode 100644 index 000000000000..561f18722d5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3562e39496a0b9f.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "0b" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e3562e39496a0b9f.sql b/tests/ast_json_fixtures/shapes/e3562e39496a0b9f.sql new file mode 100644 index 000000000000..fc30190f763f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3562e39496a0b9f.sql @@ -0,0 +1 @@ +select 0b diff --git a/tests/ast_json_fixtures/shapes/e3a2b5101731aec4.json b/tests/ast_json_fixtures/shapes/e3a2b5101731aec4.json new file mode 100644 index 000000000000..b7387c68a2c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3a2b5101731aec4.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "number", + "value_type": "String", + "value": "100" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "n", + "name": "d_numbers" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n.number", + "name_parts": ["n", "number"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e3a2b5101731aec4.sql b/tests/ast_json_fixtures/shapes/e3a2b5101731aec4.sql new file mode 100644 index 000000000000..45d3de9c0f4f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3a2b5101731aec4.sql @@ -0,0 +1 @@ +SELECT '100' AS number FROM d_numbers AS n WHERE n.number = 100 LIMIT 2 diff --git a/tests/ast_json_fixtures/shapes/e3bfba9be631544e.json b/tests/ast_json_fixtures/shapes/e3bfba9be631544e.json new file mode 100644 index 000000000000..51b440f64c75 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3bfba9be631544e.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "ttl" + }, + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + }, + "final": true + } +} diff --git a/tests/ast_json_fixtures/shapes/e3bfba9be631544e.sql b/tests/ast_json_fixtures/shapes/e3bfba9be631544e.sql new file mode 100644 index 000000000000..f9c8671871f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3bfba9be631544e.sql @@ -0,0 +1 @@ +optimize table ttl partition 10 final diff --git a/tests/ast_json_fixtures/shapes/e3c83f820164bc63.json b/tests/ast_json_fixtures/shapes/e3c83f820164bc63.json new file mode 100644 index 000000000000..f7f99856fa50 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3c83f820164bc63.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_part" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "override_test__fuzz_45" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "6" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e3c83f820164bc63.sql b/tests/ast_json_fixtures/shapes/e3c83f820164bc63.sql new file mode 100644 index 000000000000..c946eec55d18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3c83f820164bc63.sql @@ -0,0 +1 @@ +SELECT _part FROM override_test__fuzz_45 GROUP BY materialize(6), 1 diff --git a/tests/ast_json_fixtures/shapes/e3d0b013d8cedf57.json b/tests/ast_json_fixtures/shapes/e3d0b013d8cedf57.json new file mode 100644 index 000000000000..befa6b129b80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3d0b013d8cedf57.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/e3d0b013d8cedf57.sql b/tests/ast_json_fixtures/shapes/e3d0b013d8cedf57.sql new file mode 100644 index 000000000000..b4a5bb4132c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3d0b013d8cedf57.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) ORDER BY number FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/e3f7c953913b17bb.json b/tests/ast_json_fixtures/shapes/e3f7c953913b17bb.json new file mode 100644 index 000000000000..a4f5995bd11b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3f7c953913b17bb.json @@ -0,0 +1,146 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "l_", + "name": "lowerUTF8", + "arguments": [ + { + "type": "Identifier", + "name": "str" + } + ] + }, + { + "type": "Function", + "alias": "u_", + "name": "upperUTF8", + "arguments": [ + { + "type": "Identifier", + "name": "str" + } + ] + }, + { + "type": "Function", + "alias": "h_", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "0x" + }, + { + "type": "Function", + "name": "hex", + "arguments": [ + { + "type": "Identifier", + "name": "str" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "str" + } + ] + }, + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l_" + }, + { + "type": "Literal", + "value_type": "String", + "value": "�" + } + ] + }, + { + "type": "Identifier", + "name": "h_" + }, + { + "type": "Identifier", + "name": "l_" + } + ] + }, + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "u_" + }, + { + "type": "Literal", + "value_type": "String", + "value": "�" + } + ] + }, + { + "type": "Identifier", + "name": "h_" + }, + { + "type": "Identifier", + "name": "u_" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "utf8_overlap" + } + } + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/e3f7c953913b17bb.sql b/tests/ast_json_fixtures/shapes/e3f7c953913b17bb.sql new file mode 100644 index 000000000000..a6e50276dab5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e3f7c953913b17bb.sql @@ -0,0 +1,2 @@ +with lowerUTF8(str) as l_, upperUTF8(str) as u_, '0x' || hex(str) as h_ +select length(str), if(l_ == '\xe2', h_, l_), if(u_ == '\xe2', h_, u_) from utf8_overlap format CSV diff --git a/tests/ast_json_fixtures/shapes/e412bab32a958751.json b/tests/ast_json_fixtures/shapes/e412bab32a958751.json new file mode 100644 index 000000000000..2cf67bf7cc64 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e412bab32a958751.json @@ -0,0 +1,151 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "result" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "result", + "name": "toStartOfFifteenMinutes", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Function", + "name": "toStartOfFifteenMinutes", + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1000.0001220703125 + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "65536" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9223372036854775807" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1048576" + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "result" + }, + "direction": "DESC", + "nulls_first": true + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/e412bab32a958751.sql b/tests/ast_json_fixtures/shapes/e412bab32a958751.sql new file mode 100644 index 000000000000..bb4a0cd8d6f5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e412bab32a958751.sql @@ -0,0 +1 @@ +SELECT DISTINCT result FROM (SELECT toStartOfFifteenMinutes(toDateTime(toStartOfFifteenMinutes(toDateTime(1000.0001220703125) + (number * 65536))) + (number * 9223372036854775807)) AS result FROM system.numbers LIMIT 1048576) ORDER BY result DESC NULLS FIRST FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/e42b70713de25410.json b/tests/ast_json_fixtures/shapes/e42b70713de25410.json new file mode 100644 index 000000000000..bf4d5920b77d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e42b70713de25410.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e42b70713de25410.sql b/tests/ast_json_fixtures/shapes/e42b70713de25410.sql new file mode 100644 index 000000000000..1c030912cde8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e42b70713de25410.sql @@ -0,0 +1,5 @@ +SELECT + *, + count() OVER () AS c +FROM numbers(10) +ORDER BY toString(number) diff --git a/tests/ast_json_fixtures/shapes/e42c5d52a95d1844.json b/tests/ast_json_fixtures/shapes/e42c5d52a95d1844.json new file mode 100644 index 000000000000..6fdca9f3bbd5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e42c5d52a95d1844.json @@ -0,0 +1,106 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "gr", + "name": "grouping", + "nulls_action": "RESPECT NULLS", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_grouping_standard_compatibility": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e42c5d52a95d1844.sql b/tests/ast_json_fixtures/shapes/e42c5d52a95d1844.sql new file mode 100644 index 000000000000..6840d01d9d87 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e42c5d52a95d1844.sql @@ -0,0 +1 @@ +SELECT number, grouping(number % 2, number) RESPECT NULLS AS gr FROM numbers(10) GROUP BY GROUPING SETS ((number), (number % 2)) SETTINGS force_grouping_standard_compatibility = 0 diff --git a/tests/ast_json_fixtures/shapes/e42f8ded43c1da38.json b/tests/ast_json_fixtures/shapes/e42f8ded43c1da38.json new file mode 100644 index 000000000000..e994fec26afe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e42f8ded43c1da38.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tt_m" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "b" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e42f8ded43c1da38.sql b/tests/ast_json_fixtures/shapes/e42f8ded43c1da38.sql new file mode 100644 index 000000000000..0b6c63b8d087 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e42f8ded43c1da38.sql @@ -0,0 +1 @@ +SELECT b, count() FROM tt_m GROUP BY b order by b diff --git a/tests/ast_json_fixtures/shapes/e4325568812f07d3.json b/tests/ast_json_fixtures/shapes/e4325568812f07d3.json new file mode 100644 index 000000000000..343538eec7c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4325568812f07d3.json @@ -0,0 +1,77 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Identifier", + "name": "c1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_validation" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Identifier", + "name": "c1" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c0" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c1" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "c1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e4325568812f07d3.sql b/tests/ast_json_fixtures/shapes/e4325568812f07d3.sql new file mode 100644 index 000000000000..8fde7da64798 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4325568812f07d3.sql @@ -0,0 +1 @@ +SELECT c0, c1 FROM test_limit_by_validation GROUP BY c0, c1 ORDER BY c0, c1 LIMIT 1 BY c1 diff --git a/tests/ast_json_fixtures/shapes/e44b99a1ad03c550.json b/tests/ast_json_fixtures/shapes/e44b99a1ad03c550.json new file mode 100644 index 000000000000..249e074f23e8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e44b99a1ad03c550.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q3_01297"], + "limits": [ + { + "duration_sec": "3600", + "max": { + "ERRORS": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e44b99a1ad03c550.sql b/tests/ast_json_fixtures/shapes/e44b99a1ad03c550.sql new file mode 100644 index 000000000000..6c86ef315c77 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e44b99a1ad03c550.sql @@ -0,0 +1 @@ +CREATE QUOTA q3_01297 FOR 1 HOUR errors MAX 5 diff --git a/tests/ast_json_fixtures/shapes/e4592000722e2685.json b/tests/ast_json_fixtures/shapes/e4592000722e2685.json new file mode 100644 index 000000000000..b22822befa45 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4592000722e2685.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "client_name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Literal", + "value_type": "String", + "value": "select 1%" + } + ] + } + ] + } + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/e4592000722e2685.sql b/tests/ast_json_fixtures/shapes/e4592000722e2685.sql new file mode 100644 index 000000000000..677da83ed095 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4592000722e2685.sql @@ -0,0 +1 @@ +select client_name from system.query_log where current_database = currentDatabase() and query like 'select 1%' format CSV diff --git a/tests/ast_json_fixtures/shapes/e469548c84940162.json b/tests/ast_json_fixtures/shapes/e469548c84940162.json new file mode 100644 index 000000000000..72890db5b4de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e469548c84940162.json @@ -0,0 +1,208 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "query", + "name": "log_comment" + }, + { + "type": "Function", + "alias": "stats_collected", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "RuntimeDataflowStatisticsInputBytes" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "alias": "pr_used", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "ParallelReplicasUsedCount" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "yesterday", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_time" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "NOW", + "arguments": [] + }, + { + "type": "Function", + "name": "toIntervalMinute", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "15" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "log_comment" + }, + { + "type": "Literal", + "value_type": "String", + "value": "03783_autopr_dataflow_cache_reuse_query_%" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryFinish" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "log_comment" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/e469548c84940162.sql b/tests/ast_json_fixtures/shapes/e469548c84940162.sql new file mode 100644 index 000000000000..f986dc5f4881 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e469548c84940162.sql @@ -0,0 +1,5 @@ +SELECT log_comment query, ProfileEvents['RuntimeDataflowStatisticsInputBytes'] > 0 stats_collected, ProfileEvents['ParallelReplicasUsedCount'] > 0 pr_used +FROM system.query_log +WHERE (event_date >= yesterday()) AND (event_time >= (NOW() - toIntervalMinute(15))) AND (current_database = currentDatabase()) AND (log_comment LIKE '03783_autopr_dataflow_cache_reuse_query_%') AND (type = 'QueryFinish') +ORDER BY log_comment +FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/e4699cf1af94a151.json b/tests/ast_json_fixtures/shapes/e4699cf1af94a151.json new file mode 100644 index 000000000000..61df627469b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4699cf1af94a151.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectIntersectExceptQuery", + "operator": "INTERSECT ALL", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e4699cf1af94a151.sql b/tests/ast_json_fixtures/shapes/e4699cf1af94a151.sql new file mode 100644 index 000000000000..56c2bc926e89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4699cf1af94a151.sql @@ -0,0 +1 @@ +SELECT 1 INTERSECT SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/e478944db8f6e66f.json b/tests/ast_json_fixtures/shapes/e478944db8f6e66f.json new file mode 100644 index 000000000000..f9191ecea154 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e478944db8f6e66f.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_path" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03741_data" + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e478944db8f6e66f.sql b/tests/ast_json_fixtures/shapes/e478944db8f6e66f.sql new file mode 100644 index 000000000000..87449976768f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e478944db8f6e66f.sql @@ -0,0 +1 @@ +SELECT _path, count() FROM 03741_data GROUP BY 1 ORDER BY 1 diff --git a/tests/ast_json_fixtures/shapes/e47980927b898ff4.json b/tests/ast_json_fixtures/shapes/e47980927b898ff4.json new file mode 100644 index 000000000000..6335c22d1d69 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e47980927b898ff4.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "n.null", + "name_parts": ["n", "null"] + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_move_to_prewhere": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e47980927b898ff4.sql b/tests/ast_json_fixtures/shapes/e47980927b898ff4.sql new file mode 100644 index 000000000000..84f34774c341 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e47980927b898ff4.sql @@ -0,0 +1 @@ +select * from test where n.null settings optimize_move_to_prewhere=0 diff --git a/tests/ast_json_fixtures/shapes/e4847542dafefe09.json b/tests/ast_json_fixtures/shapes/e4847542dafefe09.json new file mode 100644 index 000000000000..c30cce22c4d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4847542dafefe09.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3646616306303" + } + ] + } + ] + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/e4847542dafefe09.sql b/tests/ast_json_fixtures/shapes/e4847542dafefe09.sql new file mode 100644 index 000000000000..18770e6d0996 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4847542dafefe09.sql @@ -0,0 +1 @@ +SELECT toNullable(3646616306303) FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/e4aa0f0dfdab1b24.json b/tests/ast_json_fixtures/shapes/e4aa0f0dfdab1b24.json new file mode 100644 index 000000000000..4d7c3b5fb7a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4aa0f0dfdab1b24.json @@ -0,0 +1,105 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "current_database", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.1,127.0.0.2" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/e4aa0f0dfdab1b24.sql b/tests/ast_json_fixtures/shapes/e4aa0f0dfdab1b24.sql new file mode 100644 index 000000000000..d03b8d5d31fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4aa0f0dfdab1b24.sql @@ -0,0 +1,10 @@ +SELECT + concat(current_database(), '') +FROM +( + SELECT id + FROM remote('127.0.0.1,127.0.0.2', currentDatabase(), test) + LIMIT 0.2 +) +ORDER BY ALL +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/e4e12bbab858d94b.json b/tests/ast_json_fixtures/shapes/e4e12bbab858d94b.json new file mode 100644 index 000000000000..d074cd57c95b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4e12bbab858d94b.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Identifier", + "name": "system" + }, + { + "type": "Identifier", + "name": "tables" + } + ] + } + }, + "as_database": "system", + "as_table": "tables" + } +} diff --git a/tests/ast_json_fixtures/shapes/e4e12bbab858d94b.sql b/tests/ast_json_fixtures/shapes/e4e12bbab858d94b.sql new file mode 100644 index 000000000000..946c634282c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4e12bbab858d94b.sql @@ -0,0 +1 @@ +CREATE TABLE table2 AS system.tables ENGINE = Distributed('test_shard_localhost', system, tables) diff --git a/tests/ast_json_fixtures/shapes/e4e27a23cf85126a.json b/tests/ast_json_fixtures/shapes/e4e27a23cf85126a.json new file mode 100644 index 000000000000..1275894e98a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4e27a23cf85126a.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Identifier", + "name": "data1622.json" + }, + { + "type": "Identifier", + "name": "TSV" + }, + { + "type": "Identifier", + "name": "value String" + } + ] + }, + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/e4e27a23cf85126a.sql b/tests/ast_json_fixtures/shapes/e4e27a23cf85126a.sql new file mode 100644 index 000000000000..1cc93d6856d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4e27a23cf85126a.sql @@ -0,0 +1 @@ +insert into table function file("data1622.json", "TSV", "value String") VALUES ('{"a":1}') diff --git a/tests/ast_json_fixtures/shapes/e4f2b552481aff4d.json b/tests/ast_json_fixtures/shapes/e4f2b552481aff4d.json new file mode 100644 index 000000000000..27085e002425 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4f2b552481aff4d.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e4f2b552481aff4d.sql b/tests/ast_json_fixtures/shapes/e4f2b552481aff4d.sql new file mode 100644 index 000000000000..fc16cfb9cac9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4f2b552481aff4d.sql @@ -0,0 +1 @@ +select toUInt64(1) union all select countIf(n>0) from (select 2 as n) diff --git a/tests/ast_json_fixtures/shapes/e4f623c254aed842.json b/tests/ast_json_fixtures/shapes/e4f623c254aed842.json new file mode 100644 index 000000000000..cf8ace3fb15a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4f623c254aed842.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_shard_localhost", + "database": { + "type": "Identifier", + "name": "test_01148_atomic" + }, + "table": { + "type": "Identifier", + "name": "rmt2" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "n" + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "n" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e4f623c254aed842.sql b/tests/ast_json_fixtures/shapes/e4f623c254aed842.sql new file mode 100644 index 000000000000..0d749f6ef5db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e4f623c254aed842.sql @@ -0,0 +1 @@ +CREATE TABLE test_01148_atomic.rmt2 ON CLUSTER test_shard_localhost (n int, PRIMARY KEY n) ENGINE=ReplicatedMergeTree diff --git a/tests/ast_json_fixtures/shapes/e52be7bba7f4b7fc.json b/tests/ast_json_fixtures/shapes/e52be7bba7f4b7fc.json new file mode 100644 index 000000000000..aac3fc6e8074 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e52be7bba7f4b7fc.json @@ -0,0 +1,480 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "x", + "value_type": "String", + "value": "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + }, + { + "type": "Function", + "alias": "spaces", + "name": "replaceRegexpAll", + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "String", + "value": "." + }, + { + "type": "Literal", + "value_type": "String", + "value": " " + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Identifier", + "name": "spaces" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "62" + } + ] + } + ] + }, + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "62" + } + ] + } + ] + }, + { + "type": "Function", + "name": "substring", + "arguments": [ + { + "type": "Identifier", + "name": "spaces" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "62" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "sl", + "name": "trimLeft", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Function", + "alias": "sr", + "name": "trimRight", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Function", + "alias": "t", + "name": "trimBoth", + "arguments": [ + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Function", + "alias": "slr", + "name": "replaceRegexpOne", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "^ +" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Function", + "alias": "srr", + "name": "replaceRegexpOne", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": " +$" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Function", + "alias": "tr", + "name": "replaceRegexpOne", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": "^ *(.*?) *$" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\\1" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "replaceAll", + "arguments": [ + { + "type": "Identifier", + "name": "s" + }, + { + "type": "Literal", + "value_type": "String", + "value": " " + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + } + ] + }, + { + "type": "Function", + "name": "replaceAll", + "arguments": [ + { + "type": "Identifier", + "name": "sl" + }, + { + "type": "Literal", + "value_type": "String", + "value": " " + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + } + ] + }, + { + "type": "Function", + "name": "replaceAll", + "arguments": [ + { + "type": "Identifier", + "name": "slr" + }, + { + "type": "Literal", + "value_type": "String", + "value": " " + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + } + ] + }, + { + "type": "Function", + "name": "replaceAll", + "arguments": [ + { + "type": "Identifier", + "name": "sr" + }, + { + "type": "Literal", + "value_type": "String", + "value": " " + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + } + ] + }, + { + "type": "Function", + "name": "replaceAll", + "arguments": [ + { + "type": "Identifier", + "name": "srr" + }, + { + "type": "Literal", + "value_type": "String", + "value": " " + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + } + ] + }, + { + "type": "Function", + "name": "replaceAll", + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Literal", + "value_type": "String", + "value": " " + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + } + ] + }, + { + "type": "Function", + "name": "replaceAll", + "arguments": [ + { + "type": "Identifier", + "name": "tr" + }, + { + "type": "Literal", + "value_type": "String", + "value": " " + }, + { + "type": "Literal", + "value_type": "String", + "value": "_" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "sl" + }, + { + "type": "Identifier", + "name": "slr" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "sr" + }, + { + "type": "Identifier", + "name": "srr" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t" + }, + { + "type": "Identifier", + "name": "tr" + } + ] + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e52be7bba7f4b7fc.sql b/tests/ast_json_fixtures/shapes/e52be7bba7f4b7fc.sql new file mode 100644 index 000000000000..7519877ec5eb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e52be7bba7f4b7fc.sql @@ -0,0 +1,20 @@ +WITH + '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' AS x, + replaceRegexpAll(x, '.', ' ') AS spaces, + concat(substring(spaces, 1, rand(1) % 62), substring(x, 1, rand(2) % 62), substring(spaces, 1, rand(3) % 62)) AS s, + trimLeft(s) AS sl, + trimRight(s) AS sr, + trimBoth(s) AS t, + replaceRegexpOne(s, '^ +', '') AS slr, + replaceRegexpOne(s, ' +$', '') AS srr, + replaceRegexpOne(s, '^ *(.*?) *$', '\\1') AS tr +SELECT + replaceAll(s, ' ', '_'), + replaceAll(sl, ' ', '_'), + replaceAll(slr, ' ', '_'), + replaceAll(sr, ' ', '_'), + replaceAll(srr, ' ', '_'), + replaceAll(t, ' ', '_'), + replaceAll(tr, ' ', '_') +FROM numbers(100000) +WHERE NOT ((sl = slr) AND (sr = srr) AND (t = tr)) diff --git a/tests/ast_json_fixtures/shapes/e536996329678dea.json b/tests/ast_json_fixtures/shapes/e536996329678dea.json new file mode 100644 index 000000000000..d8db7eb92bba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e536996329678dea.json @@ -0,0 +1,140 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "u_value", + "name": "tup.u", + "name_parts": ["tup", "u"] + }, + { + "type": "Function", + "alias": "cnt", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "alias": "total_n", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "avg_n", + "name": "avg", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "ids", + "name": "groupArray", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tuple_test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tup" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "tup.u", + "name_parts": ["tup", "u"] + } + ], + "having": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cnt" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "avg_n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "200" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "u_value" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e536996329678dea.sql b/tests/ast_json_fixtures/shapes/e536996329678dea.sql new file mode 100644 index 000000000000..0c63c3f914f4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e536996329678dea.sql @@ -0,0 +1,11 @@ +SELECT + tup.u as u_value, + count() as cnt, + sum(n) as total_n, + avg(n) as avg_n, + groupArray(id) as ids +FROM tuple_test +WHERE tup IS NOT NULL +GROUP BY tup.u +HAVING cnt > 0 AND avg_n > 200 +ORDER BY u_value diff --git a/tests/ast_json_fixtures/shapes/e54569cd6dceabe9.json b/tests/ast_json_fixtures/shapes/e54569cd6dceabe9.json new file mode 100644 index 000000000000..4026f0610971 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e54569cd6dceabe9.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e54569cd6dceabe9.sql b/tests/ast_json_fixtures/shapes/e54569cd6dceabe9.sql new file mode 100644 index 000000000000..21f37ce6a99f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e54569cd6dceabe9.sql @@ -0,0 +1,3 @@ +select 0 as x +from remote('127.0.0.{1,2}', system.one) +group by x diff --git a/tests/ast_json_fixtures/shapes/e54badc8337130ad.json b/tests/ast_json_fixtures/shapes/e54badc8337130ad.json new file mode 100644 index 000000000000..5ddc68634154 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e54badc8337130ad.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_ordinary", + "from_table": "src", + "to_database": "test_01155_atomic", + "to_table": "src" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e54badc8337130ad.sql b/tests/ast_json_fixtures/shapes/e54badc8337130ad.sql new file mode 100644 index 000000000000..81a842351cba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e54badc8337130ad.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_ordinary.src TO test_01155_atomic.src diff --git a/tests/ast_json_fixtures/shapes/e5525d448ca2bbeb.json b/tests/ast_json_fixtures/shapes/e5525d448ca2bbeb.json new file mode 100644 index 000000000000..ad1302d16684 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5525d448ca2bbeb.json @@ -0,0 +1,192 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "alias": "alias_value", + "name": "value" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table__fuzz_4" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "arguments": [ + { + "type": "Identifier", + "alias": "alias_value", + "name": "value" + }, + { + "type": "Identifier", + "name": "alias272.value", + "name_parts": ["alias272", "value"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "alias272", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "isNullable", + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "38" + } + ] + } + ] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table__fuzz_2" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "less", + "arguments": [ + { + "type": "Function", + "alias": "alias174", + "name": "toNullable", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "38" + } + ] + }, + { + "type": "Function", + "name": "assumeNotNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "equals", + "arguments": [ + { + "type": "Function", + "name": "isZeroOrNull", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "toUInt128", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "38" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e5525d448ca2bbeb.sql b/tests/ast_json_fixtures/shapes/e5525d448ca2bbeb.sql new file mode 100644 index 000000000000..895ec1f0b3e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5525d448ca2bbeb.sql @@ -0,0 +1 @@ +SELECT value AS alias_value FROM test_table__fuzz_4 INNER JOIN (SELECT isNullable(isNotNull(38)), * FROM test_table__fuzz_2) AS alias272 ON equals(value AS alias_value, alias272.value) GROUP BY less(toNullable(38) AS alias174, assumeNotNull(2)), 1, equals(isZeroOrNull(1), toUInt128(materialize(toNullable(toUInt128(38))))) WITH CUBE WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/e55445c480cd0f1c.json b/tests/ast_json_fixtures/shapes/e55445c480cd0f1c.json new file mode 100644 index 000000000000..accd638aa4cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e55445c480cd0f1c.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_01247" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01247" + }, + { + "type": "Identifier", + "name": "key" + } + ] + } + }, + "as_table": "data_01247" + } +} diff --git a/tests/ast_json_fixtures/shapes/e55445c480cd0f1c.sql b/tests/ast_json_fixtures/shapes/e55445c480cd0f1c.sql new file mode 100644 index 000000000000..c298e39c3552 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e55445c480cd0f1c.sql @@ -0,0 +1 @@ +create table dist_01247 as data_01247 engine=Distributed(test_cluster_two_shards, currentDatabase(), data_01247, key) diff --git a/tests/ast_json_fixtures/shapes/e57ea51dc60a5219.json b/tests/ast_json_fixtures/shapes/e57ea51dc60a5219.json new file mode 100644 index 000000000000..0ca86479fc85 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e57ea51dc60a5219.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "set", + "to_table": "set2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e57ea51dc60a5219.sql b/tests/ast_json_fixtures/shapes/e57ea51dc60a5219.sql new file mode 100644 index 000000000000..9816519a320a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e57ea51dc60a5219.sql @@ -0,0 +1 @@ +RENAME TABLE set TO set2 diff --git a/tests/ast_json_fixtures/shapes/e59441ca770ffaac.json b/tests/ast_json_fixtures/shapes/e59441ca770ffaac.json new file mode 100644 index 000000000000..fb186c36ca0a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e59441ca770ffaac.json @@ -0,0 +1,154 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2,3}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "globalIn", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Dynamic" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + }, + { + "type": "TablesInSelectQueryElement", + "array_join": { + "type": "ArrayJoin", + "kind": "INNER", + "expressions": [ + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + ] + } + } + ] + } + } + ] + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_lazy_columns_replication": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/e59441ca770ffaac.sql b/tests/ast_json_fixtures/shapes/e59441ca770ffaac.sql new file mode 100644 index 000000000000..a949a3dfa686 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e59441ca770ffaac.sql @@ -0,0 +1 @@ +select * from remote('127.0.0.{1,2,3}', numbers(100)) where number global in (select number::Dynamic from numbers(100) array Join range(number % 10)) limit 100 format Null settings enable_lazy_columns_replication=1 diff --git a/tests/ast_json_fixtures/shapes/e596a9df1661c6ad.json b/tests/ast_json_fixtures/shapes/e596a9df1661c6ad.json new file mode 100644 index 000000000000..8164ecfab224 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e596a9df1661c6ad.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01247" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e596a9df1661c6ad.sql b/tests/ast_json_fixtures/shapes/e596a9df1661c6ad.sql new file mode 100644 index 000000000000..a9895329ac5a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e596a9df1661c6ad.sql @@ -0,0 +1 @@ +select count(), * from dist_01247 group by number with cube diff --git a/tests/ast_json_fixtures/shapes/e5bd1e165521511b.json b/tests/ast_json_fixtures/shapes/e5bd1e165521511b.json new file mode 100644 index 000000000000..bccdaa26321a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5bd1e165521511b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "USER", + "names": ["test_user_02867"] + } +} diff --git a/tests/ast_json_fixtures/shapes/e5bd1e165521511b.sql b/tests/ast_json_fixtures/shapes/e5bd1e165521511b.sql new file mode 100644 index 000000000000..91c1c8c89e46 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5bd1e165521511b.sql @@ -0,0 +1 @@ +SHOW CREATE USER test_user_02867 diff --git a/tests/ast_json_fixtures/shapes/e5d04694daaa6ca1.json b/tests/ast_json_fixtures/shapes/e5d04694daaa6ca1.json new file mode 100644 index 000000000000..2aafc5ba2679 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5d04694daaa6ca1.json @@ -0,0 +1,80 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN PIPELINE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + }, + "final": true + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v1" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "now", + "arguments": [] + }, + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "180" + } + ] + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "2", + "max_final_threads": "2", + "force_data_skipping_indices": "v1_index", + "use_skip_indexes_if_final": "0" + } + } + } + ] + }, + "format": "LineAsString" + } +} diff --git a/tests/ast_json_fixtures/shapes/e5d04694daaa6ca1.sql b/tests/ast_json_fixtures/shapes/e5d04694daaa6ca1.sql new file mode 100644 index 000000000000..291aee4a7cbd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5d04694daaa6ca1.sql @@ -0,0 +1,3 @@ +EXPLAIN PIPELINE SELECT * FROM data FINAL WHERE v1 >= now() - INTERVAL 180 DAY +SETTINGS max_threads=2, max_final_threads=2, force_data_skipping_indices='v1_index', use_skip_indexes_if_final=0 +FORMAT LineAsString diff --git a/tests/ast_json_fixtures/shapes/e5e65d8b41a7078e.json b/tests/ast_json_fixtures/shapes/e5e65d8b41a7078e.json new file mode 100644 index 000000000000..c2b978107495 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5e65d8b41a7078e.json @@ -0,0 +1,294 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "alias": "path", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "[]" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Array(UInt64)" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "tree.id", + "name_parts": ["tree", "id"] + }, + { + "type": "Function", + "name": "arrayConcat", + "arguments": [ + { + "type": "Identifier", + "name": "t.path", + "name_parts": ["t", "path"] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tree.id", + "name_parts": ["tree", "id"] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tree" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tree.parent_id", + "name_parts": ["tree", "parent_id"] + }, + { + "type": "Identifier", + "name": "t.id", + "name_parts": ["t", "id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "t1.id", + "name_parts": ["t1", "id"] + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Identifier", + "name": "t2.path", + "name_parts": ["t2", "path"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.path", + "name_parts": ["t1", "path"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t2.path", + "name_parts": ["t2", "path"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "t1.path", + "name_parts": ["t1", "path"] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "t2.path", + "name_parts": ["t2", "path"] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t2", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "t1.id", + "name_parts": ["t1", "id"] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.id", + "name_parts": ["t1", "id"] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e5e65d8b41a7078e.sql b/tests/ast_json_fixtures/shapes/e5e65d8b41a7078e.sql new file mode 100644 index 000000000000..51a17554bf20 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5e65d8b41a7078e.sql @@ -0,0 +1,12 @@ +WITH RECURSIVE t AS ( + SELECT 1 AS id, []::Array(UInt64) AS path +UNION ALL + SELECT tree.id, arrayConcat(t.path, [tree.id]) + FROM tree JOIN t ON (tree.parent_id = t.id) +) +SELECT t1.id, count(t2.path) FROM t AS t1 JOIN t AS t2 ON + (t1.path[1] = t2.path[1] AND + length(t1.path) = 1 AND + length(t2.path) > 1) + GROUP BY t1.id + ORDER BY t1.id diff --git a/tests/ast_json_fixtures/shapes/e5f8e9dc426e7f87.json b/tests/ast_json_fixtures/shapes/e5f8e9dc426e7f87.json new file mode 100644 index 000000000000..be592e3a5e62 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5f8e9dc426e7f87.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["test_01605"] + } +} diff --git a/tests/ast_json_fixtures/shapes/e5f8e9dc426e7f87.sql b/tests/ast_json_fixtures/shapes/e5f8e9dc426e7f87.sql new file mode 100644 index 000000000000..a810ca416cdf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5f8e9dc426e7f87.sql @@ -0,0 +1 @@ +DROP USER 'test_01605' diff --git a/tests/ast_json_fixtures/shapes/e5fa5cb88b3efaa3.json b/tests/ast_json_fixtures/shapes/e5fa5cb88b3efaa3.json new file mode 100644 index 000000000000..dcde6de74622 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5fa5cb88b3efaa3.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "dictionary": true, + "elements": [ + { + "from_database": "test_01191", + "from_table": "table", + "to_database": "test_01191", + "to_table": "table1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e5fa5cb88b3efaa3.sql b/tests/ast_json_fixtures/shapes/e5fa5cb88b3efaa3.sql new file mode 100644 index 000000000000..e3fd3f03a884 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e5fa5cb88b3efaa3.sql @@ -0,0 +1 @@ +RENAME DICTIONARY test_01191.table TO test_01191.table1 diff --git a/tests/ast_json_fixtures/shapes/e60579fd2a892bba.json b/tests/ast_json_fixtures/shapes/e60579fd2a892bba.json new file mode 100644 index 000000000000..5e7e6637e6c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e60579fd2a892bba.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + ], + "format": "PrettyMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/e60579fd2a892bba.sql b/tests/ast_json_fixtures/shapes/e60579fd2a892bba.sql new file mode 100644 index 000000000000..b38accc28c41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e60579fd2a892bba.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a FORMAT PrettyMonoBlock diff --git a/tests/ast_json_fixtures/shapes/e6139489defbdb5c.json b/tests/ast_json_fixtures/shapes/e6139489defbdb5c.json new file mode 100644 index 000000000000..b678d70354ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e6139489defbdb5c.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "schema_inference_mode" + }, + { + "type": "Function", + "alias": "file", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "splitByChar", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/" + }, + { + "type": "Identifier", + "name": "source" + } + ] + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + }, + { + "type": "Identifier", + "name": "schema" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "schema_inference_cache", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "file" + }, + { + "type": "Literal", + "value_type": "String", + "value": "03036_archive1.zip::example1.csv" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "file" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e6139489defbdb5c.sql b/tests/ast_json_fixtures/shapes/e6139489defbdb5c.sql new file mode 100644 index 000000000000..c86c12420c42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e6139489defbdb5c.sql @@ -0,0 +1 @@ +SELECT schema_inference_mode, splitByChar('/', source)[-1] as file, schema FROM system.schema_inference_cache WHERE file = '03036_archive1.zip::example1.csv' ORDER BY file diff --git a/tests/ast_json_fixtures/shapes/e61af3769d5948ec.json b/tests/ast_json_fixtures/shapes/e61af3769d5948ec.json new file mode 100644 index 000000000000..bfc2c3992711 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e61af3769d5948ec.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r5_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/e61af3769d5948ec.sql b/tests/ast_json_fixtures/shapes/e61af3769d5948ec.sql new file mode 100644 index 000000000000..f6a32438dae1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e61af3769d5948ec.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r5_01293 diff --git a/tests/ast_json_fixtures/shapes/e635f91774cab16f.json b/tests/ast_json_fixtures/shapes/e635f91774cab16f.json new file mode 100644 index 000000000000..247344ab8336 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e635f91774cab16f.json @@ -0,0 +1,459 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "b.c", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "a", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "4" + }, + { + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Literal", + "alias": "u", + "value_type": "UInt64", + "value": "6" + }, + { + "type": "Literal", + "alias": "v", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "alias": "d", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "e", + "value_type": "Bool", + "value": true + }, + { + "type": "Literal", + "alias": "f", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "g", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "alias": "h", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "i", + "value_type": "String", + "value": "Hello" + }, + { + "type": "Literal", + "alias": "j", + "value_type": "String", + "value": "World" + }, + { + "type": "Literal", + "alias": "w", + "value_type": "String", + "value": "hi" + }, + { + "type": "Literal", + "alias": "k", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "alias": "l", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "alias": "m", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "n", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Function", + "alias": "o", + "name": "array", + "is_operator": true, + "arguments": [] + }, + { + "type": "Literal", + "alias": "p", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "alias": "q", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "alias": "r", + "name": "q" + }, + { + "type": "Literal", + "alias": "s", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "t", + "value_type": "UInt64", + "value": "1" + } + ], + "select": [ + { + "type": "Function", + "alias": "upyachka", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toIntervalMinute", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "caseWithExpression", + "arguments": [ + { + "type": "Function", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "intDiv", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b.c" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "u" + } + ] + }, + { + "type": "Identifier", + "name": "v" + } + ] + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "e" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "f" + }, + { + "type": "Identifier", + "name": "g" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "f" + }, + { + "type": "Identifier", + "name": "h" + } + ] + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Identifier", + "name": "j" + } + ] + }, + { + "type": "Identifier", + "name": "w" + }, + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "l" + }, + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "m" + }, + { + "type": "Identifier", + "name": "n" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "o" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Array(INT)" + } + ] + }, + { + "type": "Identifier", + "name": "p" + } + ] + }, + { + "type": "Identifier", + "name": "q" + } + ] + }, + { + "type": "Identifier", + "name": "r" + } + ] + }, + { + "type": "Identifier", + "name": "s" + } + ] + }, + { + "type": "Identifier", + "name": "t" + } + ] + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e635f91774cab16f.sql b/tests/ast_json_fixtures/shapes/e635f91774cab16f.sql new file mode 100644 index 000000000000..fcb27fd651fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e635f91774cab16f.sql @@ -0,0 +1,2 @@ +WITH 2 AS `b.c`, [4, 5] AS a, 6 AS u, 3 AS v, 2 AS d, TRUE AS e, 1 AS f, 0 AS g, 2 AS h, 'Hello' AS i, 'World' AS j, 'hi' AS w, NULL AS k, (1, 2) AS l, 2 AS m, 3 AS n, [] AS o, [1] AS p, 1 AS q, q AS r, 1 AS s, 1 AS t +SELECT INTERVAL CASE CASE WHEN NOT -a[`b.c`] * u DIV v + d IS NOT NULL AND e OR f BETWEEN g AND h THEN i ELSE j END WHEN w THEN k END || [l, (m, n)] MINUTE IS NULL OR NOT o::Array(INT) = p <> q < r > s != t AS upyachka diff --git a/tests/ast_json_fixtures/shapes/e668b1ababb9fe94.json b/tests/ast_json_fixtures/shapes/e668b1ababb9fe94.json new file mode 100644 index 000000000000..4b074d4f8459 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e668b1ababb9fe94.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r3_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "value": "5000000" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e668b1ababb9fe94.sql b/tests/ast_json_fixtures/shapes/e668b1ababb9fe94.sql new file mode 100644 index 000000000000..cad9d1f7b0c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e668b1ababb9fe94.sql @@ -0,0 +1 @@ +CREATE ROLE r3_01293 SETTINGS max_memory_usage=5000000 diff --git a/tests/ast_json_fixtures/shapes/e66ee15a41ee5c8b.json b/tests/ast_json_fixtures/shapes/e66ee15a41ee5c8b.json new file mode 100644 index 000000000000..cedeb66332ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e66ee15a41ee5c8b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "show_settings": true, + "like": "send_timeout" + } +} diff --git a/tests/ast_json_fixtures/shapes/e66ee15a41ee5c8b.sql b/tests/ast_json_fixtures/shapes/e66ee15a41ee5c8b.sql new file mode 100644 index 000000000000..2dfab3d0c1be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e66ee15a41ee5c8b.sql @@ -0,0 +1 @@ +show settings like 'send_timeout' diff --git a/tests/ast_json_fixtures/shapes/e68216b0f79e1bb3.json b/tests/ast_json_fixtures/shapes/e68216b0f79e1bb3.json new file mode 100644 index 000000000000..25ad5348e4f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e68216b0f79e1bb3.json @@ -0,0 +1,134 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "lon", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "180" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "lon" + }, + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Function", + "alias": "err", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greatCircleAngle", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Identifier", + "name": "lon" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "abs", + "arguments": [ + { + "type": "Identifier", + "name": "lon" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "360" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "abs", + "arguments": [ + { + "type": "Identifier", + "name": "err" + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.01 + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e68216b0f79e1bb3.sql b/tests/ast_json_fixtures/shapes/e68216b0f79e1bb3.sql new file mode 100644 index 000000000000..ab727a1a5d57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e68216b0f79e1bb3.sql @@ -0,0 +1 @@ +WITH number - 180 AS lon SELECT lon, round(greatCircleAngle(0, 0, lon, 0) - abs(lon) AS err, 2) FROM numbers(360) WHERE abs(err) > 0.01 diff --git a/tests/ast_json_fixtures/shapes/e684ae988278226f.json b/tests/ast_json_fixtures/shapes/e684ae988278226f.json new file mode 100644 index 000000000000..b53f02e1d4c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e684ae988278226f.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q1_01297"], + "key_type": "USER_NAME", + "limits": [ + { + "duration_sec": "60", + "max": { + "QUERY_SELECTS": "1" + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e684ae988278226f.sql b/tests/ast_json_fixtures/shapes/e684ae988278226f.sql new file mode 100644 index 000000000000..055d375715f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e684ae988278226f.sql @@ -0,0 +1 @@ +CREATE QUOTA q1_01297 KEYED BY user_name FOR INTERVAL 1 minute MAX query_selects = 1 TO r1_01297 diff --git a/tests/ast_json_fixtures/shapes/e687d120be49470c.json b/tests/ast_json_fixtures/shapes/e687d120be49470c.json new file mode 100644 index 000000000000..3abff6409078 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e687d120be49470c.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_ALL", + "selects": [ + { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "uuid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "uuid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "uuid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e687d120be49470c.sql b/tests/ast_json_fixtures/shapes/e687d120be49470c.sql new file mode 100644 index 000000000000..ace78541b84d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e687d120be49470c.sql @@ -0,0 +1 @@ +select uuid from test union distinct select uuid from test union all select uuid from test where name = '1' diff --git a/tests/ast_json_fixtures/shapes/e699a7674c4724fc.json b/tests/ast_json_fixtures/shapes/e699a7674c4724fc.json new file mode 100644 index 000000000000..1664ce7a68fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e699a7674c4724fc.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "dummy" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "dummy" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e699a7674c4724fc.sql b/tests/ast_json_fixtures/shapes/e699a7674c4724fc.sql new file mode 100644 index 000000000000..87194f7085d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e699a7674c4724fc.sql @@ -0,0 +1 @@ +SELECT dummy, count() GROUP BY dummy WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/e6d5fd22f6bcd80d.json b/tests/ast_json_fixtures/shapes/e6d5fd22f6bcd80d.json new file mode 100644 index 000000000000..1d4cbb1ef6de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e6d5fd22f6bcd80d.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "quantile", + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "now", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime('UTC')" + } + ] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + } + ] + } + ], + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e6d5fd22f6bcd80d.sql b/tests/ast_json_fixtures/shapes/e6d5fd22f6bcd80d.sql new file mode 100644 index 000000000000..7f9d3a7e54d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e6d5fd22f6bcd80d.sql @@ -0,0 +1 @@ +SELECT quantile(0.5)(now()::DateTime('UTC')) WHERE 0 WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/e6d6a964ec785ffc.json b/tests/ast_json_fixtures/shapes/e6d6a964ec785ffc.json new file mode 100644 index 000000000000..57c6f26192b0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e6d6a964ec785ffc.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "tab.with.dots" + } +} diff --git a/tests/ast_json_fixtures/shapes/e6d6a964ec785ffc.sql b/tests/ast_json_fixtures/shapes/e6d6a964ec785ffc.sql new file mode 100644 index 000000000000..b25d2cd323a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e6d6a964ec785ffc.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM `tab.with.dots` diff --git a/tests/ast_json_fixtures/shapes/e6de6161056b8da4.json b/tests/ast_json_fixtures/shapes/e6de6161056b8da4.json new file mode 100644 index 000000000000..fae45553da2c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e6de6161056b8da4.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "m", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "map", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "foo" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "bar" + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "3" + }, + { + "value_type": "UInt64", + "value": "4" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Map(String, Tuple(a UInt64, b UInt64))" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "m.keys", + "name_parts": ["m", "keys"] + }, + { + "type": "Identifier", + "name": "m.values", + "name_parts": ["m", "values"] + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "m.values", + "name_parts": ["m", "values"] + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e6de6161056b8da4.sql b/tests/ast_json_fixtures/shapes/e6de6161056b8da4.sql new file mode 100644 index 000000000000..216b0dd31c00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e6de6161056b8da4.sql @@ -0,0 +1,2 @@ +WITH map('foo', (1, 2), 'bar', (3, 4))::Map(String, Tuple(a UInt64, b UInt64)) AS m +SELECT m.keys, m.values, m.values.* diff --git a/tests/ast_json_fixtures/shapes/e6e41fb52f7ede95.json b/tests/ast_json_fixtures/shapes/e6e41fb52f7ede95.json new file mode 100644 index 000000000000..58a130afc295 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e6e41fb52f7ede95.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t0" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_PROJECTION", + "projection_declaration": { + "type": "Projection", + "name": "x", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Identifier", + "name": "i" + } + ], + "order_by": [ + { + "type": "Identifier", + "name": "i" + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e6e41fb52f7ede95.sql b/tests/ast_json_fixtures/shapes/e6e41fb52f7ede95.sql new file mode 100644 index 000000000000..1df2ac170536 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e6e41fb52f7ede95.sql @@ -0,0 +1 @@ +ALTER TABLE t0 ADD PROJECTION x (SELECT i ORDER BY i) SETTINGS mutations_sync = 2 diff --git a/tests/ast_json_fixtures/shapes/e73264b575fd213e.json b/tests/ast_json_fixtures/shapes/e73264b575fd213e.json new file mode 100644 index 000000000000..bc705295df10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e73264b575fd213e.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "m2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_primary_key": "1", + "max_bytes_to_read": "64" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e73264b575fd213e.sql b/tests/ast_json_fixtures/shapes/e73264b575fd213e.sql new file mode 100644 index 000000000000..a61fab5dd324 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e73264b575fd213e.sql @@ -0,0 +1 @@ +SELECT * FROM m2 WHERE id > 1 AND id < 5 ORDER BY id SETTINGS force_primary_key=1, max_bytes_to_read=64 diff --git a/tests/ast_json_fixtures/shapes/e73d7bfbb00b803b.json b/tests/ast_json_fixtures/shapes/e73d7bfbb00b803b.json new file mode 100644 index 000000000000..f8a6570789bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e73d7bfbb00b803b.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "getSetting", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "max_block_size" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "1" + } + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "3" + } + }, + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/e73d7bfbb00b803b.sql b/tests/ast_json_fixtures/shapes/e73d7bfbb00b803b.sql new file mode 100644 index 000000000000..e1c4007c007d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e73d7bfbb00b803b.sql @@ -0,0 +1 @@ +SELECT getSetting('max_block_size') SETTINGS max_block_size = 1 FORMAT TSV SETTINGS max_block_size = 3 diff --git a/tests/ast_json_fixtures/shapes/e7507082c2153858.json b/tests/ast_json_fixtures/shapes/e7507082c2153858.json new file mode 100644 index 000000000000..b98bdf06f015 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7507082c2153858.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "x", + "name": "neighbor", + "arguments": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "name": "toInt64", + "arguments": [ + { + "type": "Function", + "name": "rand64", + "arguments": [] + } + ] + } + ] + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e7507082c2153858.sql b/tests/ast_json_fixtures/shapes/e7507082c2153858.sql new file mode 100644 index 000000000000..a29d040402ff --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7507082c2153858.sql @@ -0,0 +1 @@ +WITH neighbor(toString(number), toInt64(rand64())) AS x SELECT * FROM system.numbers WHERE NOT ignore(x) diff --git a/tests/ast_json_fixtures/shapes/e7658a4eab9eb1d9.json b/tests/ast_json_fixtures/shapes/e7658a4eab9eb1d9.json new file mode 100644 index 000000000000..a90b288ec086 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7658a4eab9eb1d9.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "s" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "prewhere": { + "type": "Identifier", + "name": "e" + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e7658a4eab9eb1d9.sql b/tests/ast_json_fixtures/shapes/e7658a4eab9eb1d9.sql new file mode 100644 index 000000000000..14d88931ef68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7658a4eab9eb1d9.sql @@ -0,0 +1 @@ +SELECT s FROM t1 PREWHERE e WHERE (e = 1) diff --git a/tests/ast_json_fixtures/shapes/e76db3d78ca1a822.json b/tests/ast_json_fixtures/shapes/e76db3d78ca1a822.json new file mode 100644 index 000000000000..bfd721428e96 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e76db3d78ca1a822.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02148_test_function" + } +} diff --git a/tests/ast_json_fixtures/shapes/e76db3d78ca1a822.sql b/tests/ast_json_fixtures/shapes/e76db3d78ca1a822.sql new file mode 100644 index 000000000000..48273754d53d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e76db3d78ca1a822.sql @@ -0,0 +1 @@ +DROP FUNCTION 02148_test_function diff --git a/tests/ast_json_fixtures/shapes/e76de278f0e9e881.json b/tests/ast_json_fixtures/shapes/e76de278f0e9e881.json new file mode 100644 index 000000000000..3eff6be6a066 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e76de278f0e9e881.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "bar", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toLowCardinality", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "bar" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e76de278f0e9e881.sql b/tests/ast_json_fixtures/shapes/e76de278f0e9e881.sql new file mode 100644 index 000000000000..56fe54c98c37 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e76de278f0e9e881.sql @@ -0,0 +1 @@ +WITH ( SELECT toLowCardinality('a') ) AS bar SELECT bar diff --git a/tests/ast_json_fixtures/shapes/e7793c902d55f97c.json b/tests/ast_json_fixtures/shapes/e7793c902d55f97c.json new file mode 100644 index 000000000000..72e6aaed7cbd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7793c902d55f97c.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ShowGrantsQuery", + "for_roles": { + "type": "RolesOrUsersSet", + "names": ["u1_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e7793c902d55f97c.sql b/tests/ast_json_fixtures/shapes/e7793c902d55f97c.sql new file mode 100644 index 000000000000..247ea81ab667 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7793c902d55f97c.sql @@ -0,0 +1 @@ +SHOW GRANTS FOR u1_01292 diff --git a/tests/ast_json_fixtures/shapes/e79b5ae0be1eabee.json b/tests/ast_json_fixtures/shapes/e79b5ae0be1eabee.json new file mode 100644 index 000000000000..e2617e35034a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e79b5ae0be1eabee.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r1_01295"] + } +} diff --git a/tests/ast_json_fixtures/shapes/e79b5ae0be1eabee.sql b/tests/ast_json_fixtures/shapes/e79b5ae0be1eabee.sql new file mode 100644 index 000000000000..7a289b236c0b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e79b5ae0be1eabee.sql @@ -0,0 +1 @@ +CREATE ROLE r1_01295 diff --git a/tests/ast_json_fixtures/shapes/e7b3ed42c860b3be.json b/tests/ast_json_fixtures/shapes/e7b3ed42c860b3be.json new file mode 100644 index 000000000000..5e1ce5082581 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7b3ed42c860b3be.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "3" + }, + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "extremes": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e7b3ed42c860b3be.sql b/tests/ast_json_fixtures/shapes/e7b3ed42c860b3be.sql new file mode 100644 index 000000000000..2e9f9e5b2da8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7b3ed42c860b3be.sql @@ -0,0 +1 @@ +SELECT arrayJoin([3, 1, 2]) SETTINGS extremes = 1 diff --git a/tests/ast_json_fixtures/shapes/e7c3f14981120b77.json b/tests/ast_json_fixtures/shapes/e7c3f14981120b77.json new file mode 100644 index 000000000000..5e3a9a44f010 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7c3f14981120b77.json @@ -0,0 +1,141 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_rollup": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "alias": "gr", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "having": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "gr" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e7c3f14981120b77.sql b/tests/ast_json_fixtures/shapes/e7c3f14981120b77.sql new file mode 100644 index 000000000000..d707ab6ef4c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7c3f14981120b77.sql @@ -0,0 +1,9 @@ +SELECT + number, + grouping(number, number % 2) as gr +FROM remote('127.0.0.{2,3}', numbers(10)) +GROUP BY + ROLLUP(number, number % 2) WITH TOTALS +HAVING grouping(number) != 0 +ORDER BY + number, gr diff --git a/tests/ast_json_fixtures/shapes/e7ca48727cdc2244.json b/tests/ast_json_fixtures/shapes/e7ca48727cdc2244.json new file mode 100644 index 000000000000..d51b787fb43a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7ca48727cdc2244.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p1_01295", + "database": "db", + "table": "table" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e7ca48727cdc2244.sql b/tests/ast_json_fixtures/shapes/e7ca48727cdc2244.sql new file mode 100644 index 000000000000..7dc89d9a9a18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7ca48727cdc2244.sql @@ -0,0 +1 @@ +CREATE POLICY p1_01295 ON db.table TO NONE diff --git a/tests/ast_json_fixtures/shapes/e7d5a4707dae762d.json b/tests/ast_json_fixtures/shapes/e7d5a4707dae762d.json new file mode 100644 index 000000000000..d91931a1dba0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7d5a4707dae762d.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateTableQuery", + "table": { + "type": "Identifier", + "name": "audit_size_column" + }, + "format": "Raw" + } +} diff --git a/tests/ast_json_fixtures/shapes/e7d5a4707dae762d.sql b/tests/ast_json_fixtures/shapes/e7d5a4707dae762d.sql new file mode 100644 index 000000000000..ee48209f457f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7d5a4707dae762d.sql @@ -0,0 +1 @@ +SHOW TABLE audit_size_column FORMAT Raw diff --git a/tests/ast_json_fixtures/shapes/e7e67eabb935a311.json b/tests/ast_json_fixtures/shapes/e7e67eabb935a311.json new file mode 100644 index 000000000000..75685244b14d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7e67eabb935a311.json @@ -0,0 +1,462 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "indexOf", + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "arraySort", + "arguments": [ + { + "type": "Function", + "name": "groupUniqArray", + "arguments": [ + { + "type": "Identifier", + "name": "tid" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "transactions_info_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "txn_counters" + } + ] + } + ] + } + } + ] + } + }, + { + "type": "Identifier", + "name": "tid" + } + ] + }, + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "thread_id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + } + ] + }, + { + "type": "Function", + "name": "length", + "arguments": [ + { + "type": "Function", + "name": "queryID", + "arguments": [] + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Commit" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tid_hash" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "csn" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Identifier", + "name": "part" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "transactions_info_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tid" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "tid" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "transactions_info_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "txn_counters" + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tid" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tid" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Literal", + "value_type": "String", + "value": "txn_counters" + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e7e67eabb935a311.sql b/tests/ast_json_fixtures/shapes/e7e67eabb935a311.sql new file mode 100644 index 000000000000..070eecc86a38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7e67eabb935a311.sql @@ -0,0 +1,10 @@ +select indexOf((select arraySort(groupUniqArray(tid)) from system.transactions_info_log where database=currentDatabase() and table='txn_counters'), tid), + type, + thread_id!=0, + length(query_id)=length(queryID()) or type='Commit' and query_id='', + tid_hash!=0, + csn=0, + part +from system.transactions_info_log +where tid in (select tid from system.transactions_info_log where database=currentDatabase() and table='txn_counters' and not (tid.1=1 and tid.2=1)) +or (database=currentDatabase() and table='txn_counters') order by event_time diff --git a/tests/ast_json_fixtures/shapes/e7f69d121d26fbf7.json b/tests/ast_json_fixtures/shapes/e7f69d121d26fbf7.json new file mode 100644 index 000000000000..af33b287ab41 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7f69d121d26fbf7.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "avro" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "File", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "Avro" + } + ] + } + }, + "as_database": "test", + "as_table": "hits" + } +} diff --git a/tests/ast_json_fixtures/shapes/e7f69d121d26fbf7.sql b/tests/ast_json_fixtures/shapes/e7f69d121d26fbf7.sql new file mode 100644 index 000000000000..95dad716a7c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7f69d121d26fbf7.sql @@ -0,0 +1 @@ +CREATE TABLE avro AS test.hits ENGINE = File(Avro) diff --git a/tests/ast_json_fixtures/shapes/e7ffd0a3284da7bc.json b/tests/ast_json_fixtures/shapes/e7ffd0a3284da7bc.json new file mode 100644 index 000000000000..3176fb5b05de --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7ffd0a3284da7bc.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "team", + "wildcard": true + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["user_03141"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e7ffd0a3284da7bc.sql b/tests/ast_json_fixtures/shapes/e7ffd0a3284da7bc.sql new file mode 100644 index 000000000000..081b313a7df7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e7ffd0a3284da7bc.sql @@ -0,0 +1 @@ +GRANT SELECT ON team*.* TO user_03141 diff --git a/tests/ast_json_fixtures/shapes/e81062b3a8fb5c64.json b/tests/ast_json_fixtures/shapes/e81062b3a8fb5c64.json new file mode 100644 index 000000000000..35e2dfc49cce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e81062b3a8fb5c64.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "repeat", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "x" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "y", + "name": "repeat", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "x" + }, + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "10", + "output_format_pretty_fallback_to_vertical_min_table_width": "100", + "output_format_pretty_squash_consecutive_ms": "0" + } + } + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/e81062b3a8fb5c64.sql b/tests/ast_json_fixtures/shapes/e81062b3a8fb5c64.sql new file mode 100644 index 000000000000..7893c020ba8c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e81062b3a8fb5c64.sql @@ -0,0 +1 @@ +SELECT repeat('x', 100 - number) AS x, repeat('x', 100 - number) AS y FROM numbers(100) SETTINGS max_block_size = 10, output_format_pretty_fallback_to_vertical_min_table_width = 100, output_format_pretty_squash_consecutive_ms = 0 FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/e825ae434e45fd2d.json b/tests/ast_json_fixtures/shapes/e825ae434e45fd2d.json new file mode 100644 index 000000000000..c74514e45f7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e825ae434e45fd2d.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "cluster": "test_shard_localhost", + "names": ["02911_user"] + } +} diff --git a/tests/ast_json_fixtures/shapes/e825ae434e45fd2d.sql b/tests/ast_json_fixtures/shapes/e825ae434e45fd2d.sql new file mode 100644 index 000000000000..014f1363d42e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e825ae434e45fd2d.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS 02911_user ON CLUSTER test_shard_localhost diff --git a/tests/ast_json_fixtures/shapes/e83c378c23fbe82f.json b/tests/ast_json_fixtures/shapes/e83c378c23fbe82f.json new file mode 100644 index 000000000000..84ddaacb52ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e83c378c23fbe82f.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "limit_with_ties": true, + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "ties" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e83c378c23fbe82f.sql b/tests/ast_json_fixtures/shapes/e83c378c23fbe82f.sql new file mode 100644 index 000000000000..c183d979af18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e83c378c23fbe82f.sql @@ -0,0 +1 @@ +SELECT a FROM ties order by a limit 1, 1 with ties diff --git a/tests/ast_json_fixtures/shapes/e84295963c6de10d.json b/tests/ast_json_fixtures/shapes/e84295963c6de10d.json new file mode 100644 index 000000000000..e879065fb2bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e84295963c6de10d.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR QUERY CACHE", + "query_result_cache_tag": "def" + } +} diff --git a/tests/ast_json_fixtures/shapes/e84295963c6de10d.sql b/tests/ast_json_fixtures/shapes/e84295963c6de10d.sql new file mode 100644 index 000000000000..0e76eb416c4c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e84295963c6de10d.sql @@ -0,0 +1 @@ +SYSTEM CLEAR QUERY CACHE TAG 'def' diff --git a/tests/ast_json_fixtures/shapes/e8443a6e49ca47d4.json b/tests/ast_json_fixtures/shapes/e8443a6e49ca47d4.json new file mode 100644 index 000000000000..516e69b7e4ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e8443a6e49ca47d4.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["sqllt_role"], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/e8443a6e49ca47d4.sql b/tests/ast_json_fixtures/shapes/e8443a6e49ca47d4.sql new file mode 100644 index 000000000000..d8e730cd39fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e8443a6e49ca47d4.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE sqllt_role FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/e877f648bfea24fa.json b/tests/ast_json_fixtures/shapes/e877f648bfea24fa.json new file mode 100644 index 000000000000..849ae39c7a3d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e877f648bfea24fa.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u5_01292", + "host_pattern": "%.host.com" + }, + { + "type": "UserNameWithHost", + "name": "u6_01292", + "host_pattern": "%.host.com" + } + ] + }, + "hosts": { + "like_patterns": ["%.host.com"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e877f648bfea24fa.sql b/tests/ast_json_fixtures/shapes/e877f648bfea24fa.sql new file mode 100644 index 000000000000..748f54e66d42 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e877f648bfea24fa.sql @@ -0,0 +1 @@ +CREATE USER u5_01292@'%.host.com', u6_01292@'%.host.com' diff --git a/tests/ast_json_fixtures/shapes/e89902ed0663e693.json b/tests/ast_json_fixtures/shapes/e89902ed0663e693.json new file mode 100644 index 000000000000..8a4a7ece335a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e89902ed0663e693.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "having": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "9" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e89902ed0663e693.sql b/tests/ast_json_fixtures/shapes/e89902ed0663e693.sql new file mode 100644 index 000000000000..7fdc4a5da8ec --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e89902ed0663e693.sql @@ -0,0 +1 @@ +select number from numbers_mt(10) having number >= 9 diff --git a/tests/ast_json_fixtures/shapes/e899626f02504db4.json b/tests/ast_json_fixtures/shapes/e899626f02504db4.json new file mode 100644 index 000000000000..a3554bb861e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e899626f02504db4.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_STATISTICS", + "statistics_declaration": { + "type": "Stat", + "columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "types": { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "uniq", + "arguments": [] + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e899626f02504db4.sql b/tests/ast_json_fixtures/shapes/e899626f02504db4.sql new file mode 100644 index 000000000000..47067a82c5c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e899626f02504db4.sql @@ -0,0 +1 @@ +ALTER TABLE tab ADD STATISTICS a TYPE uniq diff --git a/tests/ast_json_fixtures/shapes/e8a8c0c9662bc63e.json b/tests/ast_json_fixtures/shapes/e8a8c0c9662bc63e.json new file mode 100644 index 000000000000..380bed376d24 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e8a8c0c9662bc63e.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "18446744073709551615" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e8a8c0c9662bc63e.sql b/tests/ast_json_fixtures/shapes/e8a8c0c9662bc63e.sql new file mode 100644 index 000000000000..e4de39f8f82b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e8a8c0c9662bc63e.sql @@ -0,0 +1,5 @@ +SELECT a +FROM a +GROUP BY a +ORDER BY a ASC +LIMIT 5, 18446744073709551615 diff --git a/tests/ast_json_fixtures/shapes/e8ed6ade34266857.json b/tests/ast_json_fixtures/shapes/e8ed6ade34266857.json new file mode 100644 index 000000000000..3e775d01aa71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e8ed6ade34266857.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "both" + }, + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Identifier", + "name": "table" + }, + { + "type": "Function", + "name": "left", + "arguments": [ + { + "type": "Identifier", + "name": "replica_name" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "replicas", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e8ed6ade34266857.sql b/tests/ast_json_fixtures/shapes/e8ed6ade34266857.sql new file mode 100644 index 000000000000..61d7f5438c9a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e8ed6ade34266857.sql @@ -0,0 +1 @@ +SELECT 'both', database, table, left(replica_name, 2) FROM system.replicas WHERE database = currentDatabase() diff --git a/tests/ast_json_fixtures/shapes/e8f8aa7d99fce3d1.json b/tests/ast_json_fixtures/shapes/e8f8aa7d99fce3d1.json new file mode 100644 index 000000000000..bec2732a44aa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e8f8aa7d99fce3d1.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t1_local" + }, + "cluster": "test_shard_localhost", + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "String", + "value": "partition1" + } + }, + "replace": true, + "from_table": "t2_local" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e8f8aa7d99fce3d1.sql b/tests/ast_json_fixtures/shapes/e8f8aa7d99fce3d1.sql new file mode 100644 index 000000000000..b8e67beed794 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e8f8aa7d99fce3d1.sql @@ -0,0 +1 @@ +ALTER TABLE t1_local ON CLUSTER test_shard_localhost REPLACE PARTITION 'partition1' FROM t2_local diff --git a/tests/ast_json_fixtures/shapes/e90f7276966c906e.json b/tests/ast_json_fixtures/shapes/e90f7276966c906e.json new file mode 100644 index 000000000000..ba9ddc22e0c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e90f7276966c906e.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "v00" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k0" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/e90f7276966c906e.sql b/tests/ast_json_fixtures/shapes/e90f7276966c906e.sql new file mode 100644 index 000000000000..abb67d6169b7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e90f7276966c906e.sql @@ -0,0 +1 @@ +SELECT v00 FROM t1 ORDER BY k0 FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/e9539fc1dbb1d45f.json b/tests/ast_json_fixtures/shapes/e9539fc1dbb1d45f.json new file mode 100644 index 000000000000..44942e4e7c53 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e9539fc1dbb1d45f.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["test_user_03593_1"] + } +} diff --git a/tests/ast_json_fixtures/shapes/e9539fc1dbb1d45f.sql b/tests/ast_json_fixtures/shapes/e9539fc1dbb1d45f.sql new file mode 100644 index 000000000000..9af8c549fc75 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e9539fc1dbb1d45f.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS test_user_03593_1 diff --git a/tests/ast_json_fixtures/shapes/e969b4bd1453921d.json b/tests/ast_json_fixtures/shapes/e969b4bd1453921d.json new file mode 100644 index 000000000000..85a7929b1162 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e969b4bd1453921d.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "numbers_indexed" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "bitShiftRight", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "number" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "16384" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e969b4bd1453921d.sql b/tests/ast_json_fixtures/shapes/e969b4bd1453921d.sql new file mode 100644 index 000000000000..c8b736a4665f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e969b4bd1453921d.sql @@ -0,0 +1 @@ +CREATE TABLE numbers_indexed Engine=MergeTree ORDER BY number PARTITION BY bitShiftRight(number,8) SETTINGS index_granularity=8 AS SELECT * FROM numbers(16384) diff --git a/tests/ast_json_fixtures/shapes/e99df31a5f371d76.json b/tests/ast_json_fixtures/shapes/e99df31a5f371d76.json new file mode 100644 index 000000000000..a06eb030bd57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e99df31a5f371d76.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "b" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "i", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "2" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e99df31a5f371d76.sql b/tests/ast_json_fixtures/shapes/e99df31a5f371d76.sql new file mode 100644 index 000000000000..358fff2f5ce0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e99df31a5f371d76.sql @@ -0,0 +1 @@ +create table b (i int) engine MergeTree order by tuple() settings index_granularity = 2 diff --git a/tests/ast_json_fixtures/shapes/e9b9193e507e220c.json b/tests/ast_json_fixtures/shapes/e9b9193e507e220c.json new file mode 100644 index 000000000000..e2c9a80de789 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e9b9193e507e220c.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "y", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "t" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Literal", + "value_type": "String", + "value": "true" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e9b9193e507e220c.sql b/tests/ast_json_fixtures/shapes/e9b9193e507e220c.sql new file mode 100644 index 000000000000..95540917b836 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e9b9193e507e220c.sql @@ -0,0 +1,2 @@ +with ('t' || x) as y + select 1 from tab where y = 'true' settings enable_analyzer=0 diff --git a/tests/ast_json_fixtures/shapes/e9c9f09258daa838.json b/tests/ast_json_fixtures/shapes/e9c9f09258daa838.json new file mode 100644 index 000000000000..98d2bdcc13cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e9c9f09258daa838.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "a" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "b" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/e9c9f09258daa838.sql b/tests/ast_json_fixtures/shapes/e9c9f09258daa838.sql new file mode 100644 index 000000000000..2940a6aa0e29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e9c9f09258daa838.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE a (b UInt8) ENGINE = MergeTree ORDER BY b diff --git a/tests/ast_json_fixtures/shapes/e9ef437eae3db196.json b/tests/ast_json_fixtures/shapes/e9ef437eae3db196.json new file mode 100644 index 000000000000..e7984d9c7e8a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e9ef437eae3db196.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q7_01297"], + "key_type": "NONE" + } +} diff --git a/tests/ast_json_fixtures/shapes/e9ef437eae3db196.sql b/tests/ast_json_fixtures/shapes/e9ef437eae3db196.sql new file mode 100644 index 000000000000..f413f21d4c68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e9ef437eae3db196.sql @@ -0,0 +1 @@ +CREATE QUOTA q7_01297 KEYED BY 'none' diff --git a/tests/ast_json_fixtures/shapes/e9fda7b619505ba8.json b/tests/ast_json_fixtures/shapes/e9fda7b619505ba8.json new file mode 100644 index 000000000000..5de9ce970cbe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e9fda7b619505ba8.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Asterisk" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "p" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "window_mt" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_read_in_order": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/e9fda7b619505ba8.sql b/tests/ast_json_fixtures/shapes/e9fda7b619505ba8.sql new file mode 100644 index 000000000000..909b177afa73 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/e9fda7b619505ba8.sql @@ -0,0 +1,2 @@ +select number, count(*) over (partition by p) + from window_mt order by number limit 10 settings optimize_read_in_order = 0 diff --git a/tests/ast_json_fixtures/shapes/ea066a390f996a96.json b/tests/ast_json_fixtures/shapes/ea066a390f996a96.json new file mode 100644 index 000000000000..a169b69e6952 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea066a390f996a96.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s3_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "value": "5000000", + "min_value": "4000000", + "max_value": "6000000", + "writability": "CONST" + } + ] + }, + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01294"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ea066a390f996a96.sql b/tests/ast_json_fixtures/shapes/ea066a390f996a96.sql new file mode 100644 index 000000000000..bb553790f0fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea066a390f996a96.sql @@ -0,0 +1 @@ +CREATE PROFILE s3_01294 SETTINGS max_memory_usage=5000000 MIN 4000000 MAX 6000000 CONST TO r1_01294 diff --git a/tests/ast_json_fixtures/shapes/ea07dbb51c4b171b.json b/tests/ast_json_fixtures/shapes/ea07dbb51c4b171b.json new file mode 100644 index 000000000000..2e2bb52537a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea07dbb51c4b171b.json @@ -0,0 +1,43 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN PIPELINE", + "query": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "t_mt" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ea07dbb51c4b171b.sql b/tests/ast_json_fixtures/shapes/ea07dbb51c4b171b.sql new file mode 100644 index 000000000000..b6ddc664d60c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea07dbb51c4b171b.sql @@ -0,0 +1 @@ +explain pipeline insert into t_mt select * from system.one diff --git a/tests/ast_json_fixtures/shapes/ea110b9e5bbb3dd6.json b/tests/ast_json_fixtures/shapes/ea110b9e5bbb3dd6.json new file mode 100644 index 000000000000..7097dcfcd958 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea110b9e5bbb3dd6.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "f0", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/ea110b9e5bbb3dd6.sql b/tests/ast_json_fixtures/shapes/ea110b9e5bbb3dd6.sql new file mode 100644 index 000000000000..774f926674d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea110b9e5bbb3dd6.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS f0 diff --git a/tests/ast_json_fixtures/shapes/ea28617e353fe70d.json b/tests/ast_json_fixtures/shapes/ea28617e353fe70d.json new file mode 100644 index 000000000000..6fc34a15bfc8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea28617e353fe70d.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "ParallelWithQuery", + "children": [ + { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "t0" + }, + "columns": [ + { + "type": "Identifier", + "name": "c0" + } + ], + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + }, + { + "type": "TruncateQuery", + "kind": "TRUNCATE", + "table": { + "type": "Identifier", + "name": "t0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ea28617e353fe70d.sql b/tests/ast_json_fixtures/shapes/ea28617e353fe70d.sql new file mode 100644 index 000000000000..3f41fcd32ce7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea28617e353fe70d.sql @@ -0,0 +1 @@ +INSERT INTO TABLE t0 (c0) SELECT 1 PARALLEL WITH TRUNCATE t0 diff --git a/tests/ast_json_fixtures/shapes/ea293a71c6d8f3ee.json b/tests/ast_json_fixtures/shapes/ea293a71c6d8f3ee.json new file mode 100644 index 000000000000..ff3d1db9e709 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea293a71c6d8f3ee.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "imdb_01148" + }, + "table": { + "type": "Identifier", + "name": "anything" + }, + "as_database": "imdb_01148", + "as_table": "movie_directors" + } +} diff --git a/tests/ast_json_fixtures/shapes/ea293a71c6d8f3ee.sql b/tests/ast_json_fixtures/shapes/ea293a71c6d8f3ee.sql new file mode 100644 index 000000000000..843cbb1d6aae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea293a71c6d8f3ee.sql @@ -0,0 +1 @@ +CREATE TABLE imdb_01148.anything AS imdb_01148.movie_directors diff --git a/tests/ast_json_fixtures/shapes/ea31382e37f0b43d.json b/tests/ast_json_fixtures/shapes/ea31382e37f0b43d.json new file mode 100644 index 000000000000..66976e30a297 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea31382e37f0b43d.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "aggregated_zookeeper_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ea31382e37f0b43d.sql b/tests/ast_json_fixtures/shapes/ea31382e37f0b43d.sql new file mode 100644 index 000000000000..2225c1bad9f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea31382e37f0b43d.sql @@ -0,0 +1 @@ +system flush logs aggregated_zookeeper_log diff --git a/tests/ast_json_fixtures/shapes/ea361603411dece6.json b/tests/ast_json_fixtures/shapes/ea361603411dece6.json new file mode 100644 index 000000000000..022d57d2bbcd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea361603411dece6.json @@ -0,0 +1,60 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "dict" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "col", + "data_type": { + "type": "DataType", + "name": "Int64" + }, + "default_value": { + "type": "Literal", + "value_type": "Null", + "value": null + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "col" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "null", + "elements": [] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 1 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "ssd_cache", + "parameters": [ + { + "type": "pair", + "key": "block_size", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ea361603411dece6.sql b/tests/ast_json_fixtures/shapes/ea361603411dece6.sql new file mode 100644 index 000000000000..99fafd6f48bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea361603411dece6.sql @@ -0,0 +1 @@ +CREATE DICTIONARY dict (col Int64 default null) PRIMARY KEY (col) SOURCE(NULL()) LAYOUT(SSD_CACHE(BLOCK_SIZE 0)) LIFETIME(1) diff --git a/tests/ast_json_fixtures/shapes/ea598b6f9fb39ee5.json b/tests/ast_json_fixtures/shapes/ea598b6f9fb39ee5.json new file mode 100644 index 000000000000..3a9675cf5a6e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea598b6f9fb39ee5.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "alias": "n", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ], + "group_by": [ + { + "type": "Identifier", + "name": "n" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "n" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/ea598b6f9fb39ee5.sql b/tests/ast_json_fixtures/shapes/ea598b6f9fb39ee5.sql new file mode 100644 index 000000000000..25a3c0075ec4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea598b6f9fb39ee5.sql @@ -0,0 +1 @@ +SELECT count(), arrayJoin([1, 2, 3]) AS n GROUP BY n WITH TOTALS ORDER BY n LIMIT 1 FORMAT JSON diff --git a/tests/ast_json_fixtures/shapes/ea6967089b5c4656.json b/tests/ast_json_fixtures/shapes/ea6967089b5c4656.json new file mode 100644 index 000000000000..482efb2ca976 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea6967089b5c4656.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "uuid": "aaaaaaaa-1111-2222-3333-aaaaaaaaaaaa", + "table": { + "type": "Identifier", + "name": "x" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/tables\/{database}\/{uuid}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "r1" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ea6967089b5c4656.sql b/tests/ast_json_fixtures/shapes/ea6967089b5c4656.sql new file mode 100644 index 000000000000..2fc4454edbe6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea6967089b5c4656.sql @@ -0,0 +1 @@ +ATTACH TABLE x UUID 'aaaaaaaa-1111-2222-3333-aaaaaaaaaaaa' (key Int) ENGINE = ReplicatedMergeTree('/tables/{database}/{uuid}', 'r1') ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/ea6b1d8f33355327.json b/tests/ast_json_fixtures/shapes/ea6b1d8f33355327.json new file mode 100644 index 000000000000..045aeb0944bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea6b1d8f33355327.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "domainRFC", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "[]:80" + } + ] + } + ] + } + ], + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/ea6b1d8f33355327.sql b/tests/ast_json_fixtures/shapes/ea6b1d8f33355327.sql new file mode 100644 index 000000000000..cf40c92ee653 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea6b1d8f33355327.sql @@ -0,0 +1 @@ +SELECT domainRFC('[]:80') FORMAT CSV diff --git a/tests/ast_json_fixtures/shapes/ea7f0a4458132d38.json b/tests/ast_json_fixtures/shapes/ea7f0a4458132d38.json new file mode 100644 index 000000000000..e358719aa5c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea7f0a4458132d38.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "v" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_sparse_distinct" + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/ea7f0a4458132d38.sql b/tests/ast_json_fixtures/shapes/ea7f0a4458132d38.sql new file mode 100644 index 000000000000..052f435f27e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea7f0a4458132d38.sql @@ -0,0 +1 @@ +SELECT DISTINCT id, v FROM t_sparse_distinct format Null diff --git a/tests/ast_json_fixtures/shapes/ea84511dfaf35fb3.json b/tests/ast_json_fixtures/shapes/ea84511dfaf35fb3.json new file mode 100644 index 000000000000..f780f165baa5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea84511dfaf35fb3.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s1_01294", "s2_01294", "s3_01294", "s4_01294", "s5_01294", "s6_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/ea84511dfaf35fb3.sql b/tests/ast_json_fixtures/shapes/ea84511dfaf35fb3.sql new file mode 100644 index 000000000000..14a09292172e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ea84511dfaf35fb3.sql @@ -0,0 +1 @@ +DROP PROFILE s1_01294, s2_01294, s3_01294, s4_01294, s5_01294, s6_01294 diff --git a/tests/ast_json_fixtures/shapes/ead6d95dd3fc86f0.json b/tests/ast_json_fixtures/shapes/ead6d95dd3fc86f0.json new file mode 100644 index 000000000000..24ed7dcdabf9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ead6d95dd3fc86f0.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u6_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "DOUBLE_SHA1_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwe123" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/ead6d95dd3fc86f0.sql b/tests/ast_json_fixtures/shapes/ead6d95dd3fc86f0.sql new file mode 100644 index 000000000000..bb830907ab62 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ead6d95dd3fc86f0.sql @@ -0,0 +1 @@ +CREATE USER u6_01292 IDENTIFIED WITH double_sha1_password BY 'qwe123' diff --git a/tests/ast_json_fixtures/shapes/eae3eee55f6894a2.json b/tests/ast_json_fixtures/shapes/eae3eee55f6894a2.json new file mode 100644 index 000000000000..1caf52ee2390 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eae3eee55f6894a2.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["🙈 🙉 🙊"] + } +} diff --git a/tests/ast_json_fixtures/shapes/eae3eee55f6894a2.sql b/tests/ast_json_fixtures/shapes/eae3eee55f6894a2.sql new file mode 100644 index 000000000000..09e567be62b3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eae3eee55f6894a2.sql @@ -0,0 +1 @@ +drop user "🙈 🙉 🙊" diff --git a/tests/ast_json_fixtures/shapes/eaeb58300e196fee.json b/tests/ast_json_fixtures/shapes/eaeb58300e196fee.json new file mode 100644 index 000000000000..5a9540651369 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eaeb58300e196fee.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateNamedCollectionQuery", + "collection_name": "cache_collection_sql", + "if_not_exists": true, + "changes": { + "path": { + "value_type": "String", + "value": "collection_sql" + }, + "max_size": { + "value_type": "String", + "value": "1Mi" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/eaeb58300e196fee.sql b/tests/ast_json_fixtures/shapes/eaeb58300e196fee.sql new file mode 100644 index 000000000000..ef8694e384a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eaeb58300e196fee.sql @@ -0,0 +1 @@ +CREATE NAMED COLLECTION IF NOT EXISTS cache_collection_sql AS path = 'collection_sql', max_size = '1Mi' diff --git a/tests/ast_json_fixtures/shapes/eaebffd2a104ddd1.json b/tests/ast_json_fixtures/shapes/eaebffd2a104ddd1.json new file mode 100644 index 000000000000..7defb73d77a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eaebffd2a104ddd1.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q2_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/eaebffd2a104ddd1.sql b/tests/ast_json_fixtures/shapes/eaebffd2a104ddd1.sql new file mode 100644 index 000000000000..bbb199ff4c44 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eaebffd2a104ddd1.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q2_01297 diff --git a/tests/ast_json_fixtures/shapes/eafc37ab1765c10a.json b/tests/ast_json_fixtures/shapes/eafc37ab1765c10a.json new file mode 100644 index 000000000000..8d9b4767c1cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eafc37ab1765c10a.json @@ -0,0 +1,27 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "table_two" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "REPLACE_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + }, + "replace": true, + "from_table": "table_one" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/eafc37ab1765c10a.sql b/tests/ast_json_fixtures/shapes/eafc37ab1765c10a.sql new file mode 100644 index 000000000000..e591f0a99dd1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eafc37ab1765c10a.sql @@ -0,0 +1 @@ +ALTER TABLE table_two REPLACE PARTITION 0 FROM table_one diff --git a/tests/ast_json_fixtures/shapes/eb37a614194f92b9.json b/tests/ast_json_fixtures/shapes/eb37a614194f92b9.json new file mode 100644 index 000000000000..a05d3c52e718 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eb37a614194f92b9.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "if_exists": true, + "names": ["r1_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/eb37a614194f92b9.sql b/tests/ast_json_fixtures/shapes/eb37a614194f92b9.sql new file mode 100644 index 000000000000..10a67700e272 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eb37a614194f92b9.sql @@ -0,0 +1 @@ +DROP ROLE IF EXISTS r1_01294 diff --git a/tests/ast_json_fixtures/shapes/eb5265e430634288.json b/tests/ast_json_fixtures/shapes/eb5265e430634288.json new file mode 100644 index 000000000000..eed7011bc46d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eb5265e430634288.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "alias": "lhs", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.{1,2}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "test_01081" + } + ] + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "rhs.dummy", + "name_parts": ["rhs", "dummy"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "rhs", + "name": "one", + "database": "system" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/eb5265e430634288.sql b/tests/ast_json_fixtures/shapes/eb5265e430634288.sql new file mode 100644 index 000000000000..5d8c851265e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eb5265e430634288.sql @@ -0,0 +1,2 @@ +select 1 from remote('127.{1,2}', currentDatabase(), test_01081) lhs join system.one as rhs on rhs.dummy = 1 order by 1 +SETTINGS enable_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/eb81a3a1d5920475.json b/tests/ast_json_fixtures/shapes/eb81a3a1d5920475.json new file mode 100644 index 000000000000..d1a1f916f9a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eb81a3a1d5920475.json @@ -0,0 +1,200 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "total", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "total_count" + } + ] + }, + { + "type": "Identifier", + "name": "domain" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "total_count", + "name": "COUNT", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "alias": "facebookHits", + "name": "SUM", + "arguments": [ + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "domain" + }, + { + "type": "Literal", + "value_type": "String", + "value": "facebook.com" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "domain" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "clicks" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "domain" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "total_count", + "name": "COUNT", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "alias": "facebookHits", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Identifier", + "name": "domain" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "transactions" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "domain" + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "domain" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "domain" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/eb81a3a1d5920475.sql b/tests/ast_json_fixtures/shapes/eb81a3a1d5920475.sql new file mode 100644 index 000000000000..6586af634a0f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eb81a3a1d5920475.sql @@ -0,0 +1,23 @@ +SELECT + sum(total_count) AS total, + domain +FROM +( + SELECT + COUNT(*) AS total_count, + SUM(if(domain = 'facebook.com', 1, 0)) AS facebookHits, + domain + FROM clicks + GROUP BY domain +UNION ALL + SELECT + COUNT(*) AS total_count, + toUInt64(0) AS facebookHits, + domain + FROM transactions + GROUP BY domain +) +GROUP BY domain +ORDER BY domain +LIMIT 10 +FORMAT JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/eba6e86011c357e9.json b/tests/ast_json_fixtures/shapes/eba6e86011c357e9.json new file mode 100644 index 000000000000..a42bb913245c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eba6e86011c357e9.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01223" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "globalIn", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toInt32", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/eba6e86011c357e9.sql b/tests/ast_json_fixtures/shapes/eba6e86011c357e9.sql new file mode 100644 index 000000000000..e3c4ee1b86ce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eba6e86011c357e9.sql @@ -0,0 +1 @@ +select distinct * from dist_01223 where key global in (select toInt32(1)) diff --git a/tests/ast_json_fixtures/shapes/ebb4a12a8df9a3ca.json b/tests/ast_json_fixtures/shapes/ebb4a12a8df9a3ca.json new file mode 100644 index 000000000000..a2e95ebace33 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebb4a12a8df9a3ca.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateFunctionQuery", + "or_replace": true, + "function_name": { + "type": "Identifier", + "name": "03518_bad_sql_udf" + }, + "function_core": { + "type": "Function", + "name": "lambda", + "arguments": [ + { + "type": "Function", + "name": "identity", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ebb4a12a8df9a3ca.sql b/tests/ast_json_fixtures/shapes/ebb4a12a8df9a3ca.sql new file mode 100644 index 000000000000..18e25ecf37c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebb4a12a8df9a3ca.sql @@ -0,0 +1 @@ +CREATE OR REPLACE FUNCTION 03518_bad_sql_udf AS lambda(identity(x), x) diff --git a/tests/ast_json_fixtures/shapes/ebbb8a9cea1543b8.json b/tests/ast_json_fixtures/shapes/ebbb8a9cea1543b8.json new file mode 100644 index 000000000000..ce0272ce858e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebbb8a9cea1543b8.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q1_01297"], + "roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ebbb8a9cea1543b8.sql b/tests/ast_json_fixtures/shapes/ebbb8a9cea1543b8.sql new file mode 100644 index 000000000000..e235f6e0a1db --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebbb8a9cea1543b8.sql @@ -0,0 +1 @@ +CREATE QUOTA q1_01297 TO NONE diff --git a/tests/ast_json_fixtures/shapes/ebc9381fc7cf33b4.json b/tests/ast_json_fixtures/shapes/ebc9381fc7cf33b4.json new file mode 100644 index 000000000000..ea49e7e414c3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebc9381fc7cf33b4.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q6_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/ebc9381fc7cf33b4.sql b/tests/ast_json_fixtures/shapes/ebc9381fc7cf33b4.sql new file mode 100644 index 000000000000..217872ecea25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebc9381fc7cf33b4.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q6_01297 diff --git a/tests/ast_json_fixtures/shapes/ebd73d26ec8d8695.json b/tests/ast_json_fixtures/shapes/ebd73d26ec8d8695.json new file mode 100644 index 000000000000..082aa7625d95 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebd73d26ec8d8695.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r2_01293@%.myhost.com"] + } +} diff --git a/tests/ast_json_fixtures/shapes/ebd73d26ec8d8695.sql b/tests/ast_json_fixtures/shapes/ebd73d26ec8d8695.sql new file mode 100644 index 000000000000..0664ebc1dafe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebd73d26ec8d8695.sql @@ -0,0 +1 @@ +CREATE ROLE r2_01293@'%.myhost.com' diff --git a/tests/ast_json_fixtures/shapes/ebdaa10bbdd53839.json b/tests/ast_json_fixtures/shapes/ebdaa10bbdd53839.json new file mode 100644 index 000000000000..e769481dcab5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebdaa10bbdd53839.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "alias": "original", + "value_type": "String", + "value": "original" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "with_fill_staleness" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC", + "with_fill": true + } + ], + "interpolate": [ + { + "type": "InterpolateElement", + "column": "c", + "expr": { + "type": "Identifier", + "name": "c" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ebdaa10bbdd53839.sql b/tests/ast_json_fixtures/shapes/ebdaa10bbdd53839.sql new file mode 100644 index 000000000000..6ac7bf5f9dc9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebdaa10bbdd53839.sql @@ -0,0 +1 @@ +SELECT a, c, 'original' as original FROM with_fill_staleness ORDER BY a ASC WITH FILL INTERPOLATE (c) diff --git a/tests/ast_json_fixtures/shapes/ebe9a9b754232c05.json b/tests/ast_json_fixtures/shapes/ebe9a9b754232c05.json new file mode 100644 index 000000000000..06649a053634 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebe9a9b754232c05.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "ttl_00933_1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + }, + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "Int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + }, + "ttl_table": { + "type": "ExpressionList", + "children": [ + { + "type": "TTLElement", + "mode": "DELETE", + "ttl": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "remove_empty_parts": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ebe9a9b754232c05.sql b/tests/ast_json_fixtures/shapes/ebe9a9b754232c05.sql new file mode 100644 index 000000000000..bc486bba04ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebe9a9b754232c05.sql @@ -0,0 +1,3 @@ +create table ttl_00933_1 (d DateTime, a Int) + engine = MergeTree order by tuple() partition by tuple() ttl d + interval 1 day + settings remove_empty_parts = 0 diff --git a/tests/ast_json_fixtures/shapes/ebffbd8439dfa1ca.json b/tests/ast_json_fixtures/shapes/ebffbd8439dfa1ca.json new file mode 100644 index 000000000000..9f7171e95cfb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebffbd8439dfa1ca.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02098_alias_function" + } +} diff --git a/tests/ast_json_fixtures/shapes/ebffbd8439dfa1ca.sql b/tests/ast_json_fixtures/shapes/ebffbd8439dfa1ca.sql new file mode 100644 index 000000000000..4f7923f54ce6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ebffbd8439dfa1ca.sql @@ -0,0 +1 @@ +DROP FUNCTION 02098_alias_function diff --git a/tests/ast_json_fixtures/shapes/ec02e74b9ad43e80.json b/tests/ast_json_fixtures/shapes/ec02e74b9ad43e80.json new file mode 100644 index 000000000000..c083d0045fc4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec02e74b9ad43e80.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_STATISTICS", + "if_not_exists": true, + "statistics_declaration": { + "type": "Stat", + "columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "f64_tdigest" + } + ] + }, + "types": { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "tdigest", + "arguments": [] + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ec02e74b9ad43e80.sql b/tests/ast_json_fixtures/shapes/ec02e74b9ad43e80.sql new file mode 100644 index 000000000000..88ef89732271 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec02e74b9ad43e80.sql @@ -0,0 +1 @@ +ALTER TABLE tab ADD STATISTICS IF NOT EXISTS f64_tdigest TYPE tdigest diff --git a/tests/ast_json_fixtures/shapes/ec10e1426fe83ec0.json b/tests/ast_json_fixtures/shapes/ec10e1426fe83ec0.json new file mode 100644 index 000000000000..912dad8cb66c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec10e1426fe83ec0.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "from dst" + }, + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "_part" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dst" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ec10e1426fe83ec0.sql b/tests/ast_json_fixtures/shapes/ec10e1426fe83ec0.sql new file mode 100644 index 000000000000..a2aa4523014f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec10e1426fe83ec0.sql @@ -0,0 +1,6 @@ +SELECT + 'from dst', + *, + _part +FROM dst +ORDER by all diff --git a/tests/ast_json_fixtures/shapes/ec16dbb0d9c8b63a.json b/tests/ast_json_fixtures/shapes/ec16dbb0d9c8b63a.json new file mode 100644 index 000000000000..660faf9ef5a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec16dbb0d9c8b63a.json @@ -0,0 +1,93 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mt_pk" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "d" + }, + "order_by": { + "type": "Identifier", + "name": "x" + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "8192", + "index_granularity_bytes": "10Mi" + } + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "d", + "name": "toDate", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "32" + } + ] + } + ] + }, + { + "type": "Identifier", + "alias": "x", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000010" + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ec16dbb0d9c8b63a.sql b/tests/ast_json_fixtures/shapes/ec16dbb0d9c8b63a.sql new file mode 100644 index 000000000000..9540019fef29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec16dbb0d9c8b63a.sql @@ -0,0 +1,2 @@ +CREATE TABLE mt_pk ENGINE = MergeTree PARTITION BY d ORDER BY x SETTINGS index_granularity = 8192, index_granularity_bytes = '10Mi' +AS SELECT toDate(number % 32) AS d, number AS x FROM system.numbers LIMIT 1000010 diff --git a/tests/ast_json_fixtures/shapes/ec4021ce0bf90f28.json b/tests/ast_json_fixtures/shapes/ec4021ce0bf90f28.json new file mode 100644 index 000000000000..c130b99c4249 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec4021ce0bf90f28.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + }, + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "primary_key" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-3" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ec4021ce0bf90f28.sql b/tests/ast_json_fixtures/shapes/ec4021ce0bf90f28.sql new file mode 100644 index 000000000000..aa91f0a0ce8b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec4021ce0bf90f28.sql @@ -0,0 +1 @@ +SELECT 'a', -x FROM primary_key WHERE -x < -3 diff --git a/tests/ast_json_fixtures/shapes/ec5ab25163912c0d.json b/tests/ast_json_fixtures/shapes/ec5ab25163912c0d.json new file mode 100644 index 000000000000..a7a23c5bb221 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec5ab25163912c0d.json @@ -0,0 +1,25 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "format_template_row": "\/dev\/null" + } + }, + "format": "Template" + } +} diff --git a/tests/ast_json_fixtures/shapes/ec5ab25163912c0d.sql b/tests/ast_json_fixtures/shapes/ec5ab25163912c0d.sql new file mode 100644 index 000000000000..dbf2ed0424ca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec5ab25163912c0d.sql @@ -0,0 +1 @@ +select 1 format Template settings format_template_row='/dev/null' diff --git a/tests/ast_json_fixtures/shapes/ec68be1c34c56c19.json b/tests/ast_json_fixtures/shapes/ec68be1c34c56c19.json new file mode 100644 index 000000000000..7abf1b0e0f90 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec68be1c34c56c19.json @@ -0,0 +1,743 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sign", + "arguments": [ + { + "type": "Function", + "name": "cos", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max2", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + }, + { + "type": "Function", + "name": "sign", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "exp", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } + ] + } + ], + "having": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + }, + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "{b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "-657301241" + } + ] + }, + { + "type": "Function", + "name": "log", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1004522121" + } + ] + } + ] + } + ] + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sign", + "arguments": [ + { + "type": "Function", + "name": "cos", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max2", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + }, + { + "type": "Function", + "name": "sign", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "exp", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } + ] + } + ], + "having": { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + }, + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "{b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "-657301241" + } + ] + }, + { + "type": "Function", + "name": "log", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1004522121" + } + ] + } + ] + } + ] + } + ] + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sign", + "arguments": [ + { + "type": "Function", + "name": "cos", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "max2", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Function", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + }, + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + }, + { + "type": "Function", + "name": "sign", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "exp", + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } + ] + } + ], + "having": { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + }, + { + "type": "Function", + "name": "MIN", + "arguments": [ + { + "type": "Identifier", + "name": "t1.c0", + "name_parts": ["t1", "c0"] + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "isNotNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "pow", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "{b" + }, + { + "type": "Literal", + "value_type": "String", + "value": "-657301241" + } + ] + }, + { + "type": "Function", + "name": "log", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1004522121" + } + ] + } + ] + } + ] + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "aggregate_functions_null_for_empty": "1", + "enable_optimize_predicate_expression": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ec68be1c34c56c19.sql b/tests/ast_json_fixtures/shapes/ec68be1c34c56c19.sql new file mode 100644 index 000000000000..b8b0fd2192c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec68be1c34c56c19.sql @@ -0,0 +1,24 @@ +SELECT MIN(t1.c0) +FROM t1 +GROUP BY + (-sign(cos(t1.c0))) * (-max2(t1.c0, t1.c0 / t1.c0)), + t1.c0 * t1.c0, + sign(-exp(-t1.c0)) +HAVING -(-(MIN(t1.c0) + MIN(t1.c0))) AND (pow('{b' > '-657301241', log(-1004522121)) IS NOT NULL) +UNION ALL +SELECT MIN(t1.c0) +FROM t1 +GROUP BY + (-sign(cos(t1.c0))) * (-max2(t1.c0, t1.c0 / t1.c0)), + t1.c0 * t1.c0, + sign(-exp(-t1.c0)) +HAVING NOT (-(-(MIN(t1.c0) + MIN(t1.c0))) AND (pow('{b' > '-657301241', log(-1004522121)) IS NOT NULL)) +UNION ALL +SELECT MIN(t1.c0) +FROM t1 +GROUP BY + (-sign(cos(t1.c0))) * (-max2(t1.c0, t1.c0 / t1.c0)), + t1.c0 * t1.c0, + sign(-exp(-t1.c0)) +HAVING (-(-(MIN(t1.c0) + MIN(t1.c0))) AND (pow('{b' > '-657301241', log(-1004522121)) IS NOT NULL)) IS NULL +SETTINGS aggregate_functions_null_for_empty = 1, enable_optimize_predicate_expression = 0 diff --git a/tests/ast_json_fixtures/shapes/ec8bd4fdb47eeb90.json b/tests/ast_json_fixtures/shapes/ec8bd4fdb47eeb90.json new file mode 100644 index 000000000000..0f1826e72b67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec8bd4fdb47eeb90.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROW POLICY", + "row_policy_names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p1_01296", + "table": "table" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ec8bd4fdb47eeb90.sql b/tests/ast_json_fixtures/shapes/ec8bd4fdb47eeb90.sql new file mode 100644 index 000000000000..78ca29d6bc1e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ec8bd4fdb47eeb90.sql @@ -0,0 +1 @@ +SHOW CREATE POLICY p1_01296 ON table diff --git a/tests/ast_json_fixtures/shapes/eca1cd07c23d7c8c.json b/tests/ast_json_fixtures/shapes/eca1cd07c23d7c8c.json new file mode 100644 index 000000000000..173e840eefe2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eca1cd07c23d7c8c.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "insert_select_dst" + }, + "columns": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "insert_select_dst" + }, + "transformers": [ + { + "type": "ColumnsExceptTransformer", + "columns": [ + { + "type": "Identifier", + "name": "middle_a" + }, + { + "type": "Identifier", + "name": "middle_b" + } + ] + } + ] + } + ], + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "insert_select_src" + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/eca1cd07c23d7c8c.sql b/tests/ast_json_fixtures/shapes/eca1cd07c23d7c8c.sql new file mode 100644 index 000000000000..50ffaccab18b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eca1cd07c23d7c8c.sql @@ -0,0 +1 @@ +INSERT INTO insert_select_dst(insert_select_dst.* EXCEPT (middle_a, middle_b)) SELECT * FROM insert_select_src diff --git a/tests/ast_json_fixtures/shapes/ecb1813575dbc4c0.json b/tests/ast_json_fixtures/shapes/ecb1813575dbc4c0.json new file mode 100644 index 000000000000..498f9b6a5be0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ecb1813575dbc4c0.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s1_01294"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "1" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ecb1813575dbc4c0.sql b/tests/ast_json_fixtures/shapes/ecb1813575dbc4c0.sql new file mode 100644 index 000000000000..273d1b89ef88 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ecb1813575dbc4c0.sql @@ -0,0 +1 @@ +CREATE PROFILE s1_01294 SETTINGS readonly=1 diff --git a/tests/ast_json_fixtures/shapes/ecc66e8f8474f1b9.json b/tests/ast_json_fixtures/shapes/ecc66e8f8474f1b9.json new file mode 100644 index 000000000000..ad44f1571952 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ecc66e8f8474f1b9.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "cramersVBiasCorrected", + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "alias": "a", + "name": "number" + }, + { + "type": "Function", + "alias": "b", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ecc66e8f8474f1b9.sql b/tests/ast_json_fixtures/shapes/ecc66e8f8474f1b9.sql new file mode 100644 index 000000000000..c5d30c33c34c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ecc66e8f8474f1b9.sql @@ -0,0 +1,10 @@ +SELECT + a, + b, + cramersVBiasCorrected(a, b) +FROM numbers(3) +GROUP BY + number AS a, + number + number AS b + WITH CUBE +SETTINGS group_by_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/ecc78df947d4a16b.json b/tests/ast_json_fixtures/shapes/ecc78df947d4a16b.json new file mode 100644 index 000000000000..c60eaad3f12b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ecc78df947d4a16b.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,1}" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ], + "having": { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": true + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ecc78df947d4a16b.sql b/tests/ast_json_fixtures/shapes/ecc78df947d4a16b.sql new file mode 100644 index 000000000000..7f388e87b36b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ecc78df947d4a16b.sql @@ -0,0 +1 @@ +SELECT 1 FROM remote('127.0.0.{1,1}') GROUP BY (2, materialize(3)) HAVING materialize(3) SETTINGS group_by_use_nulls = true diff --git a/tests/ast_json_fixtures/shapes/ed0c7f2a0f7bdb99.json b/tests/ast_json_fixtures/shapes/ed0c7f2a0f7bdb99.json new file mode 100644 index 000000000000..4105006af047 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed0c7f2a0f7bdb99.json @@ -0,0 +1,58 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "alias": "z", + "value_type": "UInt64", + "value": "42" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "z" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ed0c7f2a0f7bdb99.sql b/tests/ast_json_fixtures/shapes/ed0c7f2a0f7bdb99.sql new file mode 100644 index 000000000000..b490d2930c16 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed0c7f2a0f7bdb99.sql @@ -0,0 +1 @@ +select count(), 42 AS z from remote('127.0.0.{2,3}', system.one) group by z WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/ed1dccd9043bb5d9.json b/tests/ast_json_fixtures/shapes/ed1dccd9043bb5d9.json new file mode 100644 index 000000000000..0e8ea280b898 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed1dccd9043bb5d9.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "some_table", + "to_table": "some_table1" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ed1dccd9043bb5d9.sql b/tests/ast_json_fixtures/shapes/ed1dccd9043bb5d9.sql new file mode 100644 index 000000000000..27fb226138c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed1dccd9043bb5d9.sql @@ -0,0 +1 @@ +RENAME TABLE some_table TO some_table1 diff --git a/tests/ast_json_fixtures/shapes/ed24588bf80bc90e.json b/tests/ast_json_fixtures/shapes/ed24588bf80bc90e.json new file mode 100644 index 000000000000..2e349b54e745 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed24588bf80bc90e.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/ed24588bf80bc90e.sql b/tests/ast_json_fixtures/shapes/ed24588bf80bc90e.sql new file mode 100644 index 000000000000..426d59bf5c52 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed24588bf80bc90e.sql @@ -0,0 +1 @@ +SELECT count() FROM numbers(10) WHERE number = -1 GROUP BY number WITH TOTALS FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/ed3aa954f815f019.json b/tests/ast_json_fixtures/shapes/ed3aa954f815f019.json new file mode 100644 index 000000000000..af90d3daa3e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed3aa954f815f019.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "attach_as_replicated": true, + "table": { + "type": "Identifier", + "name": "hourly_data" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ed3aa954f815f019.sql b/tests/ast_json_fixtures/shapes/ed3aa954f815f019.sql new file mode 100644 index 000000000000..3f7d2a3dc9ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed3aa954f815f019.sql @@ -0,0 +1 @@ +ATTACH TABLE hourly_data AS REPLICATED diff --git a/tests/ast_json_fixtures/shapes/ed51875f5bc640cf.json b/tests/ast_json_fixtures/shapes/ed51875f5bc640cf.json new file mode 100644 index 000000000000..1c36195eb659 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed51875f5bc640cf.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "data_01875_1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "bitShiftRight", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "number" + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "16384" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ed51875f5bc640cf.sql b/tests/ast_json_fixtures/shapes/ed51875f5bc640cf.sql new file mode 100644 index 000000000000..d6f3c8dd0234 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed51875f5bc640cf.sql @@ -0,0 +1 @@ +CREATE TABLE data_01875_1 Engine=MergeTree ORDER BY number PARTITION BY bitShiftRight(number, 8) + 1 AS SELECT * FROM numbers(16384) diff --git a/tests/ast_json_fixtures/shapes/ed90b6a86748e508.json b/tests/ast_json_fixtures/shapes/ed90b6a86748e508.json new file mode 100644 index 000000000000..23faac16bea5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed90b6a86748e508.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "merge1" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^foo" + } + ] + } + }, + "as_table": "foo" + } +} diff --git a/tests/ast_json_fixtures/shapes/ed90b6a86748e508.sql b/tests/ast_json_fixtures/shapes/ed90b6a86748e508.sql new file mode 100644 index 000000000000..84fba611e754 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed90b6a86748e508.sql @@ -0,0 +1 @@ +CREATE TABLE merge1 AS foo ENGINE = Merge(currentDatabase(), '^foo') diff --git a/tests/ast_json_fixtures/shapes/ed9f2957b01e2310.json b/tests/ast_json_fixtures/shapes/ed9f2957b01e2310.json new file mode 100644 index 000000000000..f0a8ce80d246 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed9f2957b01e2310.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_alter_auto_statistics" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_STATISTICS", + "clear_statistics": true + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ed9f2957b01e2310.sql b/tests/ast_json_fixtures/shapes/ed9f2957b01e2310.sql new file mode 100644 index 000000000000..888532226e39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ed9f2957b01e2310.sql @@ -0,0 +1 @@ +ALTER TABLE t_alter_auto_statistics CLEAR STATISTICS ALL diff --git a/tests/ast_json_fixtures/shapes/eda21ad45619de60.json b/tests/ast_json_fixtures/shapes/eda21ad45619de60.json new file mode 100644 index 000000000000..d090ad392b62 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eda21ad45619de60.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "foo" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "i1", + "expression": { + "type": "Identifier", + "name": "key" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "key" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/eda21ad45619de60.sql b/tests/ast_json_fixtures/shapes/eda21ad45619de60.sql new file mode 100644 index 000000000000..2e4687ccd6e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eda21ad45619de60.sql @@ -0,0 +1 @@ +CREATE TABLE foo (key int, INDEX i1 key TYPE minmax GRANULARITY 1) Engine=MergeTree() ORDER BY key diff --git a/tests/ast_json_fixtures/shapes/eda22600419d3018.json b/tests/ast_json_fixtures/shapes/eda22600419d3018.json new file mode 100644 index 000000000000..0bd56d81495c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eda22600419d3018.json @@ -0,0 +1,67 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "url_na_log" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "SiteId", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + }, + { + "type": "ColumnDeclaration", + "name": "DateVisit", + "data_type": { + "type": "DataType", + "name": "Date" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "SiteId" + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "SiteId" + }, + { + "type": "Identifier", + "name": "DateVisit" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity_bytes": "1000000", + "index_granularity": "1000", + "min_bytes_for_wide_part": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/eda22600419d3018.sql b/tests/ast_json_fixtures/shapes/eda22600419d3018.sql new file mode 100644 index 000000000000..9a0364049cc2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eda22600419d3018.sql @@ -0,0 +1,9 @@ +CREATE TABLE url_na_log +( + `SiteId` UInt32, + `DateVisit` Date +) +ENGINE = MergeTree +PRIMARY KEY SiteId +ORDER BY (SiteId, DateVisit) +SETTINGS index_granularity_bytes = 1000000, index_granularity = 1000, min_bytes_for_wide_part = 0 diff --git a/tests/ast_json_fixtures/shapes/eda64f71ac3c2f5e.json b/tests/ast_json_fixtures/shapes/eda64f71ac3c2f5e.json new file mode 100644 index 000000000000..03e74dc09200 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eda64f71ac3c2f5e.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "TruncateQuery", + "kind": "TRUNCATE", + "table": { + "type": "Identifier", + "name": "eligible_test" + }, + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": true + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/eda64f71ac3c2f5e.sql b/tests/ast_json_fixtures/shapes/eda64f71ac3c2f5e.sql new file mode 100644 index 000000000000..37f2ada9b386 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eda64f71ac3c2f5e.sql @@ -0,0 +1 @@ +TRUNCATE TABLE eligible_test SETTINGS use_query_cache = true diff --git a/tests/ast_json_fixtures/shapes/edaff8586ed18fa4.json b/tests/ast_json_fixtures/shapes/edaff8586ed18fa4.json new file mode 100644 index 000000000000..c5de212ab9d4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edaff8586ed18fa4.json @@ -0,0 +1,458 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "host_id" + }, + { + "type": "Identifier", + "name": "path_id" + }, + { + "type": "Function", + "alias": "rank", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "rank" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "as_of_posts", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "row_num", + "name": "row_number", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "page_id" + }, + { + "type": "Identifier", + "name": "post_id" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "as_of" + }, + "direction": "DESC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "posts" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "created" + }, + { + "type": "Function", + "name": "subtractHours", + "arguments": [ + { + "type": "Function", + "name": "now", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "24" + } + ] + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "host_id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "as_of_post_metrics", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "row_num", + "name": "row_number", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "page_id" + }, + { + "type": "Identifier", + "name": "post_id" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "as_of" + }, + "direction": "DESC" + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "post_metrics" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "created" + }, + { + "type": "Function", + "name": "subtractHours", + "arguments": [ + { + "type": "Function", + "name": "now", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "24" + } + ] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "page_id" + }, + { + "type": "Identifier", + "name": "post_id" + }, + { + "type": "Identifier", + "name": "host_id" + }, + { + "type": "Identifier", + "name": "path_id" + }, + { + "type": "Identifier", + "name": "impressions" + }, + { + "type": "Identifier", + "name": "clicks" + }, + { + "type": "Function", + "alias": "rank", + "name": "ntile", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "page_id" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "clicks" + }, + "direction": "ASC" + } + ], + "frame_type": "ROWS", + "frame_begin": { + "type": "Unbounded", + "preceding": true + }, + "frame_end": { + "type": "Unbounded" + } + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "as_of_posts" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "locality": "GLOBAL", + "using": [ + { + "type": "Identifier", + "name": "page_id" + }, + { + "type": "Identifier", + "name": "post_id" + }, + { + "type": "Identifier", + "name": "row_num" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "as_of_post_metrics" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "row_num" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "impressions" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t.rank", + "name_parts": ["t", "rank"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "18" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "host_id" + }, + { + "type": "Identifier", + "name": "path_id" + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/edaff8586ed18fa4.sql b/tests/ast_json_fixtures/shapes/edaff8586ed18fa4.sql new file mode 100644 index 000000000000..aff0af2dbda5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edaff8586ed18fa4.sql @@ -0,0 +1,40 @@ +SELECT + host_id, + path_id, + max(rank) AS rank +FROM +( + WITH + as_of_posts AS + ( + SELECT + *, + row_number() OVER (PARTITION BY (page_id, post_id) ORDER BY as_of DESC) AS row_num + FROM posts + WHERE (created >= subtractHours(now(), 24)) AND (host_id > 0) + ), + as_of_post_metrics AS + ( + SELECT + *, + row_number() OVER (PARTITION BY (page_id, post_id) ORDER BY as_of DESC) AS row_num + FROM post_metrics + WHERE created >= subtractHours(now(), 24) + ) + SELECT + page_id, + post_id, + host_id, + path_id, + impressions, + clicks, + ntile(20) OVER (PARTITION BY page_id ORDER BY clicks ASC ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS rank + FROM as_of_posts + GLOBAL LEFT JOIN as_of_post_metrics USING (page_id, post_id, row_num) + WHERE (row_num = 1) AND (impressions > 0) +) AS t +WHERE t.rank > 18 +GROUP BY + host_id, + path_id +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/edb25f5755504173.json b/tests/ast_json_fixtures/shapes/edb25f5755504173.json new file mode 100644 index 000000000000..88f5e562882f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edb25f5755504173.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "database": { + "type": "Identifier", + "name": "db_01870" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/edb25f5755504173.sql b/tests/ast_json_fixtures/shapes/edb25f5755504173.sql new file mode 100644 index 000000000000..0117fa36dbb6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edb25f5755504173.sql @@ -0,0 +1 @@ +attach database db_01870 diff --git a/tests/ast_json_fixtures/shapes/edb9c42cc29147b6.json b/tests/ast_json_fixtures/shapes/edb9c42cc29147b6.json new file mode 100644 index 000000000000..0d2c9354aca7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edb9c42cc29147b6.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "rmt", + "to_table": "rmt2" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/edb9c42cc29147b6.sql b/tests/ast_json_fixtures/shapes/edb9c42cc29147b6.sql new file mode 100644 index 000000000000..36b2eed86004 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edb9c42cc29147b6.sql @@ -0,0 +1 @@ +RENAME TABLE rmt TO rmt2 diff --git a/tests/ast_json_fixtures/shapes/edda165329a45b0a.json b/tests/ast_json_fixtures/shapes/edda165329a45b0a.json new file mode 100644 index 000000000000..da92d261df12 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edda165329a45b0a.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_optimize_exception" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "date", + "data_type": { + "type": "DataType", + "name": "Date" + } + } + ] + }, + "storage": { + "type": "Storage", + "partition_by": { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "date" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/edda165329a45b0a.sql b/tests/ast_json_fixtures/shapes/edda165329a45b0a.sql new file mode 100644 index 000000000000..d47b5f2758ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edda165329a45b0a.sql @@ -0,0 +1 @@ +CREATE TABLE test_optimize_exception (date Date) PARTITION BY toYYYYMM(date) ORDER BY date diff --git a/tests/ast_json_fixtures/shapes/edde029f134f93d1.json b/tests/ast_json_fixtures/shapes/edde029f134f93d1.json new file mode 100644 index 000000000000..b743ca1d9eac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edde029f134f93d1.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "ExistsTableQuery", + "table": { + "type": "Identifier", + "name": "eligible_test" + }, + "settings": { + "type": "Settings", + "changes": { + "use_query_cache": true + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/edde029f134f93d1.sql b/tests/ast_json_fixtures/shapes/edde029f134f93d1.sql new file mode 100644 index 000000000000..1fdcd22a2ea0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edde029f134f93d1.sql @@ -0,0 +1 @@ +EXISTS TABLE eligible_test SETTINGS use_query_cache = true diff --git a/tests/ast_json_fixtures/shapes/ede0e684e42b71dd.json b/tests/ast_json_fixtures/shapes/ede0e684e42b71dd.json new file mode 100644 index 000000000000..97435944b1f0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ede0e684e42b71dd.json @@ -0,0 +1,115 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "n", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "groupBitmapState", + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(UInt8)" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "number" + }, + { + "type": "Function", + "name": "bitmapContains", + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ede0e684e42b71dd.sql b/tests/ast_json_fixtures/shapes/ede0e684e42b71dd.sql new file mode 100644 index 000000000000..c4452b99af2b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ede0e684e42b71dd.sql @@ -0,0 +1 @@ +WITH (SELECT groupBitmapState(number::Nullable(UInt8)) as n from numbers(1)) as n SELECT number as x, bitmapContains(n, x) FROM numbers(10) diff --git a/tests/ast_json_fixtures/shapes/edfafa67a821d897.json b/tests/ast_json_fixtures/shapes/edfafa67a821d897.json new file mode 100644 index 000000000000..4a8b6df5e5d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edfafa67a821d897.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["03172_user_invalid_bcrypt_hash"] + } +} diff --git a/tests/ast_json_fixtures/shapes/edfafa67a821d897.sql b/tests/ast_json_fixtures/shapes/edfafa67a821d897.sql new file mode 100644 index 000000000000..6836b3b21185 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edfafa67a821d897.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS 03172_user_invalid_bcrypt_hash diff --git a/tests/ast_json_fixtures/shapes/edfbb38913d36064.json b/tests/ast_json_fixtures/shapes/edfbb38913d36064.json new file mode 100644 index 000000000000..937fbc31c477 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edfbb38913d36064.json @@ -0,0 +1,239 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "vec_1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "groupNumericIndexedVectorStateIf", + "arguments": [ + { + "type": "Identifier", + "name": "uin" + }, + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ds" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2023-12-20" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "uin_value_details" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "alias": "vec_2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "groupNumericIndexedVectorStateIf", + "arguments": [ + { + "type": "Identifier", + "name": "uin" + }, + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ds" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2023-12-21" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "uin_value_details" + } + } + } + ] + } + } + ] + } + }, + { + "type": "Function", + "alias": "vec_3", + "name": "numericIndexedVectorPointwiseDivide", + "arguments": [ + { + "type": "Identifier", + "name": "vec_1" + }, + { + "type": "Identifier", + "name": "vec_2" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "arrayJoin", + "arguments": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "numericIndexedVectorShortDebugString", + "arguments": [ + { + "type": "Identifier", + "name": "vec_1" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "numericIndexedVectorAllValueSum", + "arguments": [ + { + "type": "Identifier", + "name": "vec_1" + } + ] + } + ] + }, + { + "type": "Function", + "name": "numericIndexedVectorShortDebugString", + "arguments": [ + { + "type": "Identifier", + "name": "vec_2" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "numericIndexedVectorAllValueSum", + "arguments": [ + { + "type": "Identifier", + "name": "vec_2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "numericIndexedVectorShortDebugString", + "arguments": [ + { + "type": "Identifier", + "name": "vec_3" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "numericIndexedVectorAllValueSum", + "arguments": [ + { + "type": "Identifier", + "name": "vec_3" + } + ] + } + ] + } + ] + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/edfbb38913d36064.sql b/tests/ast_json_fixtures/shapes/edfbb38913d36064.sql new file mode 100644 index 000000000000..463f26a53f9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edfbb38913d36064.sql @@ -0,0 +1,18 @@ +with +( + select groupNumericIndexedVectorStateIf(uin, value, ds = '2023-12-20') + from uin_value_details +) as vec_1, +( + select groupNumericIndexedVectorStateIf(uin, value, ds = '2023-12-21') + from uin_value_details +) as vec_2 +, numericIndexedVectorPointwiseDivide(vec_1, vec_2) as vec_3 +select arrayJoin([ + numericIndexedVectorShortDebugString(vec_1) + , toString(numericIndexedVectorAllValueSum(vec_1)) + , numericIndexedVectorShortDebugString(vec_2) + , toString(numericIndexedVectorAllValueSum(vec_2)) + , numericIndexedVectorShortDebugString(vec_3) + , toString(numericIndexedVectorAllValueSum(vec_3)) +]) diff --git a/tests/ast_json_fixtures/shapes/edfd2cd4c0906d40.json b/tests/ast_json_fixtures/shapes/edfd2cd4c0906d40.json new file mode 100644 index 000000000000..4d5d4c3523ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edfd2cd4c0906d40.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u2_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "NO_PASSWORD", + "arguments": [] + } + ], + "replace_authentication_methods": true, + "hosts": { + "like_patterns": ["%.%.myhost.com"] + }, + "default_roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/edfd2cd4c0906d40.sql b/tests/ast_json_fixtures/shapes/edfd2cd4c0906d40.sql new file mode 100644 index 000000000000..0ff52f321e1d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/edfd2cd4c0906d40.sql @@ -0,0 +1 @@ +CREATE USER u2_01292 NOT IDENTIFIED HOST LIKE '%.%.myhost.com' DEFAULT ROLE NONE diff --git a/tests/ast_json_fixtures/shapes/ee10be4550d78de7.json b/tests/ast_json_fixtures/shapes/ee10be4550d78de7.json new file mode 100644 index 000000000000..6522730dec5c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee10be4550d78de7.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u12_01292" + } + ] + }, + "hosts": { + "addresses": ["192.168.1.1"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ee10be4550d78de7.sql b/tests/ast_json_fixtures/shapes/ee10be4550d78de7.sql new file mode 100644 index 000000000000..875e9b9755bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee10be4550d78de7.sql @@ -0,0 +1 @@ +CREATE USER u12_01292 HOST IP '192.168.1.1' diff --git a/tests/ast_json_fixtures/shapes/ee21711161e49f9c.json b/tests/ast_json_fixtures/shapes/ee21711161e49f9c.json new file mode 100644 index 000000000000..cd71c2622910 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee21711161e49f9c.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "udf_preprocessor", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/ee21711161e49f9c.sql b/tests/ast_json_fixtures/shapes/ee21711161e49f9c.sql new file mode 100644 index 000000000000..95718f1fb930 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee21711161e49f9c.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS udf_preprocessor diff --git a/tests/ast_json_fixtures/shapes/ee2dd3f85f3d99e0.json b/tests/ast_json_fixtures/shapes/ee2dd3f85f3d99e0.json new file mode 100644 index 000000000000..89181ea11d78 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee2dd3f85f3d99e0.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "db1", + "table": "tb1" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ee2dd3f85f3d99e0.sql b/tests/ast_json_fixtures/shapes/ee2dd3f85f3d99e0.sql new file mode 100644 index 000000000000..54bb98b1f673 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee2dd3f85f3d99e0.sql @@ -0,0 +1 @@ +GRANT SELECT ON db1.tb1 TO test_user_01999 diff --git a/tests/ast_json_fixtures/shapes/ee42320a213a8fb1.json b/tests/ast_json_fixtures/shapes/ee42320a213a8fb1.json new file mode 100644 index 000000000000..8d7edbaea5fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee42320a213a8fb1.json @@ -0,0 +1,40 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "c0", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "c0" + } + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "c0" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ee42320a213a8fb1.sql b/tests/ast_json_fixtures/shapes/ee42320a213a8fb1.sql new file mode 100644 index 000000000000..14bc828a7dd3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee42320a213a8fb1.sql @@ -0,0 +1 @@ +CREATE TABLE t1 (c0 Int32, PRIMARY KEY (c0)) ENGINE=MergeTree diff --git a/tests/ast_json_fixtures/shapes/ee78579f62353ee0.json b/tests/ast_json_fixtures/shapes/ee78579f62353ee0.json new file mode 100644 index 000000000000..8aa5b4085390 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee78579f62353ee0.json @@ -0,0 +1,223 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "sample_frequency", + "value_type": "UInt64", + "value": "44100" + }, + { + "type": "Identifier", + "alias": "tick", + "name": "number" + }, + { + "type": "Function", + "alias": "time", + "name": "divide", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tick" + }, + { + "type": "Identifier", + "name": "sample_frequency" + } + ] + }, + { + "type": "Function", + "alias": "delay", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Identifier", + "name": "wave" + }, + { + "type": "Identifier", + "name": "delay_" + }, + { + "type": "Identifier", + "name": "decay" + }, + { + "type": "Identifier", + "name": "count" + } + ] + }, + { + "type": "Function", + "name": "arraySum", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n1" + } + ] + }, + { + "type": "Function", + "name": "wave", + "arguments": [ + { + "type": "Function", + "name": "minus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "delay_" + }, + { + "type": "Identifier", + "name": "n1" + } + ] + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "count" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "kick", + "name": "delay", + "arguments": [ + { + "type": "Identifier", + "name": "time" + }, + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.2 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "kick" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ee78579f62353ee0.sql b/tests/ast_json_fixtures/shapes/ee78579f62353ee0.sql new file mode 100644 index 000000000000..f75a5008eb6a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee78579f62353ee0.sql @@ -0,0 +1,17 @@ +WITH + + 44100 AS sample_frequency + , number AS tick + , tick / sample_frequency AS time + + + , (time, wave, delay_, decay, count) -> arraySum(n1 -> wave(time - delay_ * n1), range(count)) AS delay + + , delay(time, (time -> 0.5), 0.2, 0.5, 5) AS kick + +SELECT + + kick + +FROM system.numbers +LIMIT 5 diff --git a/tests/ast_json_fixtures/shapes/ee7e5a7b3b7e4a2a.json b/tests/ast_json_fixtures/shapes/ee7e5a7b3b7e4a2a.json new file mode 100644 index 000000000000..03b5a6c69563 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee7e5a7b3b7e4a2a.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MODIFY_STATISTICS", + "statistics_declaration": { + "type": "Stat", + "columns": { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "types": { + "type": "ExpressionList", + "children": [ + { + "type": "Function", + "name": "uniq", + "arguments": [] + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ee7e5a7b3b7e4a2a.sql b/tests/ast_json_fixtures/shapes/ee7e5a7b3b7e4a2a.sql new file mode 100644 index 000000000000..f6f9fb6f3f2b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee7e5a7b3b7e4a2a.sql @@ -0,0 +1 @@ +ALTER TABLE tab MODIFY STATISTICS a TYPE uniq diff --git a/tests/ast_json_fixtures/shapes/ee80dc74d228f35e.json b/tests/ast_json_fixtures/shapes/ee80dc74d228f35e.json new file mode 100644 index 000000000000..c47e1fbfc177 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee80dc74d228f35e.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "rename2", + "to_table": "rename3" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ee80dc74d228f35e.sql b/tests/ast_json_fixtures/shapes/ee80dc74d228f35e.sql new file mode 100644 index 000000000000..bcda20fa8e17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee80dc74d228f35e.sql @@ -0,0 +1 @@ +RENAME TABLE rename2 TO rename3 diff --git a/tests/ast_json_fixtures/shapes/ee8a9a020f1bb8de.json b/tests/ast_json_fixtures/shapes/ee8a9a020f1bb8de.json new file mode 100644 index 000000000000..d1a4c251a125 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee8a9a020f1bb8de.json @@ -0,0 +1,95 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "pid", + "value_type": "UInt64", + "value": "123" + } + ], + "select": [ + { + "type": "Identifier", + "name": "a.col1", + "name_parts": ["a", "col1"] + }, + { + "type": "Function", + "alias": "summ", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "a.col2", + "name_parts": ["a", "col2"] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "a", + "name": "table1" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "pid" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.col2", + "name_parts": ["a", "col2"] + }, + { + "type": "Identifier", + "name": "pid" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a.col1", + "name_parts": ["a", "col1"] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ee8a9a020f1bb8de.sql b/tests/ast_json_fixtures/shapes/ee8a9a020f1bb8de.sql new file mode 100644 index 000000000000..3f93144fd289 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee8a9a020f1bb8de.sql @@ -0,0 +1,5 @@ +with 123 as pid +select a.col1, sum(a.col2) as summ +from table1 a +prewhere (pid is null or a.col2 = pid) +group by a.col1 diff --git a/tests/ast_json_fixtures/shapes/ee936123e15932aa.json b/tests/ast_json_fixtures/shapes/ee936123e15932aa.json new file mode 100644 index 000000000000..fa6d15f488a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee936123e15932aa.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "lc" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ee936123e15932aa.sql b/tests/ast_json_fixtures/shapes/ee936123e15932aa.sql new file mode 100644 index 000000000000..6d3d5573c281 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ee936123e15932aa.sql @@ -0,0 +1 @@ +SELECT a, count(a) FROM lc GROUP BY a WITH CUBE ORDER BY a diff --git a/tests/ast_json_fixtures/shapes/eea990020522058c.json b/tests/ast_json_fixtures/shapes/eea990020522058c.json new file mode 100644 index 000000000000..2a26603e4214 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eea990020522058c.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "RevokeQuery", + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "sqllt", + "table": "table" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["sqllt_user"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/eea990020522058c.sql b/tests/ast_json_fixtures/shapes/eea990020522058c.sql new file mode 100644 index 000000000000..bf553211cbb3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eea990020522058c.sql @@ -0,0 +1 @@ +REVOKE SELECT ON sqllt.table FROM sqllt_user diff --git a/tests/ast_json_fixtures/shapes/eeb0ebe7068588f5.json b/tests/ast_json_fixtures/shapes/eeb0ebe7068588f5.json new file mode 100644 index 000000000000..f1113d214c38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eeb0ebe7068588f5.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "QUOTA", + "if_exists": true, + "names": ["q15_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/eeb0ebe7068588f5.sql b/tests/ast_json_fixtures/shapes/eeb0ebe7068588f5.sql new file mode 100644 index 000000000000..297125c7f6a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eeb0ebe7068588f5.sql @@ -0,0 +1 @@ +DROP QUOTA IF EXISTS q15_01297 diff --git a/tests/ast_json_fixtures/shapes/eee901b6838bd105.json b/tests/ast_json_fixtures/shapes/eee901b6838bd105.json new file mode 100644 index 000000000000..184c659a8d6d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eee901b6838bd105.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01223" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/eee901b6838bd105.sql b/tests/ast_json_fixtures/shapes/eee901b6838bd105.sql new file mode 100644 index 000000000000..97b33da722df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eee901b6838bd105.sql @@ -0,0 +1 @@ +select distinct * from dist_01223 order by key diff --git a/tests/ast_json_fixtures/shapes/eef67ae590f23f7f.json b/tests/ast_json_fixtures/shapes/eef67ae590f23f7f.json new file mode 100644 index 000000000000..4848482480c7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eef67ae590f23f7f.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Identifier", + "name": "fact_3_id" + }, + { + "type": "Identifier", + "name": "fact_4_id" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "grouping_sets" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "fact_3_id" + }, + { + "type": "Identifier", + "name": "fact_4_id" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "fact_3_id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "fact_4_id" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "optimize_aggregation_in_order": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/eef67ae590f23f7f.sql b/tests/ast_json_fixtures/shapes/eef67ae590f23f7f.sql new file mode 100644 index 000000000000..ad54dc7f2d04 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eef67ae590f23f7f.sql @@ -0,0 +1,7 @@ +SELECT fact_3_id, fact_4_id, count() +FROM grouping_sets +GROUP BY + GROUPING SETS ( + ( fact_3_id, fact_4_id)) +ORDER BY fact_3_id, fact_4_id +SETTINGS optimize_aggregation_in_order=1 diff --git a/tests/ast_json_fixtures/shapes/eefae3ec9eb6d6c3.json b/tests/ast_json_fixtures/shapes/eefae3ec9eb6d6c3.json new file mode 100644 index 000000000000..e19b5f8edd56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eefae3ec9eb6d6c3.json @@ -0,0 +1,172 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "recursive", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "uuid3" + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "id", + "name": "parent" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "tab.id", + "name_parts": ["tab", "id"] + }, + { + "type": "Identifier", + "name": "recursive" + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "parent" + }, + { + "type": "Literal", + "value_type": "String", + "value": "empty" + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "parent" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recursive" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/eefae3ec9eb6d6c3.sql b/tests/ast_json_fixtures/shapes/eefae3ec9eb6d6c3.sql new file mode 100644 index 000000000000..f1fd4af79543 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eefae3ec9eb6d6c3.sql @@ -0,0 +1,13 @@ +WITH RECURSIVE + recursive AS ( + SELECT id FROM tab WHERE id = 'uuid3' + UNION ALL + SELECT parent AS id + FROM tab + WHERE tab.id IN recursive AND parent != 'empty' + GROUP BY parent + ) +SELECT * +FROM recursive +GROUP BY id +ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/eefb321fc5029156.json b/tests/ast_json_fixtures/shapes/eefb321fc5029156.json new file mode 100644 index 000000000000..0343599f820e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eefb321fc5029156.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "SUM", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "log_comment": "03783_autopr_dataflow_cache_reuse_query_0" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/eefb321fc5029156.sql b/tests/ast_json_fixtures/shapes/eefb321fc5029156.sql new file mode 100644 index 000000000000..9aa0d69b8280 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/eefb321fc5029156.sql @@ -0,0 +1 @@ +SELECT key, SUM(value) FROM t GROUP BY key FORMAT Null SETTINGS log_comment='03783_autopr_dataflow_cache_reuse_query_0' diff --git a/tests/ast_json_fixtures/shapes/ef0105c1f0a73a14.json b/tests/ast_json_fixtures/shapes/ef0105c1f0a73a14.json new file mode 100644 index 000000000000..d138dd33330a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef0105c1f0a73a14.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "UndropQuery", + "table": { + "type": "Identifier", + "name": "02681_undrop_log" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ef0105c1f0a73a14.sql b/tests/ast_json_fixtures/shapes/ef0105c1f0a73a14.sql new file mode 100644 index 000000000000..8873cf4c468f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef0105c1f0a73a14.sql @@ -0,0 +1 @@ +undrop table 02681_undrop_log diff --git a/tests/ast_json_fixtures/shapes/ef0575c9e3772165.json b/tests/ast_json_fixtures/shapes/ef0575c9e3772165.json new file mode 100644 index 000000000000..bb315bc58c31 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef0575c9e3772165.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "load_marks_asynchronously": "0" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/ef0575c9e3772165.sql b/tests/ast_json_fixtures/shapes/ef0575c9e3772165.sql new file mode 100644 index 000000000000..35c272e062e1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef0575c9e3772165.sql @@ -0,0 +1 @@ +select * from data format Null settings load_marks_asynchronously=0 diff --git a/tests/ast_json_fixtures/shapes/ef15741de3696771.json b/tests/ast_json_fixtures/shapes/ef15741de3696771.json new file mode 100644 index 000000000000..ce7493a0cf4b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef15741de3696771.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "toNullable", + "arguments": [ + { + "type": "Function", + "name": "concat", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "\/03727_prewhere_intermediate_columns.parquet" + } + ] + } + ] + } + ] + } + } + } + ] + }, + "prewhere": { + "type": "Identifier", + "name": "x" + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ef15741de3696771.sql b/tests/ast_json_fixtures/shapes/ef15741de3696771.sql new file mode 100644 index 000000000000..557defd7dc56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef15741de3696771.sql @@ -0,0 +1 @@ +select x from file(toNullable(concat(currentDatabase(), '/03727_prewhere_intermediate_columns.parquet'))) prewhere x order by x diff --git a/tests/ast_json_fixtures/shapes/ef245d981c2c1be0.json b/tests/ast_json_fixtures/shapes/ef245d981c2c1be0.json new file mode 100644 index 000000000000..fcb62841ae3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef245d981c2c1be0.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "something", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "25" + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "something" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Function", + "name": "assumeNotNull", + "arguments": [ + { + "type": "Identifier", + "name": "something" + } + ] + } + ] + } + ] + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ef245d981c2c1be0.sql b/tests/ast_json_fixtures/shapes/ef245d981c2c1be0.sql new file mode 100644 index 000000000000..e06cb6de86ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef245d981c2c1be0.sql @@ -0,0 +1,4 @@ +with + (select 25) as something +select *, something +from numbers(toUInt64(assumeNotNull(something))) diff --git a/tests/ast_json_fixtures/shapes/ef68ebad01013411.json b/tests/ast_json_fixtures/shapes/ef68ebad01013411.json new file mode 100644 index 000000000000..2481bd9195e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef68ebad01013411.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q1_01297", "q2_01297"], + "limits": [ + { + "duration_sec": "86400" + } + ], + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ef68ebad01013411.sql b/tests/ast_json_fixtures/shapes/ef68ebad01013411.sql new file mode 100644 index 000000000000..10f7ebe8183c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef68ebad01013411.sql @@ -0,0 +1 @@ +ALTER QUOTA q1_01297, q2_01297 FOR 1 day TRACKING ONLY TO r1_01297 diff --git a/tests/ast_json_fixtures/shapes/ef91289e4671d321.json b/tests/ast_json_fixtures/shapes/ef91289e4671d321.json new file mode 100644 index 000000000000..d1e8327cc97e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef91289e4671d321.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "BackupQuery", + "kind": "BACKUP", + "elements": [ + { + "element_type": "TABLE", + "table": "03760_backup_keepermap" + } + ], + "backup_name": { + "type": "Function", + "name": "Null", + "kind": "BACKUP_NAME", + "arguments": [] + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/ef91289e4671d321.sql b/tests/ast_json_fixtures/shapes/ef91289e4671d321.sql new file mode 100644 index 000000000000..c708b8cd00a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef91289e4671d321.sql @@ -0,0 +1 @@ +BACKUP TABLE 03760_backup_keepermap TO Null FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/ef97cf8a2fe66e71.json b/tests/ast_json_fixtures/shapes/ef97cf8a2fe66e71.json new file mode 100644 index 000000000000..eccf73fb3241 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef97cf8a2fe66e71.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_table": "set2", + "to_table": "set" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ef97cf8a2fe66e71.sql b/tests/ast_json_fixtures/shapes/ef97cf8a2fe66e71.sql new file mode 100644 index 000000000000..5a7fb966c424 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ef97cf8a2fe66e71.sql @@ -0,0 +1 @@ +RENAME TABLE set2 TO set diff --git a/tests/ast_json_fixtures/shapes/efa92bbccecb1ae9.json b/tests/ast_json_fixtures/shapes/efa92bbccecb1ae9.json new file mode 100644 index 000000000000..d6bac06c3625 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/efa92bbccecb1ae9.json @@ -0,0 +1,134 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "base64Decode", + "arguments": [ + { + "type": "Function", + "name": "base64Encode", + "arguments": [ + { + "type": "Function", + "name": "normalizeQuery", + "arguments": [ + { + "type": "Identifier", + "name": "query" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryFinish" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "log_comment" + }, + { + "type": "Literal", + "value_type": "String", + "value": "ad15a651" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "normalizeQuery", + "arguments": [ + { + "type": "Identifier", + "name": "query" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "normalizeQuery", + "arguments": [ + { + "type": "Identifier", + "name": "query" + } + ] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/efa92bbccecb1ae9.sql b/tests/ast_json_fixtures/shapes/efa92bbccecb1ae9.sql new file mode 100644 index 000000000000..a1a048079bfc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/efa92bbccecb1ae9.sql @@ -0,0 +1,5 @@ +SELECT base64Decode(base64Encode(normalizeQuery(query))) + FROM system.query_log + WHERE type = 'QueryFinish' AND log_comment = 'ad15a651' AND current_database = currentDatabase() + GROUP BY normalizeQuery(query) + ORDER BY normalizeQuery(query) diff --git a/tests/ast_json_fixtures/shapes/efb82fb21ef44712.json b/tests/ast_json_fixtures/shapes/efb82fb21ef44712.json new file mode 100644 index 000000000000..fe596c34dd92 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/efb82fb21ef44712.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "exp10", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ], + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/efb82fb21ef44712.sql b/tests/ast_json_fixtures/shapes/efb82fb21ef44712.sql new file mode 100644 index 000000000000..9abadcde9617 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/efb82fb21ef44712.sql @@ -0,0 +1 @@ +SELECT exp10(number) FROM numbers(10) FORMAT PrettySpace diff --git a/tests/ast_json_fixtures/shapes/efc7c4cf33d93cf8.json b/tests/ast_json_fixtures/shapes/efc7c4cf33d93cf8.json new file mode 100644 index 000000000000..b7635488a0fd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/efc7c4cf33d93cf8.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "CD" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "sequence" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "userID" + } + ], + "having": { + "type": "Function", + "name": "sequenceMatch", + "arguments": [ + { + "type": "Identifier", + "name": "EventTime" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "eventType" + }, + { + "type": "Literal", + "value_type": "String", + "value": "C" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "eventType" + }, + { + "type": "Literal", + "value_type": "String", + "value": "D" + } + ] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "String", + "value": "(?1)(?t>=10000000000000)(?2)" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/efc7c4cf33d93cf8.sql b/tests/ast_json_fixtures/shapes/efc7c4cf33d93cf8.sql new file mode 100644 index 000000000000..44a13576ce13 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/efc7c4cf33d93cf8.sql @@ -0,0 +1,4 @@ +SELECT 'CD' +FROM sequence +GROUP BY userID +HAVING sequenceMatch('(?1)(?t>=10000000000000)(?2)')(EventTime, eventType = 'C', eventType = 'D') diff --git a/tests/ast_json_fixtures/shapes/efe839ed585ca48a.json b/tests/ast_json_fixtures/shapes/efe839ed585ca48a.json new file mode 100644 index 000000000000..ece2a016cfe7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/efe839ed585ca48a.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.{2..11}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data_01730" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "Float64", + "value": 1000000 + }, + "settings": { + "type": "Settings", + "changes": { + "distributed_group_by_no_merge": "2", + "max_memory_usage": "100Mi", + "optimize_aggregation_in_order": "1", + "max_threads": "10" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/efe839ed585ca48a.sql b/tests/ast_json_fixtures/shapes/efe839ed585ca48a.sql new file mode 100644 index 000000000000..2cdf09b213dc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/efe839ed585ca48a.sql @@ -0,0 +1 @@ +select * from remote('127.{2..11}', currentDatabase(), data_01730) group by key order by key limit 1e6 settings distributed_group_by_no_merge=2, max_memory_usage='100Mi', optimize_aggregation_in_order=1, max_threads=10 format Null diff --git a/tests/ast_json_fixtures/shapes/f00c71022aebb1b1.json b/tests/ast_json_fixtures/shapes/f00c71022aebb1b1.json new file mode 100644 index 000000000000..7638aa11949a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f00c71022aebb1b1.json @@ -0,0 +1,91 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_cluster_two_shards_different_databases", + "table": { + "type": "Identifier", + "name": "demo_loan_01568" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "Int64" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "id" + } + }, + { + "type": "ColumnDeclaration", + "name": "date_stat", + "data_type": { + "type": "DataType", + "name": "Date" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "date of stat" + } + }, + { + "type": "ColumnDeclaration", + "name": "customer_no", + "data_type": { + "type": "DataType", + "name": "String" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "customer no" + } + }, + { + "type": "ColumnDeclaration", + "name": "loan_principal", + "data_type": { + "type": "DataType", + "name": "Float64" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "loan principal" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYYYYMM", + "arguments": [ + { + "type": "Identifier", + "name": "date_stat" + } + ] + }, + "order_by": { + "type": "Identifier", + "name": "id" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f00c71022aebb1b1.sql b/tests/ast_json_fixtures/shapes/f00c71022aebb1b1.sql new file mode 100644 index 000000000000..58db412529a7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f00c71022aebb1b1.sql @@ -0,0 +1 @@ +CREATE TABLE demo_loan_01568 ON CLUSTER test_cluster_two_shards_different_databases ( `id` Int64 COMMENT 'id', `date_stat` Date COMMENT 'date of stat', `customer_no` String COMMENT 'customer no', `loan_principal` Float64 COMMENT 'loan principal' ) ENGINE=ReplacingMergeTree() ORDER BY id PARTITION BY toYYYYMM(date_stat) diff --git a/tests/ast_json_fixtures/shapes/f02426f7173df0cd.json b/tests/ast_json_fixtures/shapes/f02426f7173df0cd.json new file mode 100644 index 000000000000..7b56ca83f4a9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f02426f7173df0cd.json @@ -0,0 +1,90 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test_foo" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "123_secure", + "data_type": { + "type": "DataType", + "name": "Int8" + } + }, + { + "type": "ColumnDeclaration", + "name": "date", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "town", + "data_type": { + "type": "DataType", + "name": "LowCardinality", + "arguments": [ + { + "type": "DataType", + "name": "String" + } + ] + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Function", + "name": "toYear", + "arguments": [ + { + "type": "Identifier", + "name": "date" + } + ] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "town" + }, + { + "type": "Identifier", + "name": "date" + } + ] + } + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "test" + }, + "settings": { + "type": "Settings", + "changes": { + "enforce_strict_identifier_format": true + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f02426f7173df0cd.sql b/tests/ast_json_fixtures/shapes/f02426f7173df0cd.sql new file mode 100644 index 000000000000..920308453e09 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f02426f7173df0cd.sql @@ -0,0 +1,11 @@ +CREATE TABLE test_foo ( + `123_secure` Int8, + `date` Date, + `town` LowCardinality(String), +) +ENGINE = MergeTree +PRIMARY KEY (town, date) +PARTITION BY toYear(date) +COMMENT 'test' +SETTINGS + enforce_strict_identifier_format=true diff --git a/tests/ast_json_fixtures/shapes/f024d326d77e106b.json b/tests/ast_json_fixtures/shapes/f024d326d77e106b.json new file mode 100644 index 000000000000..072bd2edc525 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f024d326d77e106b.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "String", + "value": "Hello, \"World\"" + }, + { + "type": "Literal", + "alias": "y", + "value_type": "UInt64", + "value": "123" + }, + { + "type": "Literal", + "alias": "z", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "alias": "a", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "456" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "abc" + }, + { + "value_type": "String", + "value": "def" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "b", + "value_type": "String", + "value": "Newline\nhere" + } + ] + } + ], + "format": "CSVWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/f024d326d77e106b.sql b/tests/ast_json_fixtures/shapes/f024d326d77e106b.sql new file mode 100644 index 000000000000..a7ec6e721511 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f024d326d77e106b.sql @@ -0,0 +1 @@ +SELECT 'Hello, "World"' AS x, 123 AS y, [1, 2, 3] AS z, (456, ['abc', 'def']) AS a, 'Newline\nhere' AS b FORMAT CSVWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/f02551697bd0aaa3.json b/tests/ast_json_fixtures/shapes/f02551697bd0aaa3.json new file mode 100644 index 000000000000..c2adc6ee83d8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f02551697bd0aaa3.json @@ -0,0 +1,108 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "a", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "alias": "b", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "CROSS" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "a" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.b", + "name_parts": ["a", "b"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f02551697bd0aaa3.sql b/tests/ast_json_fixtures/shapes/f02551697bd0aaa3.sql new file mode 100644 index 000000000000..b17da379a05b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f02551697bd0aaa3.sql @@ -0,0 +1,5 @@ +WITH a AS (select (select 1 WHERE 0) as b) +select 1 +from system.one +cross join a +where a.b = 0 diff --git a/tests/ast_json_fixtures/shapes/f041ac5d2ffd2b07.json b/tests/ast_json_fixtures/shapes/f041ac5d2ffd2b07.json new file mode 100644 index 000000000000..a81923c634d6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f041ac5d2ffd2b07.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "START REPLICATION QUEUES", + "table": { + "type": "Identifier", + "name": "checksums_r2" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f041ac5d2ffd2b07.sql b/tests/ast_json_fixtures/shapes/f041ac5d2ffd2b07.sql new file mode 100644 index 000000000000..154a38b43b36 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f041ac5d2ffd2b07.sql @@ -0,0 +1 @@ +SYSTEM START REPLICATION QUEUES checksums_r2 diff --git a/tests/ast_json_fixtures/shapes/f066380fc18e5ac6.json b/tests/ast_json_fixtures/shapes/f066380fc18e5ac6.json new file mode 100644 index 000000000000..615f4ff0adf6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f066380fc18e5ac6.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/f066380fc18e5ac6.sql b/tests/ast_json_fixtures/shapes/f066380fc18e5ac6.sql new file mode 100644 index 000000000000..84aa253259c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f066380fc18e5ac6.sql @@ -0,0 +1 @@ +SELECT 1 UNION ALL SELECT 2 FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/f06bb0da5593b072.json b/tests/ast_json_fixtures/shapes/f06bb0da5593b072.json new file mode 100644 index 000000000000..b4416c7f350f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f06bb0da5593b072.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q2_01297"], + "roles": { + "type": "RolesOrUsersSet" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f06bb0da5593b072.sql b/tests/ast_json_fixtures/shapes/f06bb0da5593b072.sql new file mode 100644 index 000000000000..ae55ab3fbeed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f06bb0da5593b072.sql @@ -0,0 +1 @@ +CREATE QUOTA q2_01297 TO NONE diff --git a/tests/ast_json_fixtures/shapes/f06ea8090e9397e8.json b/tests/ast_json_fixtures/shapes/f06ea8090e9397e8.json new file mode 100644 index 000000000000..921b0d2acf7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f06ea8090e9397e8.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "ShowGrantsQuery", + "for_roles": { + "type": "RolesOrUsersSet", + "names": ["user_03141"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f06ea8090e9397e8.sql b/tests/ast_json_fixtures/shapes/f06ea8090e9397e8.sql new file mode 100644 index 000000000000..551012591c94 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f06ea8090e9397e8.sql @@ -0,0 +1 @@ +SHOW GRANTS FOR user_03141 diff --git a/tests/ast_json_fixtures/shapes/f0725378222908ae.json b/tests/ast_json_fixtures/shapes/f0725378222908ae.json new file mode 100644 index 000000000000..8df30aaa4303 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0725378222908ae.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "exchange": true, + "elements": [ + { + "from_database": "test1601_detach_permanently_atomic", + "from_table": "test_name_rename_attempt", + "to_database": "test1601_detach_permanently_atomic", + "to_table": "test_name_reuse" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f0725378222908ae.sql b/tests/ast_json_fixtures/shapes/f0725378222908ae.sql new file mode 100644 index 000000000000..a1db6d429dbb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0725378222908ae.sql @@ -0,0 +1 @@ +EXCHANGE TABLES test1601_detach_permanently_atomic.test_name_rename_attempt AND test1601_detach_permanently_atomic.test_name_reuse diff --git a/tests/ast_json_fixtures/shapes/f0750f0e132bfaf0.json b/tests/ast_json_fixtures/shapes/f0750f0e132bfaf0.json new file mode 100644 index 000000000000..9562628ce595 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0750f0e132bfaf0.json @@ -0,0 +1,48 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "database": { + "type": "Identifier", + "name": "test_01457" + }, + "table": { + "type": "Identifier", + "name": "tf_remote_explicit_structure" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "as_table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "tmp" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f0750f0e132bfaf0.sql b/tests/ast_json_fixtures/shapes/f0750f0e132bfaf0.sql new file mode 100644 index 000000000000..65a77ec33c40 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0750f0e132bfaf0.sql @@ -0,0 +1 @@ +CREATE TABLE test_01457.tf_remote_explicit_structure (n UInt64) AS remote('localhost', currentDatabase(), 'tmp') diff --git a/tests/ast_json_fixtures/shapes/f07e52e07d97deb2.json b/tests/ast_json_fixtures/shapes/f07e52e07d97deb2.json new file mode 100644 index 000000000000..44e21b311c05 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f07e52e07d97deb2.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "alias": "a", + "name": "c" + }, + { + "type": "Identifier", + "alias": "b", + "name": "d" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table2" + } + } + } + ] + } + } + ], + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/f07e52e07d97deb2.sql b/tests/ast_json_fixtures/shapes/f07e52e07d97deb2.sql new file mode 100644 index 000000000000..d6baab3c5908 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f07e52e07d97deb2.sql @@ -0,0 +1 @@ +SELECT *, c as a, d as b FROM table2 FORMAT PrettyCompact diff --git a/tests/ast_json_fixtures/shapes/f0839053c1b97e0e.json b/tests/ast_json_fixtures/shapes/f0839053c1b97e0e.json new file mode 100644 index 000000000000..9636c568be06 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0839053c1b97e0e.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "dynamicType", + "arguments": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "d.Nested(x UInt32, y Dynamic).x", + "name_parts": ["d", "Nested(x UInt32, y Dynamic)", "x"] + }, + { + "type": "Identifier", + "name": "d.Nested(x UInt32, y Dynamic).y", + "name_parts": ["d", "Nested(x UInt32, y Dynamic)", "y"] + }, + { + "type": "Function", + "name": "dynamicType", + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d.Nested(x UInt32, y Dynamic).y", + "name_parts": ["d", "Nested(x UInt32, y Dynamic)", "y"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "d.Nested(x UInt32, y Dynamic).y.String", + "name_parts": ["d", "Nested(x UInt32, y Dynamic)", "y", "String"] + }, + { + "type": "Identifier", + "name": "d.Nested(x UInt32, y Dynamic).y.Tuple(Int64, Array(String))", + "name_parts": ["d", "Nested(x UInt32, y Dynamic)", "y", "Tuple(Int64, Array(String))"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + } + ] + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/f0839053c1b97e0e.sql b/tests/ast_json_fixtures/shapes/f0839053c1b97e0e.sql new file mode 100644 index 000000000000..1528dae00643 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0839053c1b97e0e.sql @@ -0,0 +1,9 @@ +SELECT dynamicType(d), + d, + d.`Nested(x UInt32, y Dynamic)`.x, + d.`Nested(x UInt32, y Dynamic)`.y, + dynamicType(d.`Nested(x UInt32, y Dynamic)`.y[1]), + d.`Nested(x UInt32, y Dynamic)`.y.`String`, + d.`Nested(x UInt32, y Dynamic)`.y.`Tuple(Int64, Array(String))` +FROM t ORDER BY d +FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/f08c1718b873796b.json b/tests/ast_json_fixtures/shapes/f08c1718b873796b.json new file mode 100644 index 000000000000..22c6a6a674fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f08c1718b873796b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02484_plusone", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/f08c1718b873796b.sql b/tests/ast_json_fixtures/shapes/f08c1718b873796b.sql new file mode 100644 index 000000000000..eb5e105d4bd9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f08c1718b873796b.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02484_plusone diff --git a/tests/ast_json_fixtures/shapes/f09ffd399fc1b585.json b/tests/ast_json_fixtures/shapes/f09ffd399fc1b585.json new file mode 100644 index 000000000000..60bd230a2d84 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f09ffd399fc1b585.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ary" + }, + { + "type": "Function", + "name": "indexOf", + "arguments": [ + { + "type": "Identifier", + "name": "ary" + }, + { + "type": "Literal", + "value_type": "String", + "value": "value1" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_bf_indexOf" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ary" + }, + { + "type": "Function", + "name": "indexOf", + "arguments": [ + { + "type": "Identifier", + "name": "ary" + }, + { + "type": "Literal", + "value_type": "String", + "value": "value1" + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "value1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/f09ffd399fc1b585.sql b/tests/ast_json_fixtures/shapes/f09ffd399fc1b585.sql new file mode 100644 index 000000000000..4b69a9d1b8ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f09ffd399fc1b585.sql @@ -0,0 +1 @@ +SELECT id, ary[indexOf(ary, 'value1')] FROM test_bf_indexOf WHERE ary[indexOf(ary, 'value1')] = 'value1' ORDER BY id FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/f0a7579e053e0ad9.json b/tests/ast_json_fixtures/shapes/f0a7579e053e0ad9.json new file mode 100644 index 000000000000..a4e36d292bfb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0a7579e053e0ad9.json @@ -0,0 +1,10 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "b" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f0a7579e053e0ad9.sql b/tests/ast_json_fixtures/shapes/f0a7579e053e0ad9.sql new file mode 100644 index 000000000000..556b4c112034 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0a7579e053e0ad9.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE b diff --git a/tests/ast_json_fixtures/shapes/f0dc7de9a6d58de6.json b/tests/ast_json_fixtures/shapes/f0dc7de9a6d58de6.json new file mode 100644 index 000000000000..300f4f6b0c38 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0dc7de9a6d58de6.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + } + ] + } + } + ], + "format": "JSONEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/f0dc7de9a6d58de6.sql b/tests/ast_json_fixtures/shapes/f0dc7de9a6d58de6.sql new file mode 100644 index 000000000000..56953b8847d8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0dc7de9a6d58de6.sql @@ -0,0 +1 @@ +select * from numbers(1) format JSONEachRow diff --git a/tests/ast_json_fixtures/shapes/f0f4d7de0256f8b5.json b/tests/ast_json_fixtures/shapes/f0f4d7de0256f8b5.json new file mode 100644 index 000000000000..1a301d781acc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0f4d7de0256f8b5.json @@ -0,0 +1,235 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + }, + { + "type": "Function", + "name": "transform", + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "updates" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Identifier", + "name": "y" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "y" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "updates" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } + }, + { + "type": "Identifier", + "name": "y" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_xy" + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "y" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f0f4d7de0256f8b5.sql b/tests/ast_json_fixtures/shapes/f0f4d7de0256f8b5.sql new file mode 100644 index 000000000000..bcca579964c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f0f4d7de0256f8b5.sql @@ -0,0 +1,7 @@ +SELECT x, y, + transform(x, + (select groupArray(x) from (select x, y from updates order by x) t1), + (select groupArray(y) from (select x, y from updates order by x) t2), + y) +FROM test_xy +WHERE 1 ORDER BY x, y diff --git a/tests/ast_json_fixtures/shapes/f104fa0522cb2cc3.json b/tests/ast_json_fixtures/shapes/f104fa0522cb2cc3.json new file mode 100644 index 000000000000..a05ee950af3f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f104fa0522cb2cc3.json @@ -0,0 +1,334 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "n_" + } + ] + }, + { + "type": "Identifier", + "alias": "n", + "name": "number" + }, + { + "type": "Function", + "alias": "n_", + "name": "bitOr", + "arguments": [ + { + "type": "Function", + "name": "bitShiftLeft", + "arguments": [ + { + "type": "Function", + "name": "bitOr", + "arguments": [ + { + "type": "Function", + "name": "bitShiftLeft", + "arguments": [ + { + "type": "Function", + "name": "bitOr", + "arguments": [ + { + "type": "Function", + "name": "bitShiftLeft", + "arguments": [ + { + "type": "Function", + "name": "bitOr", + "arguments": [ + { + "type": "Function", + "name": "bitShiftLeft", + "arguments": [ + { + "type": "Function", + "name": "bitOr", + "arguments": [ + { + "type": "Function", + "name": "bitShiftLeft", + "arguments": [ + { + "type": "Function", + "name": "bitOr", + "arguments": [ + { + "type": "Function", + "name": "bitShiftLeft", + "arguments": [ + { + "type": "Function", + "name": "bitOr", + "arguments": [ + { + "type": "Function", + "name": "bitShiftLeft", + "arguments": [ + { + "type": "Identifier", + "name": "b7" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "b6" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "b5" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "b4" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "b3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "b2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "b1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "b0" + } + ] + }, + { + "type": "Function", + "alias": "b7", + "name": "bitTest", + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + }, + { + "type": "Function", + "alias": "b6", + "name": "bitTest", + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "6" + } + ] + }, + { + "type": "Function", + "alias": "b5", + "name": "bitTest", + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "alias": "b4", + "name": "bitTest", + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Function", + "alias": "b3", + "name": "bitTest", + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "alias": "b2", + "name": "bitTest", + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "alias": "b1", + "name": "bitTest", + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "alias": "b0", + "name": "bitTest", + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "256" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f104fa0522cb2cc3.sql b/tests/ast_json_fixtures/shapes/f104fa0522cb2cc3.sql new file mode 100644 index 000000000000..248735db2ac2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f104fa0522cb2cc3.sql @@ -0,0 +1,12 @@ +select n = n_, + number as n, + bitOr(bitShiftLeft(bitOr(bitShiftLeft(bitOr(bitShiftLeft(bitOr(bitShiftLeft(bitOr(bitShiftLeft(bitOr(bitShiftLeft(bitOr(bitShiftLeft(b7, 1), b6), 1), b5), 1), b4), 1), b3), 1), b2), 1), b1), 1), b0) as n_, + bitTest(n, 7) as b7, + bitTest(n, 6) as b6, + bitTest(n, 5) as b5, + bitTest(n, 4) as b4, + bitTest(n, 3) as b3, + bitTest(n, 2) as b2, + bitTest(n, 1) as b1, + bitTest(n, 0) as b0 +from system.numbers limit 256 diff --git a/tests/ast_json_fixtures/shapes/f111583300e55995.json b/tests/ast_json_fixtures/shapes/f111583300e55995.json new file mode 100644 index 000000000000..93899c980251 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f111583300e55995.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toUnixTimestamp", + "arguments": [ + { + "type": "Identifier", + "name": "v1" + } + ] + }, + { + "type": "Identifier", + "name": "v2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab1" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "v2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "v1" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "use_top_k_dynamic_filtering": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f111583300e55995.sql b/tests/ast_json_fixtures/shapes/f111583300e55995.sql new file mode 100644 index 000000000000..925f3a38a54e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f111583300e55995.sql @@ -0,0 +1 @@ +SELECT toUnixTimestamp(v1), v2 FROM tab1 WHERE v2 > 100000 ORDER BY v1 ASC LIMIT 10 SETTINGS use_top_k_dynamic_filtering=1 diff --git a/tests/ast_json_fixtures/shapes/f122f3ab9cd18622.json b/tests/ast_json_fixtures/shapes/f122f3ab9cd18622.json new file mode 100644 index 000000000000..dcafd3a317e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f122f3ab9cd18622.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "tab", + "like": "%int%", + "not_like": true + } +} diff --git a/tests/ast_json_fixtures/shapes/f122f3ab9cd18622.sql b/tests/ast_json_fixtures/shapes/f122f3ab9cd18622.sql new file mode 100644 index 000000000000..987886fdeb8d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f122f3ab9cd18622.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM tab NOT LIKE '%int%' diff --git a/tests/ast_json_fixtures/shapes/f131517bae8ac54e.json b/tests/ast_json_fixtures/shapes/f131517bae8ac54e.json new file mode 100644 index 000000000000..6bfdb33e4f25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f131517bae8ac54e.json @@ -0,0 +1,73 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "alias": "x", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "8" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "120" + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "Int64", + "value": "-2" + }, + "limit": { + "type": "Literal", + "value_type": "Int64", + "value": "-3" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f131517bae8ac54e.sql b/tests/ast_json_fixtures/shapes/f131517bae8ac54e.sql new file mode 100644 index 000000000000..f3910a40545c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f131517bae8ac54e.sql @@ -0,0 +1 @@ +SELECT DISTINCT number % 8 AS x FROM numbers(120) ORDER BY x LIMIT -3 OFFSET -2 diff --git a/tests/ast_json_fixtures/shapes/f138b6dcc8f707ce.json b/tests/ast_json_fixtures/shapes/f138b6dcc8f707ce.json new file mode 100644 index 000000000000..e43c69eddc80 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f138b6dcc8f707ce.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "ShowFunctions", + "like": "a' or 1=1;--" + } +} diff --git a/tests/ast_json_fixtures/shapes/f138b6dcc8f707ce.sql b/tests/ast_json_fixtures/shapes/f138b6dcc8f707ce.sql new file mode 100644 index 000000000000..33a4890770b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f138b6dcc8f707ce.sql @@ -0,0 +1 @@ +show functions like 'a\' or 1=1;--' diff --git a/tests/ast_json_fixtures/shapes/f13c33dbab7b1a24.json b/tests/ast_json_fixtures/shapes/f13c33dbab7b1a24.json new file mode 100644 index 000000000000..fbabfd842495 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f13c33dbab7b1a24.json @@ -0,0 +1,102 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Function", + "alias": "a", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "s" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tb" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "FULL", + "using": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tabc" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f13c33dbab7b1a24.sql b/tests/ast_json_fixtures/shapes/f13c33dbab7b1a24.sql new file mode 100644 index 000000000000..087ca6af05d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f13c33dbab7b1a24.sql @@ -0,0 +1 @@ +SELECT b + 1 AS a, s FROM tb FULL OUTER JOIN tabc USING (a) PREWHERE a > 2 ORDER BY ALL SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/f141f27d7504636c.json b/tests/ast_json_fixtures/shapes/f141f27d7504636c.json new file mode 100644 index 000000000000..221db08ad96b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f141f27d7504636c.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "alias": "subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + }, + { + "type": "Literal", + "alias": "subquery", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f141f27d7504636c.sql b/tests/ast_json_fixtures/shapes/f141f27d7504636c.sql new file mode 100644 index 000000000000..06f80ea19291 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f141f27d7504636c.sql @@ -0,0 +1 @@ +SELECT (SELECT 1) AS subquery, 1 AS subquery diff --git a/tests/ast_json_fixtures/shapes/f15d83a4c7892358.json b/tests/ast_json_fixtures/shapes/f15d83a4c7892358.json new file mode 100644 index 000000000000..ba22a93e958e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f15d83a4c7892358.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "table_merge_tree_02525" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "ColumnDeclaration", + "name": "info", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "id" + }, + "order_by": { + "type": "Identifier", + "name": "id" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f15d83a4c7892358.sql b/tests/ast_json_fixtures/shapes/f15d83a4c7892358.sql new file mode 100644 index 000000000000..a798f3a00218 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f15d83a4c7892358.sql @@ -0,0 +1,8 @@ +CREATE TEMPORARY TABLE table_merge_tree_02525 +( + id UInt64, + info String +) +ENGINE = MergeTree +ORDER BY id +PRIMARY KEY id diff --git a/tests/ast_json_fixtures/shapes/f16a046a2d30bcfd.json b/tests/ast_json_fixtures/shapes/f16a046a2d30bcfd.json new file mode 100644 index 000000000000..179b4658359a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f16a046a2d30bcfd.json @@ -0,0 +1,116 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t1", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "key", + "value_type": "UInt64", + "value": "1" + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t1.key", + "name_parts": ["t1", "key"] + }, + { + "type": "Identifier", + "name": "t2.key", + "name_parts": ["t2", "key"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "key", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "t1.key", + "name_parts": ["t1", "key"] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f16a046a2d30bcfd.sql b/tests/ast_json_fixtures/shapes/f16a046a2d30bcfd.sql new file mode 100644 index 000000000000..b4e650e1d348 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f16a046a2d30bcfd.sql @@ -0,0 +1 @@ +SELECT * FROM ( SELECT 1 AS key GROUP BY NULL ) AS t1 INNER JOIN (SELECT 1 AS key) AS t2 ON t1.key = t2.key WHERE t1.key ORDER BY key diff --git a/tests/ast_json_fixtures/shapes/f178b40f50e89e92.json b/tests/ast_json_fixtures/shapes/f178b40f50e89e92.json new file mode 100644 index 000000000000..59653d596b9a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f178b40f50e89e92.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ], + "settings": { + "type": "Settings", + "changes": { + "output_format_pretty_single_large_number_tip_threshold": "1000" + } + } + } + ], + "format": "PrettyNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/f178b40f50e89e92.sql b/tests/ast_json_fixtures/shapes/f178b40f50e89e92.sql new file mode 100644 index 000000000000..84016b92f888 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f178b40f50e89e92.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a SETTINGS output_format_pretty_single_large_number_tip_threshold = 1000 FORMAT PrettyNoEscapes diff --git a/tests/ast_json_fixtures/shapes/f17d9308e55254d0.json b/tests/ast_json_fixtures/shapes/f17d9308e55254d0.json new file mode 100644 index 000000000000..91f31e3e61c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f17d9308e55254d0.json @@ -0,0 +1,37 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "ColumnsListMatcher", + "columns": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f17d9308e55254d0.sql b/tests/ast_json_fixtures/shapes/f17d9308e55254d0.sql new file mode 100644 index 000000000000..ada2fc80ae8f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f17d9308e55254d0.sql @@ -0,0 +1 @@ +SELECT COLUMNS(id) FROM test_table diff --git a/tests/ast_json_fixtures/shapes/f199bb8e62e611c8.json b/tests/ast_json_fixtures/shapes/f199bb8e62e611c8.json new file mode 100644 index 000000000000..46af80e697f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f199bb8e62e611c8.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "u" + }, + { + "type": "Function", + "alias": "s", + "name": "windowFunnel", + "arguments": [ + { + "type": "Identifier", + "name": "dt" + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + } + ] + } + ] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "86400" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "funnel_test_non_null" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "u" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "u" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONCompactEachRow" + } +} diff --git a/tests/ast_json_fixtures/shapes/f199bb8e62e611c8.sql b/tests/ast_json_fixtures/shapes/f199bb8e62e611c8.sql new file mode 100644 index 000000000000..5fc23a8a2170 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f199bb8e62e611c8.sql @@ -0,0 +1 @@ +select u, windowFunnel(86400)(dt, a is null and b is null) as s from funnel_test_non_null group by u order by u format JSONCompactEachRow diff --git a/tests/ast_json_fixtures/shapes/f1a27ab221479e84.json b/tests/ast_json_fixtures/shapes/f1a27ab221479e84.json new file mode 100644 index 000000000000..09e5efb81d5d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f1a27ab221479e84.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "replace_access": true, + "access_rights": [ + { + "access_types": ["SELECT"], + "database": "db5", + "table": "table", + "columns": ["cola"] + }, + { + "access_types": ["INSERT"], + "database": "db6", + "table": "tb61", + "columns": ["colb"] + }, + { + "access_types": ["SHOW"], + "database": "db7" + } + ], + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f1a27ab221479e84.sql b/tests/ast_json_fixtures/shapes/f1a27ab221479e84.sql new file mode 100644 index 000000000000..7fe34df9a0e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f1a27ab221479e84.sql @@ -0,0 +1 @@ +GRANT SELECT(cola) ON db5.table, INSERT(colb) ON db6.tb61, SHOW ON db7.* TO test_user_01999 WITH REPLACE OPTION diff --git a/tests/ast_json_fixtures/shapes/f1c4ac67eb8a9409.json b/tests/ast_json_fixtures/shapes/f1c4ac67eb8a9409.json new file mode 100644 index 000000000000..214e3a311b5a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f1c4ac67eb8a9409.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropWorkloadQuery", + "workload_name": "admin", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/f1c4ac67eb8a9409.sql b/tests/ast_json_fixtures/shapes/f1c4ac67eb8a9409.sql new file mode 100644 index 000000000000..06ecde014a65 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f1c4ac67eb8a9409.sql @@ -0,0 +1 @@ +drop workload if exists admin diff --git a/tests/ast_json_fixtures/shapes/f1c9add76a0705d9.json b/tests/ast_json_fixtures/shapes/f1c9add76a0705d9.json new file mode 100644 index 000000000000..2f43159da29b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f1c9add76a0705d9.json @@ -0,0 +1,19 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u16_01292" + } + ] + }, + "hosts": { + "local_host": true, + "subnets": ["65:ff0c::\/96"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f1c9add76a0705d9.sql b/tests/ast_json_fixtures/shapes/f1c9add76a0705d9.sql new file mode 100644 index 000000000000..7599b96b7c04 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f1c9add76a0705d9.sql @@ -0,0 +1 @@ +CREATE USER u16_01292 HOST IP '65:ff0c::/96', '::1' diff --git a/tests/ast_json_fixtures/shapes/f1d9c0b49dd46a7c.json b/tests/ast_json_fixtures/shapes/f1d9c0b49dd46a7c.json new file mode 100644 index 000000000000..1da2ac1654b1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f1d9c0b49dd46a7c.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "distributed_00588" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "mergetree_00588" + } + ] + } + }, + "as_table": "mergetree_00588" + } +} diff --git a/tests/ast_json_fixtures/shapes/f1d9c0b49dd46a7c.sql b/tests/ast_json_fixtures/shapes/f1d9c0b49dd46a7c.sql new file mode 100644 index 000000000000..1d3a248d348d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f1d9c0b49dd46a7c.sql @@ -0,0 +1 @@ +CREATE TABLE distributed_00588 AS mergetree_00588 ENGINE = Distributed(test_shard_localhost, currentDatabase(), mergetree_00588) diff --git a/tests/ast_json_fixtures/shapes/f1dada2f686be00e.json b/tests/ast_json_fixtures/shapes/f1dada2f686be00e.json new file mode 100644 index 000000000000..09f82275f41a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f1dada2f686be00e.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "alter": true, + "names": ["r3_01293"], + "alter_settings": { + "type": "AlterSettingsProfileElements", + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f1dada2f686be00e.sql b/tests/ast_json_fixtures/shapes/f1dada2f686be00e.sql new file mode 100644 index 000000000000..285de50fe9bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f1dada2f686be00e.sql @@ -0,0 +1 @@ +ALTER ROLE r3_01293 SETTINGS NONE diff --git a/tests/ast_json_fixtures/shapes/f20a3bf6e7810a10.json b/tests/ast_json_fixtures/shapes/f20a3bf6e7810a10.json new file mode 100644 index 000000000000..9809da3392e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f20a3bf6e7810a10.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "hello", + "name": "number" + }, + { + "type": "Function", + "alias": "world", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Identifier", + "name": "world" + } + ] + }, + { + "type": "Function", + "alias": "sometimes_nulls", + "name": "nullIf", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "5" + } + } + } + ], + "format": "PrettyNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/f20a3bf6e7810a10.sql b/tests/ast_json_fixtures/shapes/f20a3bf6e7810a10.sql new file mode 100644 index 000000000000..48d63a6444fb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f20a3bf6e7810a10.sql @@ -0,0 +1 @@ +SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 10 SETTINGS max_block_size = 5 FORMAT PrettyNoEscapes diff --git a/tests/ast_json_fixtures/shapes/f21d71d00986ebb9.json b/tests/ast_json_fixtures/shapes/f21d71d00986ebb9.json new file mode 100644 index 000000000000..7713a2b55e5e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f21d71d00986ebb9.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Identifier", + "name": "complex1" + }, + { + "type": "Function", + "name": "byteSize", + "arguments": [ + { + "type": "Identifier", + "name": "complex1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_byte_size_more_complex" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f21d71d00986ebb9.sql b/tests/ast_json_fixtures/shapes/f21d71d00986ebb9.sql new file mode 100644 index 000000000000..4b2d48989035 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f21d71d00986ebb9.sql @@ -0,0 +1 @@ +select key, byteSize(*), complex1, byteSize(complex1) from test_byte_size_more_complex order by key diff --git a/tests/ast_json_fixtures/shapes/f21eb583189bd35e.json b/tests/ast_json_fixtures/shapes/f21eb583189bd35e.json new file mode 100644 index 000000000000..68eef22a451d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f21eb583189bd35e.json @@ -0,0 +1,85 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "#02136_scalar_subquery_4" + }, + { + "type": "Subquery", + "alias": "n", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + } + ] + } + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f21eb583189bd35e.sql b/tests/ast_json_fixtures/shapes/f21eb583189bd35e.sql new file mode 100644 index 000000000000..1d153656f8d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f21eb583189bd35e.sql @@ -0,0 +1 @@ +SELECT '#02136_scalar_subquery_4', (SELECT max(number) FROM numbers(1000)) as n FROM system.numbers LIMIT 2 diff --git a/tests/ast_json_fixtures/shapes/f21f813232def686.json b/tests/ast_json_fixtures/shapes/f21f813232def686.json new file mode 100644 index 000000000000..6b3d4b83b1f6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f21f813232def686.json @@ -0,0 +1,227 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "query" + }, + { + "type": "Identifier", + "name": "query_kind" + }, + { + "type": "Identifier", + "name": "exception_code" + }, + { + "type": "Identifier", + "name": "read_rows" + }, + { + "type": "Identifier", + "name": "written_rows" + }, + { + "type": "Function", + "alias": "QueriesWithSubqueries", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueriesWithSubqueries" + } + ] + }, + { + "type": "Function", + "alias": "SelectQueriesWithSubqueries", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "SelectQueriesWithSubqueries" + } + ] + }, + { + "type": "Function", + "alias": "AsyncInsertRows", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "AsyncInsertRows" + } + ] + }, + { + "type": "Function", + "alias": "SelfDuplicatedAsyncInserts", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "SelfDuplicatedAsyncInserts" + } + ] + }, + { + "type": "Function", + "alias": "DuplicatedAsyncInserts", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ProfileEvents" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DuplicatedAsyncInserts" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "has", + "arguments": [ + { + "type": "Identifier", + "name": "databases" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "has", + "arguments": [ + { + "type": "Identifier", + "name": "tables" + }, + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": ".src_table" + } + ] + } + ] + }, + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryStart" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_kind" + }, + { + "type": "Literal", + "value_type": "String", + "value": "AsyncInsertFlush" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "DESC" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/f21f813232def686.sql b/tests/ast_json_fixtures/shapes/f21f813232def686.sql new file mode 100644 index 000000000000..58502cd8fb9d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f21f813232def686.sql @@ -0,0 +1,14 @@ +select query, query_kind, exception_code, + read_rows, written_rows, + ProfileEvents['QueriesWithSubqueries'] as QueriesWithSubqueries, + ProfileEvents['SelectQueriesWithSubqueries'] as SelectQueriesWithSubqueries, + ProfileEvents['AsyncInsertRows'] as AsyncInsertRows, + ProfileEvents['SelfDuplicatedAsyncInserts'] as SelfDuplicatedAsyncInserts, + ProfileEvents['DuplicatedAsyncInserts'] as DuplicatedAsyncInserts +from system.query_log +where + has(databases, currentDatabase()) + and has(tables, currentDatabase() || '.src_table') + and type != 'QueryStart' + and query_kind = 'AsyncInsertFlush' +order by all desc FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/f247d8121ba02722.json b/tests/ast_json_fixtures/shapes/f247d8121ba02722.json new file mode 100644 index 000000000000..d81203d67b1f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f247d8121ba02722.json @@ -0,0 +1,820 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "metric_id" + }, + { + "type": "Function", + "alias": "c1", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:10" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:01:00" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + { + "type": "Function", + "alias": "c2", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:10" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(4, 'UTC')" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:01:00" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + { + "type": "Function", + "alias": "c3", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:10" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:01:00" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(2, 'UTC')" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + { + "type": "Function", + "alias": "c4", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:10.123" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(4, 'UTC')" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:01:01" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + { + "type": "Function", + "alias": "c5", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:10.123456" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(4, 'UTC')" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:01:00.123" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + { + "type": "Function", + "alias": "c6", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:10.12" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(1, 'UTC')" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:01:00.123" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + { + "type": "Function", + "alias": "c7", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:10.123" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(0, 'UTC')" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:01:00" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + { + "type": "Function", + "alias": "c8", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:10" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime('UTC')" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:01:00" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(3, 'UTC')" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + }, + { + "type": "Function", + "alias": "c9", + "name": "timeSeriesInstantRateToGrid", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "samples" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "parameters": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:00:10.123" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime64(2, 'UTC')" + } + ] + }, + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2024-12-12 12:01:01" + }, + { + "type": "Literal", + "value_type": "String", + "value": "DateTime('UTC')" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "60" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "clusterAllReplicas", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "t_resampled_timeseries_64" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "metric_id" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/f247d8121ba02722.sql b/tests/ast_json_fixtures/shapes/f247d8121ba02722.sql new file mode 100644 index 000000000000..464cb944bfce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f247d8121ba02722.sql @@ -0,0 +1,14 @@ +SELECT + metric_id, + timeSeriesInstantRateToGrid('2024-12-12 12:00:10'::DateTime64(3,'UTC'), '2024-12-12 12:01:00'::DateTime64(3,'UTC'), 10, 60)(samples.1, samples.2) as c1, + timeSeriesInstantRateToGrid('2024-12-12 12:00:10'::DateTime64(4,'UTC'), '2024-12-12 12:01:00'::DateTime64(3,'UTC'), 10, 60)(samples.1, samples.2) as c2, + timeSeriesInstantRateToGrid('2024-12-12 12:00:10'::DateTime64(3,'UTC'), '2024-12-12 12:01:00'::DateTime64(2,'UTC'), 10, 60)(samples.1, samples.2) as c3, + timeSeriesInstantRateToGrid('2024-12-12 12:00:10.123'::DateTime64(4,'UTC'), '2024-12-12 12:01:01'::DateTime64(3,'UTC'), 10, 60)(samples.1, samples.2) as c4, + timeSeriesInstantRateToGrid('2024-12-12 12:00:10.123456'::DateTime64(4,'UTC'), '2024-12-12 12:01:00.123'::DateTime64(3,'UTC'), 10, 60)(samples.1, samples.2) as c5, + timeSeriesInstantRateToGrid('2024-12-12 12:00:10.12'::DateTime64(1,'UTC'), '2024-12-12 12:01:00.123'::DateTime64(3,'UTC'), 10, 60)(samples.1, samples.2) as c6, + timeSeriesInstantRateToGrid('2024-12-12 12:00:10.123'::DateTime64(0,'UTC'), '2024-12-12 12:01:00'::DateTime64(3,'UTC'), 10, 60)(samples.1, samples.2) as c7, + timeSeriesInstantRateToGrid('2024-12-12 12:00:10'::DateTime('UTC'), '2024-12-12 12:01:00'::DateTime64(3,'UTC'), 10, 60)(samples.1, samples.2) as c8, + timeSeriesInstantRateToGrid('2024-12-12 12:00:10.123'::DateTime64(2,'UTC'), '2024-12-12 12:01:01'::DateTime('UTC'), 10, 60)(samples.1, samples.2) as c9 +FROM clusterAllReplicas('test_shard_localhost', currentDatabase(), t_resampled_timeseries_64) +GROUP BY metric_id +FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/f25aeb7a866d90e4.json b/tests/ast_json_fixtures/shapes/f25aeb7a866d90e4.json new file mode 100644 index 000000000000..961722ebeb12 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f25aeb7a866d90e4.json @@ -0,0 +1,112 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "a_id", + "name": "A.id", + "name_parts": ["A", "id"] + }, + { + "type": "Subquery", + "alias": "b_ids_containing_a_id", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "groupArraySorted", + "arguments": [ + { + "type": "Identifier", + "name": "B.id", + "name_parts": ["B", "id"] + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "B" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "has", + "arguments": [ + { + "type": "Identifier", + "name": "B.A_ids", + "name_parts": ["B", "A_ids"] + }, + { + "type": "Identifier", + "name": "A.id", + "name_parts": ["A", "id"] + } + ] + } + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "A" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a_id" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f25aeb7a866d90e4.sql b/tests/ast_json_fixtures/shapes/f25aeb7a866d90e4.sql new file mode 100644 index 000000000000..94ed09db3d10 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f25aeb7a866d90e4.sql @@ -0,0 +1,10 @@ +SELECT + A.id AS a_id, + ( + SELECT groupArraySorted(5)(B.id) + FROM B + WHERE has(B.A_ids, A.id) + ) AS b_ids_containing_a_id +FROM A +ORDER BY a_id +LIMIT 20 diff --git a/tests/ast_json_fixtures/shapes/f28cf58b2c333689.json b/tests/ast_json_fixtures/shapes/f28cf58b2c333689.json new file mode 100644 index 000000000000..1254723759ae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f28cf58b2c333689.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "zookeeper_log" + }, + { + "table": "query_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f28cf58b2c333689.sql b/tests/ast_json_fixtures/shapes/f28cf58b2c333689.sql new file mode 100644 index 000000000000..231300317c09 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f28cf58b2c333689.sql @@ -0,0 +1 @@ +system flush logs zookeeper_log, query_log diff --git a/tests/ast_json_fixtures/shapes/f291c3d089b0e1c2.json b/tests/ast_json_fixtures/shapes/f291c3d089b0e1c2.json new file mode 100644 index 000000000000..2bfa675b49e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f291c3d089b0e1c2.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "labels", + "name": "errors.name", + "name_parts": ["errors", "name"] + }, + { + "type": "Identifier", + "name": "value" + }, + { + "type": "Literal", + "alias": "name", + "value_type": "String", + "value": "ch_errors_total" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "errors", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/f291c3d089b0e1c2.sql b/tests/ast_json_fixtures/shapes/f291c3d089b0e1c2.sql new file mode 100644 index 000000000000..b1415fb97437 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f291c3d089b0e1c2.sql @@ -0,0 +1,7 @@ +SELECT + errors.name AS labels, + value, + 'ch_errors_total' AS name +FROM system.errors +LIMIT 1 +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/f2924b942b5557ea.json b/tests/ast_json_fixtures/shapes/f2924b942b5557ea.json new file mode 100644 index 000000000000..0dfb129b7c8d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f2924b942b5557ea.json @@ -0,0 +1,36 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "x" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "ADD_PROJECTION", + "projection_declaration": { + "type": "Projection", + "name": "p_agg", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "j" + } + ] + } + ] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f2924b942b5557ea.sql b/tests/ast_json_fixtures/shapes/f2924b942b5557ea.sql new file mode 100644 index 000000000000..f8a7059ea2d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f2924b942b5557ea.sql @@ -0,0 +1 @@ +alter table x add projection p_agg (select sum(j)) diff --git a/tests/ast_json_fixtures/shapes/f2a54e030428120d.json b/tests/ast_json_fixtures/shapes/f2a54e030428120d.json new file mode 100644 index 000000000000..f48e54755e26 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f2a54e030428120d.json @@ -0,0 +1,103 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t" + } + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "s" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.a", + "name_parts": ["s", "a"] + }, + { + "type": "Identifier", + "name": "t.a", + "name_parts": ["t", "a"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "s.b", + "name_parts": ["s", "b"] + }, + { + "type": "Identifier", + "name": "t.b", + "name_parts": ["t", "b"] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "s" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "join_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f2a54e030428120d.sql b/tests/ast_json_fixtures/shapes/f2a54e030428120d.sql new file mode 100644 index 000000000000..16a514c223e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f2a54e030428120d.sql @@ -0,0 +1 @@ +select t.*, s.* from t left join s on (s.a = t.a and s.b = t.b) SETTINGS join_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/f2a58f2621e0312c.json b/tests/ast_json_fixtures/shapes/f2a58f2621e0312c.json new file mode 100644 index 000000000000..38350e7bb4f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f2a58f2621e0312c.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "header": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f2a58f2621e0312c.sql b/tests/ast_json_fixtures/shapes/f2a58f2621e0312c.sql new file mode 100644 index 000000000000..a90b914923b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f2a58f2621e0312c.sql @@ -0,0 +1 @@ +explain header = 1 select 1 as x diff --git a/tests/ast_json_fixtures/shapes/f2ae77c243b7efe0.json b/tests/ast_json_fixtures/shapes/f2ae77c243b7efe0.json new file mode 100644 index 000000000000..bd63ed8cbc21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f2ae77c243b7efe0.json @@ -0,0 +1,137 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "tab1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "valueDate", + "data_type": { + "type": "DataType", + "name": "Date" + } + }, + { + "type": "ColumnDeclaration", + "name": "bb_ticker", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "ric", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "update_timestamp", + "data_type": { + "type": "DataType", + "name": "DateTime" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "tab1_bb_ticker_idx", + "expression": { + "type": "Identifier", + "name": "bb_ticker" + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [] + }, + "granularity": 4 + }, + { + "type": "Index", + "name": "tab1_ric_idx", + "expression": { + "type": "Identifier", + "name": "ric" + }, + "index_type": { + "type": "Function", + "name": "bloom_filter", + "arguments": [] + }, + "granularity": 4 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplacingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "update_timestamp" + } + ] + }, + "primary_key": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "valueDate" + }, + { + "type": "Identifier", + "name": "bb_ticker" + }, + { + "type": "Identifier", + "name": "ric" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "valueDate" + }, + { + "type": "Identifier", + "name": "bb_ticker" + }, + { + "type": "Identifier", + "name": "ric" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "111", + "index_granularity_bytes": "0", + "compress_primary_key": "0" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f2ae77c243b7efe0.sql b/tests/ast_json_fixtures/shapes/f2ae77c243b7efe0.sql new file mode 100644 index 000000000000..57e3b7269b7a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f2ae77c243b7efe0.sql @@ -0,0 +1,13 @@ +CREATE TABLE tab1 +( + `valueDate` Date, + `bb_ticker` String, + `ric` String, + `update_timestamp` DateTime, + INDEX tab1_bb_ticker_idx bb_ticker TYPE bloom_filter GRANULARITY 4, + INDEX tab1_ric_idx ric TYPE bloom_filter GRANULARITY 4 +) +ENGINE = ReplacingMergeTree(update_timestamp) +PRIMARY KEY (valueDate, bb_ticker, ric) +ORDER BY (valueDate, bb_ticker, ric) +SETTINGS index_granularity = 111, index_granularity_bytes = 0, compress_primary_key = 0 diff --git a/tests/ast_json_fixtures/shapes/f2eb06846fbe0944.json b/tests/ast_json_fixtures/shapes/f2eb06846fbe0944.json new file mode 100644 index 000000000000..653b9ce9048b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f2eb06846fbe0944.json @@ -0,0 +1,154 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "w\u0000\u0000ldworldwo\u0000l\u0000world" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "grouping_sets" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "fact_4_id" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "fact_3_id" + }, + { + "type": "Identifier", + "name": "fact_4_id" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "Null", + "value": null + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "Null", + "value": null + }, + "direction": "DESC", + "nulls_first": true + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "fact_3_id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "fact_3_id" + }, + "direction": "ASC", + "nulls_first": false + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "String", + "value": "wo\u0000ldworldwo\u0000ldworld" + }, + "direction": "ASC", + "nulls_first": false + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "String", + "value": "w\u0000\u0000ldworldwo\u0000l\u0000world" + }, + "direction": "DESC", + "nulls_first": true + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "String", + "value": "wo\u0000ldworldwo\u0000ldworld" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Literal", + "value_type": "Null", + "value": null + }, + "direction": "ASC", + "nulls_first": true + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "fact_4_id" + }, + "direction": "DESC", + "nulls_first": false + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f2eb06846fbe0944.sql b/tests/ast_json_fixtures/shapes/f2eb06846fbe0944.sql new file mode 100644 index 000000000000..06b9c7422120 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f2eb06846fbe0944.sql @@ -0,0 +1,17 @@ +SELECT 'w\0\0ldworldwo\0l\0world' +FROM grouping_sets +GROUP BY + GROUPING SETS ( + ( fact_4_id), + ( NULL), + ( fact_3_id, fact_4_id)) +ORDER BY + NULL ASC, + NULL DESC NULLS FIRST, + fact_3_id ASC, + fact_3_id ASC NULLS LAST, + 'wo\0ldworldwo\0ldworld' ASC NULLS LAST, + 'w\0\0ldworldwo\0l\0world' DESC NULLS FIRST, + 'wo\0ldworldwo\0ldworld' ASC, + NULL ASC NULLS FIRST, + fact_4_id DESC NULLS LAST diff --git a/tests/ast_json_fixtures/shapes/f301df44fc335f00.json b/tests/ast_json_fixtures/shapes/f301df44fc335f00.json new file mode 100644 index 000000000000..6bb035e77cd8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f301df44fc335f00.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "alias": "orig", + "value_type": "String", + "value": "original" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test3" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC", + "with_fill": true, + "fill_to": { + "type": "Literal", + "value_type": "UInt64", + "value": "33" + }, + "fill_step": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b" + }, + "direction": "ASC", + "with_fill": true, + "fill_from": { + "type": "Literal", + "value_type": "Int64", + "value": "-10" + }, + "fill_step": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f301df44fc335f00.sql b/tests/ast_json_fixtures/shapes/f301df44fc335f00.sql new file mode 100644 index 000000000000..4cc4a0233ba3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f301df44fc335f00.sql @@ -0,0 +1 @@ +SELECT a, b, 'original' AS orig FROM test3 ORDER BY a WITH FILL TO 33 STEP 3, b WITH FILL FROM -10 STEP 2 diff --git a/tests/ast_json_fixtures/shapes/f30476c31d71d76d.json b/tests/ast_json_fixtures/shapes/f30476c31d71d76d.json new file mode 100644 index 000000000000..3ed69c5d1b63 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f30476c31d71d76d.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02103_test_function_with_nested_function_arg" + } +} diff --git a/tests/ast_json_fixtures/shapes/f30476c31d71d76d.sql b/tests/ast_json_fixtures/shapes/f30476c31d71d76d.sql new file mode 100644 index 000000000000..452a5d6bce74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f30476c31d71d76d.sql @@ -0,0 +1 @@ +DROP FUNCTION 02103_test_function_with_nested_function_arg diff --git a/tests/ast_json_fixtures/shapes/f309b5dc03f0d81a.json b/tests/ast_json_fixtures/shapes/f309b5dc03f0d81a.json new file mode 100644 index 000000000000..ef0badb5f95c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f309b5dc03f0d81a.json @@ -0,0 +1,100 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "DESC", + "with_fill": true, + "fill_from": { + "type": "Literal", + "value_type": "UInt64", + "value": "15" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f309b5dc03f0d81a.sql b/tests/ast_json_fixtures/shapes/f309b5dc03f0d81a.sql new file mode 100644 index 000000000000..a7be20e08236 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f309b5dc03f0d81a.sql @@ -0,0 +1,8 @@ +SELECT + number, + sum(number) +FROM numbers(10) +WHERE number % 3 = 1 +GROUP BY number + WITH TOTALS +ORDER BY number DESC WITH FILL FROM 15 diff --git a/tests/ast_json_fixtures/shapes/f3374204d52a733b.json b/tests/ast_json_fixtures/shapes/f3374204d52a733b.json new file mode 100644 index 000000000000..a682f9a4dfdd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f3374204d52a733b.json @@ -0,0 +1,83 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_idx_skipping_idx_size" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "key_val_idx", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value" + } + ] + }, + "index_type": { + "type": "Function", + "name": "set", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + ] + }, + "granularity": 1 + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "index_granularity": "100000", + "min_bytes_for_wide_part": "0", + "index_granularity_bytes": 10000000, + "distributed_index_analysis_min_parts_to_activate": "0", + "distributed_index_analysis_min_indexes_bytes_to_activate": "10M" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f3374204d52a733b.sql b/tests/ast_json_fixtures/shapes/f3374204d52a733b.sql new file mode 100644 index 000000000000..8aa07dc5157f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f3374204d52a733b.sql @@ -0,0 +1 @@ +create table dist_idx_skipping_idx_size (key String, value String, index key_val_idx (key, value) type set(100000)) engine=MergeTree() settings index_granularity=100000, min_bytes_for_wide_part=0, index_granularity_bytes=10e6, distributed_index_analysis_min_parts_to_activate=0, distributed_index_analysis_min_indexes_bytes_to_activate='10M' diff --git a/tests/ast_json_fixtures/shapes/f338350662f9e657.json b/tests/ast_json_fixtures/shapes/f338350662f9e657.json new file mode 100644 index 000000000000..89aa081e5102 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f338350662f9e657.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "replicated_merge_tree_insert_quorum_fail_0" + } +} diff --git a/tests/ast_json_fixtures/shapes/f338350662f9e657.sql b/tests/ast_json_fixtures/shapes/f338350662f9e657.sql new file mode 100644 index 000000000000..b976e628acd1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f338350662f9e657.sql @@ -0,0 +1 @@ +system enable failpoint replicated_merge_tree_insert_quorum_fail_0 diff --git a/tests/ast_json_fixtures/shapes/f347cfc495a05d26.json b/tests/ast_json_fixtures/shapes/f347cfc495a05d26.json new file mode 100644 index 000000000000..763f34398ddf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f347cfc495a05d26.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p3_01295", + "database": "db", + "table": "table" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01295"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f347cfc495a05d26.sql b/tests/ast_json_fixtures/shapes/f347cfc495a05d26.sql new file mode 100644 index 000000000000..e478e37a5e68 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f347cfc495a05d26.sql @@ -0,0 +1 @@ +CREATE POLICY p3_01295 ON db.table TO r1_01295 diff --git a/tests/ast_json_fixtures/shapes/f35986eda8812285.json b/tests/ast_json_fixtures/shapes/f35986eda8812285.json new file mode 100644 index 000000000000..4d949fabc987 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f35986eda8812285.json @@ -0,0 +1,103 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "m" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "key" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "b" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "ID" + }, + { + "type": "Identifier", + "name": "key" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "ID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ID" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f35986eda8812285.sql b/tests/ast_json_fixtures/shapes/f35986eda8812285.sql new file mode 100644 index 000000000000..ad70e227931b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f35986eda8812285.sql @@ -0,0 +1 @@ +SELECT * FROM m INNER JOIN b USING(key) WHERE ID = 1 GROUP BY ID, key HAVING ID = 1 ORDER BY ID diff --git a/tests/ast_json_fixtures/shapes/f36a78d12de4904e.json b/tests/ast_json_fixtures/shapes/f36a78d12de4904e.json new file mode 100644 index 000000000000..e50f6ea45d8d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f36a78d12de4904e.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s8_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/f36a78d12de4904e.sql b/tests/ast_json_fixtures/shapes/f36a78d12de4904e.sql new file mode 100644 index 000000000000..d438a7d3b23f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f36a78d12de4904e.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s8_01294 diff --git a/tests/ast_json_fixtures/shapes/f36b2fbc50144b19.json b/tests/ast_json_fixtures/shapes/f36b2fbc50144b19.json new file mode 100644 index 000000000000..a90a364a0b5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f36b2fbc50144b19.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "copied_table" + }, + "as_table": "src_table" + } +} diff --git a/tests/ast_json_fixtures/shapes/f36b2fbc50144b19.sql b/tests/ast_json_fixtures/shapes/f36b2fbc50144b19.sql new file mode 100644 index 000000000000..72097c969ee1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f36b2fbc50144b19.sql @@ -0,0 +1 @@ +CREATE TABLE copied_table AS src_table diff --git a/tests/ast_json_fixtures/shapes/f3704229f2cae92e.json b/tests/ast_json_fixtures/shapes/f3704229f2cae92e.json new file mode 100644 index 000000000000..1c75dd0a613e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f3704229f2cae92e.json @@ -0,0 +1,57 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_shard_localhost", + "table": { + "type": "Identifier", + "name": "t1_local" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "partition_col_1", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "tc1", + "data_type": { + "type": "DataType", + "name": "int" + } + }, + { + "type": "ColumnDeclaration", + "name": "tc2", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "partition_by": { + "type": "Identifier", + "name": "partition_col_1" + }, + "order_by": { + "type": "Identifier", + "name": "tc1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f3704229f2cae92e.sql b/tests/ast_json_fixtures/shapes/f3704229f2cae92e.sql new file mode 100644 index 000000000000..62549743917d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f3704229f2cae92e.sql @@ -0,0 +1 @@ +CREATE TABLE t1_local ON CLUSTER test_shard_localhost(partition_col_1 String, tc1 int,tc2 int)ENGINE=MergeTree() PARTITION BY partition_col_1 ORDER BY tc1 diff --git a/tests/ast_json_fixtures/shapes/f388adffe5ab29e6.json b/tests/ast_json_fixtures/shapes/f388adffe5ab29e6.json new file mode 100644 index 000000000000..7b4cdcd177a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f388adffe5ab29e6.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "STOP TTL MERGES", + "table": { + "type": "Identifier", + "name": "ttl" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f388adffe5ab29e6.sql b/tests/ast_json_fixtures/shapes/f388adffe5ab29e6.sql new file mode 100644 index 000000000000..e58dab25791e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f388adffe5ab29e6.sql @@ -0,0 +1 @@ +system stop ttl merges ttl diff --git a/tests/ast_json_fixtures/shapes/f3c089a341b57430.json b/tests/ast_json_fixtures/shapes/f3c089a341b57430.json new file mode 100644 index 000000000000..12168e1136c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f3c089a341b57430.json @@ -0,0 +1,163 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "foo", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "name": "toUInt256", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ANY", + "on": { + "type": "Function", + "name": "and", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "foo.b", + "name_parts": ["foo", "b"] + }, + { + "type": "Identifier", + "name": "bar.b", + "name_parts": ["bar", "b"] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "foo.a", + "name_parts": ["foo", "a"] + }, + { + "type": "Identifier", + "name": "bar.b", + "name_parts": ["bar", "b"] + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "bar", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "b", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f3c089a341b57430.sql b/tests/ast_json_fixtures/shapes/f3c089a341b57430.sql new file mode 100644 index 000000000000..973711e54a03 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f3c089a341b57430.sql @@ -0,0 +1,7 @@ +SELECT DISTINCT 2 +FROM + (SELECT 2 AS b, 1 AS a GROUP BY 1, toUInt256(1), 1 WITH CUBE WITH TOTALS) AS foo + ANY LEFT JOIN + (SELECT 2 AS b, 1 AS a) AS bar + ON and(foo.b = bar.b, foo.a = bar.b) +WHERE 0 diff --git a/tests/ast_json_fixtures/shapes/f3f20991cde62a3d.json b/tests/ast_json_fixtures/shapes/f3f20991cde62a3d.json new file mode 100644 index 000000000000..535355f3c554 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f3f20991cde62a3d.json @@ -0,0 +1,432 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_all": true, + "group_by_with_cube": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c0", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c1", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c2", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c3", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c4", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c5", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c6", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c7", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c8", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c9", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c10", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c11", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c12", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c13", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c14", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c15", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c16", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c17", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c18", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c19", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c20", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c21", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c22", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c23", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c24", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c25", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c26", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c27", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c28", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c29", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c30", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c31", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c32", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c33", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c34", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c35", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c36", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c37", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c38", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c39", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c40", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c41", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c42", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c43", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c44", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c45", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c46", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c47", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c48", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c49", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c50", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c51", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c52", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c53", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c54", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c55", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c56", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c57", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c58", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c59", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c60", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c61", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c62", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c63", + "value_type": "String", + "value": "" + }, + { + "type": "Literal", + "alias": "c64", + "value_type": "String", + "value": "" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f3f20991cde62a3d.sql b/tests/ast_json_fixtures/shapes/f3f20991cde62a3d.sql new file mode 100644 index 000000000000..4a259ab08141 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f3f20991cde62a3d.sql @@ -0,0 +1,2 @@ +SELECT * FROM (SELECT '' AS c0, '' AS c1, '' AS c2, '' AS c3, '' AS c4, '' AS c5, '' AS c6, '' AS c7, '' AS c8, '' AS c9, '' AS c10, '' AS c11, '' AS c12, '' AS c13, '' AS c14, '' AS c15, '' AS c16, '' AS c17, '' AS c18, '' AS c19, '' AS c20, '' AS c21, '' AS c22, '' AS c23, '' AS c24, '' AS c25, '' AS c26, '' AS c27, '' AS c28, '' AS c29, '' AS c30, '' AS c31, '' AS c32, '' AS c33, '' AS c34, '' AS c35, '' AS c36, '' AS c37, '' AS c38, '' AS c39, '' AS c40, '' AS c41, '' AS c42, '' AS c43, '' AS c44, '' AS c45, '' AS c46, '' AS c47, '' AS c48, '' AS c49, '' AS c50, '' AS c51, '' AS c52, '' AS c53, '' AS c54, '' AS c55, '' AS c56, '' AS c57, '' AS c58, '' AS c59, '' AS c60, '' AS c61, '' AS c62, '' AS c63, '' AS c64) +GROUP BY ALL WITH CUBE diff --git a/tests/ast_json_fixtures/shapes/f40dd6f8cd9b5d23.json b/tests/ast_json_fixtures/shapes/f40dd6f8cd9b5d23.json new file mode 100644 index 000000000000..d11ccd532f2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f40dd6f8cd9b5d23.json @@ -0,0 +1,16 @@ +{ + "version": 2, + "ast": { + "type": "OptimizeQuery", + "table": { + "type": "Identifier", + "name": "tab" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f40dd6f8cd9b5d23.sql b/tests/ast_json_fixtures/shapes/f40dd6f8cd9b5d23.sql new file mode 100644 index 000000000000..962eb2a9fa91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f40dd6f8cd9b5d23.sql @@ -0,0 +1 @@ +OPTIMIZE TABLE tab SETTINGS mutations_sync = 2 diff --git a/tests/ast_json_fixtures/shapes/f423f1aef29ef6c2.json b/tests/ast_json_fixtures/shapes/f423f1aef29ef6c2.json new file mode 100644 index 000000000000..fc34ce61fd0e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f423f1aef29ef6c2.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "ttl" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_TTL" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f423f1aef29ef6c2.sql b/tests/ast_json_fixtures/shapes/f423f1aef29ef6c2.sql new file mode 100644 index 000000000000..96de593f2f12 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f423f1aef29ef6c2.sql @@ -0,0 +1 @@ +alter table ttl materialize ttl diff --git a/tests/ast_json_fixtures/shapes/f42b6ca879e0b493.json b/tests/ast_json_fixtures/shapes/f42b6ca879e0b493.json new file mode 100644 index 000000000000..d1e3d27ab73e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f42b6ca879e0b493.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02484_plustwo", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/f42b6ca879e0b493.sql b/tests/ast_json_fixtures/shapes/f42b6ca879e0b493.sql new file mode 100644 index 000000000000..400009ee4806 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f42b6ca879e0b493.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02484_plustwo diff --git a/tests/ast_json_fixtures/shapes/f43f57cc0bfe8906.json b/tests/ast_json_fixtures/shapes/f43f57cc0bfe8906.json new file mode 100644 index 000000000000..6463ef3ba29b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f43f57cc0bfe8906.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q3_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "QUERY_SELECTS": "12000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f43f57cc0bfe8906.sql b/tests/ast_json_fixtures/shapes/f43f57cc0bfe8906.sql new file mode 100644 index 000000000000..2aa31bdf031d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f43f57cc0bfe8906.sql @@ -0,0 +1 @@ +CREATE QUOTA q3_01297 FOR INTERVAL 1 MINUTE MAX query_selects = '12M' diff --git a/tests/ast_json_fixtures/shapes/f4480f6d737f7801.json b/tests/ast_json_fixtures/shapes/f4480f6d737f7801.json new file mode 100644 index 000000000000..799b273451ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4480f6d737f7801.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN AST", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "isNotDistinctFrom", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f4480f6d737f7801.sql b/tests/ast_json_fixtures/shapes/f4480f6d737f7801.sql new file mode 100644 index 000000000000..0189fad6f883 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4480f6d737f7801.sql @@ -0,0 +1 @@ +EXPLAIN AST SELECT 1 <=> 1 == 1 diff --git a/tests/ast_json_fixtures/shapes/f44b45d72c54ec42.json b/tests/ast_json_fixtures/shapes/f44b45d72c54ec42.json new file mode 100644 index 000000000000..c7ed03626f5b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f44b45d72c54ec42.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q6_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "QUERY_SELECTS": "12884901888" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f44b45d72c54ec42.sql b/tests/ast_json_fixtures/shapes/f44b45d72c54ec42.sql new file mode 100644 index 000000000000..839180fec0e0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f44b45d72c54ec42.sql @@ -0,0 +1 @@ +CREATE QUOTA q6_01297 FOR INTERVAL 1 MINUTE MAX query_selects = '12Gi' diff --git a/tests/ast_json_fixtures/shapes/f44f25be9b4e203f.json b/tests/ast_json_fixtures/shapes/f44f25be9b4e203f.json new file mode 100644 index 000000000000..bd226449ff16 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f44f25be9b4e203f.json @@ -0,0 +1,149 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "alias": "k", + "name": "intDiv", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "numbers500k" + } + ] + } + } + } + ] + }, + "prewhere": { + "type": "Literal", + "value_type": "UInt64", + "value": "31" + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "65537" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "DESC", + "nulls_first": true + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "k" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC", + "nulls_first": false + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483648" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f44f25be9b4e203f.sql b/tests/ast_json_fixtures/shapes/f44f25be9b4e203f.sql new file mode 100644 index 000000000000..c4a1e0cb4db1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f44f25be9b4e203f.sql @@ -0,0 +1 @@ +SELECT intDiv(number, NULL) AS k FROM (SELECT * FROM remote('127.0.0.{2,3}', currentDatabase(), numbers500k) PREWHERE 31 WHERE 65537 > 0 ORDER BY number DESC NULLS FIRST) GROUP BY GROUPING SETS ((k)) WITH TOTALS ORDER BY k ASC NULLS LAST LIMIT 2147483648 diff --git a/tests/ast_json_fixtures/shapes/f467318fbf2ad196.json b/tests/ast_json_fixtures/shapes/f467318fbf2ad196.json new file mode 100644 index 000000000000..fb2e69628797 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f467318fbf2ad196.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_max_size_drop" + }, + "settings": { + "type": "Settings", + "changes": { + "max_partition_size_to_drop": "1" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_PARTITION", + "partition": { + "type": "Partition", + "value": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f467318fbf2ad196.sql b/tests/ast_json_fixtures/shapes/f467318fbf2ad196.sql new file mode 100644 index 000000000000..783503342cc7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f467318fbf2ad196.sql @@ -0,0 +1 @@ +ALTER TABLE test_max_size_drop DROP PARTITION tuple() SETTINGS max_partition_size_to_drop = 1 diff --git a/tests/ast_json_fixtures/shapes/f47cd4170c24e160.json b/tests/ast_json_fixtures/shapes/f47cd4170c24e160.json new file mode 100644 index 000000000000..7a7078afd959 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f47cd4170c24e160.json @@ -0,0 +1,55 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "dist_01213" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "optimize_skip_unused_shards": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f47cd4170c24e160.sql b/tests/ast_json_fixtures/shapes/f47cd4170c24e160.sql new file mode 100644 index 000000000000..7c663123f2be --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f47cd4170c24e160.sql @@ -0,0 +1 @@ +SELECT DISTINCT id FROM dist_01213 WHERE id = 1 SETTINGS optimize_skip_unused_shards=1 diff --git a/tests/ast_json_fixtures/shapes/f4878c27a8a3394f.json b/tests/ast_json_fixtures/shapes/f4878c27a8a3394f.json new file mode 100644 index 000000000000..1d4330a4690a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4878c27a8a3394f.json @@ -0,0 +1,94 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "table": { + "type": "Identifier", + "name": "mv_projections" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "projections": [ + { + "type": "Projection", + "name": "p", + "query": { + "type": "ProjectionSelectQuery", + "select": [ + { + "type": "Function", + "name": "uniqCombined", + "arguments": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + ] + } + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "data" + } + } + } + ] + } + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Identifier", + "name": "key" + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f4878c27a8a3394f.sql b/tests/ast_json_fixtures/shapes/f4878c27a8a3394f.sql new file mode 100644 index 000000000000..f5029f639923 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4878c27a8a3394f.sql @@ -0,0 +1,8 @@ +CREATE MATERIALIZED VIEW mv_projections +( + key String, + projection p (SELECT uniqCombined(key)) +) +ENGINE = MergeTree +ORDER BY key +AS SELECT * FROM data diff --git a/tests/ast_json_fixtures/shapes/f48c773809962c3e.json b/tests/ast_json_fixtures/shapes/f48c773809962c3e.json new file mode 100644 index 000000000000..37ae39df4326 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f48c773809962c3e.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u1_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "PLAINTEXT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwe123" + } + ] + }, + { + "type": "AuthenticationData", + "auth_type": "KERBEROS", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwerty10" + } + ] + }, + { + "type": "AuthenticationData", + "auth_type": "BCRYPT_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "123qwe" + } + ] + }, + { + "type": "AuthenticationData", + "auth_type": "LDAP", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "abc" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/f48c773809962c3e.sql b/tests/ast_json_fixtures/shapes/f48c773809962c3e.sql new file mode 100644 index 000000000000..f75daf5d683e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f48c773809962c3e.sql @@ -0,0 +1 @@ +CREATE USER u1_01292 IDENTIFIED WITH plaintext_password by 'qwe123', kerberos REALM 'qwerty10', bcrypt_password by '123qwe', ldap SERVER 'abc' diff --git a/tests/ast_json_fixtures/shapes/f4ab5860ca5bbd00.json b/tests/ast_json_fixtures/shapes/f4ab5860ca5bbd00.json new file mode 100644 index 000000000000..f1071a294cb0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4ab5860ca5bbd00.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_clone_as": true, + "table": { + "type": "Identifier", + "name": "clone_as_foo_memory" + }, + "as_table": "foo_memory" + } +} diff --git a/tests/ast_json_fixtures/shapes/f4ab5860ca5bbd00.sql b/tests/ast_json_fixtures/shapes/f4ab5860ca5bbd00.sql new file mode 100644 index 000000000000..c4cc476a25aa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4ab5860ca5bbd00.sql @@ -0,0 +1 @@ +CREATE TABLE clone_as_foo_memory CLONE AS foo_memory diff --git a/tests/ast_json_fixtures/shapes/f4bce515b747cd2f.json b/tests/ast_json_fixtures/shapes/f4bce515b747cd2f.json new file mode 100644 index 000000000000..7ea68ecaa644 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4bce515b747cd2f.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Identifier", + "name": "value" + } + ] + }, + { + "type": "Identifier", + "name": "f" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "bool_test" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f4bce515b747cd2f.sql b/tests/ast_json_fixtures/shapes/f4bce515b747cd2f.sql new file mode 100644 index 000000000000..c111173a6c55 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4bce515b747cd2f.sql @@ -0,0 +1 @@ +SELECT toUInt64(value),f FROM bool_test diff --git a/tests/ast_json_fixtures/shapes/f4c387372137db1a.json b/tests/ast_json_fixtures/shapes/f4c387372137db1a.json new file mode 100644 index 000000000000..fef38118ca29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4c387372137db1a.json @@ -0,0 +1,92 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "d", + "name": "date" + }, + { + "type": "Function", + "alias": "f", + "name": "toNullable", + "arguments": [ + { + "type": "Identifier", + "name": "f" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "02861_interpolate" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "1" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC", + "with_fill": true, + "fill_step": { + "type": "Function", + "name": "toIntervalDay", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ], + "interpolate": [ + { + "type": "InterpolateElement", + "column": "f", + "expr": { + "type": "Identifier", + "name": "f" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f4c387372137db1a.sql b/tests/ast_json_fixtures/shapes/f4c387372137db1a.sql new file mode 100644 index 000000000000..1622355a3c79 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4c387372137db1a.sql @@ -0,0 +1 @@ +SELECT date AS d, toNullable(f) AS f FROM 02861_interpolate WHERE id = '1' ORDER BY d ASC WITH FILL STEP toIntervalDay(1) INTERPOLATE (f) diff --git a/tests/ast_json_fixtures/shapes/f4daae58b980238c.json b/tests/ast_json_fixtures/shapes/f4daae58b980238c.json new file mode 100644 index 000000000000..9fdd79474ef7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4daae58b980238c.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "alter": true, + "names": ["s2_01294"], + "alter_settings": { + "type": "AlterSettingsProfileElements", + "add_settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "readonly", + "value": "1" + } + ] + }, + "drop_all_settings": true, + "drop_all_profiles": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f4daae58b980238c.sql b/tests/ast_json_fixtures/shapes/f4daae58b980238c.sql new file mode 100644 index 000000000000..66cc51630a56 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4daae58b980238c.sql @@ -0,0 +1 @@ +ALTER PROFILE s2_01294 SETTINGS readonly=1 diff --git a/tests/ast_json_fixtures/shapes/f4e84cfc6226656a.json b/tests/ast_json_fixtures/shapes/f4e84cfc6226656a.json new file mode 100644 index 000000000000..b3ec06a613a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4e84cfc6226656a.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "alter": true, + "names": ["q1_01297"], + "roles": { + "type": "RolesOrUsersSet", + "names": ["u1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f4e84cfc6226656a.sql b/tests/ast_json_fixtures/shapes/f4e84cfc6226656a.sql new file mode 100644 index 000000000000..a1cf5b3425d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4e84cfc6226656a.sql @@ -0,0 +1 @@ +ALTER QUOTA q1_01297 TO u1_01297 diff --git a/tests/ast_json_fixtures/shapes/f4e9eac5194c7dfd.json b/tests/ast_json_fixtures/shapes/f4e9eac5194c7dfd.json new file mode 100644 index 000000000000..25d842b5abb8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4e9eac5194c7dfd.json @@ -0,0 +1,163 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "b", + "name": "a" + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "c", + "name": "b" + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Identifier", + "alias": "d", + "name": "c" + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e" + }, + { + "type": "Literal", + "value_type": "String", + "value": "true" + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "allow_experimental_analyzer": "0" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f4e9eac5194c7dfd.sql b/tests/ast_json_fixtures/shapes/f4e9eac5194c7dfd.sql new file mode 100644 index 000000000000..ea902a411784 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f4e9eac5194c7dfd.sql @@ -0,0 +1,12 @@ +WITH + a as b +SELECT 1 FROM ( + WITH b as c + SELECT 1 FROM ( + WITH c as d + SELECT 1 FROM ( + SELECT 1 FROM tab WHERE e = 'true' + ) + ) +) +SETTINGS allow_experimental_analyzer = 0 diff --git a/tests/ast_json_fixtures/shapes/f509d8e6dc5aa0dd.json b/tests/ast_json_fixtures/shapes/f509d8e6dc5aa0dd.json new file mode 100644 index 000000000000..c04d06203b3a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f509d8e6dc5aa0dd.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Identifier", + "name": "_part" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_dst" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "v" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f509d8e6dc5aa0dd.sql b/tests/ast_json_fixtures/shapes/f509d8e6dc5aa0dd.sql new file mode 100644 index 000000000000..a6ff3cba0736 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f509d8e6dc5aa0dd.sql @@ -0,0 +1 @@ +SELECT *, _part FROM t_dst ORDER BY v diff --git a/tests/ast_json_fixtures/shapes/f50a4457f0091be5.json b/tests/ast_json_fixtures/shapes/f50a4457f0091be5.json new file mode 100644 index 000000000000..44f5fd326cd5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f50a4457f0091be5.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "order_by_all": true, + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Literal", + "value_type": "String", + "value": "str" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "all" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f50a4457f0091be5.sql b/tests/ast_json_fixtures/shapes/f50a4457f0091be5.sql new file mode 100644 index 000000000000..3074954e9a17 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f50a4457f0091be5.sql @@ -0,0 +1 @@ +select * from test group by grouping sets ((d), ('str')) order by all diff --git a/tests/ast_json_fixtures/shapes/f50abd92bf2f2245.json b/tests/ast_json_fixtures/shapes/f50abd92bf2f2245.json new file mode 100644 index 000000000000..a2f690b8db7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f50abd92bf2f2245.json @@ -0,0 +1,202 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "c", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "ID", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "alias": "dt", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2023-06-24" + } + ] + }, + { + "type": "Literal", + "alias": "p", + "value_type": "UInt64", + "value": "0" + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Function", + "alias": "params", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t.ID", + "name_parts": ["t", "ID"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "formatRowNoNewline", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "JSONEachRow" + }, + { + "type": "Identifier", + "name": "dd" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + } + ] + }, + { + "type": "Identifier", + "name": "dd" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "ID" + }, + { + "type": "Function", + "alias": "dd", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "p" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Function", + "name": "plus", + "arguments": [ + { + "type": "Identifier", + "name": "dt" + }, + { + "type": "Function", + "name": "toIntervalHour", + "arguments": [ + { + "type": "Identifier", + "name": "p" + } + ] + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "2022-01-01" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "c" + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f50abd92bf2f2245.sql b/tests/ast_json_fixtures/shapes/f50abd92bf2f2245.sql new file mode 100644 index 000000000000..5baed8fc303d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f50abd92bf2f2245.sql @@ -0,0 +1 @@ +with c as ( select 1 ID, toDate('2023-06-24') dt, 0 p ) select multiIf(t.ID = 1, formatRowNoNewline('JSONEachRow', dd), '') AS params, dd from (select ID, case when p = 0 then toString(date_add(hour, p, dt)) else '2022-01-01' end as dd from c) t diff --git a/tests/ast_json_fixtures/shapes/f51203a57d379cfb.json b/tests/ast_json_fixtures/shapes/f51203a57d379cfb.json new file mode 100644 index 000000000000..2c63367da93a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f51203a57d379cfb.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "tab_fully" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DROP_INDEX", + "if_exists": true, + "index": { + "type": "Identifier", + "name": "idx" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f51203a57d379cfb.sql b/tests/ast_json_fixtures/shapes/f51203a57d379cfb.sql new file mode 100644 index 000000000000..455bccace0ba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f51203a57d379cfb.sql @@ -0,0 +1 @@ +ALTER TABLE tab_fully drop index if exists idx diff --git a/tests/ast_json_fixtures/shapes/f51c4cf098419282.json b/tests/ast_json_fixtures/shapes/f51c4cf098419282.json new file mode 100644 index 000000000000..bf0c10f2a43a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f51c4cf098419282.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s2_01418"] + } +} diff --git a/tests/ast_json_fixtures/shapes/f51c4cf098419282.sql b/tests/ast_json_fixtures/shapes/f51c4cf098419282.sql new file mode 100644 index 000000000000..64b60b771255 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f51c4cf098419282.sql @@ -0,0 +1 @@ +SHOW CREATE SETTINGS PROFILE s2_01418 diff --git a/tests/ast_json_fixtures/shapes/f52a91fac4fcb503.json b/tests/ast_json_fixtures/shapes/f52a91fac4fcb503.json new file mode 100644 index 000000000000..01e5a301a9ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f52a91fac4fcb503.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "number", + "value_type": "String", + "value": "100" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "n", + "name": "d_numbers" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n.number", + "name_parts": ["n", "number"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1", + "prefer_localhost_replica": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f52a91fac4fcb503.sql b/tests/ast_json_fixtures/shapes/f52a91fac4fcb503.sql new file mode 100644 index 000000000000..6ad746ae0b85 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f52a91fac4fcb503.sql @@ -0,0 +1 @@ +SELECT '100' AS number FROM d_numbers AS n WHERE n.number = 100 LIMIT 2 SETTINGS max_threads = 1, prefer_localhost_replica=1 diff --git a/tests/ast_json_fixtures/shapes/f530ddc22ca690e7.json b/tests/ast_json_fixtures/shapes/f530ddc22ca690e7.json new file mode 100644 index 000000000000..b89dbcc1dc2b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f530ddc22ca690e7.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "SETTINGS PROFILE", + "names": ["s4_01294"] + } +} diff --git a/tests/ast_json_fixtures/shapes/f530ddc22ca690e7.sql b/tests/ast_json_fixtures/shapes/f530ddc22ca690e7.sql new file mode 100644 index 000000000000..e42cf4fe60d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f530ddc22ca690e7.sql @@ -0,0 +1 @@ +SHOW CREATE PROFILE s4_01294 diff --git a/tests/ast_json_fixtures/shapes/f53a7266a9f8716e.json b/tests/ast_json_fixtures/shapes/f53a7266a9f8716e.json new file mode 100644 index 000000000000..000a63589c2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f53a7266a9f8716e.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "uniqCombined", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_bytes_before_external_group_by": "1", + "max_bytes_ratio_before_external_group_by": "0", + "max_rows_to_group_by": "10000000000", + "group_by_overflow_mode": "any", + "totals_mode": "before_having", + "max_untracked_memory": "0", + "group_by_two_level_threshold": "10000", + "max_block_size": "1000", + "max_threads": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f53a7266a9f8716e.sql b/tests/ast_json_fixtures/shapes/f53a7266a9f8716e.sql new file mode 100644 index 000000000000..584fe35e55ee --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f53a7266a9f8716e.sql @@ -0,0 +1,20 @@ +SELECT uniqCombined(number) +FROM numbers(10000) +GROUP BY number + WITH TOTALS +ORDER BY number DESC +LIMIT 10 +SETTINGS + + max_bytes_before_external_group_by=1, + max_bytes_ratio_before_external_group_by=0, + + max_rows_to_group_by=10000000000, + group_by_overflow_mode='any', + totals_mode='before_having', + + max_untracked_memory=0, + group_by_two_level_threshold=10000, + + max_block_size=1000, + max_threads=1 diff --git a/tests/ast_json_fixtures/shapes/f54272acd12c994e.json b/tests/ast_json_fixtures/shapes/f54272acd12c994e.json new file mode 100644 index 000000000000..89abe1a86cce --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f54272acd12c994e.json @@ -0,0 +1,544 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "input_1", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "parent_id", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + }, + { + "type": "Function", + "alias": "id", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + }, + { + "type": "Function", + "alias": "value", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1000000 + } + ] + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "dimensions_1", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "value_id", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1000000 + } + ] + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "dimensions_2", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "value_id", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers_mt", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1000000 + } + ] + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "parents", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "type", + "value_type": "String", + "value": "foo" + }, + { + "type": "Identifier", + "name": "parent_id" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "input_1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "parent_id" + } + ] + } + ] + } + } + }, + { + "type": "WithElement", + "name": "parents_with_value", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Identifier", + "name": "parent_id" + }, + { + "type": "Identifier", + "name": "t.value", + "name_parts": ["t", "value"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parents" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t.id", + "name_parts": ["t", "id"] + }, + { + "type": "Identifier", + "name": "parents.parent_id", + "name_parts": ["parents", "parent_id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t", + "name": "input_1" + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "values", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "type", + "value_type": "String", + "value": "foo" + }, + { + "type": "Literal", + "alias": "parent_id", + "value_type": "String", + "value": "" + }, + { + "type": "Identifier", + "name": "value" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "input_1" + } + } + } + ] + } + } + ] + } + } + }, + { + "type": "WithElement", + "name": "all", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "parents_with_value" + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "values" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Identifier", + "name": "value" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "all" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "all.value", + "name_parts": ["all", "value"] + }, + { + "type": "Identifier", + "name": "dim1.value_id", + "name_parts": ["dim1", "value_id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "dim1", + "name": "dimensions_1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "all.value", + "name_parts": ["all", "value"] + }, + { + "type": "Identifier", + "name": "dim2.value_id", + "name_parts": ["dim2", "value_id"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "dim2", + "name": "dimensions_2" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "65535", + "max_joined_block_size_rows": "65535", + "max_threads": "32" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/f54272acd12c994e.sql b/tests/ast_json_fixtures/shapes/f54272acd12c994e.sql new file mode 100644 index 000000000000..83bc61a4e37f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f54272acd12c994e.sql @@ -0,0 +1,33 @@ +WITH + input_1 AS (SELECT number::String AS parent_id, number::String as id, number::String as value FROM numbers_mt(1e6)), + dimensions_1 AS (SELECT number::String AS value_id FROM numbers_mt(1e6)), + dimensions_2 AS (SELECT number::String AS value_id FROM numbers_mt(1e6)), + parents AS + ( + SELECT 'foo' AS type, parent_id + FROM input_1 + GROUP BY parent_id + ), + parents_with_value AS + ( + SELECT type, parent_id, t.value + FROM parents + LEFT JOIN input_1 AS t ON t.id = parents.parent_id + ), + values AS + ( + SELECT 'foo' AS type, '' AS parent_id, value + FROM input_1 + ), + all AS + ( + SELECT * FROM parents_with_value + UNION ALL + SELECT * FROM values + ) +SELECT type, value +FROM all +INNER JOIN dimensions_1 AS dim1 ON all.value = dim1.value_id +INNER JOIN dimensions_2 AS dim2 ON all.value = dim2.value_id +FORMAT `Null` +SETTINGS max_block_size=65535, max_joined_block_size_rows=65535, max_threads=32 diff --git a/tests/ast_json_fixtures/shapes/f543401ecf607f3e.json b/tests/ast_json_fixtures/shapes/f543401ecf607f3e.json new file mode 100644 index 000000000000..d624edd8b8d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f543401ecf607f3e.json @@ -0,0 +1,7 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "CLEAR VECTOR SIMILARITY INDEX CACHE" + } +} diff --git a/tests/ast_json_fixtures/shapes/f543401ecf607f3e.sql b/tests/ast_json_fixtures/shapes/f543401ecf607f3e.sql new file mode 100644 index 000000000000..dd4dcee17150 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f543401ecf607f3e.sql @@ -0,0 +1 @@ +SYSTEM CLEAR VECTOR SIMILARITY INDEX CACHE diff --git a/tests/ast_json_fixtures/shapes/f55e02e061941068.json b/tests/ast_json_fixtures/shapes/f55e02e061941068.json new file mode 100644 index 000000000000..49ef06b92520 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f55e02e061941068.json @@ -0,0 +1,93 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_rollup": true, + "select": [ + { + "type": "Function", + "name": "arraySplit", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [] + } + ] + } + ], + "where": { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Function", + "name": "ignore", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "a" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "group_by_use_nulls": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f55e02e061941068.sql b/tests/ast_json_fixtures/shapes/f55e02e061941068.sql new file mode 100644 index 000000000000..1e859fb98c07 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f55e02e061941068.sql @@ -0,0 +1 @@ +SELECT arraySplit(x -> 0, []) WHERE materialize(1) GROUP BY (0, ignore('a')) WITH ROLLUP SETTINGS group_by_use_nulls = 1 diff --git a/tests/ast_json_fixtures/shapes/f561ecf80d3bef15.json b/tests/ast_json_fixtures/shapes/f561ecf80d3bef15.json new file mode 100644 index 000000000000..aa9a99672d25 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f561ecf80d3bef15.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "FLUSH LOGS", + "tables": [ + { + "table": "trace_log" + }, + { + "table": "query_log" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f561ecf80d3bef15.sql b/tests/ast_json_fixtures/shapes/f561ecf80d3bef15.sql new file mode 100644 index 000000000000..78fe93c6503d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f561ecf80d3bef15.sql @@ -0,0 +1 @@ +SYSTEM FLUSH LOGS trace_log, query_log diff --git a/tests/ast_json_fixtures/shapes/f56adff0211f3a83.json b/tests/ast_json_fixtures/shapes/f56adff0211f3a83.json new file mode 100644 index 000000000000..25c07bca7dfe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f56adff0211f3a83.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1__fuzz_17" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "a" + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2__fuzz_0" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "a" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/f56adff0211f3a83.sql b/tests/ast_json_fixtures/shapes/f56adff0211f3a83.sql new file mode 100644 index 000000000000..0dc8cb1f7544 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f56adff0211f3a83.sql @@ -0,0 +1 @@ +SELECT * FROM t1__fuzz_17 INNER JOIN t2__fuzz_0 ON c = a WHERE a format Null diff --git a/tests/ast_json_fixtures/shapes/f578a5f34ede617f.json b/tests/ast_json_fixtures/shapes/f578a5f34ede617f.json new file mode 100644 index 000000000000..70aa4a3a0d2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f578a5f34ede617f.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "r1" + }, + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Function", + "name": "uniqExact", + "arguments": [ + { + "type": "Identifier", + "name": "unique_value" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "replicated_deduplicate_by_columns_r1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "val" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "val" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f578a5f34ede617f.sql b/tests/ast_json_fixtures/shapes/f578a5f34ede617f.sql new file mode 100644 index 000000000000..dc1cb99c9984 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f578a5f34ede617f.sql @@ -0,0 +1 @@ +SELECT 'r1', id, val, count(), uniqExact(unique_value) FROM replicated_deduplicate_by_columns_r1 GROUP BY id, val ORDER BY id, val diff --git a/tests/ast_json_fixtures/shapes/f59eb83e1c04c106.json b/tests/ast_json_fixtures/shapes/f59eb83e1c04c106.json new file mode 100644 index 000000000000..257a2b52d2a5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f59eb83e1c04c106.json @@ -0,0 +1,175 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "database": { + "type": "Identifier", + "name": "01760_db" + }, + "table": { + "type": "Identifier", + "name": "dict_array" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "DataType", + "name": "Array", + "arguments": [ + { + "type": "TupleDataType", + "name": "Tuple", + "arguments": [ + { + "type": "DataType", + "name": "Float64" + }, + { + "type": "DataType", + "name": "Float64" + } + ] + } + ] + } + ] + } + ] + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "name", + "data_type": { + "type": "DataType", + "name": "String" + }, + "default_value": { + "type": "Literal", + "value_type": "String", + "value": "qqq" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value_nullable", + "data_type": { + "type": "DataType", + "name": "Nullable", + "arguments": [ + { + "type": "DataType", + "name": "UInt64" + } + ] + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "20" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "key" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "user", + "value": { + "type": "Literal", + "value_type": "String", + "value": "default" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "polygons" + } + }, + { + "type": "pair", + "key": "db", + "value": { + "type": "Literal", + "value_type": "String", + "value": "01760_db" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 0 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "polygon", + "parameters": [] + }, + "settings": { + "type": "DictionarySettings", + "changes": { + "dictionary_use_async_executor": "1", + "max_threads": "8" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f59eb83e1c04c106.sql b/tests/ast_json_fixtures/shapes/f59eb83e1c04c106.sql new file mode 100644 index 000000000000..93f9aefe8a89 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f59eb83e1c04c106.sql @@ -0,0 +1,12 @@ +CREATE DICTIONARY 01760_db.dict_array +( + key Array(Array(Array(Tuple(Float64, Float64)))), + name String DEFAULT 'qqq', + value UInt64 DEFAULT 10, + value_nullable Nullable(UInt64) DEFAULT 20 +) +PRIMARY KEY key +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'polygons' DB '01760_db')) +LIFETIME(0) +LAYOUT(POLYGON()) +SETTINGS(dictionary_use_async_executor=1, max_threads=8) diff --git a/tests/ast_json_fixtures/shapes/f5a4caf726e9f75e.json b/tests/ast_json_fixtures/shapes/f5a4caf726e9f75e.json new file mode 100644 index 000000000000..ad4541c813f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f5a4caf726e9f75e.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Identifier", + "name": "val" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "03408_memory" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "val" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "exact_rows_before_limit": "1" + } + }, + "format": "JsonCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/f5a4caf726e9f75e.sql b/tests/ast_json_fixtures/shapes/f5a4caf726e9f75e.sql new file mode 100644 index 000000000000..d954eff39e99 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f5a4caf726e9f75e.sql @@ -0,0 +1,2 @@ +SELECT id, val FROM 03408_memory ORDER BY id, val LIMIT 1 BY id LIMIT 3 +FORMAT JsonCompact SETTINGS exact_rows_before_limit=1 diff --git a/tests/ast_json_fixtures/shapes/f5b75a0e7257d18e.json b/tests/ast_json_fixtures/shapes/f5b75a0e7257d18e.json new file mode 100644 index 000000000000..000498fb0ce4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f5b75a0e7257d18e.json @@ -0,0 +1,71 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "issue", + "name": "throwIf", + "arguments": [ + { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "val" + }, + { + "type": "Literal", + "value_type": "String", + "value": "one" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "column_modify_test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ], + "format": "NULL" + } +} diff --git a/tests/ast_json_fixtures/shapes/f5b75a0e7257d18e.sql b/tests/ast_json_fixtures/shapes/f5b75a0e7257d18e.sql new file mode 100644 index 000000000000..cdfa58d4a636 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f5b75a0e7257d18e.sql @@ -0,0 +1 @@ +SELECT *, throwIf(val <> 'one') as issue FROM column_modify_test WHERE id = 1 FORMAT NULL diff --git a/tests/ast_json_fixtures/shapes/f5cc804169fc8d2e.json b/tests/ast_json_fixtures/shapes/f5cc804169fc8d2e.json new file mode 100644 index 000000000000..0daca02c9467 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f5cc804169fc8d2e.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "alias": "k", + "name": "TraficSourceID" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1704509" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "totals_mode": "after_having_auto", + "max_rows_to_group_by": "100000", + "group_by_overflow_mode": "any" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f5cc804169fc8d2e.sql b/tests/ast_json_fixtures/shapes/f5cc804169fc8d2e.sql new file mode 100644 index 000000000000..aeba636a6a39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f5cc804169fc8d2e.sql @@ -0,0 +1 @@ +SELECT TraficSourceID AS k, count() AS c FROM test.hits WHERE CounterID = 1704509 GROUP BY k WITH TOTALS ORDER BY k SETTINGS totals_mode = 'after_having_auto', max_rows_to_group_by = 100000, group_by_overflow_mode = 'any' diff --git a/tests/ast_json_fixtures/shapes/f5ff40c69473bab9.json b/tests/ast_json_fixtures/shapes/f5ff40c69473bab9.json new file mode 100644 index 000000000000..0008bc245973 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f5ff40c69473bab9.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "d" + } + }, + { + "type": "Identifier", + "name": "d.values", + "name_parts": ["d", "values"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "value", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "SEMI", + "using": [ + { + "type": "Identifier", + "name": "id" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "d", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "values", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f5ff40c69473bab9.sql b/tests/ast_json_fixtures/shapes/f5ff40c69473bab9.sql new file mode 100644 index 000000000000..d6acea33b13d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f5ff40c69473bab9.sql @@ -0,0 +1 @@ +SELECT *, d.*, d.values FROM ( SELECT 1 AS id, 2 AS value ) SEMI LEFT JOIN ( SELECT 1 AS id, 3 AS values ) AS d USING id diff --git a/tests/ast_json_fixtures/shapes/f602a149631985f4.json b/tests/ast_json_fixtures/shapes/f602a149631985f4.json new file mode 100644 index 000000000000..c40e866de9b8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f602a149631985f4.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1091" + } + ], + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f602a149631985f4.sql b/tests/ast_json_fixtures/shapes/f602a149631985f4.sql new file mode 100644 index 000000000000..bf0dff3f7000 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f602a149631985f4.sql @@ -0,0 +1 @@ +WITH 01091 AS id SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/f607a2c2226e972f.json b/tests/ast_json_fixtures/shapes/f607a2c2226e972f.json new file mode 100644 index 000000000000..924c7785184b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f607a2c2226e972f.json @@ -0,0 +1,70 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "Num" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "limit_by" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "Num" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "Num" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + "by": [ + { + "type": "Identifier", + "name": "Num" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f607a2c2226e972f.sql b/tests/ast_json_fixtures/shapes/f607a2c2226e972f.sql new file mode 100644 index 000000000000..8f992ca12de3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f607a2c2226e972f.sql @@ -0,0 +1 @@ +SELECT Num, count(*) FROM limit_by GROUP BY Num ORDER BY Num LIMIT 2 BY Num diff --git a/tests/ast_json_fixtures/shapes/f62bcd3af1152873.json b/tests/ast_json_fixtures/shapes/f62bcd3af1152873.json new file mode 100644 index 000000000000..8df0321151e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f62bcd3af1152873.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "MATERIALIZE_INDEX", + "index": { + "type": "Identifier", + "name": "i1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f62bcd3af1152873.sql b/tests/ast_json_fixtures/shapes/f62bcd3af1152873.sql new file mode 100644 index 000000000000..3093cf3b36ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f62bcd3af1152873.sql @@ -0,0 +1 @@ +ALTER TABLE test MATERIALIZE INDEX i1 diff --git a/tests/ast_json_fixtures/shapes/f6369a3c561d6c82.json b/tests/ast_json_fixtures/shapes/f6369a3c561d6c82.json new file mode 100644 index 000000000000..fce7ee2e204c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6369a3c561d6c82.json @@ -0,0 +1,314 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "id_and_start_tuple", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_id" + }, + { + "type": "Identifier", + "name": "query_start_time" + }, + { + "type": "Identifier", + "name": "query_start_time_microseconds" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "yesterday", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "current_database" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "log_comment" + }, + { + "type": "Literal", + "value_type": "String", + "value": "02985_shard_query_start_time_query_1" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Literal", + "value_type": "String", + "value": "QueryFinish" + } + ] + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "type" + }, + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_start_time" + }, + { + "type": "Identifier", + "name": "initial_query_start_time" + } + ] + } + ] + }, + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "query_start_time_microseconds" + }, + { + "type": "Identifier", + "name": "initial_query_start_time_microseconds" + } + ] + } + ] + }, + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "initial_query_start_time" + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id_and_start_tuple" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + } + ] + }, + { + "type": "Function", + "name": "countIf", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "initial_query_start_time_microseconds" + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id_and_start_tuple" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "query_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "is_initial_query" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "initial_query_id" + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id_and_start_tuple" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "type" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f6369a3c561d6c82.sql b/tests/ast_json_fixtures/shapes/f6369a3c561d6c82.sql new file mode 100644 index 000000000000..54c0e58cbb24 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6369a3c561d6c82.sql @@ -0,0 +1,23 @@ +WITH +( + SELECT + (query_id, query_start_time, query_start_time_microseconds) + FROM + system.query_log + WHERE + event_date >= yesterday() + AND current_database = currentDatabase() + AND log_comment = '02985_shard_query_start_time_query_1' + AND type = 'QueryFinish' +) AS id_and_start_tuple +SELECT + type, + countIf(query_start_time >= initial_query_start_time), + countIf(query_start_time_microseconds > initial_query_start_time_microseconds), + countIf(initial_query_start_time = id_and_start_tuple.2), + countIf(initial_query_start_time_microseconds = id_and_start_tuple.3) +FROM + system.query_log +WHERE + NOT is_initial_query AND initial_query_id = id_and_start_tuple.1 +GROUP BY type diff --git a/tests/ast_json_fixtures/shapes/f651df4a93a870b7.json b/tests/ast_json_fixtures/shapes/f651df4a93a870b7.json new file mode 100644 index 000000000000..88058a46cab4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f651df4a93a870b7.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN PIPELINE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "merge1" + } + } + } + ] + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "graph": "1", + "compact": "1" + } + }, + "format": "Null", + "output_settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f651df4a93a870b7.sql b/tests/ast_json_fixtures/shapes/f651df4a93a870b7.sql new file mode 100644 index 000000000000..8615d2dd0462 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f651df4a93a870b7.sql @@ -0,0 +1 @@ +EXPLAIN PIPELINE graph = 1, compact = 1 SELECT * FROM merge1 FORMAT Null SETTINGS enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/f6563550db97f900.json b/tests/ast_json_fixtures/shapes/f6563550db97f900.json new file mode 100644 index 000000000000..c0eb62e18970 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6563550db97f900.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "order_by_all": true, + "select": [ + { + "type": "Identifier", + "name": "c" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "multi_int" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "ALL" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "extremes": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f6563550db97f900.sql b/tests/ast_json_fixtures/shapes/f6563550db97f900.sql new file mode 100644 index 000000000000..761c5d81b4d3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6563550db97f900.sql @@ -0,0 +1 @@ +SELECT c FROM multi_int ORDER BY ALL SETTINGS extremes=1 diff --git a/tests/ast_json_fixtures/shapes/f666e1a310a55b4d.json b/tests/ast_json_fixtures/shapes/f666e1a310a55b4d.json new file mode 100644 index 000000000000..06dbd7ab40d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f666e1a310a55b4d.json @@ -0,0 +1,351 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 1000.0001 + } + ] + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775807" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "foo_merge" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "Val" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-2" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Val" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Val" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "Val" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-2147483648" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Val" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Val" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Int64", + "value": "-2" + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Val" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Id" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "Val" + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483647" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f666e1a310a55b4d.sql b/tests/ast_json_fixtures/shapes/f666e1a310a55b4d.sql new file mode 100644 index 000000000000..1d4cce7281bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f666e1a310a55b4d.sql @@ -0,0 +1 @@ +SELECT 7, count(1000.0001), -9223372036854775807 FROM foo_merge INNER JOIN t2 USING (Val) WHERE (((NULL AND -2 AND (Val = NULL)) AND (Id = NULL) AND (Val = NULL) AND (Id = NULL)) AND (Id = NULL) AND Val AND NULL) AND ((3 AND NULL AND -2147483648 AND (Val = NULL)) AND (Id = NULL) AND (Val = NULL)) AND ((NULL AND -2 AND (Val = NULL)) AND (Id = NULL) AND (Val = NULL)) AND 2147483647 WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/f6811316ab7a1988.json b/tests/ast_json_fixtures/shapes/f6811316ab7a1988.json new file mode 100644 index 000000000000..ece9eb871074 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6811316ab7a1988.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "k" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "force_primary_key": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f6811316ab7a1988.sql b/tests/ast_json_fixtures/shapes/f6811316ab7a1988.sql new file mode 100644 index 000000000000..3a7ca00405d9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6811316ab7a1988.sql @@ -0,0 +1,7 @@ +SELECT + k, + count() +FROM t1 +GROUP BY k +ORDER BY k +SETTINGS force_primary_key = 1 diff --git a/tests/ast_json_fixtures/shapes/f684d04ad223837a.json b/tests/ast_json_fixtures/shapes/f684d04ad223837a.json new file mode 100644 index 000000000000..0da938c06478 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f684d04ad223837a.json @@ -0,0 +1,161 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "excludes", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "exclude", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "b" + }, + { + "value_type": "String", + "value": "d" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "a" + }, + { + "value_type": "String", + "value": "c" + } + ] + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "id", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "x" + }, + { + "value_type": "String", + "value": "y" + } + ] + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "result", + "name": "arrayExcept", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "String", + "value": "a" + }, + { + "value_type": "String", + "value": "b" + }, + { + "value_type": "String", + "value": "c" + } + ] + }, + { + "type": "Identifier", + "name": "exclude" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "excludes" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f684d04ad223837a.sql b/tests/ast_json_fixtures/shapes/f684d04ad223837a.sql new file mode 100644 index 000000000000..1a6e76df8a7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f684d04ad223837a.sql @@ -0,0 +1,10 @@ +WITH excludes AS ( + SELECT 1 as id, ['b','d'] AS exclude + UNION ALL + SELECT 2 as id, ['a','c'] + UNION ALL + SELECT 3 as id, ['x','y'] +) +SELECT + id, arrayExcept(['a','b','c'], exclude) AS result +FROM excludes ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/f693d84e0235454c.json b/tests/ast_json_fixtures/shapes/f693d84e0235454c.json new file mode 100644 index 000000000000..560b56b33a70 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f693d84e0235454c.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "not_existing", + "name": "if", + "is_operator": true, + "arguments": [ + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "hasColumnInTable", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "system" + }, + { + "type": "Literal", + "value_type": "String", + "value": "numbers" + }, + { + "type": "Literal", + "value_type": "String", + "value": "not_existing" + } + ] + } + ] + } + ] + } + }, + { + "type": "Identifier", + "name": "not_existing" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "42" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "TSKV" + } +} diff --git a/tests/ast_json_fixtures/shapes/f693d84e0235454c.sql b/tests/ast_json_fixtures/shapes/f693d84e0235454c.sql new file mode 100644 index 000000000000..c90cccbd2b61 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f693d84e0235454c.sql @@ -0,0 +1 @@ +SELECT (SELECT hasColumnInTable('system', 'numbers', 'not_existing')) ? not_existing : 42 as not_existing FROM system.numbers LIMIT 1 FORMAT TSKV diff --git a/tests/ast_json_fixtures/shapes/f6a2ef625addbfdb.json b/tests/ast_json_fixtures/shapes/f6a2ef625addbfdb.json new file mode 100644 index 000000000000..6ba48107d15d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6a2ef625addbfdb.json @@ -0,0 +1,99 @@ +{ + "version": 2, + "ast": { + "type": "ExecuteAsQuery", + "target_user": { + "type": "UserNameWithHost", + "name": "test_03727" + }, + "subquery": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "normal" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + "assignments": [ + { + "type": "Assignment", + "column": "s", + "expression": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "secret" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } + } + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f6a2ef625addbfdb.sql b/tests/ast_json_fixtures/shapes/f6a2ef625addbfdb.sql new file mode 100644 index 000000000000..1ce8e4ef6279 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6a2ef625addbfdb.sql @@ -0,0 +1 @@ +EXECUTE AS test_03727 ALTER TABLE normal UPDATE s = (SELECT * FROM remote('localhost', currentDatabase(), 'secret') LIMIT 1) WHERE n=1 diff --git a/tests/ast_json_fixtures/shapes/f6bf0e93480e1304.json b/tests/ast_json_fixtures/shapes/f6bf0e93480e1304.json new file mode 100644 index 000000000000..a954f29c8606 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6bf0e93480e1304.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "hl", + "name": "hits_layer" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "WatchID" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "vl", + "name": "visits_layer" + } + } + } + ] + } + } + ] + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f6bf0e93480e1304.sql b/tests/ast_json_fixtures/shapes/f6bf0e93480e1304.sql new file mode 100644 index 000000000000..ca7c9e65d5bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6bf0e93480e1304.sql @@ -0,0 +1,6 @@ +SELECT 0 FROM hits_layer AS hl +PREWHERE WatchID IN +( + SELECT 0 FROM visits_layer AS vl +) +WHERE 0 diff --git a/tests/ast_json_fixtures/shapes/f6d08167ba444358.json b/tests/ast_json_fixtures/shapes/f6d08167ba444358.json new file mode 100644 index 000000000000..58578e6468aa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6d08167ba444358.json @@ -0,0 +1,28 @@ +{ + "version": 2, + "ast": { + "type": "CreateIndexQuery", + "table": { + "type": "Identifier", + "name": "t_index_3146" + }, + "index_name": { + "type": "Identifier", + "name": "i4" + }, + "index_declaration": { + "type": "Index", + "name": "i4", + "expression": { + "type": "Identifier", + "name": "a" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f6d08167ba444358.sql b/tests/ast_json_fixtures/shapes/f6d08167ba444358.sql new file mode 100644 index 000000000000..0807de5cfa00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f6d08167ba444358.sql @@ -0,0 +1 @@ +CREATE INDEX i4 ON t_index_3146 a TYPE minmax diff --git a/tests/ast_json_fixtures/shapes/f709221ff65fdb47.json b/tests/ast_json_fixtures/shapes/f709221ff65fdb47.json new file mode 100644 index 000000000000..20611c7169e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f709221ff65fdb47.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "tab", + "like": "%INT%", + "case_insensitive_like": true + } +} diff --git a/tests/ast_json_fixtures/shapes/f709221ff65fdb47.sql b/tests/ast_json_fixtures/shapes/f709221ff65fdb47.sql new file mode 100644 index 000000000000..d0bd9ee44ea3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f709221ff65fdb47.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM tab ILIKE '%INT%' diff --git a/tests/ast_json_fixtures/shapes/f7104544cc810023.json b/tests/ast_json_fixtures/shapes/f7104544cc810023.json new file mode 100644 index 000000000000..f5eb004c56e6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7104544cc810023.json @@ -0,0 +1,52 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_02381" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f7104544cc810023.sql b/tests/ast_json_fixtures/shapes/f7104544cc810023.sql new file mode 100644 index 000000000000..d8a1474619ad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7104544cc810023.sql @@ -0,0 +1 @@ +select * from test_02381 where a = 10000 limit 1 diff --git a/tests/ast_json_fixtures/shapes/f726afb5b0d45c22.json b/tests/ast_json_fixtures/shapes/f726afb5b0d45c22.json new file mode 100644 index 000000000000..8e009fad98a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f726afb5b0d45c22.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "table": { + "type": "Identifier", + "name": "tmp2" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "n" + } + }, + "storage": { + "type": "Storage", + "primary_key": { + "type": "Identifier", + "name": "n" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f726afb5b0d45c22.sql b/tests/ast_json_fixtures/shapes/f726afb5b0d45c22.sql new file mode 100644 index 000000000000..748c53b448f2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f726afb5b0d45c22.sql @@ -0,0 +1 @@ +CREATE TEMPORARY TABLE tmp2 (n int, PRIMARY KEY (n)) diff --git a/tests/ast_json_fixtures/shapes/f73168684a28a721.json b/tests/ast_json_fixtures/shapes/f73168684a28a721.json new file mode 100644 index 000000000000..9b0ecb221d96 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f73168684a28a721.json @@ -0,0 +1,172 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "Nul\u0000able\u0000String)Nul\u0000\u0000ble(String)Nul\u0000able(String)Nul\u0000able(String)" + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "alias": "k", + "value_type": "Null", + "value": null + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Function", + "name": "materialize", + "arguments": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-9223372036854775808" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1023" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1023" + }, + "settings": { + "type": "Settings", + "changes": { + "max_bytes_before_external_sort": "1000000", + "max_bytes_ratio_before_external_sort": "0" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/f73168684a28a721.sql b/tests/ast_json_fixtures/shapes/f73168684a28a721.sql new file mode 100644 index 000000000000..411624464330 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f73168684a28a721.sql @@ -0,0 +1,21 @@ +SELECT + 'Nul\0able\0String)Nul\0\0ble(String)Nul\0able(String)Nul\0able(String)', + NULL AND 2, + '', + number, + NULL AS k +FROM +( + SELECT + materialize(NULL) OR materialize(-9223372036854775808), + number + FROM system.numbers + LIMIT 1000000 +) +ORDER BY + k ASC, + number ASC, + k ASC +LIMIT 1023, 1023 +SETTINGS max_bytes_before_external_sort = 1000000, max_bytes_ratio_before_external_sort = 0 +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/f739fae3d7098ee6.json b/tests/ast_json_fixtures/shapes/f739fae3d7098ee6.json new file mode 100644 index 000000000000..7fe044616e82 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f739fae3d7098ee6.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "id", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ], + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f739fae3d7098ee6.sql b/tests/ast_json_fixtures/shapes/f739fae3d7098ee6.sql new file mode 100644 index 000000000000..042ab0326b7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f739fae3d7098ee6.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1,2,3]) AS id WHERE id = 1 diff --git a/tests/ast_json_fixtures/shapes/f73a6cd545432acd.json b/tests/ast_json_fixtures/shapes/f73a6cd545432acd.json new file mode 100644 index 000000000000..9416a4e4a7bd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f73a6cd545432acd.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "or_replace": true, + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "rp", + "table": "t" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f73a6cd545432acd.sql b/tests/ast_json_fixtures/shapes/f73a6cd545432acd.sql new file mode 100644 index 000000000000..7bca74c5fac5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f73a6cd545432acd.sql @@ -0,0 +1 @@ +CREATE ROW POLICY OR REPLACE rp ON t FOR SELECT USING 0 TO ALL diff --git a/tests/ast_json_fixtures/shapes/f73e4fb9acab962d.json b/tests/ast_json_fixtures/shapes/f73e4fb9acab962d.json new file mode 100644 index 000000000000..9af111dae21b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f73e4fb9acab962d.json @@ -0,0 +1,119 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "alias": "minhash", + "name": "ngramMinHash", + "arguments": [ + { + "type": "Asterisk" + } + ] + }, + { + "type": "Function", + "alias": "z", + "name": "mortonEncode", + "arguments": [ + { + "type": "Function", + "name": "untuple", + "arguments": [ + { + "type": "Function", + "name": "ngramMinHash", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "z" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f73e4fb9acab962d.sql b/tests/ast_json_fixtures/shapes/f73e4fb9acab962d.sql new file mode 100644 index 000000000000..47496ba3c558 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f73e4fb9acab962d.sql @@ -0,0 +1,3 @@ +SELECT *, ngramMinHash(*) AS minhash, mortonEncode(untuple(ngramMinHash(*))) AS z +FROM (SELECT toString(number) FROM numbers(10)) +ORDER BY z LIMIT 100 diff --git a/tests/ast_json_fixtures/shapes/f745fbd1a71e71cd.json b/tests/ast_json_fixtures/shapes/f745fbd1a71e71cd.json new file mode 100644 index 000000000000..200610338ede --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f745fbd1a71e71cd.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q9_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "EXECUTION_TIME": "12000000000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f745fbd1a71e71cd.sql b/tests/ast_json_fixtures/shapes/f745fbd1a71e71cd.sql new file mode 100644 index 000000000000..a83161806356 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f745fbd1a71e71cd.sql @@ -0,0 +1 @@ +CREATE QUOTA q9_01297 FOR INTERVAL 1 MINUTE MAX execution_time = '12K' diff --git a/tests/ast_json_fixtures/shapes/f74a1adb82c4969e.json b/tests/ast_json_fixtures/shapes/f74a1adb82c4969e.json new file mode 100644 index 000000000000..df7bc44a8830 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f74a1adb82c4969e.json @@ -0,0 +1,126 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN PIPELINE", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Subquery", + "alias": "c0", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "tx", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c0", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "alias": "c1", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Identifier", + "name": "c1" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "ty", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "c0", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "alias": "c1", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } + } + } + ] + } + } + ] + }, + "format": "Null", + "output_settings": { + "type": "Settings", + "changes": { + "enable_analyzer": "1" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f74a1adb82c4969e.sql b/tests/ast_json_fixtures/shapes/f74a1adb82c4969e.sql new file mode 100644 index 000000000000..d819244a1ab8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f74a1adb82c4969e.sql @@ -0,0 +1 @@ +EXPLAIN PIPELINE SELECT (SELECT 1) AS c0 FROM (SELECT 1 AS c0, 1 AS c1) tx JOIN (SELECT 0 AS c0, 1 AS c1) ty USING (c0, c1) FORMAT Null SETTINGS enable_analyzer = 1 diff --git a/tests/ast_json_fixtures/shapes/f7687d63d12baa77.json b/tests/ast_json_fixtures/shapes/f7687d63d12baa77.json new file mode 100644 index 000000000000..15abac15cee2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7687d63d12baa77.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "pp", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "ParsedParams.Key2" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "ParsedParams.Key2", + "name_parts": ["ParsedParams", "Key2"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f7687d63d12baa77.sql b/tests/ast_json_fixtures/shapes/f7687d63d12baa77.sql new file mode 100644 index 000000000000..31cbf49bb327 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7687d63d12baa77.sql @@ -0,0 +1 @@ +WITH arrayJoin(`ParsedParams.Key2`) AS pp SELECT ParsedParams.Key2 AS x FROM test.hits ORDER BY x ASC LIMIT 2 diff --git a/tests/ast_json_fixtures/shapes/f7811854ac7bbd31.json b/tests/ast_json_fixtures/shapes/f7811854ac7bbd31.json new file mode 100644 index 000000000000..6bf91661d6d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7811854ac7bbd31.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q2_01297"], + "key_type": "USER_NAME" + } +} diff --git a/tests/ast_json_fixtures/shapes/f7811854ac7bbd31.sql b/tests/ast_json_fixtures/shapes/f7811854ac7bbd31.sql new file mode 100644 index 000000000000..94eab39272fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7811854ac7bbd31.sql @@ -0,0 +1 @@ +CREATE QUOTA q2_01297 KEY BY user_name diff --git a/tests/ast_json_fixtures/shapes/f79649e5584d5609.json b/tests/ast_json_fixtures/shapes/f79649e5584d5609.json new file mode 100644 index 000000000000..0f585bab8ff7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f79649e5584d5609.json @@ -0,0 +1,69 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "x", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Identifier", + "name": "system.one", + "name_parts": ["system", "one"] + } + ] + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "dummy" + }, + "direction": "ASC" + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f79649e5584d5609.sql b/tests/ast_json_fixtures/shapes/f79649e5584d5609.sql new file mode 100644 index 000000000000..9e7eb03be2d8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f79649e5584d5609.sql @@ -0,0 +1 @@ +SELECT 1 AS x FROM remote('127.0.0.{2,3}', system.one) ORDER BY dummy LIMIT 1 BY x diff --git a/tests/ast_json_fixtures/shapes/f7bfa4df4665a6a4.json b/tests/ast_json_fixtures/shapes/f7bfa4df4665a6a4.json new file mode 100644 index 000000000000..d0f620186f53 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7bfa4df4665a6a4.json @@ -0,0 +1,189 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "Carrier" + }, + { + "type": "Function", + "alias": "C1", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Identifier", + "name": "C3" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "C2", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Identifier", + "name": "C1" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "C3", + "name": "sum", + "arguments": [ + { + "type": "Function", + "name": "toFloat64", + "arguments": [ + { + "type": "Identifier", + "name": "C2" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "ITBL", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "Carrier", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "alias": "C1", + "name": "count", + "arguments": [ + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(Int32)" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "C2", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "C3", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "Carrier" + } + ] + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "Carrier" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000001" + }, + "settings": { + "type": "Settings", + "changes": { + "prefer_column_name_to_alias": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f7bfa4df4665a6a4.sql b/tests/ast_json_fixtures/shapes/f7bfa4df4665a6a4.sql new file mode 100644 index 000000000000..6fd6a3f8990c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7bfa4df4665a6a4.sql @@ -0,0 +1,18 @@ +SELECT + Carrier, + sum(toFloat64(C3)) AS C1, + sum(toFloat64(C1)) AS C2, + sum(toFloat64(C2)) AS C3 +FROM + ( + SELECT + 1 AS Carrier, + count(CAST(1, 'Nullable(Int32)')) AS C1, + max(number) AS C2, + min(number) AS C3 + FROM numbers(10) + GROUP BY Carrier + ) AS ITBL +GROUP BY Carrier +LIMIT 1000001 +SETTINGS prefer_column_name_to_alias=1 diff --git a/tests/ast_json_fixtures/shapes/f7cf914fa5563ae9.json b/tests/ast_json_fixtures/shapes/f7cf914fa5563ae9.json new file mode 100644 index 000000000000..341fe0fa5068 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7cf914fa5563ae9.json @@ -0,0 +1,1702 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Literal", + "alias": "b", + "value_type": "String", + "value": "abb" + }, + { + "type": "Literal", + "alias": "c", + "value_type": "String", + "value": "abc" + }, + { + "type": "Literal", + "alias": "d", + "value_type": "String", + "value": "abd" + }, + { + "type": "Function", + "alias": "bf", + "name": "toFixedString", + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "alias": "cf", + "name": "toFixedString", + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "alias": "df", + "name": "toFixedString", + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "bf" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "cf" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "c" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "d" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "bf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "cf" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "df" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "df" + }, + { + "type": "Identifier", + "name": "df" + } + ] + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/f7cf914fa5563ae9.sql b/tests/ast_json_fixtures/shapes/f7cf914fa5563ae9.sql new file mode 100644 index 000000000000..55f58beaa218 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7cf914fa5563ae9.sql @@ -0,0 +1,45 @@ +WITH 'abb' AS b, 'abc' AS c, 'abd' AS d, toFixedString(b, 5) AS bf, toFixedString(c, 5) AS cf, toFixedString(d, 5) AS df +SELECT + b = b, b > b, b < b, + b = c, b > c, b < c, + b = d, b > d, b < d, + b = bf, b > bf, b < bf, + b = cf, b > cf, b < cf, + b = df, b > df, b < df, + + c = b, c > b, c < b, + c = c, c > c, c < c, + c = d, c > d, c < d, + c = bf, c > bf, c < bf, + c = cf, c > cf, c < cf, + c = df, c > df, c < df, + + d = b, d > b, d < b, + d = c, d > c, d < c, + d = d, d > d, d < d, + d = bf, d > bf, d < bf, + d = cf, d > cf, d < cf, + d = df, d > df, d < df, + + bf = b, bf > b, bf < b, + bf = c, bf > c, bf < c, + bf = d, bf > d, bf < d, + bf = bf, bf > bf, bf < bf, + bf = cf, bf > cf, bf < cf, + bf = df, bf > df, bf < df, + + cf = b, cf > b, cf < b, + cf = c, cf > c, cf < c, + cf = d, cf > d, cf < d, + cf = bf, cf > bf, cf < bf, + cf = cf, cf > cf, cf < cf, + cf = df, cf > df, cf < df, + + df = b, df > b, df < b, + df = c, df > c, df < c, + df = d, df > d, df < d, + df = bf, df > bf, df < bf, + df = cf, df > cf, df < cf, + df = df, df > df, df < df + +FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/f7d5a21bc31c95a7.json b/tests/ast_json_fixtures/shapes/f7d5a21bc31c95a7.json new file mode 100644 index 000000000000..04de0942c55f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7d5a21bc31c95a7.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "toFixedString", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "!#$%&(*+,-.\/:<=>?@[^`{|}~" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "25" + } + ] + } + ] + } + ], + "format": "Markdown" + } +} diff --git a/tests/ast_json_fixtures/shapes/f7d5a21bc31c95a7.sql b/tests/ast_json_fixtures/shapes/f7d5a21bc31c95a7.sql new file mode 100644 index 000000000000..aff130121a76 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7d5a21bc31c95a7.sql @@ -0,0 +1 @@ +SELECT toFixedString('!#$%&(*+,-./:<=>?@[^`{|}~', 25) AS a FORMAT Markdown diff --git a/tests/ast_json_fixtures/shapes/f7fe99a04d1ab364.json b/tests/ast_json_fixtures/shapes/f7fe99a04d1ab364.json new file mode 100644 index 000000000000..1955be155097 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7fe99a04d1ab364.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "CheckQuery", + "table": { + "type": "Identifier", + "name": "mt_table" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "1" + } + }, + "partition": { + "type": "Partition", + "value": { + "type": "Literal", + "value_type": "UInt64", + "value": "201902" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f7fe99a04d1ab364.sql b/tests/ast_json_fixtures/shapes/f7fe99a04d1ab364.sql new file mode 100644 index 000000000000..a297e89aea18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f7fe99a04d1ab364.sql @@ -0,0 +1 @@ +CHECK TABLE mt_table PARTITION 201902 SETTINGS max_threads = 1 diff --git a/tests/ast_json_fixtures/shapes/f8278503c782804b.json b/tests/ast_json_fixtures/shapes/f8278503c782804b.json new file mode 100644 index 000000000000..d9032a45554c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8278503c782804b.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "t0.c2", + "name_parts": ["t0", "c2"] + }, + { + "type": "Identifier", + "name": "t0.c1", + "name_parts": ["t0", "c1"] + }, + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t0" + } + } + } + ] + }, + "prewhere": { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t0.c2", + "name_parts": ["t0", "c2"] + }, + { + "type": "Identifier", + "name": "t0.c1", + "name_parts": ["t0", "c1"] + } + ] + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "isNull", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "negate", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + }, + { + "type": "Identifier", + "name": "t0.c0", + "name_parts": ["t0", "c0"] + } + ] + } + ] + } + ] + }, + "direction": "ASC" + } + ] + } + ], + "format": "TabSeparatedWithNamesAndTypes" + } +} diff --git a/tests/ast_json_fixtures/shapes/f8278503c782804b.sql b/tests/ast_json_fixtures/shapes/f8278503c782804b.sql new file mode 100644 index 000000000000..d83fc86b5713 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8278503c782804b.sql @@ -0,0 +1 @@ +SELECT t0.c2, t0.c1, t0.c0 FROM t0 PREWHERE t0.c0 ORDER BY ((t0.c2)>=(t0.c1)), (((- (((t0.c0)>(t0.c0))))) IS NULL) FORMAT TabSeparatedWithNamesAndTypes diff --git a/tests/ast_json_fixtures/shapes/f83c15227ff7796b.json b/tests/ast_json_fixtures/shapes/f83c15227ff7796b.json new file mode 100644 index 000000000000..66a596ce0a74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f83c15227ff7796b.json @@ -0,0 +1,115 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "extract", + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "SeL.+?;" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "text_log", + "database": "system" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "event_date" + }, + { + "type": "Function", + "name": "yesterday", + "arguments": [] + } + ] + }, + { + "type": "Function", + "name": "like", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "message" + }, + { + "type": "Literal", + "value_type": "String", + "value": "%SeLeCt 'ab\n%" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "logger_name" + }, + { + "type": "Literal", + "value_type": "String", + "value": "executeQuery" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "event_time" + }, + "direction": "DESC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ], + "format": "TSVRaw" + } +} diff --git a/tests/ast_json_fixtures/shapes/f83c15227ff7796b.sql b/tests/ast_json_fixtures/shapes/f83c15227ff7796b.sql new file mode 100644 index 000000000000..cf97cf1f4029 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f83c15227ff7796b.sql @@ -0,0 +1 @@ +SELECT extract(message, 'SeL.+?;') FROM system.text_log WHERE event_date >= yesterday() AND message LIKE '%SeLeCt \'ab\n%' and logger_name = 'executeQuery' ORDER BY event_time DESC LIMIT 1 FORMAT TSVRaw diff --git a/tests/ast_json_fixtures/shapes/f861ce66a0b2530c.json b/tests/ast_json_fixtures/shapes/f861ce66a0b2530c.json new file mode 100644 index 000000000000..68559a5912bb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f861ce66a0b2530c.json @@ -0,0 +1,87 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "k", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "u" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t_sparse_full" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "u" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "k" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f861ce66a0b2530c.sql b/tests/ast_json_fixtures/shapes/f861ce66a0b2530c.sql new file mode 100644 index 000000000000..146dbbb6d7aa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f861ce66a0b2530c.sql @@ -0,0 +1 @@ +SELECT id % 3 AS k, sum(u) FROM t_sparse_full WHERE u != 0 GROUP BY k ORDER BY k diff --git a/tests/ast_json_fixtures/shapes/f878d09edfc79f32.json b/tests/ast_json_fixtures/shapes/f878d09edfc79f32.json new file mode 100644 index 000000000000..9dbfca9bfc8e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f878d09edfc79f32.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "table_for_rename" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "if_exists": true, + "column": { + "type": "Identifier", + "name": "value100" + }, + "rename_to": { + "type": "Identifier", + "name": "renamed_value100" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f878d09edfc79f32.sql b/tests/ast_json_fixtures/shapes/f878d09edfc79f32.sql new file mode 100644 index 000000000000..1f6d0437473e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f878d09edfc79f32.sql @@ -0,0 +1 @@ +ALTER TABLE table_for_rename RENAME COLUMN IF EXISTS value100 to renamed_value100 diff --git a/tests/ast_json_fixtures/shapes/f87beb8d5b763b41.json b/tests/ast_json_fixtures/shapes/f87beb8d5b763b41.json new file mode 100644 index 000000000000..d8a44151a818 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f87beb8d5b763b41.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "res", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleepEachRow", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "one", + "database": "system" + } + } + } + ] + } + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_execution_time": "2" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/f87beb8d5b763b41.sql b/tests/ast_json_fixtures/shapes/f87beb8d5b763b41.sql new file mode 100644 index 000000000000..bf6b8c2e2f11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f87beb8d5b763b41.sql @@ -0,0 +1,7 @@ +WITH ( + SELECT sleepEachRow(3) + ) AS res +SELECT * +FROM system.one +FORMAT Null +SETTINGS max_execution_time = 2 diff --git a/tests/ast_json_fixtures/shapes/f87f1a1fddf79a2e.json b/tests/ast_json_fixtures/shapes/f87f1a1fddf79a2e.json new file mode 100644 index 000000000000..510db9933236 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f87f1a1fddf79a2e.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02125_function", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/f87f1a1fddf79a2e.sql b/tests/ast_json_fixtures/shapes/f87f1a1fddf79a2e.sql new file mode 100644 index 000000000000..639998599311 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f87f1a1fddf79a2e.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02125_function diff --git a/tests/ast_json_fixtures/shapes/f888664ac0e89b4a.json b/tests/ast_json_fixtures/shapes/f888664ac0e89b4a.json new file mode 100644 index 000000000000..442aaadef976 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f888664ac0e89b4a.json @@ -0,0 +1,65 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "mt_00168_buffer" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Buffer", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "mt_00168" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "16" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10000000" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100000000" + } + ] + } + }, + "as_table": "mt_00168" + } +} diff --git a/tests/ast_json_fixtures/shapes/f888664ac0e89b4a.sql b/tests/ast_json_fixtures/shapes/f888664ac0e89b4a.sql new file mode 100644 index 000000000000..1ecea8e08c91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f888664ac0e89b4a.sql @@ -0,0 +1 @@ +CREATE TABLE mt_00168_buffer AS mt_00168 ENGINE = Buffer(currentDatabase(), mt_00168, 16, 10, 100, 10000, 1000000, 10000000, 100000000) diff --git a/tests/ast_json_fixtures/shapes/f8aed4e4cd7f344a.json b/tests/ast_json_fixtures/shapes/f8aed4e4cd7f344a.json new file mode 100644 index 000000000000..d598a0a45dd7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8aed4e4cd7f344a.json @@ -0,0 +1,120 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100000" + } + } + ] + } + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "having": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f8aed4e4cd7f344a.sql b/tests/ast_json_fixtures/shapes/f8aed4e4cd7f344a.sql new file mode 100644 index 000000000000..d0990ba81bfa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8aed4e4cd7f344a.sql @@ -0,0 +1 @@ +SELECT number, count() FROM (SELECT * FROM system.numbers LIMIT 100000) GROUP BY number WITH TOTALS HAVING number % 3 = 0 ORDER BY number LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/f8c14338e1f348fe.json b/tests/ast_json_fixtures/shapes/f8c14338e1f348fe.json new file mode 100644 index 000000000000..5490fd5da954 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8c14338e1f348fe.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "GrantQuery", + "roles": { + "type": "RolesOrUsersSet", + "names": ["test_role_01999"] + }, + "grantees": { + "type": "RolesOrUsersSet", + "names": ["test_user_01999"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f8c14338e1f348fe.sql b/tests/ast_json_fixtures/shapes/f8c14338e1f348fe.sql new file mode 100644 index 000000000000..88e0695e248a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8c14338e1f348fe.sql @@ -0,0 +1 @@ +GRANT test_role_01999 to test_user_01999 diff --git a/tests/ast_json_fixtures/shapes/f8ce69c23e368714.json b/tests/ast_json_fixtures/shapes/f8ce69c23e368714.json new file mode 100644 index 000000000000..e6c4a11b83f3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8ce69c23e368714.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "a" + }, + "format": "Values" + } +} diff --git a/tests/ast_json_fixtures/shapes/f8ce69c23e368714.sql b/tests/ast_json_fixtures/shapes/f8ce69c23e368714.sql new file mode 100644 index 000000000000..d65432bf9f7e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8ce69c23e368714.sql @@ -0,0 +1 @@ +INSERT INTO a VALUES (0) diff --git a/tests/ast_json_fixtures/shapes/f8dbd4dce4706a73.json b/tests/ast_json_fixtures/shapes/f8dbd4dce4706a73.json new file mode 100644 index 000000000000..701879e98842 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8dbd4dce4706a73.json @@ -0,0 +1,29 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "filter", + "table": "tbl" + } + ] + }, + "filters": [ + { + "filter_type": "SELECT_FILTER", + "condition": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ], + "roles": { + "type": "RolesOrUsersSet", + "all": true + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f8dbd4dce4706a73.sql b/tests/ast_json_fixtures/shapes/f8dbd4dce4706a73.sql new file mode 100644 index 000000000000..6fd9475cea4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8dbd4dce4706a73.sql @@ -0,0 +1 @@ +create row policy filter on tbl using 0 to all diff --git a/tests/ast_json_fixtures/shapes/f8e73c887835b6e5.json b/tests/ast_json_fixtures/shapes/f8e73c887835b6e5.json new file mode 100644 index 000000000000..aa7aef7dd929 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8e73c887835b6e5.json @@ -0,0 +1,53 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "sleep", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "1" + } + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/f8e73c887835b6e5.sql b/tests/ast_json_fixtures/shapes/f8e73c887835b6e5.sql new file mode 100644 index 000000000000..dae85bc8659a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8e73c887835b6e5.sql @@ -0,0 +1 @@ +SELECT sleep(3) from numbers(4) settings max_block_size= 1 format Null diff --git a/tests/ast_json_fixtures/shapes/f8ee2fed88457c16.json b/tests/ast_json_fixtures/shapes/f8ee2fed88457c16.json new file mode 100644 index 000000000000..75f0058ff789 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8ee2fed88457c16.json @@ -0,0 +1,328 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_cube": true, + "select": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "singleValueOrNull", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048577" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + } + ] + } + } + ] + } + } + } + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Function", + "name": "notIn", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "2147483647" + }, + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1024" + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "UInt64", + "value": "2147483648" + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + }, + { + "value_type": "Null", + "value": null + } + ] + }, + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1048576" + } + ] + } + } + } + ] + }, + "where": { + "type": "Literal", + "value_type": "Null", + "value": null + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "notIn", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + } + ] + } + } + ] + } + } + ] + } + ], + "group_by": [ + { + "type": "Literal", + "value_type": "Null", + "value": null + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f8ee2fed88457c16.sql b/tests/ast_json_fixtures/shapes/f8ee2fed88457c16.sql new file mode 100644 index 000000000000..3d4d80d0af88 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8ee2fed88457c16.sql @@ -0,0 +1,31 @@ +SELECT + 0.5 IN ( + SELECT singleValueOrNull(*) + FROM + ( + SELECT 1048577 + FROM numbers(0) + ) +WITH TOTALS + ), + NULL, + NULL NOT IN ( +SELECT + 2147483647, + 1024 IN ( + SELECT + [NULL, 2147483648, NULL, NULL], + number + FROM numbers(7, 100) + ), + [NULL, NULL, NULL, NULL, NULL], + number +FROM numbers(1048576) +WHERE NULL + ), + NULL NOT IN ( +SELECT number +FROM numbers(0) + ) +GROUP BY NULL +WITH CUBE diff --git a/tests/ast_json_fixtures/shapes/f8f33880e89200ea.json b/tests/ast_json_fixtures/shapes/f8f33880e89200ea.json new file mode 100644 index 000000000000..ae93474db5f1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8f33880e89200ea.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropFunctionQuery", + "function_name": "02148_test_function_nested", + "if_exists": true + } +} diff --git a/tests/ast_json_fixtures/shapes/f8f33880e89200ea.sql b/tests/ast_json_fixtures/shapes/f8f33880e89200ea.sql new file mode 100644 index 000000000000..3e0fbde39cdf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8f33880e89200ea.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS 02148_test_function_nested diff --git a/tests/ast_json_fixtures/shapes/f8f9da9c9e1bb1df.json b/tests/ast_json_fixtures/shapes/f8f9da9c9e1bb1df.json new file mode 100644 index 000000000000..a7e5eeb293e4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8f9da9c9e1bb1df.json @@ -0,0 +1,59 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t" + } + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "t" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "qualified_match_nullable_tuple_direct" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f8f9da9c9e1bb1df.sql b/tests/ast_json_fixtures/shapes/f8f9da9c9e1bb1df.sql new file mode 100644 index 000000000000..74e39dbfc9bf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f8f9da9c9e1bb1df.sql @@ -0,0 +1,6 @@ +SELECT + id, + t.*, + toTypeName(t) +FROM qualified_match_nullable_tuple_direct +ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/f90be84085e49257.json b/tests/ast_json_fixtures/shapes/f90be84085e49257.json new file mode 100644 index 000000000000..15c6ffe7b1cb --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f90be84085e49257.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table": { + "type": "Identifier", + "name": "test_00707" + }, + "format": "CSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/f90be84085e49257.sql b/tests/ast_json_fixtures/shapes/f90be84085e49257.sql new file mode 100644 index 000000000000..1ac862b58cdd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f90be84085e49257.sql @@ -0,0 +1,3 @@ +INSERT INTO test_00707 FORMAT CSV 123.456|789.012|345678|Hello + +SELECT * FROM test_00707 diff --git a/tests/ast_json_fixtures/shapes/f92e0567bb16648c.json b/tests/ast_json_fixtures/shapes/f92e0567bb16648c.json new file mode 100644 index 000000000000..0ee9fd299474 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f92e0567bb16648c.json @@ -0,0 +1,161 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "n", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "246" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Function", + "alias": "d", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toDate", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2000-01-01" + } + ] + }, + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "arr", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + }, + { + "type": "Function", + "alias": "s", + "name": "arrayStringConcat", + "arguments": [ + { + "type": "Function", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "reinterpretAsString", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "arr" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Identifier", + "name": "d" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + } + ], + "format": "JSONCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/f92e0567bb16648c.sql b/tests/ast_json_fixtures/shapes/f92e0567bb16648c.sql new file mode 100644 index 000000000000..a8b125390ffa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f92e0567bb16648c.sql @@ -0,0 +1 @@ +SELECT number * 246 + 10 AS n, toDate('2000-01-01') + n AS d, range(n) AS arr, arrayStringConcat(arrayMap(x -> reinterpretAsString(x), arr)) AS s, (n, d) AS tuple FROM system.numbers LIMIT 2 FORMAT JSONCompact diff --git a/tests/ast_json_fixtures/shapes/f9445fdada7ac0fc.json b/tests/ast_json_fixtures/shapes/f9445fdada7ac0fc.json new file mode 100644 index 000000000000..66af0fb7e6c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9445fdada7ac0fc.json @@ -0,0 +1,21 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["02294_profile1"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "timeout_before_checking_execution_speed", + "value": "3" + } + ] + }, + "to_roles": { + "type": "RolesOrUsersSet", + "names": ["default"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f9445fdada7ac0fc.sql b/tests/ast_json_fixtures/shapes/f9445fdada7ac0fc.sql new file mode 100644 index 000000000000..aec58ecd292f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9445fdada7ac0fc.sql @@ -0,0 +1 @@ +CREATE SETTINGS PROFILE 02294_profile1 SETTINGS timeout_before_checking_execution_speed = 3 TO default diff --git a/tests/ast_json_fixtures/shapes/f9820739278ee824.json b/tests/ast_json_fixtures/shapes/f9820739278ee824.json new file mode 100644 index 000000000000..d35e95e06718 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9820739278ee824.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "test_alter_atomic" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DELETE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c0" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + }, + { + "type": "AlterCommand", + "command_type": "RENAME_COLUMN", + "column": { + "type": "Identifier", + "name": "c0" + }, + "rename_to": { + "type": "Identifier", + "name": "c1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f9820739278ee824.sql b/tests/ast_json_fixtures/shapes/f9820739278ee824.sql new file mode 100644 index 000000000000..3fb3f61922e3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9820739278ee824.sql @@ -0,0 +1 @@ +ALTER TABLE test_alter_atomic DELETE WHERE c0 = 0, RENAME COLUMN c0 TO c1 diff --git a/tests/ast_json_fixtures/shapes/f9a72f75170f35c6.json b/tests/ast_json_fixtures/shapes/f9a72f75170f35c6.json new file mode 100644 index 000000000000..7258b623c458 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9a72f75170f35c6.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "hierarchy_flat_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "parent_id", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "hierarchical": true + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "hierarchy_source_table" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 1, + "max_sec": 1000 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f9a72f75170f35c6.sql b/tests/ast_json_fixtures/shapes/f9a72f75170f35c6.sql new file mode 100644 index 000000000000..7943c40acf67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9a72f75170f35c6.sql @@ -0,0 +1,9 @@ +CREATE DICTIONARY hierarchy_flat_dictionary +( + id UInt64, + parent_id UInt64 HIERARCHICAL +) +PRIMARY KEY id +SOURCE(CLICKHOUSE(TABLE 'hierarchy_source_table')) +LAYOUT(FLAT()) +LIFETIME(MIN 1 MAX 1000) diff --git a/tests/ast_json_fixtures/shapes/f9b53758fa20ec03.json b/tests/ast_json_fixtures/shapes/f9b53758fa20ec03.json new file mode 100644 index 000000000000..7c627bc57896 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9b53758fa20ec03.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dist_out" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_shard_localhost" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "data" + } + ] + } + }, + "as_table": "data" + } +} diff --git a/tests/ast_json_fixtures/shapes/f9b53758fa20ec03.sql b/tests/ast_json_fixtures/shapes/f9b53758fa20ec03.sql new file mode 100644 index 000000000000..1c2de1469128 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9b53758fa20ec03.sql @@ -0,0 +1 @@ +create table dist_out as data engine=Distributed(test_shard_localhost, currentDatabase(), data) diff --git a/tests/ast_json_fixtures/shapes/f9c61de30250e57b.json b/tests/ast_json_fixtures/shapes/f9c61de30250e57b.json new file mode 100644 index 000000000000..b529b7705048 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9c61de30250e57b.json @@ -0,0 +1,81 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Subquery", + "alias": "v", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "111111111111111111111111111111111111111" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt128" + } + ] + } + ] + } + ] + } + } + ], + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "v" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f9c61de30250e57b.sql b/tests/ast_json_fixtures/shapes/f9c61de30250e57b.sql new file mode 100644 index 000000000000..9dae0457f198 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9c61de30250e57b.sql @@ -0,0 +1 @@ +WITH (SELECT '111111111111111111111111111111111111111'::UInt128) AS v SELECT sum(x), max(v) FROM test diff --git a/tests/ast_json_fixtures/shapes/f9cdbd7c48c6054f.json b/tests/ast_json_fixtures/shapes/f9cdbd7c48c6054f.json new file mode 100644 index 000000000000..6ac0909e9df3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9cdbd7c48c6054f.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateRowPolicyQuery", + "names": { + "type": "RowPolicyNames", + "policies": [ + { + "short_name": "p4_01295", + "database": "db", + "table": "table" + } + ] + }, + "roles": { + "type": "RolesOrUsersSet", + "names": ["u1_01295"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f9cdbd7c48c6054f.sql b/tests/ast_json_fixtures/shapes/f9cdbd7c48c6054f.sql new file mode 100644 index 000000000000..2440d2f0d2ea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9cdbd7c48c6054f.sql @@ -0,0 +1 @@ +CREATE POLICY p4_01295 ON db.table TO u1_01295 diff --git a/tests/ast_json_fixtures/shapes/f9d549b7ed5d2f66.json b/tests/ast_json_fixtures/shapes/f9d549b7ed5d2f66.json new file mode 100644 index 000000000000..f30bdcb3b593 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9d549b7ed5d2f66.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "table_02184" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "partition_by": { + "type": "Identifier", + "name": "x" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f9d549b7ed5d2f66.sql b/tests/ast_json_fixtures/shapes/f9d549b7ed5d2f66.sql new file mode 100644 index 000000000000..5c8c06ead920 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9d549b7ed5d2f66.sql @@ -0,0 +1 @@ +CREATE TABLE table_02184 (x UInt8) PARTITION BY x diff --git a/tests/ast_json_fixtures/shapes/f9e78ad90f850f9d.json b/tests/ast_json_fixtures/shapes/f9e78ad90f850f9d.json new file mode 100644 index 000000000000..5d6d6e8acc39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9e78ad90f850f9d.json @@ -0,0 +1,203 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "c" + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table2" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "6" + } + ] + }, + { + "type": "Function", + "name": "less", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + } + ] + } + ] + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "c" + }, + "direction": "ASC" + } + ] + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/f9e78ad90f850f9d.sql b/tests/ast_json_fixtures/shapes/f9e78ad90f850f9d.sql new file mode 100644 index 000000000000..d3e7a77947c6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9e78ad90f850f9d.sql @@ -0,0 +1,8 @@ +SELECT * +FROM table1 +INNER JOIN table2 + ON (a = c) +WHERE (a > 0) AND (c > 0) + AND ( ((a > 5) AND (c < 10)) OR ((a > 6) AND (c < 11)) ) +ORDER BY a, c +FORMAT TSV diff --git a/tests/ast_json_fixtures/shapes/f9edc7222967ef12.json b/tests/ast_json_fixtures/shapes/f9edc7222967ef12.json new file mode 100644 index 000000000000..6be3c67e9eb8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9edc7222967ef12.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_large" + }, + "settings": { + "type": "Settings", + "changes": { + "mutations_sync": "2" + } + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DELETE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/f9edc7222967ef12.sql b/tests/ast_json_fixtures/shapes/f9edc7222967ef12.sql new file mode 100644 index 000000000000..1cb78c2829f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9edc7222967ef12.sql @@ -0,0 +1 @@ +ALTER TABLE t_large DELETE WHERE a=1 SETTINGS mutations_sync=2 diff --git a/tests/ast_json_fixtures/shapes/f9fd3b892a7cfa6d.json b/tests/ast_json_fixtures/shapes/f9fd3b892a7cfa6d.json new file mode 100644 index 000000000000..1294a79150d1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9fd3b892a7cfa6d.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "SetRoleQuery", + "kind": "SET_DEFAULT_ROLE", + "roles": { + "type": "RolesOrUsersSet", + "all": true + }, + "to_users": { + "type": "RolesOrUsersSet", + "names": ["u4_01292"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/f9fd3b892a7cfa6d.sql b/tests/ast_json_fixtures/shapes/f9fd3b892a7cfa6d.sql new file mode 100644 index 000000000000..717dd1ce6291 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/f9fd3b892a7cfa6d.sql @@ -0,0 +1 @@ +SET DEFAULT ROLE ALL TO u4_01292 diff --git a/tests/ast_json_fixtures/shapes/fa11181ea06058c8.json b/tests/ast_json_fixtures/shapes/fa11181ea06058c8.json new file mode 100644 index 000000000000..541d478f5f00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa11181ea06058c8.json @@ -0,0 +1,46 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "no cleanup 2" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "uid" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fa11181ea06058c8.sql b/tests/ast_json_fixtures/shapes/fa11181ea06058c8.sql new file mode 100644 index 000000000000..71fb8156c48f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa11181ea06058c8.sql @@ -0,0 +1 @@ +select 'no cleanup 2', * from test order by uid diff --git a/tests/ast_json_fixtures/shapes/fa144d8012504177.json b/tests/ast_json_fixtures/shapes/fa144d8012504177.json new file mode 100644 index 000000000000..9b6eb4e1baca --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa144d8012504177.json @@ -0,0 +1,125 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t1", + "name": "table1" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ALL", + "using": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t2", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Literal", + "value_type": "String", + "value": "0.10" + }, + { + "type": "Identifier", + "name": "c" + }, + { + "type": "Identifier", + "alias": "b", + "name": "d" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "table2" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "d" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t1.a", + "name_parts": ["t1", "a"] + }, + "direction": "ASC" + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_rows_in_join": "1" + } + }, + "format": "PrettyCompact" + } +} diff --git a/tests/ast_json_fixtures/shapes/fa144d8012504177.sql b/tests/ast_json_fixtures/shapes/fa144d8012504177.sql new file mode 100644 index 000000000000..3e26805a9dea --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa144d8012504177.sql @@ -0,0 +1 @@ +SELECT * FROM table1 AS t1 ALL LEFT JOIN (SELECT *, '0.10', c, d AS b FROM table2) AS t2 USING (a, b) ORDER BY d, t1.a ASC FORMAT PrettyCompact settings max_rows_in_join = 1 diff --git a/tests/ast_json_fixtures/shapes/fa15f34b8b1ad1e3.json b/tests/ast_json_fixtures/shapes/fa15f34b8b1ad1e3.json new file mode 100644 index 000000000000..1af8fd95c102 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa15f34b8b1ad1e3.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "dp" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Distributed", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "test_cluster_two_shards" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "d" + }, + { + "type": "Identifier", + "name": "i" + } + ] + } + }, + "as_table": "d" + } +} diff --git a/tests/ast_json_fixtures/shapes/fa15f34b8b1ad1e3.sql b/tests/ast_json_fixtures/shapes/fa15f34b8b1ad1e3.sql new file mode 100644 index 000000000000..cdee2e7a8254 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa15f34b8b1ad1e3.sql @@ -0,0 +1 @@ +create table dp as d Engine=Distributed(test_cluster_two_shards, currentDatabase(), d, i) diff --git a/tests/ast_json_fixtures/shapes/fa2e369e45ea3a82.json b/tests/ast_json_fixtures/shapes/fa2e369e45ea3a82.json new file mode 100644 index 000000000000..49a4ebe5b624 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa2e369e45ea3a82.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "alter": true, + "names": ["r2_01293"], + "new_name": "r2_01293_renamed" + } +} diff --git a/tests/ast_json_fixtures/shapes/fa2e369e45ea3a82.sql b/tests/ast_json_fixtures/shapes/fa2e369e45ea3a82.sql new file mode 100644 index 000000000000..8ac34bff90bf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa2e369e45ea3a82.sql @@ -0,0 +1 @@ +ALTER ROLE r2_01293 RENAME TO 'r2_01293_renamed' diff --git a/tests/ast_json_fixtures/shapes/fa67722ea7ce1eb3.json b/tests/ast_json_fixtures/shapes/fa67722ea7ce1eb3.json new file mode 100644 index 000000000000..103dc7220e71 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa67722ea7ce1eb3.json @@ -0,0 +1,164 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "reference_vec", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "toFloat32", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "dist", + "name": "round", + "arguments": [ + { + "type": "Function", + "name": "L2DistanceTransposed", + "arguments": [ + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Function", + "name": "tupleElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "vec" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Identifier", + "name": "reference_vec" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "qbit" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fa67722ea7ce1eb3.sql b/tests/ast_json_fixtures/shapes/fa67722ea7ce1eb3.sql new file mode 100644 index 000000000000..3a8c05b7f2fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa67722ea7ce1eb3.sql @@ -0,0 +1 @@ +WITH [toFloat32(0), 1, 2] AS reference_vec SELECT id, round(L2DistanceTransposed(vec.1, vec.2, vec.3, vec.4, 0, reference_vec), 5) AS dist FROM qbit ORDER BY id diff --git a/tests/ast_json_fixtures/shapes/fa7a64f8f3a7d385.json b/tests/ast_json_fixtures/shapes/fa7a64f8f3a7d385.json new file mode 100644 index 000000000000..a401d322a305 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa7a64f8f3a7d385.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test_01155_ordinary", + "from_table": "dict1", + "to_database": "test_01155_ordinary", + "to_table": "dict" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fa7a64f8f3a7d385.sql b/tests/ast_json_fixtures/shapes/fa7a64f8f3a7d385.sql new file mode 100644 index 000000000000..a650bca90424 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa7a64f8f3a7d385.sql @@ -0,0 +1 @@ +RENAME TABLE test_01155_ordinary.dict1 TO test_01155_ordinary.dict diff --git a/tests/ast_json_fixtures/shapes/fa7be43d7b8445a7.json b/tests/ast_json_fixtures/shapes/fa7be43d7b8445a7.json new file mode 100644 index 000000000000..6fe67c64b30e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa7be43d7b8445a7.json @@ -0,0 +1,84 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "j", + "name": "sum", + "arguments": [ + { + "type": "Function", + "alias": "i", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "uint64" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "i" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "j" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fa7be43d7b8445a7.sql b/tests/ast_json_fixtures/shapes/fa7be43d7b8445a7.sql new file mode 100644 index 000000000000..8d3df7259c2a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa7be43d7b8445a7.sql @@ -0,0 +1 @@ +SELECT sum(1 + uint64 AS i) j from test_table where i > 0 having j > 0 diff --git a/tests/ast_json_fixtures/shapes/fa83fde1ad6e8153.json b/tests/ast_json_fixtures/shapes/fa83fde1ad6e8153.json new file mode 100644 index 000000000000..6d2976650d7b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa83fde1ad6e8153.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Literal", + "alias": "k", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Function", + "alias": "c", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "hits", + "database": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "CounterID" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1704509" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "k" + } + ], + "settings": { + "type": "Settings", + "changes": { + "totals_mode": "after_having_auto", + "max_rows_to_group_by": "100000", + "group_by_overflow_mode": "any" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fa83fde1ad6e8153.sql b/tests/ast_json_fixtures/shapes/fa83fde1ad6e8153.sql new file mode 100644 index 000000000000..b75c69d636a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa83fde1ad6e8153.sql @@ -0,0 +1 @@ +SELECT 1 AS k, count() AS c FROM test.hits WHERE CounterID = 1704509 GROUP BY k WITH TOTALS SETTINGS totals_mode = 'after_having_auto', max_rows_to_group_by = 100000, group_by_overflow_mode = 'any' diff --git a/tests/ast_json_fixtures/shapes/fa96e52d0c51bcc0.json b/tests/ast_json_fixtures/shapes/fa96e52d0c51bcc0.json new file mode 100644 index 000000000000..48ba3cdacd7c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa96e52d0c51bcc0.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "CreateNamedCollectionQuery", + "collection_name": "02918_json_fuzzer", + "changes": { + "json_str": { + "value_type": "String", + "value": "{}" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fa96e52d0c51bcc0.sql b/tests/ast_json_fixtures/shapes/fa96e52d0c51bcc0.sql new file mode 100644 index 000000000000..4eac36c12386 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa96e52d0c51bcc0.sql @@ -0,0 +1 @@ +CREATE NAMED COLLECTION 02918_json_fuzzer AS json_str='{}' diff --git a/tests/ast_json_fixtures/shapes/fa9c230e5ecb297d.json b/tests/ast_json_fixtures/shapes/fa9c230e5ecb297d.json new file mode 100644 index 000000000000..afec02920cad --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa9c230e5ecb297d.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q7_01297"], + "limits": [ + { + "duration_sec": "60", + "max": { + "QUERY_SELECTS": "12000000000000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fa9c230e5ecb297d.sql b/tests/ast_json_fixtures/shapes/fa9c230e5ecb297d.sql new file mode 100644 index 000000000000..518f1be337ac --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fa9c230e5ecb297d.sql @@ -0,0 +1 @@ +CREATE QUOTA q7_01297 FOR INTERVAL 1 MINUTE MAX query_selects = '12T' diff --git a/tests/ast_json_fixtures/shapes/fad2a0633a6ac0c6.json b/tests/ast_json_fixtures/shapes/fad2a0633a6ac0c6.json new file mode 100644 index 000000000000..e9e1296d6223 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fad2a0633a6ac0c6.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "0", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Literal", + "alias": "18", + "value_type": "UInt64", + "value": "18" + }, + { + "type": "Identifier", + "alias": "k", + "name": "__table1.k", + "name_parts": ["__table1", "k"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "__table1", + "name": "test__fuzz_2_dist" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "11" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Nullable(UInt8)" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "__table1.k", + "name_parts": ["__table1", "k"] + }, + "direction": "DESC", + "nulls_first": false + } + ], + "offset": { + "type": "Literal", + "value_type": "Float64", + "value": 0.9999 + }, + "limit": { + "type": "Function", + "name": "_CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + { + "type": "Literal", + "value_type": "String", + "value": "UInt64" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fad2a0633a6ac0c6.sql b/tests/ast_json_fixtures/shapes/fad2a0633a6ac0c6.sql new file mode 100644 index 000000000000..47493dd1f903 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fad2a0633a6ac0c6.sql @@ -0,0 +1,5 @@ +SELECT 0 AS `0`, 18 AS `18`, __table1.k AS k +FROM test__fuzz_2_dist AS __table1 +PREWHERE _CAST(11, 'Nullable(UInt8)') +ORDER BY __table1.k DESC NULLS LAST +LIMIT 0.9999, _CAST(100, 'UInt64') diff --git a/tests/ast_json_fixtures/shapes/faeb39ec0428bdf1.json b/tests/ast_json_fixtures/shapes/faeb39ec0428bdf1.json new file mode 100644 index 000000000000..61f827370cef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/faeb39ec0428bdf1.json @@ -0,0 +1,160 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Function", + "alias": "zero_as_start_val", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + { + "type": "Identifier", + "name": "c1" + } + ] + }, + { + "type": "Function", + "alias": "one_as_start_val", + "name": "range", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Identifier", + "name": "c1" + } + ] + }, + { + "type": "Function", + "alias": "no_start_val", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "c1" + } + ] + }, + { + "type": "Function", + "alias": "val_as_start", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ] + }, + { + "type": "Function", + "alias": "complex_start_step", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "c1" + }, + { + "type": "Identifier", + "name": "c1" + } + ] + }, + { + "type": "Identifier", + "name": "c1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "values", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "4" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + } + } + } + ] + } + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/faeb39ec0428bdf1.sql b/tests/ast_json_fixtures/shapes/faeb39ec0428bdf1.sql new file mode 100644 index 000000000000..c369eb66e7b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/faeb39ec0428bdf1.sql @@ -0,0 +1,9 @@ +SELECT + c1, + range(0, c1) AS zero_as_start_val, + range(1, c1) AS one_as_start_val, + range(c1) AS no_start_val, + range(c1, c1 * 2) AS val_as_start, + range(c1, c1 * c1, c1) AS complex_start_step +FROM values(1, 2, 3, 4, 5) +FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/faf8ca7ba4f6992c.json b/tests/ast_json_fixtures/shapes/faf8ca7ba4f6992c.json new file mode 100644 index 000000000000..19e2203a171f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/faf8ca7ba4f6992c.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "d", + "data_type": { + "type": "DataType", + "name": "Dynamic" + } + } + ], + "indices": [ + { + "type": "Index", + "name": "idx", + "expression": { + "type": "Identifier", + "name": "d" + }, + "index_type": { + "type": "Function", + "name": "minmax", + "arguments": [] + }, + "granularity": 1 + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/faf8ca7ba4f6992c.sql b/tests/ast_json_fixtures/shapes/faf8ca7ba4f6992c.sql new file mode 100644 index 000000000000..f550dd5359a0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/faf8ca7ba4f6992c.sql @@ -0,0 +1 @@ +create table test (d Dynamic, index idx d type minmax) diff --git a/tests/ast_json_fixtures/shapes/fb076eb751995f79.json b/tests/ast_json_fixtures/shapes/fb076eb751995f79.json new file mode 100644 index 000000000000..3a436f7afe18 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb076eb751995f79.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + ], + "format": "PrettyCompactMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/fb076eb751995f79.sql b/tests/ast_json_fixtures/shapes/fb076eb751995f79.sql new file mode 100644 index 000000000000..b3c195eaad4d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb076eb751995f79.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a FORMAT PrettyCompactMonoBlock diff --git a/tests/ast_json_fixtures/shapes/fb10852c64c91d92.json b/tests/ast_json_fixtures/shapes/fb10852c64c91d92.json new file mode 100644 index 000000000000..30160ac3a5a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb10852c64c91d92.json @@ -0,0 +1,11 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "x_as" + }, + "as_table": "x" + } +} diff --git a/tests/ast_json_fixtures/shapes/fb10852c64c91d92.sql b/tests/ast_json_fixtures/shapes/fb10852c64c91d92.sql new file mode 100644 index 000000000000..8aa1b2ba3b5d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb10852c64c91d92.sql @@ -0,0 +1 @@ +CREATE TABLE x_as AS x diff --git a/tests/ast_json_fixtures/shapes/fb1743cccc1bb450.json b/tests/ast_json_fixtures/shapes/fb1743cccc1bb450.json new file mode 100644 index 000000000000..817e22ac71c0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb1743cccc1bb450.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateRoleQuery", + "names": ["r4_01293"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "max_memory_usage", + "min_value": "5000000" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fb1743cccc1bb450.sql b/tests/ast_json_fixtures/shapes/fb1743cccc1bb450.sql new file mode 100644 index 000000000000..04e28b99e70e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb1743cccc1bb450.sql @@ -0,0 +1 @@ +CREATE ROLE r4_01293 SETTINGS max_memory_usage MIN=5000000 diff --git a/tests/ast_json_fixtures/shapes/fb1af98610ec0c02.json b/tests/ast_json_fixtures/shapes/fb1af98610ec0c02.json new file mode 100644 index 000000000000..bb46a2c250c5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb1af98610ec0c02.json @@ -0,0 +1,72 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "hierarchical_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "parent_id", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "hierarchical": true + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "name", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "hierarchy_source" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 0 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "hashed", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fb1af98610ec0c02.sql b/tests/ast_json_fixtures/shapes/fb1af98610ec0c02.sql new file mode 100644 index 000000000000..510efd4c84d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb1af98610ec0c02.sql @@ -0,0 +1,10 @@ +CREATE DICTIONARY hierarchical_dictionary +( + id UInt64, + parent_id UInt64 HIERARCHICAL, + name String +) +PRIMARY KEY id +SOURCE(CLICKHOUSE(TABLE 'hierarchy_source')) +LAYOUT(HASHED()) +LIFETIME(0) diff --git a/tests/ast_json_fixtures/shapes/fb2382c26aa35797.json b/tests/ast_json_fixtures/shapes/fb2382c26aa35797.json new file mode 100644 index 000000000000..84b0b04c42e2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb2382c26aa35797.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables", + "databases": true, + "like": "%01470" + } +} diff --git a/tests/ast_json_fixtures/shapes/fb2382c26aa35797.sql b/tests/ast_json_fixtures/shapes/fb2382c26aa35797.sql new file mode 100644 index 000000000000..e0dfeedf3ebd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb2382c26aa35797.sql @@ -0,0 +1 @@ +show databases like '%01470' diff --git a/tests/ast_json_fixtures/shapes/fb257428dec85f79.json b/tests/ast_json_fixtures/shapes/fb257428dec85f79.json new file mode 100644 index 000000000000..6ab20d12cd4a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb257428dec85f79.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "if_exists": true, + "names": ["u1_01292", "u2_01292", "u3_01292", "u4_01292", "u5_01292", "u6_01292", "u7_01292", "u8_01292", "u9_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/fb257428dec85f79.sql b/tests/ast_json_fixtures/shapes/fb257428dec85f79.sql new file mode 100644 index 000000000000..ef3fa1c8b8cc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb257428dec85f79.sql @@ -0,0 +1 @@ +DROP USER IF EXISTS u1_01292, u2_01292, u3_01292, u4_01292, u5_01292, u6_01292, u7_01292, u8_01292, u9_01292 diff --git a/tests/ast_json_fixtures/shapes/fb292b1918a9e014.json b/tests/ast_json_fixtures/shapes/fb292b1918a9e014.json new file mode 100644 index 000000000000..e3d77898ab1f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb292b1918a9e014.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "ROLE", + "names": ["r7_01293"] + } +} diff --git a/tests/ast_json_fixtures/shapes/fb292b1918a9e014.sql b/tests/ast_json_fixtures/shapes/fb292b1918a9e014.sql new file mode 100644 index 000000000000..a2d27ff67393 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb292b1918a9e014.sql @@ -0,0 +1 @@ +SHOW CREATE ROLE r7_01293 diff --git a/tests/ast_json_fixtures/shapes/fb2d3bb6983b9940.json b/tests/ast_json_fixtures/shapes/fb2d3bb6983b9940.json new file mode 100644 index 000000000000..4c2e2fa5fb0e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb2d3bb6983b9940.json @@ -0,0 +1,62 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "a" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.4" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "02863_delayed_source" + } + ] + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "extremes": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fb2d3bb6983b9940.sql b/tests/ast_json_fixtures/shapes/fb2d3bb6983b9940.sql new file mode 100644 index 000000000000..92059b2a1b1c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb2d3bb6983b9940.sql @@ -0,0 +1 @@ +SELECT sum(a) FROM remote('127.0.0.4', currentDatabase(), '02863_delayed_source') WITH TOTALS SETTINGS extremes = 1 diff --git a/tests/ast_json_fixtures/shapes/fb2e7aa257010315.json b/tests/ast_json_fixtures/shapes/fb2e7aa257010315.json new file mode 100644 index 000000000000..41148e24e006 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb2e7aa257010315.json @@ -0,0 +1,133 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "subquery", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [] + } + ] + } + ] + } + } + } + ], + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "t" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "t", + "name": "02834_t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "arrayExists", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "t.arr", + "name_parts": ["t", "arr"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "subquery" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "t.id", + "name_parts": ["t", "id"] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fb2e7aa257010315.sql b/tests/ast_json_fixtures/shapes/fb2e7aa257010315.sql new file mode 100644 index 000000000000..c8b9b17fd472 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb2e7aa257010315.sql @@ -0,0 +1 @@ +WITH subquery AS (SELECT []) SELECT t.* FROM 02834_t AS t JOIN subquery ON arrayExists(x -> x = 1, t.arr) ORDER BY t.id diff --git a/tests/ast_json_fixtures/shapes/fb31d1132b404417.json b/tests/ast_json_fixtures/shapes/fb31d1132b404417.json new file mode 100644 index 000000000000..721dcfa7585a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb31d1132b404417.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowCreateAccessEntityQuery", + "entity_type": "QUOTA", + "names": ["q4_01297"] + } +} diff --git a/tests/ast_json_fixtures/shapes/fb31d1132b404417.sql b/tests/ast_json_fixtures/shapes/fb31d1132b404417.sql new file mode 100644 index 000000000000..01fbdfc83eaf --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb31d1132b404417.sql @@ -0,0 +1 @@ +SHOW CREATE QUOTA q4_01297 diff --git a/tests/ast_json_fixtures/shapes/fb3c5b0eebe79fbe.json b/tests/ast_json_fixtures/shapes/fb3c5b0eebe79fbe.json new file mode 100644 index 000000000000..15171fc58ffc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb3c5b0eebe79fbe.json @@ -0,0 +1,157 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a2" + }, + { + "type": "Identifier", + "name": "b2" + }, + { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a3" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + ] + }, + { + "type": "Identifier", + "name": "b3" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab2" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "LEFT", + "strictness": "ANY", + "on": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a2" + }, + { + "type": "Identifier", + "name": "a3" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b2" + }, + { + "type": "Identifier", + "name": "b3" + } + ] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tab3" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a2" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b2" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "b3" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fb3c5b0eebe79fbe.sql b/tests/ast_json_fixtures/shapes/fb3c5b0eebe79fbe.sql new file mode 100644 index 000000000000..f43a7b881e14 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb3c5b0eebe79fbe.sql @@ -0,0 +1 @@ +select a2, b2, a3 == 5 OR a3 == 100, b3 from tab2 any left join tab3 on a2 = a3 or b2 = b3 ORDER BY a2, b2, b3 diff --git a/tests/ast_json_fixtures/shapes/fb420d758b1bd6b6.json b/tests/ast_json_fixtures/shapes/fb420d758b1bd6b6.json new file mode 100644 index 000000000000..3e75e9b1be97 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb420d758b1bd6b6.json @@ -0,0 +1,106 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "users", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "WithElement", + "name": "t", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "users" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "users" + } + } + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/fb420d758b1bd6b6.sql b/tests/ast_json_fixtures/shapes/fb420d758b1bd6b6.sql new file mode 100644 index 000000000000..79ae60754426 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb420d758b1bd6b6.sql @@ -0,0 +1,10 @@ +WITH + users AS ( + WITH t as ( + SELECT * FROM users + ) + SELECT * FROM t + ) +SELECT * +FROM users +FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/fb42464b33d752e0.json b/tests/ast_json_fixtures/shapes/fb42464b33d752e0.json new file mode 100644 index 000000000000..cbb8281dce29 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb42464b33d752e0.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_lwd_mutations" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "DELETE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "6" + } + ] + } + }, + { + "type": "AlterCommand", + "command_type": "UPDATE", + "predicate": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "7" + } + ] + }, + "assignments": [ + { + "type": "Assignment", + "column": "_row_exists", + "expression": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fb42464b33d752e0.sql b/tests/ast_json_fixtures/shapes/fb42464b33d752e0.sql new file mode 100644 index 000000000000..74408cc80e4c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb42464b33d752e0.sql @@ -0,0 +1 @@ +ALTER TABLE t_lwd_mutations DELETE WHERE id % 10 = 6, UPDATE _row_exists = 0 WHERE id % 10 = 7 diff --git a/tests/ast_json_fixtures/shapes/fb4d7d6929f0fa73.json b/tests/ast_json_fixtures/shapes/fb4d7d6929f0fa73.json new file mode 100644 index 000000000000..dfe5dd3548b2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb4d7d6929f0fa73.json @@ -0,0 +1,49 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "union_mode": "UNION_DISTINCT", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fb4d7d6929f0fa73.sql b/tests/ast_json_fixtures/shapes/fb4d7d6929f0fa73.sql new file mode 100644 index 000000000000..b9387b3196f7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb4d7d6929f0fa73.sql @@ -0,0 +1 @@ +SELECT 1 UNION SELECT 1 UNION SELECT 1 UNION DISTINCT SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/fb59951370d7dc01.json b/tests/ast_json_fixtures/shapes/fb59951370d7dc01.json new file mode 100644 index 000000000000..a3d848ce33d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb59951370d7dc01.json @@ -0,0 +1,82 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "id_with", + "name": "toUInt64", + "arguments": [ + { + "type": "Identifier", + "name": "id" + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "day" + }, + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Identifier", + "name": "id_with" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day" + }, + { + "type": "Literal", + "value_type": "String", + "value": "2023-01-01" + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "day" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fb59951370d7dc01.sql b/tests/ast_json_fixtures/shapes/fb59951370d7dc01.sql new file mode 100644 index 000000000000..8da2b5fa6a55 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb59951370d7dc01.sql @@ -0,0 +1 @@ +with toUInt64(id) as id_with select day, count(id_with) from test where day >= '2023-01-01' group by day limit 1000 diff --git a/tests/ast_json_fixtures/shapes/fb5b9f52b1386e14.json b/tests/ast_json_fixtures/shapes/fb5b9f52b1386e14.json new file mode 100644 index 000000000000..544b35efa799 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb5b9f52b1386e14.json @@ -0,0 +1,170 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Identifier", + "name": "t.name", + "name_parts": ["t", "name"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "t", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "name" + }, + { + "type": "Identifier", + "alias": "x", + "name": "database" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "tables", + "database": "system" + } + } + } + ] + } + } + ] + } + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "using": [ + { + "type": "Identifier", + "name": "x" + } + ] + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "db", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "x", + "name": "name" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "databases", + "database": "system" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "String", + "value": "system" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "t.name", + "name_parts": ["t", "name"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "one" + } + ] + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "join_default_strictness": "ALL" + } + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/fb5b9f52b1386e14.sql b/tests/ast_json_fixtures/shapes/fb5b9f52b1386e14.sql new file mode 100644 index 000000000000..86046f07bdf6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb5b9f52b1386e14.sql @@ -0,0 +1,6 @@ +SELECT x, t.name + FROM (SELECT name, database AS x FROM system.tables) AS t + JOIN (SELECT name AS x FROM system.databases) AS db USING x + WHERE x = 'system' AND t.name = 'one' + SETTINGS join_default_strictness = 'ALL' + FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/fb70fbb32caa86e4.json b/tests/ast_json_fixtures/shapes/fb70fbb32caa86e4.json new file mode 100644 index 000000000000..7b32c811e741 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb70fbb32caa86e4.json @@ -0,0 +1,66 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a" + }, + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "Tuple", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "String", + "value": "a" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Literal", + "value_type": "Float64", + "value": null + } + ] + } + ], + "format": "JSONStrings" + } +} diff --git a/tests/ast_json_fixtures/shapes/fb70fbb32caa86e4.sql b/tests/ast_json_fixtures/shapes/fb70fbb32caa86e4.sql new file mode 100644 index 000000000000..1d88dd962089 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb70fbb32caa86e4.sql @@ -0,0 +1,8 @@ +SELECT + 1, + 'a', + [1, 2, 3], + (1, 'a'), + null, + nan +FORMAT JSONStrings diff --git a/tests/ast_json_fixtures/shapes/fb77f6dc6682fcf7.json b/tests/ast_json_fixtures/shapes/fb77f6dc6682fcf7.json new file mode 100644 index 000000000000..ac172c3328a3 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb77f6dc6682fcf7.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettyNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/fb77f6dc6682fcf7.sql b/tests/ast_json_fixtures/shapes/fb77f6dc6682fcf7.sql new file mode 100644 index 000000000000..fd0c184036d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb77f6dc6682fcf7.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettyNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/fb858f9897ac6d17.json b/tests/ast_json_fixtures/shapes/fb858f9897ac6d17.json new file mode 100644 index 000000000000..534f4f8574df --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb858f9897ac6d17.json @@ -0,0 +1,18 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u4_01292" + } + ] + }, + "hosts": { + "names": ["myhost.com"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fb858f9897ac6d17.sql b/tests/ast_json_fixtures/shapes/fb858f9897ac6d17.sql new file mode 100644 index 000000000000..2cabbf8cf3d5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb858f9897ac6d17.sql @@ -0,0 +1 @@ +CREATE USER u4_01292 HOST NAME 'myhost.com' diff --git a/tests/ast_json_fixtures/shapes/fb92beef7a37f475.json b/tests/ast_json_fixtures/shapes/fb92beef7a37f475.json new file mode 100644 index 000000000000..7f1718b2d942 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb92beef7a37f475.json @@ -0,0 +1,117 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "file", + "arguments": [ + { + "type": "Function", + "name": "concat", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "database", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "_test.csv" + } + ] + }, + { + "type": "Identifier", + "name": "CSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "a Int, b Int DEFAULT 77" + } + ] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "if", + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Literal", + "value_type": "Null", + "value": null + }, + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + } + } + ] + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fb92beef7a37f475.sql b/tests/ast_json_fixtures/shapes/fb92beef7a37f475.sql new file mode 100644 index 000000000000..9aa59e506806 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fb92beef7a37f475.sql @@ -0,0 +1 @@ +INSERT INTO TABLE FUNCTION file(database() || '_test.csv', CSV, 'a Int, b Int DEFAULT 77') SELECT number, if(number%2=1, NULL, number) FROM numbers(3) diff --git a/tests/ast_json_fixtures/shapes/fba461f55e7404e0.json b/tests/ast_json_fixtures/shapes/fba461f55e7404e0.json new file mode 100644 index 000000000000..b38f95df3180 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fba461f55e7404e0.json @@ -0,0 +1,94 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "uniqExact", + "arguments": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 10000000 + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "CAST", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "String" + } + ] + } + ] + } + ], + "settings": { + "type": "Settings", + "changes": { + "max_bytes_ratio_before_external_group_by": "1" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/fba461f55e7404e0.sql b/tests/ast_json_fixtures/shapes/fba461f55e7404e0.sql new file mode 100644 index 000000000000..07bd8e988199 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fba461f55e7404e0.sql @@ -0,0 +1 @@ +SELECT uniqExact(number::String) FROM numbers(10e6) GROUP BY (number%100)::String FORMAT Null SETTINGS max_bytes_ratio_before_external_group_by=1 diff --git a/tests/ast_json_fixtures/shapes/fba4d1d24663acbf.json b/tests/ast_json_fixtures/shapes/fba4d1d24663acbf.json new file mode 100644 index 000000000000..1bd955ca416a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fba4d1d24663acbf.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "_table" + }, + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "m3" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fba4d1d24663acbf.sql b/tests/ast_json_fixtures/shapes/fba4d1d24663acbf.sql new file mode 100644 index 000000000000..43cd5cdc023b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fba4d1d24663acbf.sql @@ -0,0 +1 @@ +SELECT _table, * FROM m3 ORDER BY key ASC diff --git a/tests/ast_json_fixtures/shapes/fbb7ea802cf960eb.json b/tests/ast_json_fixtures/shapes/fbb7ea802cf960eb.json new file mode 100644 index 000000000000..ea02f66ef774 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fbb7ea802cf960eb.json @@ -0,0 +1,104 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "json.k1.:`Array(JSON)`", + "name_parts": ["json", "k1", ":`Array(JSON)`"] + }, + { + "type": "Identifier", + "name": "json.k1.:`Array(JSON)`.k1_1.:`Array(JSON)`", + "name_parts": ["json", "k1", ":`Array(JSON)`", "k1_1", ":`Array(JSON)`"] + }, + { + "type": "Identifier", + "name": "json.k1.:`Array(JSON)`.k1_1.:`Array(JSON)`.k1_1_1", + "name_parts": ["json", "k1", ":`Array(JSON)`", "k1_1", ":`Array(JSON)`", "k1_1_1"] + }, + { + "type": "Identifier", + "name": "json.k1.:`Array(JSON)`.k1_2.:`Array(JSON)`", + "name_parts": ["json", "k1", ":`Array(JSON)`", "k1_2", ":`Array(JSON)`"] + }, + { + "type": "Identifier", + "name": "json.k1.:`Array(JSON)`.k1_2.:`Array(JSON)`.k1_2_1", + "name_parts": ["json", "k1", ":`Array(JSON)`", "k1_2", ":`Array(JSON)`", "k1_2_1"] + }, + { + "type": "Identifier", + "name": "json.k2.:`Array(JSON)`", + "name_parts": ["json", "k2", ":`Array(JSON)`"] + }, + { + "type": "Identifier", + "name": "json.k2.:`Array(JSON)`.k2_1.:`Array(JSON)`", + "name_parts": ["json", "k2", ":`Array(JSON)`", "k2_1", ":`Array(JSON)`"] + }, + { + "type": "Identifier", + "name": "json.k2.:`Array(JSON)`.k2_1.:`Array(JSON)`.k2_1_1", + "name_parts": ["json", "k2", ":`Array(JSON)`", "k2_1", ":`Array(JSON)`", "k2_1_1"] + }, + { + "type": "Identifier", + "name": "json.k2.:`Array(JSON)`.k2_2.:`Array(JSON)`", + "name_parts": ["json", "k2", ":`Array(JSON)`", "k2_2", ":`Array(JSON)`"] + }, + { + "type": "Identifier", + "name": "json.k2.:`Array(JSON)`.k2_2.:`Array(JSON)`.k2_2_1", + "name_parts": ["json", "k2", ":`Array(JSON)`", "k2_2", ":`Array(JSON)`", "k2_2_1"] + }, + { + "type": "Identifier", + "name": "json.k9.:`Array(JSON)`", + "name_parts": ["json", "k9", ":`Array(JSON)`"] + }, + { + "type": "Identifier", + "name": "json.k9.:`Array(JSON)`.k9_1.:`Array(JSON)`", + "name_parts": ["json", "k9", ":`Array(JSON)`", "k9_1", ":`Array(JSON)`"] + }, + { + "type": "Identifier", + "name": "json.k9.:`Array(JSON)`.k9_1.:`Array(JSON)`.k9_1_1", + "name_parts": ["json", "k9", ":`Array(JSON)`", "k9_1", ":`Array(JSON)`", "k9_1_1"] + }, + { + "type": "Identifier", + "name": "json.k9.:`Array(JSON)`.k9_2.:`Array(JSON)`", + "name_parts": ["json", "k9", ":`Array(JSON)`", "k9_2", ":`Array(JSON)`"] + }, + { + "type": "Identifier", + "name": "json.k9.:`Array(JSON)`.k9_2.:`Array(JSON)`.k9_2_1", + "name_parts": ["json", "k9", ":`Array(JSON)`", "k9_2", ":`Array(JSON)`", "k9_2_1"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + } + } + ], + "format": "JSONColumns" + } +} diff --git a/tests/ast_json_fixtures/shapes/fbb7ea802cf960eb.sql b/tests/ast_json_fixtures/shapes/fbb7ea802cf960eb.sql new file mode 100644 index 000000000000..290dcaaf658f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fbb7ea802cf960eb.sql @@ -0,0 +1 @@ +select json.k1[], json.k1[].k1_1[], json.k1[].k1_1[].k1_1_1, json.k1[].k1_2[], json.k1[].k1_2[].k1_2_1, json.k2[], json.k2[].k2_1[], json.k2[].k2_1[].k2_1_1, json.k2[].k2_2[], json.k2[].k2_2[].k2_2_1, json.k9[], json.k9[].k9_1[], json.k9[].k9_1[].k9_1_1, json.k9[].k9_2[], json.k9[].k9_2[].k9_2_1 from test format JSONColumns diff --git a/tests/ast_json_fixtures/shapes/fbdc6d735f4dd09b.json b/tests/ast_json_fixtures/shapes/fbdc6d735f4dd09b.json new file mode 100644 index 000000000000..1a8f3004c7c1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fbdc6d735f4dd09b.json @@ -0,0 +1,61 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "bftest" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "has", + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "Float64", + "value": -0 + } + ] + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0 + } + ] + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/fbdc6d735f4dd09b.sql b/tests/ast_json_fixtures/shapes/fbdc6d735f4dd09b.sql new file mode 100644 index 000000000000..9dbaac689090 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fbdc6d735f4dd09b.sql @@ -0,0 +1 @@ +SELECT 1 FROM bftest WHERE has(x, -0.) OR 0. FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/fbe65904735c81d7.json b/tests/ast_json_fixtures/shapes/fbe65904735c81d7.json new file mode 100644 index 000000000000..cf87bbbebecd --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fbe65904735c81d7.json @@ -0,0 +1,153 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "database": { + "type": "Identifier", + "name": "memory_db" + }, + "table": { + "type": "Identifier", + "name": "dict2" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "key_column", + "data_type": { + "type": "DataType", + "name": "UInt64" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "injective": true + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "second_column", + "data_type": { + "type": "DataType", + "name": "UInt8" + }, + "default_value": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "expression": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "rand", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "222" + } + ] + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "third_column", + "data_type": { + "type": "DataType", + "name": "String" + }, + "default_value": { + "type": "Literal", + "value_type": "String", + "value": "qqq" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "key_column" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "user", + "value": { + "type": "Literal", + "value_type": "String", + "value": "default" + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "table_for_dict" + } + }, + { + "type": "pair", + "key": "password", + "value": { + "type": "Literal", + "value_type": "String", + "value": "" + } + }, + { + "type": "pair", + "key": "db", + "value": { + "type": "Literal", + "value_type": "String", + "value": "database_for_dict_01018" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 1, + "max_sec": 10 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fbe65904735c81d7.sql b/tests/ast_json_fixtures/shapes/fbe65904735c81d7.sql new file mode 100644 index 000000000000..17e72cf0c7c2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fbe65904735c81d7.sql @@ -0,0 +1,10 @@ +CREATE DICTIONARY memory_db.dict2 +( + key_column UInt64 DEFAULT 0 INJECTIVE, + second_column UInt8 DEFAULT 1 EXPRESSION rand() % 222, + third_column String DEFAULT 'qqq' +) +PRIMARY KEY key_column +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() USER 'default' TABLE 'table_for_dict' PASSWORD '' DB 'database_for_dict_01018')) +LIFETIME(MIN 1 MAX 10) +LAYOUT(FLAT()) diff --git a/tests/ast_json_fixtures/shapes/fbf4308e9680569e.json b/tests/ast_json_fixtures/shapes/fbf4308e9680569e.json new file mode 100644 index 000000000000..de69f6359662 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fbf4308e9680569e.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Identifier", + "name": "level" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "errors_local" + }, + "final": true + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Identifier", + "name": "level" + } + ] + }, + "where": { + "type": "Function", + "name": "isNotNull", + "arguments": [ + { + "type": "Identifier", + "name": "level" + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fbf4308e9680569e.sql b/tests/ast_json_fixtures/shapes/fbf4308e9680569e.sql new file mode 100644 index 000000000000..b3f780036fe2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fbf4308e9680569e.sql @@ -0,0 +1 @@ +SELECT toTypeName(level) FROM errors_local FINAL PREWHERE isNotNull(level) WHERE isNotNull(level) LIMIT 1 diff --git a/tests/ast_json_fixtures/shapes/fc05344f11fb5e54.json b/tests/ast_json_fixtures/shapes/fc05344f11fb5e54.json new file mode 100644 index 000000000000..0f6760b5ab51 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc05344f11fb5e54.json @@ -0,0 +1,30 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u4_01292" + } + ] + }, + "authentication_methods": [ + { + "type": "AuthenticationData", + "auth_type": "SHA256_PASSWORD", + "contains_password": true, + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "qwe123" + } + ] + } + ], + "replace_authentication_methods": true + } +} diff --git a/tests/ast_json_fixtures/shapes/fc05344f11fb5e54.sql b/tests/ast_json_fixtures/shapes/fc05344f11fb5e54.sql new file mode 100644 index 000000000000..f515312aa05c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc05344f11fb5e54.sql @@ -0,0 +1 @@ +CREATE USER u4_01292 IDENTIFIED WITH sha256_password BY 'qwe123' diff --git a/tests/ast_json_fixtures/shapes/fc0e68b251b23a16.json b/tests/ast_json_fixtures/shapes/fc0e68b251b23a16.json new file mode 100644 index 000000000000..8d6b31f79e81 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc0e68b251b23a16.json @@ -0,0 +1,33 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Identifier", + "name": "n" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "mt" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fc0e68b251b23a16.sql b/tests/ast_json_fixtures/shapes/fc0e68b251b23a16.sql new file mode 100644 index 000000000000..e2a486ea14d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc0e68b251b23a16.sql @@ -0,0 +1 @@ +select distinct n from mt diff --git a/tests/ast_json_fixtures/shapes/fc229024cd56f257.json b/tests/ast_json_fixtures/shapes/fc229024cd56f257.json new file mode 100644 index 000000000000..eede01236482 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc229024cd56f257.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "AlterQuery", + "alter_object": "TABLE", + "table": { + "type": "Identifier", + "name": "t_apply_patches" + }, + "commands": [ + { + "type": "AlterCommand", + "command_type": "APPLY_PATCHES" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fc229024cd56f257.sql b/tests/ast_json_fixtures/shapes/fc229024cd56f257.sql new file mode 100644 index 000000000000..935903e8dcae --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc229024cd56f257.sql @@ -0,0 +1 @@ +ALTER TABLE t_apply_patches APPLY PATCHES diff --git a/tests/ast_json_fixtures/shapes/fc2aea491c5b47ea.json b/tests/ast_json_fixtures/shapes/fc2aea491c5b47ea.json new file mode 100644 index 000000000000..e029e9699952 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc2aea491c5b47ea.json @@ -0,0 +1,35 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "data_r2" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "\/tables\/{database}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "r2" + } + ] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fc2aea491c5b47ea.sql b/tests/ast_json_fixtures/shapes/fc2aea491c5b47ea.sql new file mode 100644 index 000000000000..baab54139984 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc2aea491c5b47ea.sql @@ -0,0 +1 @@ +create table data_r2 engine=ReplicatedMergeTree('/tables/{database}', 'r2') order by tuple() diff --git a/tests/ast_json_fixtures/shapes/fc336c88658c8bcd.json b/tests/ast_json_fixtures/shapes/fc336c88658c8bcd.json new file mode 100644 index 000000000000..176e3a5fcf05 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc336c88658c8bcd.json @@ -0,0 +1,78 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "quantilesTiming", + "arguments": [ + { + "type": "Identifier", + "name": "dummy" + } + ], + "parameters": [ + { + "type": "Literal", + "value_type": "Float64", + "value": 0.1 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.5 + }, + { + "type": "Literal", + "value_type": "Float64", + "value": 0.9 + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Identifier", + "name": "system" + }, + { + "type": "Identifier", + "name": "one" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fc336c88658c8bcd.sql b/tests/ast_json_fixtures/shapes/fc336c88658c8bcd.sql new file mode 100644 index 000000000000..b7e672a32b67 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc336c88658c8bcd.sql @@ -0,0 +1 @@ +SELECT quantilesTiming(0.1, 0.5, 0.9)(dummy) FROM remote('127.0.0.{2,3}', system, one) GROUP BY 1 WITH TOTALS diff --git a/tests/ast_json_fixtures/shapes/fc37d43ba15466f6.json b/tests/ast_json_fixtures/shapes/fc37d43ba15466f6.json new file mode 100644 index 000000000000..24f786528654 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc37d43ba15466f6.json @@ -0,0 +1,96 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "h", + "name": "toStartOfHour", + "arguments": [ + { + "type": "Function", + "name": "toDateTime", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "2025-01-01 12:00:00" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Identifier", + "name": "h" + }, + { + "type": "Identifier", + "name": "category" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_limit_by_all" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "h" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "category" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "enable_positional_arguments": "0" + } + }, + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "by": [] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fc37d43ba15466f6.sql b/tests/ast_json_fixtures/shapes/fc37d43ba15466f6.sql new file mode 100644 index 000000000000..7177ea5dcba9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc37d43ba15466f6.sql @@ -0,0 +1,6 @@ +WITH toStartOfHour(toDateTime('2025-01-01 12:00:00')) AS h +SELECT h, category +FROM test_limit_by_all +ORDER BY h, category, value +LIMIT 1 BY ALL +SETTINGS enable_positional_arguments = 0 diff --git a/tests/ast_json_fixtures/shapes/fc68be7f94880682.json b/tests/ast_json_fixtures/shapes/fc68be7f94880682.json new file mode 100644 index 000000000000..d6f5b2c72339 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc68be7f94880682.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "Explain", + "kind": "EXPLAIN SYNTAX", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "Int64", + "value": "-1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fc68be7f94880682.sql b/tests/ast_json_fixtures/shapes/fc68be7f94880682.sql new file mode 100644 index 000000000000..3aaf3ec17f11 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc68be7f94880682.sql @@ -0,0 +1 @@ +EXPLAIN SYNTAX SELECT -1 diff --git a/tests/ast_json_fixtures/shapes/fc7e74fcb632bb55.json b/tests/ast_json_fixtures/shapes/fc7e74fcb632bb55.json new file mode 100644 index 000000000000..e1ddaf440dfa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc7e74fcb632bb55.json @@ -0,0 +1,44 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "json.a.b.c", + "name_parts": ["json", "a", "b", "c"] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "id" + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSONColumns" + } +} diff --git a/tests/ast_json_fixtures/shapes/fc7e74fcb632bb55.sql b/tests/ast_json_fixtures/shapes/fc7e74fcb632bb55.sql new file mode 100644 index 000000000000..2c9ac71d7a74 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc7e74fcb632bb55.sql @@ -0,0 +1 @@ +select json.a.b.c from test order by id format JSONColumns diff --git a/tests/ast_json_fixtures/shapes/fc846d6d0abbb383.json b/tests/ast_json_fixtures/shapes/fc846d6d0abbb383.json new file mode 100644 index 000000000000..3d3364389332 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc846d6d0abbb383.json @@ -0,0 +1,12 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuotaQuery", + "names": ["q1_01297"], + "key_type": "USER_NAME", + "roles": { + "type": "RolesOrUsersSet", + "names": ["r1_01297"] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fc846d6d0abbb383.sql b/tests/ast_json_fixtures/shapes/fc846d6d0abbb383.sql new file mode 100644 index 000000000000..e5f51741dd95 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fc846d6d0abbb383.sql @@ -0,0 +1 @@ +CREATE QUOTA q1_01297 KEYED BY user_name TO r1_01297 diff --git a/tests/ast_json_fixtures/shapes/fcae381153e3ea53.json b/tests/ast_json_fixtures/shapes/fcae381153e3ea53.json new file mode 100644 index 000000000000..1b4659b59a6c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fcae381153e3ea53.json @@ -0,0 +1,101 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "hello", + "name": "number" + }, + { + "type": "Function", + "alias": "world", + "name": "toString", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + }, + { + "type": "Function", + "alias": "tuple", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Identifier", + "name": "world" + } + ] + }, + { + "type": "Function", + "alias": "sometimes_nulls", + "name": "nullIf", + "arguments": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "hello" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "max_block_size": "5" + } + } + } + ], + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/fcae381153e3ea53.sql b/tests/ast_json_fixtures/shapes/fcae381153e3ea53.sql new file mode 100644 index 000000000000..9c87508c63a6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fcae381153e3ea53.sql @@ -0,0 +1 @@ +SELECT number AS hello, toString(number) AS world, (hello, world) AS tuple, nullIf(hello % 3, 0) AS sometimes_nulls FROM system.numbers LIMIT 10 SETTINGS max_block_size = 5 FORMAT PrettySpace diff --git a/tests/ast_json_fixtures/shapes/fccc7141b9c3d0ab.json b/tests/ast_json_fixtures/shapes/fccc7141b9c3d0ab.json new file mode 100644 index 000000000000..2fe4f30cdc2e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fccc7141b9c3d0ab.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "ROLE", + "if_exists": true, + "names": ["test_role_01999"] + } +} diff --git a/tests/ast_json_fixtures/shapes/fccc7141b9c3d0ab.sql b/tests/ast_json_fixtures/shapes/fccc7141b9c3d0ab.sql new file mode 100644 index 000000000000..a00eb713f478 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fccc7141b9c3d0ab.sql @@ -0,0 +1 @@ +DROP ROLE IF EXISTS test_role_01999 diff --git a/tests/ast_json_fixtures/shapes/fd1f83454e3cf7f6.json b/tests/ast_json_fixtures/shapes/fd1f83454e3cf7f6.json new file mode 100644 index 000000000000..f565a569a5fe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd1f83454e3cf7f6.json @@ -0,0 +1,79 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "key", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + }, + { + "type": "Function", + "name": "count", + "arguments": [] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ], + "qualify": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fd1f83454e3cf7f6.sql b/tests/ast_json_fixtures/shapes/fd1f83454e3cf7f6.sql new file mode 100644 index 000000000000..5f81c41e5333 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd1f83454e3cf7f6.sql @@ -0,0 +1 @@ +SELECT (number % 2) AS key, count() FROM numbers(10) GROUP BY key QUALIFY key == 0 diff --git a/tests/ast_json_fixtures/shapes/fd2188bf1d2c5420.json b/tests/ast_json_fixtures/shapes/fd2188bf1d2c5420.json new file mode 100644 index 000000000000..b83ebdecef2d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd2188bf1d2c5420.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "sample_merge_00579" + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Merge", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "String", + "value": "^sample_00579_\\d$" + } + ] + } + }, + "as_table": "sample_00579_1" + } +} diff --git a/tests/ast_json_fixtures/shapes/fd2188bf1d2c5420.sql b/tests/ast_json_fixtures/shapes/fd2188bf1d2c5420.sql new file mode 100644 index 000000000000..3c2e078bf14e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd2188bf1d2c5420.sql @@ -0,0 +1 @@ +CREATE TABLE sample_merge_00579 AS sample_00579_1 ENGINE = Merge(currentDatabase(), '^sample_00579_\\d$') diff --git a/tests/ast_json_fixtures/shapes/fd339a2a020784b8.json b/tests/ast_json_fixtures/shapes/fd339a2a020784b8.json new file mode 100644 index 000000000000..bc830fa8739a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd339a2a020784b8.json @@ -0,0 +1,26 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "null", + "arguments": [] + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fd339a2a020784b8.sql b/tests/ast_json_fixtures/shapes/fd339a2a020784b8.sql new file mode 100644 index 000000000000..8d2bde0a6676 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd339a2a020784b8.sql @@ -0,0 +1 @@ +INSERT INTO function null() SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/fd3713b3d90273a5.json b/tests/ast_json_fixtures/shapes/fd3713b3d90273a5.json new file mode 100644 index 000000000000..67dbfe3d5752 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd3713b3d90273a5.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "alias": "a", + "value_type": "UInt64", + "value": "1000000" + } + ] + } + ], + "format": "PrettySpaceNoEscapesMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/fd3713b3d90273a5.sql b/tests/ast_json_fixtures/shapes/fd3713b3d90273a5.sql new file mode 100644 index 000000000000..b822d06a87ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd3713b3d90273a5.sql @@ -0,0 +1 @@ +SELECT 1_000_000 as a FORMAT PrettySpaceNoEscapesMonoBlock diff --git a/tests/ast_json_fixtures/shapes/fd40c3774634cc52.json b/tests/ast_json_fixtures/shapes/fd40c3774634cc52.json new file mode 100644 index 000000000000..2eec15a830bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd40c3774634cc52.json @@ -0,0 +1,64 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "v" + }, + { + "type": "Function", + "name": "variantElement", + "arguments": [ + { + "type": "Identifier", + "name": "v" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Bool" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "format", + "arguments": [ + { + "type": "Identifier", + "name": "TSV" + }, + { + "type": "Literal", + "value_type": "String", + "value": "v Variant(String, Bool)" + }, + { + "type": "Literal", + "value_type": "String", + "value": "\\N\ntruee\ntrue" + } + ] + } + } + } + ] + } + } + ], + "format": "TSV" + } +} diff --git a/tests/ast_json_fixtures/shapes/fd40c3774634cc52.sql b/tests/ast_json_fixtures/shapes/fd40c3774634cc52.sql new file mode 100644 index 000000000000..84fe6f2c6611 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd40c3774634cc52.sql @@ -0,0 +1 @@ +select v, variantElement(v, 'Bool') from format(TSV, 'v Variant(String, Bool)', '\\N\ntruee\ntrue') format TSV diff --git a/tests/ast_json_fixtures/shapes/fd436219182763c0.json b/tests/ast_json_fixtures/shapes/fd436219182763c0.json new file mode 100644 index 000000000000..8d5462f6ba27 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd436219182763c0.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Function", + "alias": "a", + "name": "arrayJoin", + "arguments": [ + { + "type": "Identifier", + "name": "value_1" + } + ] + }, + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_table" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fd436219182763c0.sql b/tests/ast_json_fixtures/shapes/fd436219182763c0.sql new file mode 100644 index 000000000000..37501d0d70e7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd436219182763c0.sql @@ -0,0 +1 @@ +SELECT id, arrayJoin(value_1) AS a, a FROM test_table diff --git a/tests/ast_json_fixtures/shapes/fd5cbef8ef8b7568.json b/tests/ast_json_fixtures/shapes/fd5cbef8ef8b7568.json new file mode 100644 index 000000000000..3d5dce85ab0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd5cbef8ef8b7568.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "attach_from_path": "\/etc\/passwd", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "s", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "File", + "kind": "TABLE_ENGINE", + "arguments": [ + { + "type": "Identifier", + "name": "TSVRaw" + } + ] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fd5cbef8ef8b7568.sql b/tests/ast_json_fixtures/shapes/fd5cbef8ef8b7568.sql new file mode 100644 index 000000000000..91b48f99cc53 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd5cbef8ef8b7568.sql @@ -0,0 +1 @@ +attach table test from '/etc/passwd' (s String) engine=File(TSVRaw) diff --git a/tests/ast_json_fixtures/shapes/fd670879875803a3.json b/tests/ast_json_fixtures/shapes/fd670879875803a3.json new file mode 100644 index 000000000000..836fa432d8d2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd670879875803a3.json @@ -0,0 +1,83 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_totals": true, + "select": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "count", + "arguments": [] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "200000" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{2,3}" + }, + { + "type": "Function", + "name": "currentDatabase", + "arguments": [] + }, + { + "type": "Identifier", + "name": "numbers_100k_log" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "number" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "number" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fd670879875803a3.sql b/tests/ast_json_fixtures/shapes/fd670879875803a3.sql new file mode 100644 index 000000000000..5cfd6cd91278 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd670879875803a3.sql @@ -0,0 +1 @@ +SELECT count() = 200000 FROM remote('127.0.0.{2,3}', currentDatabase(), numbers_100k_log) GROUP BY number WITH TOTALS ORDER BY number LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/fd6876e31dcf09cd.json b/tests/ast_json_fixtures/shapes/fd6876e31dcf09cd.json new file mode 100644 index 000000000000..5ab95b067afe --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd6876e31dcf09cd.json @@ -0,0 +1,45 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "range", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ], + "format": "PrettyCompactNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/fd6876e31dcf09cd.sql b/tests/ast_json_fixtures/shapes/fd6876e31dcf09cd.sql new file mode 100644 index 000000000000..fb256e9ff218 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd6876e31dcf09cd.sql @@ -0,0 +1 @@ +SELECT range(number) FROM system.numbers LIMIT 100 FORMAT PrettyCompactNoEscapes diff --git a/tests/ast_json_fixtures/shapes/fd86625e9106b063.json b/tests/ast_json_fixtures/shapes/fd86625e9106b063.json new file mode 100644 index 000000000000..ac403377116d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd86625e9106b063.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ], + "format": "PrettySpace" + } +} diff --git a/tests/ast_json_fixtures/shapes/fd86625e9106b063.sql b/tests/ast_json_fixtures/shapes/fd86625e9106b063.sql new file mode 100644 index 000000000000..d2fdc99b46e5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd86625e9106b063.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) FORMAT PrettySpace diff --git a/tests/ast_json_fixtures/shapes/fd89d7caca451e50.json b/tests/ast_json_fixtures/shapes/fd89d7caca451e50.json new file mode 100644 index 000000000000..e94c22508270 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd89d7caca451e50.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "other", + "name": "array", + "is_operator": true, + "arguments": [] + }, + { + "type": "Identifier", + "name": "arr" + }, + { + "type": "Function", + "name": "round", + "arguments": [ + { + "type": "Function", + "name": "arrayJaccardIndex", + "arguments": [ + { + "type": "Identifier", + "name": "other" + }, + { + "type": "Identifier", + "name": "arr" + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "array_jaccard_index" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "arr" + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fd89d7caca451e50.sql b/tests/ast_json_fixtures/shapes/fd89d7caca451e50.sql new file mode 100644 index 000000000000..17981597c04d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fd89d7caca451e50.sql @@ -0,0 +1 @@ +SELECT [] AS other, arr, round(arrayJaccardIndex(other, arr), 2) FROM array_jaccard_index ORDER BY arr diff --git a/tests/ast_json_fixtures/shapes/fda3c1b62ed1b219.json b/tests/ast_json_fixtures/shapes/fda3c1b62ed1b219.json new file mode 100644 index 000000000000..c6cc81380169 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fda3c1b62ed1b219.json @@ -0,0 +1,24 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "String", + "value": "你好" + }, + { + "type": "Literal", + "value_type": "String", + "value": "世界" + } + ] + } + ], + "format": "Vertical" + } +} diff --git a/tests/ast_json_fixtures/shapes/fda3c1b62ed1b219.sql b/tests/ast_json_fixtures/shapes/fda3c1b62ed1b219.sql new file mode 100644 index 000000000000..86e3f663c125 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fda3c1b62ed1b219.sql @@ -0,0 +1 @@ +SELECT '你好', '世界' FORMAT Vertical diff --git a/tests/ast_json_fixtures/shapes/fdbff4a0a40cdbdc.json b/tests/ast_json_fixtures/shapes/fdbff4a0a40cdbdc.json new file mode 100644 index 000000000000..2b22e8d7424d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fdbff4a0a40cdbdc.json @@ -0,0 +1,109 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "group_by_with_grouping_sets": true, + "select": [ + { + "type": "Function", + "alias": "amount", + "name": "count", + "arguments": [] + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + }, + { + "type": "Function", + "name": "grouping", + "arguments": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test02416" + } + } + } + ] + }, + "group_by": [ + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + { + "type": "ExpressionList", + "children": [ + { + "type": "Identifier", + "name": "a" + } + ] + }, + { + "type": "ExpressionList" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "amount" + }, + { + "type": "Identifier", + "name": "a" + }, + { + "type": "Identifier", + "name": "b" + } + ] + }, + "direction": "ASC" + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fdbff4a0a40cdbdc.sql b/tests/ast_json_fixtures/shapes/fdbff4a0a40cdbdc.sql new file mode 100644 index 000000000000..86ee3bad8f91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fdbff4a0a40cdbdc.sql @@ -0,0 +1 @@ +SELECT count() AS amount, a, b, GROUPING(a, b) FROM test02416 GROUP BY GROUPING SETS ((a, b), (a), ()) ORDER BY (amount, a, b) diff --git a/tests/ast_json_fixtures/shapes/fdc5a7b4154642d1.json b/tests/ast_json_fixtures/shapes/fdc5a7b4154642d1.json new file mode 100644 index 000000000000..9bf3192ca0d7 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fdc5a7b4154642d1.json @@ -0,0 +1,68 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "select": [ + { + "type": "Function", + "name": "arrayReduce", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "quantile(0.5)" + }, + { + "type": "Function", + "name": "CAST", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "[]" + }, + { + "type": "Literal", + "value_type": "String", + "value": "Array(Float64)" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fdc5a7b4154642d1.sql b/tests/ast_json_fixtures/shapes/fdc5a7b4154642d1.sql new file mode 100644 index 000000000000..dd4ba0acd8c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fdc5a7b4154642d1.sql @@ -0,0 +1 @@ +SELECT DISTINCT arrayReduce('quantile(0.5)', []::Array(Float64)) FROM numbers(1000) LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/fde276336e76d87f.json b/tests/ast_json_fixtures/shapes/fde276336e76d87f.json new file mode 100644 index 000000000000..8c087f003c0d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fde276336e76d87f.json @@ -0,0 +1,13 @@ +{ + "version": 2, + "ast": { + "type": "DetachQuery", + "kind": "DETACH", + "table": { + "type": "Identifier", + "name": "test_repl" + }, + "cluster": "test_shard_localhost", + "sync": true + } +} diff --git a/tests/ast_json_fixtures/shapes/fde276336e76d87f.sql b/tests/ast_json_fixtures/shapes/fde276336e76d87f.sql new file mode 100644 index 000000000000..53b842f0287c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fde276336e76d87f.sql @@ -0,0 +1 @@ +DETACH TABLE test_repl ON CLUSTER test_shard_localhost NO DELAY diff --git a/tests/ast_json_fixtures/shapes/fde7aae86e5eb016.json b/tests/ast_json_fixtures/shapes/fde7aae86e5eb016.json new file mode 100644 index 000000000000..4b73086083f9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fde7aae86e5eb016.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "cluster": "test_shard_localhost", + "table": { + "type": "Identifier", + "name": "t02006" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "String" + } + }, + { + "type": "ColumnDeclaration", + "name": "b", + "data_type": { + "type": "DataType", + "name": "UInt32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "ReplicatedMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "primary_key": { + "type": "Identifier", + "name": "a" + }, + "order_by": { + "type": "Identifier", + "name": "a" + } + }, + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/fde7aae86e5eb016.sql b/tests/ast_json_fixtures/shapes/fde7aae86e5eb016.sql new file mode 100644 index 000000000000..3135e121eeda --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fde7aae86e5eb016.sql @@ -0,0 +1,9 @@ +CREATE TABLE t02006 ON CLUSTER test_shard_localhost +( + `a` String, + `b` UInt32 +) +ENGINE = ReplicatedMergeTree +PRIMARY KEY a +ORDER BY a +format Null diff --git a/tests/ast_json_fixtures/shapes/fde7f74af687a408.json b/tests/ast_json_fixtures/shapes/fde7f74af687a408.json new file mode 100644 index 000000000000..b986dab9061e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fde7f74af687a408.json @@ -0,0 +1,6 @@ +{ + "version": 2, + "ast": { + "type": "ShowTables" + } +} diff --git a/tests/ast_json_fixtures/shapes/fde7f74af687a408.sql b/tests/ast_json_fixtures/shapes/fde7f74af687a408.sql new file mode 100644 index 000000000000..2ffbcaf81f00 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fde7f74af687a408.sql @@ -0,0 +1 @@ +show tables diff --git a/tests/ast_json_fixtures/shapes/fdf7f8b71ed05c74.json b/tests/ast_json_fixtures/shapes/fdf7f8b71ed05c74.json new file mode 100644 index 000000000000..0416fcc088d0 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fdf7f8b71ed05c74.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "ShowColumns", + "table": "tab", + "like": "%int%" + } +} diff --git a/tests/ast_json_fixtures/shapes/fdf7f8b71ed05c74.sql b/tests/ast_json_fixtures/shapes/fdf7f8b71ed05c74.sql new file mode 100644 index 000000000000..8333d1570290 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fdf7f8b71ed05c74.sql @@ -0,0 +1 @@ +SHOW COLUMNS FROM tab LIKE '%int%' diff --git a/tests/ast_json_fixtures/shapes/fe176bdf7110a904.json b/tests/ast_json_fixtures/shapes/fe176bdf7110a904.json new file mode 100644 index 000000000000..8cf625d46397 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe176bdf7110a904.json @@ -0,0 +1,47 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t1" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "x", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fe176bdf7110a904.sql b/tests/ast_json_fixtures/shapes/fe176bdf7110a904.sql new file mode 100644 index 000000000000..2ebeb6cc0384 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe176bdf7110a904.sql @@ -0,0 +1 @@ +CREATE TABLE t1 (x String) ENGINE = Memory AS SELECT 1 diff --git a/tests/ast_json_fixtures/shapes/fe1c4222b8e85f5c.json b/tests/ast_json_fixtures/shapes/fe1c4222b8e85f5c.json new file mode 100644 index 000000000000..af49045a8cde --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe1c4222b8e85f5c.json @@ -0,0 +1,39 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + } + } + } + ] + } + } + ], + "format": "PrettySpaceNoEscapes" + } +} diff --git a/tests/ast_json_fixtures/shapes/fe1c4222b8e85f5c.sql b/tests/ast_json_fixtures/shapes/fe1c4222b8e85f5c.sql new file mode 100644 index 000000000000..5474e7f8a860 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe1c4222b8e85f5c.sql @@ -0,0 +1 @@ +SELECT * FROM numbers(10) FORMAT PrettySpaceNoEscapes diff --git a/tests/ast_json_fixtures/shapes/fe47b9ced86b6d5d.json b/tests/ast_json_fixtures/shapes/fe47b9ced86b6d5d.json new file mode 100644 index 000000000000..2e29358427a4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe47b9ced86b6d5d.json @@ -0,0 +1,51 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "arr", + "name": "arrayJoin", + "arguments": [ + { + "type": "Literal", + "value_type": "Array", + "value": [ + { + "value_type": "UInt64", + "value": "1" + }, + { + "value_type": "UInt64", + "value": "2" + }, + { + "value_type": "UInt64", + "value": "3" + } + ] + } + ] + }, + { + "type": "Literal", + "alias": "s1", + "value_type": "String", + "value": "hello" + }, + { + "type": "Literal", + "alias": "s2", + "value_type": "String", + "value": "world" + } + ] + } + ], + "format": "TSVWithNames" + } +} diff --git a/tests/ast_json_fixtures/shapes/fe47b9ced86b6d5d.sql b/tests/ast_json_fixtures/shapes/fe47b9ced86b6d5d.sql new file mode 100644 index 000000000000..6452220f2639 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe47b9ced86b6d5d.sql @@ -0,0 +1 @@ +SELECT arrayJoin([1, 2, 3]) AS arr, 'hello' AS s1, 'world' AS s2 FORMAT TSVWithNames diff --git a/tests/ast_json_fixtures/shapes/fe57c066321a8995.json b/tests/ast_json_fixtures/shapes/fe57c066321a8995.json new file mode 100644 index 000000000000..6f8150095035 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe57c066321a8995.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "trunc" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "int" + } + } + ], + "primary_key": { + "type": "Identifier", + "name": "n" + } + }, + "storage": { + "type": "Storage", + "partition_by": { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "primary_key": { + "type": "Identifier", + "name": "n" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fe57c066321a8995.sql b/tests/ast_json_fixtures/shapes/fe57c066321a8995.sql new file mode 100644 index 000000000000..791d971ed681 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe57c066321a8995.sql @@ -0,0 +1 @@ +create table trunc (n int, primary key n) partition by n % 10 diff --git a/tests/ast_json_fixtures/shapes/fe62d05df3be1492.json b/tests/ast_json_fixtures/shapes/fe62d05df3be1492.json new file mode 100644 index 000000000000..0cd14eb6d0b5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe62d05df3be1492.json @@ -0,0 +1,147 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value1" + }, + { + "type": "Identifier", + "name": "value2" + }, + { + "type": "Function", + "alias": "start_ts", + "name": "toUInt64", + "arguments": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "join_inner_table" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "833c9e22-c245-4eb5-8745-117a9a1f26b1" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1610517366120" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value1" + }, + { + "type": "Identifier", + "name": "value2" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value2" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fe62d05df3be1492.sql b/tests/ast_json_fixtures/shapes/fe62d05df3be1492.sql new file mode 100644 index 000000000000..3db87055137a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe62d05df3be1492.sql @@ -0,0 +1,10 @@ +SELECT + key, + value1, + value2, + toUInt64(min(time)) AS start_ts +FROM join_inner_table + PREWHERE (id = '833c9e22-c245-4eb5-8745-117a9a1f26b1') AND (number > toUInt64('1610517366120')) +GROUP BY key, value1, value2 +ORDER BY key, value1, value2 +LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/fe7083fa75586b24.json b/tests/ast_json_fixtures/shapes/fe7083fa75586b24.json new file mode 100644 index 000000000000..00fba9985562 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe7083fa75586b24.json @@ -0,0 +1,54 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "map_formats" + } + } + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Function", + "name": "arrayElement", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "m" + }, + { + "type": "Literal", + "value_type": "String", + "value": "k1" + } + ] + }, + "direction": "ASC" + } + ] + } + ], + "format": "JSON" + } +} diff --git a/tests/ast_json_fixtures/shapes/fe7083fa75586b24.sql b/tests/ast_json_fixtures/shapes/fe7083fa75586b24.sql new file mode 100644 index 000000000000..d8a164009a4e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe7083fa75586b24.sql @@ -0,0 +1 @@ +SELECT * FROM map_formats ORDER BY m['k1'] FORMAT JSON diff --git a/tests/ast_json_fixtures/shapes/fe73afb919450be4.json b/tests/ast_json_fixtures/shapes/fe73afb919450be4.json new file mode 100644 index 000000000000..b1d6034617a1 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe73afb919450be4.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "ColumnsListMatcher", + "columns": [ + { + "type": "Identifier", + "name": "dummy" + } + ] + } + ] + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fe73afb919450be4.sql b/tests/ast_json_fixtures/shapes/fe73afb919450be4.sql new file mode 100644 index 000000000000..d15d94bdfbb4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe73afb919450be4.sql @@ -0,0 +1 @@ +SELECT COLUMNS(dummy) diff --git a/tests/ast_json_fixtures/shapes/fe75e1291a8bd731.json b/tests/ast_json_fixtures/shapes/fe75e1291a8bd731.json new file mode 100644 index 000000000000..2ab2c74506bc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe75e1291a8bd731.json @@ -0,0 +1,154 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value1" + }, + { + "type": "Identifier", + "name": "value2" + }, + { + "type": "Function", + "alias": "start_ts", + "name": "toUInt64", + "arguments": [ + { + "type": "Function", + "name": "min", + "arguments": [ + { + "type": "Identifier", + "name": "time" + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "join_inner_table" + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "id" + }, + { + "type": "Literal", + "value_type": "String", + "value": "833c9e22-c245-4eb5-8745-117a9a1f26b1" + } + ] + }, + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Function", + "name": "toUInt64", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "1610517366120" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Identifier", + "name": "value1" + }, + { + "type": "Identifier", + "name": "value2" + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "key" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value1" + }, + "direction": "ASC" + }, + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "value2" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "settings": { + "type": "Settings", + "changes": { + "enable_parallel_replicas": "1", + "enable_analyzer": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/fe75e1291a8bd731.sql b/tests/ast_json_fixtures/shapes/fe75e1291a8bd731.sql new file mode 100644 index 000000000000..71c729945ac5 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe75e1291a8bd731.sql @@ -0,0 +1,11 @@ +SELECT + key, + value1, + value2, + toUInt64(min(time)) AS start_ts +FROM join_inner_table +PREWHERE (id = '833c9e22-c245-4eb5-8745-117a9a1f26b1') AND (number > toUInt64('1610517366120')) +GROUP BY key, value1, value2 +ORDER BY key, value1, value2 +LIMIT 10 +SETTINGS enable_parallel_replicas = 1, enable_analyzer=1 diff --git a/tests/ast_json_fixtures/shapes/fe7e750ebaff3e17.json b/tests/ast_json_fixtures/shapes/fe7e750ebaff3e17.json new file mode 100644 index 000000000000..d919027b6cde --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe7e750ebaff3e17.json @@ -0,0 +1,22 @@ +{ + "version": 2, + "ast": { + "type": "InsertQuery", + "table_function": { + "type": "Function", + "name": "null", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "x String" + } + ] + }, + "infile": { + "type": "Literal", + "value_type": "String", + "value": "\/dev\/null" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fe7e750ebaff3e17.sql b/tests/ast_json_fixtures/shapes/fe7e750ebaff3e17.sql new file mode 100644 index 000000000000..fe094579aace --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe7e750ebaff3e17.sql @@ -0,0 +1 @@ +INSERT INTO function null('x String') FROM INFILE '/dev/null' diff --git a/tests/ast_json_fixtures/shapes/fe8432c5732268a3.json b/tests/ast_json_fixtures/shapes/fe8432c5732268a3.json new file mode 100644 index 000000000000..f4a8a4a33e13 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe8432c5732268a3.json @@ -0,0 +1,34 @@ +{ + "version": 2, + "ast": { + "type": "AttachQuery", + "attach": true, + "attach_from_path": "some\/path", + "table": { + "type": "Identifier", + "name": "test" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "n", + "data_type": { + "type": "DataType", + "name": "UInt8" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Memory", + "kind": "TABLE_ENGINE", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fe8432c5732268a3.sql b/tests/ast_json_fixtures/shapes/fe8432c5732268a3.sql new file mode 100644 index 000000000000..5f150e8995fa --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe8432c5732268a3.sql @@ -0,0 +1 @@ +attach table test from 'some/path' (n UInt8) engine=Memory diff --git a/tests/ast_json_fixtures/shapes/fe8b54264586866c.json b/tests/ast_json_fixtures/shapes/fe8b54264586866c.json new file mode 100644 index 000000000000..6e8ca62ea2c9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe8b54264586866c.json @@ -0,0 +1,86 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "2024_dictionary_with_comment" + }, + "comment": { + "type": "Literal", + "value_type": "String", + "value": "Test dictionary with comment" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "id", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "value", + "data_type": { + "type": "DataType", + "name": "String" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "id" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "host", + "value": { + "type": "Literal", + "value_type": "String", + "value": "localhost" + } + }, + { + "type": "pair", + "key": "port", + "value": { + "type": "Function", + "name": "tcpPort", + "arguments": [] + } + }, + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "source_table" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 1000 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "flat", + "parameters": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fe8b54264586866c.sql b/tests/ast_json_fixtures/shapes/fe8b54264586866c.sql new file mode 100644 index 000000000000..1ae520c36a8c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fe8b54264586866c.sql @@ -0,0 +1,10 @@ +CREATE DICTIONARY 2024_dictionary_with_comment +( + id UInt64, + value String +) +PRIMARY KEY id +SOURCE(CLICKHOUSE(HOST 'localhost' PORT tcpPort() TABLE 'source_table')) +LAYOUT(FLAT()) +LIFETIME(MIN 0 MAX 1000) +COMMENT 'Test dictionary with comment' diff --git a/tests/ast_json_fixtures/shapes/feb6e09c1061991d.json b/tests/ast_json_fixtures/shapes/feb6e09c1061991d.json new file mode 100644 index 000000000000..1cc4c39a4965 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/feb6e09c1061991d.json @@ -0,0 +1,244 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "recursive_with": true, + "with": [ + { + "type": "WithElement", + "name": "search_graph", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Literal", + "alias": "is_cycle", + "value_type": "Bool", + "value": false + }, + { + "type": "Function", + "alias": "path", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "g.f", + "name_parts": ["g", "f"] + }, + { + "type": "Identifier", + "name": "g.t", + "name_parts": ["g", "t"] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "g", + "name": "graph" + } + } + } + ] + } + }, + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedAsterisk", + "qualifier": { + "type": "Identifier", + "name": "g" + } + }, + { + "type": "Function", + "name": "has", + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "g.f", + "name_parts": ["g", "f"] + }, + { + "type": "Identifier", + "name": "g.t", + "name_parts": ["g", "t"] + } + ] + } + ] + }, + { + "type": "Function", + "name": "arrayConcat", + "arguments": [ + { + "type": "Identifier", + "name": "sg.path", + "name_parts": ["sg", "path"] + }, + { + "type": "Function", + "name": "array", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "tuple", + "arguments": [ + { + "type": "Identifier", + "name": "g.f", + "name_parts": ["g", "f"] + }, + { + "type": "Identifier", + "name": "g.t", + "name_parts": ["g", "t"] + } + ] + } + ] + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "g", + "name": "graph" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "sg", + "name": "search_graph" + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "g.f", + "name_parts": ["g", "f"] + }, + { + "type": "Identifier", + "name": "sg.t", + "name_parts": ["sg", "t"] + } + ] + }, + { + "type": "Function", + "name": "not", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "is_cycle" + } + ] + } + ] + } + } + ] + } + } + } + ], + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "search_graph" + } + } + } + ] + }, + "settings": { + "type": "Settings", + "changes": { + "query_plan_join_swap_table": "false" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/feb6e09c1061991d.sql b/tests/ast_json_fixtures/shapes/feb6e09c1061991d.sql new file mode 100644 index 000000000000..b11667848612 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/feb6e09c1061991d.sql @@ -0,0 +1,9 @@ +WITH RECURSIVE search_graph AS ( + SELECT *, false AS is_cycle, [tuple(g.f, g.t)] AS path FROM graph g + UNION ALL + SELECT g.*, has(path, tuple(g.f, g.t)), arrayConcat(sg.path, [tuple(g.f, g.t)]) + FROM graph g, search_graph sg + WHERE g.f = sg.t AND NOT is_cycle +) +SELECT * FROM search_graph +SETTINGS query_plan_join_swap_table = 'false' diff --git a/tests/ast_json_fixtures/shapes/fec17f011d310295.json b/tests/ast_json_fixtures/shapes/fec17f011d310295.json new file mode 100644 index 000000000000..1feaec7b2046 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fec17f011d310295.json @@ -0,0 +1,111 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_materialized_view": true, + "cluster": "test_shard_localhost", + "table": { + "type": "Identifier", + "name": "mview" + }, + "select": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "day", + "name": "toDate", + "arguments": [ + { + "type": "Identifier", + "name": "timestamp" + } + ] + }, + { + "type": "Identifier", + "name": "card_id" + }, + { + "type": "Function", + "alias": "card_view", + "name": "count", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "source" + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day" + }, + { + "type": "Identifier", + "name": "card_id" + } + ] + } + ] + } + ] + }, + "targets": { + "type": "ViewTargets", + "targets": [ + { + "kind": "to", + "inner_engine": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "SummingMergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "day" + }, + { + "type": "Identifier", + "name": "card_id" + } + ] + } + } + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fec17f011d310295.sql b/tests/ast_json_fixtures/shapes/fec17f011d310295.sql new file mode 100644 index 000000000000..bfb406bc1e57 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fec17f011d310295.sql @@ -0,0 +1,7 @@ +CREATE MATERIALIZED VIEW mview on cluster test_shard_localhost +ENGINE = SummingMergeTree ORDER BY (day, card_id) +as SELECT + toDate(timestamp) AS day, + card_id, + count(*) AS card_view +FROM source GROUP BY (day, card_id) diff --git a/tests/ast_json_fixtures/shapes/fec9a77c11a76f26.json b/tests/ast_json_fixtures/shapes/fec9a77c11a76f26.json new file mode 100644 index 000000000000..f0fda4149764 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fec9a77c11a76f26.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "SYSTEM", + "system_type": "ENABLE FAILPOINT", + "fail_point_name": "execute_query_calling_empty_set_result_func_on_exception" + } +} diff --git a/tests/ast_json_fixtures/shapes/fec9a77c11a76f26.sql b/tests/ast_json_fixtures/shapes/fec9a77c11a76f26.sql new file mode 100644 index 000000000000..bf135561d50e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fec9a77c11a76f26.sql @@ -0,0 +1 @@ +SYSTEM ENABLE FAILPOINT execute_query_calling_empty_set_result_func_on_exception diff --git a/tests/ast_json_fixtures/shapes/fed5113d4b384806.json b/tests/ast_json_fixtures/shapes/fed5113d4b384806.json new file mode 100644 index 000000000000..811cb6c7182f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fed5113d4b384806.json @@ -0,0 +1,20 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "if_not_exists": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u_02001" + } + ] + }, + "default_database": { + "type": "DatabaseOrNone", + "database": "system" + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fed5113d4b384806.sql b/tests/ast_json_fixtures/shapes/fed5113d4b384806.sql new file mode 100644 index 000000000000..1cd0a22d0ae4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fed5113d4b384806.sql @@ -0,0 +1 @@ +create user if not exists u_02001 default database system diff --git a/tests/ast_json_fixtures/shapes/fefc568755cd57a4.json b/tests/ast_json_fixtures/shapes/fefc568755cd57a4.json new file mode 100644 index 000000000000..dfda8f7187fc --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fefc568755cd57a4.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateUserQuery", + "alter": true, + "names": { + "type": "UserNamesWithHost", + "users": [ + { + "type": "UserNameWithHost", + "name": "u2_01292" + } + ] + }, + "new_name": "u2_01292_renamed" + } +} diff --git a/tests/ast_json_fixtures/shapes/fefc568755cd57a4.sql b/tests/ast_json_fixtures/shapes/fefc568755cd57a4.sql new file mode 100644 index 000000000000..cdef94928c04 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fefc568755cd57a4.sql @@ -0,0 +1 @@ +ALTER USER u2_01292 RENAME TO 'u2_01292_renamed' diff --git a/tests/ast_json_fixtures/shapes/ff1ddb51de6e5909.json b/tests/ast_json_fixtures/shapes/ff1ddb51de6e5909.json new file mode 100644 index 000000000000..0a88019a1c75 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff1ddb51de6e5909.json @@ -0,0 +1,50 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "QualifiedColumnsRegexpMatcher", + "pattern": "^c", + "qualifier": { + "type": "Identifier", + "name": "t" + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "COMMA" + }, + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "u" + } + } + } + ] + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ff1ddb51de6e5909.sql b/tests/ast_json_fixtures/shapes/ff1ddb51de6e5909.sql new file mode 100644 index 000000000000..8140926354e9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff1ddb51de6e5909.sql @@ -0,0 +1 @@ +SELECT t.COLUMNS('^c') FROM t, u diff --git a/tests/ast_json_fixtures/shapes/ff37da646317f599.json b/tests/ast_json_fixtures/shapes/ff37da646317f599.json new file mode 100644 index 000000000000..534808bb0ed8 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff37da646317f599.json @@ -0,0 +1,76 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "is_dictionary": true, + "table": { + "type": "Identifier", + "name": "02183_range_dictionary" + }, + "dictionary_attributes": [ + { + "type": "DictionaryAttributeDeclaration", + "name": "key", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "start", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + }, + { + "type": "DictionaryAttributeDeclaration", + "name": "end", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ], + "dictionary": { + "type": "Dictionary", + "primary_key": [ + { + "type": "Identifier", + "name": "key" + } + ], + "source": { + "type": "FunctionWithKeyValueArguments", + "name": "clickhouse", + "elements": [ + { + "type": "pair", + "key": "table", + "value": { + "type": "Literal", + "value_type": "String", + "value": "02183_range_dictionary_source_table" + } + } + ] + }, + "lifetime": { + "type": "DictionaryLifetime", + "min_sec": 0, + "max_sec": 0 + }, + "layout": { + "type": "DictionaryLayout", + "layout_type": "range_hashed", + "parameters": [] + }, + "range": { + "type": "DictionaryRange", + "min_attr_name": "start", + "max_attr_name": "end" + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ff37da646317f599.sql b/tests/ast_json_fixtures/shapes/ff37da646317f599.sql new file mode 100644 index 000000000000..16b043f61d91 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff37da646317f599.sql @@ -0,0 +1,11 @@ +CREATE DICTIONARY 02183_range_dictionary +( + key UInt64, + start UInt64, + end UInt64 +) +PRIMARY KEY key +SOURCE(CLICKHOUSE(TABLE '02183_range_dictionary_source_table')) +LAYOUT(RANGE_HASHED()) +RANGE(MIN start MAX end) +LIFETIME(0) diff --git a/tests/ast_json_fixtures/shapes/ff46bb7f93feef85.json b/tests/ast_json_fixtures/shapes/ff46bb7f93feef85.json new file mode 100644 index 000000000000..7bf62fab5b7f --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff46bb7f93feef85.json @@ -0,0 +1,74 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + }, + { + "type": "Function", + "name": "toTypeName", + "arguments": [ + { + "type": "Asterisk" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Asterisk" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "numbers", + "database": "system" + } + } + } + ] + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + } + ] + } + } + } + } + ] + } + } + ], + "format": "PrettySpaceMonoBlock" + } +} diff --git a/tests/ast_json_fixtures/shapes/ff46bb7f93feef85.sql b/tests/ast_json_fixtures/shapes/ff46bb7f93feef85.sql new file mode 100644 index 000000000000..d16346c038c4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff46bb7f93feef85.sql @@ -0,0 +1 @@ +SELECT *, toTypeName(*) FROM (SELECT * FROM system.numbers LIMIT 100) FORMAT PrettySpaceMonoBlock diff --git a/tests/ast_json_fixtures/shapes/ff6ae9011216117b.json b/tests/ast_json_fixtures/shapes/ff6ae9011216117b.json new file mode 100644 index 000000000000..dd7279dfaab6 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff6ae9011216117b.json @@ -0,0 +1,8 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "names": ["u1_01292", "u2_01292", "u3_01292", "u4_01292", "u5_01292"] + } +} diff --git a/tests/ast_json_fixtures/shapes/ff6ae9011216117b.sql b/tests/ast_json_fixtures/shapes/ff6ae9011216117b.sql new file mode 100644 index 000000000000..572488727c39 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff6ae9011216117b.sql @@ -0,0 +1 @@ +DROP USER u1_01292, u2_01292, u3_01292, u4_01292, u5_01292 diff --git a/tests/ast_json_fixtures/shapes/ff6f2f2ed8117b53.json b/tests/ast_json_fixtures/shapes/ff6f2f2ed8117b53.json new file mode 100644 index 000000000000..dee88846767b --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff6f2f2ed8117b53.json @@ -0,0 +1,168 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "with": [ + { + "type": "Function", + "alias": "alias_in_error", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test1" + } + ] + }, + { + "type": "Function", + "name": "match", + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test2" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "match", + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test3" + } + ] + }, + { + "type": "Function", + "name": "match", + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test2" + } + ] + } + ] + }, + { + "type": "Function", + "name": "match", + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test4" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test5" + } + ] + }, + { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "path" + }, + { + "type": "Literal", + "value_type": "String", + "value": "test6" + } + ] + } + ] + } + ], + "select": [ + { + "type": "Function", + "name": "count", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "test_bug_optimization" + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "alias_in_error" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ff6f2f2ed8117b53.sql b/tests/ast_json_fixtures/shapes/ff6f2f2ed8117b53.sql new file mode 100644 index 000000000000..4a37302a9cba --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff6f2f2ed8117b53.sql @@ -0,0 +1,4 @@ +WITH (path = 'test1') OR match(path, 'test2') OR (match(path, 'test3') AND match(path, 'test2')) OR match(path, 'test4') OR (path = 'test5') OR (path = 'test6') AS alias_in_error +SELECT count(1) +FROM test_bug_optimization +WHERE alias_in_error diff --git a/tests/ast_json_fixtures/shapes/ff769bb23ab24768.json b/tests/ast_json_fixtures/shapes/ff769bb23ab24768.json new file mode 100644 index 000000000000..25e6524ad55a --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff769bb23ab24768.json @@ -0,0 +1,88 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "a" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "a", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "key" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Identifier", + "name": "key" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "t1" + } + } + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "key" + } + ] + } + ] + } + } + } + } + ] + }, + "where": { + "type": "Identifier", + "name": "key" + } + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/ff769bb23ab24768.sql b/tests/ast_json_fixtures/shapes/ff769bb23ab24768.sql new file mode 100644 index 000000000000..9469eda5637e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff769bb23ab24768.sql @@ -0,0 +1 @@ +SELECT a FROM ( SELECT key + 1 as a, key FROM t1 GROUP BY key ) WHERE key FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/ff8db3d6784e05bc.json b/tests/ast_json_fixtures/shapes/ff8db3d6784e05bc.json new file mode 100644 index 000000000000..ce1e36c2125c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff8db3d6784e05bc.json @@ -0,0 +1,186 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Function", + "alias": "mA", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "A" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + ] + } + }, + { + "type": "Function", + "alias": "mB", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "B" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + ] + } + }, + { + "type": "Function", + "alias": "mC", + "name": "max", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "C" + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Function", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + ] + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "x" + } + } + } + ] + }, + "qualify": { + "type": "Function", + "name": "or", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "mA" + }, + { + "type": "Identifier", + "name": "mB" + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "mA" + }, + { + "type": "Identifier", + "name": "mC" + } + ] + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ff8db3d6784e05bc.sql b/tests/ast_json_fixtures/shapes/ff8db3d6784e05bc.sql new file mode 100644 index 000000000000..495ced2b7de4 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff8db3d6784e05bc.sql @@ -0,0 +1,9 @@ +SELECT + x, + max(A) OVER (PARTITION BY x % 1000) AS mA, + max(B) OVER (PARTITION BY x % 1000) AS mB, + max(C) OVER (PARTITION BY x % 1000) AS mC +FROM x +QUALIFY (mA AND mB) OR (mA AND mC) +ORDER BY x +LIMIT 10 diff --git a/tests/ast_json_fixtures/shapes/ff9d00bc2e41882f.json b/tests/ast_json_fixtures/shapes/ff9d00bc2e41882f.json new file mode 100644 index 000000000000..d9bf08d2078d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff9d00bc2e41882f.json @@ -0,0 +1,9 @@ +{ + "version": 2, + "ast": { + "type": "DropAccessEntityQuery", + "entity_type": "USER", + "cluster": "test_shard_localhost", + "names": ["02911_user"] + } +} diff --git a/tests/ast_json_fixtures/shapes/ff9d00bc2e41882f.sql b/tests/ast_json_fixtures/shapes/ff9d00bc2e41882f.sql new file mode 100644 index 000000000000..350cf6f3a3ed --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ff9d00bc2e41882f.sql @@ -0,0 +1 @@ +DROP USER 02911_user ON CLUSTER test_shard_localhost diff --git a/tests/ast_json_fixtures/shapes/ffb51dc397b23bc5.json b/tests/ast_json_fixtures/shapes/ffb51dc397b23bc5.json new file mode 100644 index 000000000000..a2146c9bda78 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ffb51dc397b23bc5.json @@ -0,0 +1,63 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "temporary": true, + "if_not_exists": true, + "table": { + "type": "Identifier", + "name": "tmp_a" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "k1", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "k2", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "d1", + "data_type": { + "type": "DataType", + "name": "Int32" + } + }, + { + "type": "ColumnDeclaration", + "name": "d2", + "data_type": { + "type": "DataType", + "name": "Int32" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "MergeTree", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "order_by": { + "type": "Function", + "name": "tuple", + "arguments": [] + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ffb51dc397b23bc5.sql b/tests/ast_json_fixtures/shapes/ffb51dc397b23bc5.sql new file mode 100644 index 000000000000..958625d53b21 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ffb51dc397b23bc5.sql @@ -0,0 +1,7 @@ +CREATE TEMPORARY TABLE IF NOT EXISTS tmp_a +( + k1 Int32, + k2 Int32, + d1 Int32, + d2 Int32 +) ENGINE = MergeTree ORDER BY tuple() diff --git a/tests/ast_json_fixtures/shapes/ffb558470673e379.json b/tests/ast_json_fixtures/shapes/ffb558470673e379.json new file mode 100644 index 000000000000..3ceeaba9a56e --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ffb558470673e379.json @@ -0,0 +1,14 @@ +{ + "version": 2, + "ast": { + "type": "Rename", + "elements": [ + { + "from_database": "test1601_detach_permanently_ordinary", + "from_table": "test_name_rename_attempt", + "to_database": "test1601_detach_permanently_ordinary", + "to_table": "test_name_reuse" + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ffb558470673e379.sql b/tests/ast_json_fixtures/shapes/ffb558470673e379.sql new file mode 100644 index 000000000000..88a50ddadce2 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ffb558470673e379.sql @@ -0,0 +1 @@ +RENAME TABLE test1601_detach_permanently_ordinary.test_name_rename_attempt TO test1601_detach_permanently_ordinary.test_name_reuse diff --git a/tests/ast_json_fixtures/shapes/ffc0bb0ae22a2467.json b/tests/ast_json_fixtures/shapes/ffc0bb0ae22a2467.json new file mode 100644 index 000000000000..388b5f68e8ef --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ffc0bb0ae22a2467.json @@ -0,0 +1,38 @@ +{ + "version": 2, + "ast": { + "type": "CreateQuery", + "table": { + "type": "Identifier", + "name": "t" + }, + "columns_list": { + "type": "Columns", + "columns": [ + { + "type": "ColumnDeclaration", + "name": "a", + "data_type": { + "type": "DataType", + "name": "UInt64" + } + } + ] + }, + "storage": { + "type": "Storage", + "engine": { + "type": "Function", + "name": "Log", + "kind": "TABLE_ENGINE", + "arguments": [] + }, + "settings": { + "type": "Settings", + "changes": { + "disk": "s3_cache" + } + } + } + } +} diff --git a/tests/ast_json_fixtures/shapes/ffc0bb0ae22a2467.sql b/tests/ast_json_fixtures/shapes/ffc0bb0ae22a2467.sql new file mode 100644 index 000000000000..8b37a1389918 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ffc0bb0ae22a2467.sql @@ -0,0 +1,3 @@ +CREATE TABLE t(a UInt64) +ENGINE = Log +SETTINGS disk = 's3_cache' diff --git a/tests/ast_json_fixtures/shapes/ffcdc32f0ac209d5.json b/tests/ast_json_fixtures/shapes/ffcdc32f0ac209d5.json new file mode 100644 index 000000000000..a373fe78049d --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ffcdc32f0ac209d5.json @@ -0,0 +1,107 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "alias": "x", + "name": "groupArray", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Identifier", + "name": "number" + } + ] + } + ], + "window_definition": { + "type": "WindowDefinition", + "frame_type": "ROWS", + "frame_begin": { + "type": "Unbounded", + "preceding": true + }, + "frame_end": { + "type": "Current" + } + } + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "remote", + "arguments": [ + { + "type": "Literal", + "value_type": "String", + "value": "127.0.0.{1,2}" + }, + { + "type": "Literal", + "value_type": "String", + "value": "" + }, + { + "type": "Identifier", + "name": "t_01568" + } + ] + } + } + } + ] + }, + "group_by": [ + { + "type": "Function", + "name": "mod", + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "x" + }, + "direction": "ASC" + } + ], + "settings": { + "type": "Settings", + "changes": { + "distributed_group_by_no_merge": "1" + } + } + } + ] + } +} diff --git a/tests/ast_json_fixtures/shapes/ffcdc32f0ac209d5.sql b/tests/ast_json_fixtures/shapes/ffcdc32f0ac209d5.sql new file mode 100644 index 000000000000..c209d1f5921c --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ffcdc32f0ac209d5.sql @@ -0,0 +1 @@ +select groupArray(groupArray(number)) over (rows unbounded preceding) as x from remote('127.0.0.{1,2}', '', t_01568) group by mod(number, 3) order by x settings distributed_group_by_no_merge=1 diff --git a/tests/ast_json_fixtures/shapes/ffed61fbf27e47bc.json b/tests/ast_json_fixtures/shapes/ffed61fbf27e47bc.json new file mode 100644 index 000000000000..d31d62a92c83 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ffed61fbf27e47bc.json @@ -0,0 +1,42 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "x" + }, + { + "type": "Subquery", + "alias": "x", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ], + "where": { + "type": "Literal", + "value_type": "Null", + "value": null + } + } + ] + } + } + ] + } + ], + "format": "Null" + } +} diff --git a/tests/ast_json_fixtures/shapes/ffed61fbf27e47bc.sql b/tests/ast_json_fixtures/shapes/ffed61fbf27e47bc.sql new file mode 100644 index 000000000000..12135b203014 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/ffed61fbf27e47bc.sql @@ -0,0 +1 @@ +SELECT x, (SELECT 1 WHERE NULL) AS x FORMAT Null diff --git a/tests/ast_json_fixtures/shapes/fff00ac72c723cef.json b/tests/ast_json_fixtures/shapes/fff00ac72c723cef.json new file mode 100644 index 000000000000..e3d1189c6740 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fff00ac72c723cef.json @@ -0,0 +1,17 @@ +{ + "version": 2, + "ast": { + "type": "CreateSettingsProfileQuery", + "names": ["s1_01418"], + "settings": { + "type": "SettingsProfileElements", + "elements": [ + { + "type": "SettingsProfileElement", + "setting_name": "custom_compound.identifier.v2", + "value": "100" + } + ] + } + } +} diff --git a/tests/ast_json_fixtures/shapes/fff00ac72c723cef.sql b/tests/ast_json_fixtures/shapes/fff00ac72c723cef.sql new file mode 100644 index 000000000000..b79ce8191dd9 --- /dev/null +++ b/tests/ast_json_fixtures/shapes/fff00ac72c723cef.sql @@ -0,0 +1 @@ +CREATE SETTINGS PROFILE s1_01418 SETTINGS custom_compound.identifier.v2 = 100 diff --git a/tests/queries/0_stateless/03917_explain_ast_json_function.reference b/tests/queries/0_stateless/03917_explain_ast_json_function.reference new file mode 100644 index 000000000000..9665d301dda4 --- /dev/null +++ b/tests/queries/0_stateless/03917_explain_ast_json_function.reference @@ -0,0 +1,12 @@ +-- plain call +{"type":"Function","name":"f","arguments":[{"type":"Identifier","name":"x"},{"type":"Identifier","name":"y"}]} +-- parametric aggregate +{"type":"Function","name":"quantile","arguments":[{"type":"Identifier","name":"x"}],"parameters":[{"type":"Literal","value_type":"Float64","value":0.9}]} +-- windowed via name +{"type":"Function","name":"sum","is_window_function":true,"kind":"WINDOW_FUNCTION","arguments":[{"type":"Identifier","name":"x"}],"window_name":"w"} +-- windowed via inline definition +{"type":"Function","name":"sum","is_window_function":true,"kind":"WINDOW_FUNCTION","arguments":[{"type":"Identifier","name":"x"}],"window_definition":{"type":"WindowDefinition","partition_by":[{"type":"Identifier","name":"y"}]}} +-- operator +{"type":"Function","name":"plus","is_operator":true,"arguments":[{"type":"Identifier","name":"a"},{"type":"Identifier","name":"b"}]} +-- no arguments +{"type":"Function","name":"now","arguments":[]} diff --git a/tests/queries/0_stateless/03917_explain_ast_json_function.sh b/tests/queries/0_stateless/03917_explain_ast_json_function.sh new file mode 100755 index 000000000000..0e5507ff973a --- /dev/null +++ b/tests/queries/0_stateless/03917_explain_ast_json_function.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` exposes ASTFunction sub-nodes through named slots +# (`arguments`, `parameters`, `window_definition`) instead of a positional +# `children` array. Print the Function nodes with jq to keep the references +# focused on the relevant subtree. + +explain_function() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" \ + | jq -c '.. | objects | select(.type == "Function")' +} + +echo "-- plain call" +explain_function "SELECT f(x, y)" + +echo "-- parametric aggregate" +explain_function "SELECT quantile(0.9)(x)" + +echo "-- windowed via name" +explain_function "SELECT sum(x) OVER w FROM t WINDOW w AS (PARTITION BY y)" + +echo "-- windowed via inline definition" +explain_function "SELECT sum(x) OVER (PARTITION BY y) FROM t" + +echo "-- operator" +explain_function "SELECT a + b" + +echo "-- no arguments" +explain_function "SELECT now()" diff --git a/tests/queries/0_stateless/03918_explain_ast_json_order_by.reference b/tests/queries/0_stateless/03918_explain_ast_json_order_by.reference new file mode 100644 index 000000000000..9a067c3802be --- /dev/null +++ b/tests/queries/0_stateless/03918_explain_ast_json_order_by.reference @@ -0,0 +1,6 @@ +-- direction and explicit nulls +{"type":"OrderByElement","expression":{"type":"Identifier","name":"a"},"direction":"DESC","nulls_first":true} +-- collation +{"type":"OrderByElement","expression":{"type":"Identifier","name":"b"},"direction":"ASC","collation":{"type":"Literal","value_type":"String","value":"en"}} +-- with fill bounds +{"type":"OrderByElement","expression":{"type":"Identifier","name":"c"},"direction":"ASC","with_fill":true,"fill_from":{"type":"Literal","value_type":"UInt64","value":"1"},"fill_to":{"type":"Literal","value_type":"UInt64","value":"10"},"fill_step":{"type":"Literal","value_type":"UInt64","value":"2"}} diff --git a/tests/queries/0_stateless/03918_explain_ast_json_order_by.sh b/tests/queries/0_stateless/03918_explain_ast_json_order_by.sh new file mode 100755 index 000000000000..04cb7e4147a3 --- /dev/null +++ b/tests/queries/0_stateless/03918_explain_ast_json_order_by.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` exposes ASTOrderByElement sub-nodes through named +# slots (`expression`, `collation`, `fill_from`, `fill_to`, `fill_step`, +# `fill_staleness`) instead of a positional `children` array. + +explain_order_by() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" \ + | jq -c '.. | objects | select(.type == "OrderByElement")' +} + +echo "-- direction and explicit nulls" +explain_order_by "SELECT x FROM t ORDER BY a DESC NULLS FIRST" + +echo "-- collation" +explain_order_by "SELECT x FROM t ORDER BY b ASC COLLATE 'en'" + +echo "-- with fill bounds" +explain_order_by "SELECT x FROM t ORDER BY c WITH FILL FROM 1 TO 10 STEP 2" diff --git a/tests/queries/0_stateless/03919_explain_ast_json_select_query.reference b/tests/queries/0_stateless/03919_explain_ast_json_select_query.reference new file mode 100644 index 000000000000..8322f57ea052 --- /dev/null +++ b/tests/queries/0_stateless/03919_explain_ast_json_select_query.reference @@ -0,0 +1,12 @@ +-- all clauses: slot names present, in order +["type","select","from","prewhere","where","group_by","having","qualify","order_by","settings","limit_by"] +-- minimal +{"type":"SelectQuery","select":[{"type":"Literal","value_type":"UInt64","value":"1"}]} +-- WITH / CTE list +[{"type":"Literal","alias":"x","value_type":"UInt64","value":"1"}] +-- WINDOW list +[{"type":"WindowListElement","name":"w","definition":{"type":"WindowDefinition","partition_by":[{"type":"Identifier","name":"b"}]}}] +-- single-expression clauses are objects, list clauses are arrays +{"where":{"type":"Identifier","name":"w"},"group_by":[{"type":"Identifier","name":"g"}]} +-- LIMIT ... WITH TIES: limit_with_ties flag +{"limit_with_ties":true,"limit":{"type":"Literal","value_type":"UInt64","value":"3"}} diff --git a/tests/queries/0_stateless/03919_explain_ast_json_select_query.sh b/tests/queries/0_stateless/03919_explain_ast_json_select_query.sh new file mode 100755 index 000000000000..e9d7452d7198 --- /dev/null +++ b/tests/queries/0_stateless/03919_explain_ast_json_select_query.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` exposes ASTSelectQuery clauses through named slots +# (`with`, `select`, `tables`, `where`, `group_by`, `order_by`, ...) instead of +# a positional `children` array. List-shaped clauses inline their inner +# `ExpressionList` wrapper. + +select_query() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" \ + | jq -c '.. | objects | select(.type == "SelectQuery") | '"$2" +} + +echo "-- all clauses: slot names present, in order" +select_query "SELECT a FROM t PREWHERE p WHERE w GROUP BY g HAVING h QUALIFY q ORDER BY o LIMIT 5, 10 BY b SETTINGS max_threads = 1" "keys_unsorted" + +echo "-- minimal" +select_query "SELECT 1" "." + +echo "-- WITH / CTE list" +select_query "WITH 1 AS x SELECT x" ".with" + +echo "-- WINDOW list" +select_query "SELECT sum(a) OVER w FROM t WINDOW w AS (PARTITION BY b)" ".window" + +echo "-- single-expression clauses are objects, list clauses are arrays" +select_query "SELECT a FROM t WHERE w GROUP BY g" "{where, group_by}" + +echo "-- LIMIT ... WITH TIES: limit_with_ties flag" +select_query "SELECT x FROM t ORDER BY x DESC LIMIT 3 WITH TIES" "{limit_with_ties, limit}" diff --git a/tests/queries/0_stateless/03920_explain_ast_json_expressions.reference b/tests/queries/0_stateless/03920_explain_ast_json_expressions.reference new file mode 100644 index 000000000000..324bb2c3156b --- /dev/null +++ b/tests/queries/0_stateless/03920_explain_ast_json_expressions.reference @@ -0,0 +1,17 @@ +-- literal value types +[{"value_type":"Array","value":[{"value_type":"UInt64","value":"1"},{"value_type":"UInt64","value":"2"},{"value_type":"UInt64","value":"3"}]},{"value_type":"Tuple","value":[{"value_type":"UInt64","value":"1"},{"value_type":"String","value":"a"}]},{"value_type":"String","value":"k"},{"value_type":"UInt64","value":"1"},{"value_type":"Null","value":null},{"value_type":"Int64","value":"-5"},{"value_type":"Float64","value":1.5},{"value_type":"Bool","value":true},{"value_type":"String","value":"str"}] +-- 64-bit integers are emitted as strings (JS-safe; would lose precision as JSON numbers) +[{"value_type":"UInt64","value":"18446744073709551615"},{"value_type":"Int64","value":"-9223372036854775808"}] +-- nested containers recurse, preserving each element's type +[{"value_type":"Array","value":[{"value_type":"Array","value":[{"value_type":"UInt64","value":"1"},{"value_type":"UInt64","value":"2"}]},{"value_type":"Array","value":[{"value_type":"UInt64","value":"3"}]}]}] +-- lambda function: parameter tuple + body via arguments +{"type":"Function","name":"lambda","is_operator":true,"is_lambda_function":true,"kind":"LAMBDA_FUNCTION","arguments":[{"type":"Function","name":"tuple","is_operator":true,"arguments":[{"type":"Identifier","name":"x"}]},{"type":"Function","name":"plus","is_operator":true,"arguments":[{"type":"Identifier","name":"x"},{"type":"Literal","value_type":"UInt64","value":"1"}]}]} +-- operators normalize to functions +[{"name":"in","is_operator":true,"args":2},{"name":"and","is_operator":true,"args":2},{"name":"greaterOrEquals","is_operator":true,"args":2},{"name":"lessOrEquals","is_operator":true,"args":2},{"name":"not","is_operator":true,"args":1},{"name":"or","is_operator":true,"args":2},{"name":"and","is_operator":true,"args":2},{"name":"arrayElement","is_operator":true,"args":2},{"name":"tupleElement","is_operator":true,"args":2}] +-- CAST forms +[{"name":"CAST","is_operator":null,"args":2},{"name":"CAST","is_operator":true,"args":2}] +-- NULLS action on aggregate +{"name":"first_value","nulls_action":"IGNORE NULLS"} +-- compound identifier and qualified table +{"type":"Identifier","name":"db.tbl.col","name_parts":["db","tbl","col"]} +{"type":"TableIdentifier","name":"tbl","database":"db"} diff --git a/tests/queries/0_stateless/03920_explain_ast_json_expressions.sh b/tests/queries/0_stateless/03920_explain_ast_json_expressions.sh new file mode 100755 index 000000000000..c9c966b0c834 --- /dev/null +++ b/tests/queries/0_stateless/03920_explain_ast_json_expressions.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# Exercise `EXPLAIN AST json = 1` over a variety of expressions: literal value +# types, lambda functions, operators (which the parser normalizes to ordinary +# functions), CAST, the NULLS action, and compound / qualified identifiers. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- literal value types" +ast "SELECT [1, 2, 3], (1, 'a'), map('k', 1), NULL, -5, 1.5, true, 'str'" \ + | jq -c '[.. | objects | select(.type == "Literal") | {value_type, value}]' + +echo "-- 64-bit integers are emitted as strings (JS-safe; would lose precision as JSON numbers)" +ast "SELECT 18446744073709551615, -9223372036854775808" \ + | jq -c '[.. | objects | select(.type == "Literal") | {value_type, value}]' + +echo "-- nested containers recurse, preserving each element's type" +ast "SELECT [[1, 2], [3]]" \ + | jq -c '[.. | objects | select(.type == "Literal") | {value_type, value}]' + +echo "-- lambda function: parameter tuple + body via arguments" +ast "SELECT arrayMap(x -> x + 1, arr)" \ + | jq -c '.. | objects | select(.name == "lambda")' + +echo "-- operators normalize to functions" +ast "SELECT x IN (1, 2), y BETWEEN 1 AND 2, NOT z, a AND b OR c, arr[1], tup.2" \ + | jq -c '[.. | objects | select(.type == "Function") | {name, is_operator, args: (.arguments | length)}]' + +echo "-- CAST forms" +ast "SELECT CAST(x AS Int64), y::String" \ + | jq -c '[.. | objects | select(.name == "CAST") | {name, is_operator, args: (.arguments | length)}]' + +echo "-- NULLS action on aggregate" +ast "SELECT first_value(x) IGNORE NULLS FROM t" \ + | jq -c '.. | objects | select(.name == "first_value") | {name, nulls_action}' + +echo "-- compound identifier and qualified table" +ast "SELECT db.tbl.col FROM db.tbl" \ + | jq -c '.. | objects | select(.type == "Identifier" or .type == "TableIdentifier")' diff --git a/tests/queries/0_stateless/03921_explain_ast_json_union.reference b/tests/queries/0_stateless/03921_explain_ast_json_union.reference new file mode 100644 index 000000000000..6ef7a27bb36f --- /dev/null +++ b/tests/queries/0_stateless/03921_explain_ast_json_union.reference @@ -0,0 +1,8 @@ +-- UNION ALL: default mode, no union_mode field +{"type":"SelectWithUnionQuery","union_mode":null} +-- UNION DISTINCT: explicit mode +{"type":"SelectWithUnionQuery","union_mode":"UNION_DISTINCT"} +-- INTERSECT: operator plus both operand selects +{"operator":"INTERSECT ALL","operands":["SelectQuery","SelectQuery"]} +-- EXCEPT: operator plus both operand selects +{"operator":"EXCEPT ALL","operands":["SelectWithUnionQuery","SelectQuery"]} diff --git a/tests/queries/0_stateless/03921_explain_ast_json_union.sh b/tests/queries/0_stateless/03921_explain_ast_json_union.sh new file mode 100755 index 000000000000..69eb0d0565da --- /dev/null +++ b/tests/queries/0_stateless/03921_explain_ast_json_union.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` for set operations. `ASTSelectWithUnionQuery` reports a +# non-default `union_mode`; `ASTSelectIntersectExceptQuery` derives from +# `ASTSelectQuery` but keeps its operand selects in `children`, so they must +# still be emitted (regression guard) alongside its `operator`. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- UNION ALL: default mode, no union_mode field" +ast "SELECT 1 UNION ALL SELECT 2" \ + | jq -c '.. | objects | select(.type == "SelectWithUnionQuery") | {type, union_mode}' + +echo "-- UNION DISTINCT: explicit mode" +ast "SELECT 1 UNION DISTINCT SELECT 2" \ + | jq -c '.. | objects | select(.type == "SelectWithUnionQuery") | {type, union_mode}' + +echo "-- INTERSECT: operator plus both operand selects" +ast "SELECT 1 INTERSECT SELECT 2" \ + | jq -c '.. | objects | select(.type == "SelectIntersectExceptQuery") | {operator, operands: [.selects[].type]}' + +echo "-- EXCEPT: operator plus both operand selects" +ast "SELECT 1 EXCEPT SELECT 2" \ + | jq -c '.. | objects | select(.type == "SelectIntersectExceptQuery") | {operator, operands: [.selects[].type]}' diff --git a/tests/queries/0_stateless/03922_explain_ast_json_showcase.reference b/tests/queries/0_stateless/03922_explain_ast_json_showcase.reference new file mode 100644 index 000000000000..c43f88548304 --- /dev/null +++ b/tests/queries/0_stateless/03922_explain_ast_json_showcase.reference @@ -0,0 +1,682 @@ +{ + "version": 2, + "ast": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "distinct": true, + "group_by_with_rollup": true, + "with": [ + { + "type": "WithElement", + "name": "recent", + "subquery": { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "alias": "n", + "name": "number" + }, + { + "type": "Function", + "alias": "g", + "name": "modulo", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "3" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "table_function": { + "type": "Function", + "name": "numbers", + "arguments": [ + { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + } + ] + } + } + } + ] + }, + "where": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "number" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ] + } + } + }, + { + "type": "Subquery", + "alias": "max_n", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Function", + "name": "max", + "arguments": [ + { + "type": "Identifier", + "name": "n" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recent" + } + } + } + ] + } + } + ] + } + } + ], + "select": [ + { + "type": "Identifier", + "alias": "grp", + "name": "a.g", + "name_parts": ["a", "g"] + }, + { + "type": "Function", + "alias": "total", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Identifier", + "name": "b.v", + "name_parts": ["b", "v"] + } + ] + }, + { + "type": "Function", + "alias": "scaled", + "name": "arrayMap", + "arguments": [ + { + "type": "Function", + "name": "lambda", + "is_operator": true, + "is_lambda_function": true, + "kind": "LAMBDA_FUNCTION", + "arguments": [ + { + "type": "Function", + "name": "tuple", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e" + } + ] + }, + { + "type": "Function", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "e" + }, + { + "type": "Identifier", + "name": "max_n" + } + ] + } + ] + }, + { + "type": "Function", + "name": "groupArray", + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + } + ] + } + ] + }, + { + "type": "Function", + "alias": "running", + "name": "sum", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Identifier", + "name": "b.v", + "name_parts": ["b", "v"] + } + ], + "window_definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "a.g", + "name_parts": ["a", "g"] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + "direction": "ASC" + } + ], + "frame_type": "ROWS", + "frame_begin": { + "type": "Offset", + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + }, + "preceding": true + }, + "frame_end": { + "type": "Current" + } + } + }, + { + "type": "Function", + "alias": "cnt", + "name": "count", + "is_window_function": true, + "kind": "WINDOW_FUNCTION", + "arguments": [ + { + "type": "Asterisk" + } + ], + "window_name": "w" + }, + { + "type": "Function", + "alias": "bucket", + "name": "multiIf", + "arguments": [ + { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + { + "type": "Literal", + "value_type": "String", + "value": "hi" + }, + { + "type": "Literal", + "value_type": "String", + "value": "lo" + } + ] + }, + { + "type": "Function", + "alias": "nf", + "name": "CAST", + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Literal", + "value_type": "String", + "value": "Float64" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "alias": "a", + "name": "recent" + } + } + }, + { + "type": "TablesInSelectQueryElement", + "table_join": { + "type": "TableJoin", + "kind": "INNER", + "on": { + "type": "Function", + "name": "equals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Identifier", + "name": "b.n", + "name_parts": ["b", "n"] + } + ] + } + }, + "table_expression": { + "type": "TableExpression", + "subquery": { + "type": "Subquery", + "alias": "b", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Function", + "alias": "v", + "name": "multiply", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "n" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "2" + } + ] + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recent" + } + } + } + ] + } + } + ] + } + } + } + } + ] + }, + "prewhere": { + "type": "Function", + "name": "notEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "where": { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "in", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + { + "type": "Subquery", + "query": { + "type": "SelectWithUnionQuery", + "selects": [ + { + "type": "SelectQuery", + "select": [ + { + "type": "Identifier", + "name": "n" + } + ], + "from": { + "type": "TablesInSelectQuery", + "children": [ + { + "type": "TablesInSelectQueryElement", + "table_expression": { + "type": "TableExpression", + "database_and_table_name": { + "type": "TableIdentifier", + "name": "recent" + } + } + } + ] + } + } + ] + } + } + ] + }, + { + "type": "Function", + "name": "and", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b.v", + "name_parts": ["b", "v"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + }, + { + "type": "Function", + "name": "lessOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "b.v", + "name_parts": ["b", "v"] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1000" + } + ] + } + ] + } + ] + }, + "group_by": [ + { + "type": "Identifier", + "name": "a.g", + "name_parts": ["a", "g"] + }, + { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + } + ], + "having": { + "type": "Function", + "name": "greater", + "is_operator": true, + "arguments": [ + { + "type": "Function", + "name": "sum", + "arguments": [ + { + "type": "Identifier", + "name": "b.v", + "name_parts": ["b", "v"] + } + ] + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + ] + }, + "window": [ + { + "type": "WindowListElement", + "name": "w", + "definition": { + "type": "WindowDefinition", + "partition_by": [ + { + "type": "Identifier", + "name": "a.g", + "name_parts": ["a", "g"] + } + ], + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "a.n", + "name_parts": ["a", "n"] + }, + "direction": "DESC" + } + ] + } + } + ], + "qualify": { + "type": "Function", + "name": "greaterOrEquals", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "running" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + } + ] + }, + "order_by": [ + { + "type": "OrderByElement", + "expression": { + "type": "Identifier", + "name": "total" + }, + "direction": "DESC", + "nulls_first": false, + "with_fill": true, + "fill_from": { + "type": "Literal", + "value_type": "UInt64", + "value": "0" + }, + "fill_to": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + "fill_step": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + } + } + ], + "offset": { + "type": "Literal", + "value_type": "UInt64", + "value": "10" + }, + "limit": { + "type": "Literal", + "value_type": "UInt64", + "value": "100" + }, + "settings": { + "type": "Settings", + "changes": { + "max_threads": "4", + "max_block_size": "1000" + } + }, + "interpolate": [ + { + "type": "InterpolateElement", + "column": "nf", + "expr": { + "type": "Function", + "name": "plus", + "is_operator": true, + "arguments": [ + { + "type": "Identifier", + "name": "nf" + }, + { + "type": "Literal", + "value_type": "UInt64", + "value": "1" + } + ] + } + } + ], + "limit_by": { + "length": { + "type": "Literal", + "value_type": "UInt64", + "value": "5" + }, + "by": [ + { + "type": "Identifier", + "name": "a.g", + "name_parts": ["a", "g"] + } + ] + } + } + ] + } +} diff --git a/tests/queries/0_stateless/03922_explain_ast_json_showcase.sh b/tests/queries/0_stateless/03922_explain_ast_json_showcase.sh new file mode 100755 index 000000000000..75c988f72f02 --- /dev/null +++ b/tests/queries/0_stateless/03922_explain_ast_json_showcase.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# A runnable showcase of `EXPLAIN AST json = 1`: one deeply nested query that +# exercises most of the named slots and node types at once, dumped in full +# (no node filtering). The query only needs to parse, not run. +# +# Clauses / constructs covered: +# - WITH: a named CTE and a scalar subquery binding +# - DISTINCT select with aliases +# - lambda (arrayMap), window function with inline definition and named +# window, COUNT(*), CASE, CAST +# - FROM with an INNER JOIN over a subquery, PREWHERE, WHERE with IN +# (subquery) and BETWEEN +# - GROUP BY ... WITH ROLLUP, HAVING, WINDOW, QUALIFY +# - ORDER BY ... DESC NULLS LAST WITH FILL ... INTERPOLATE +# - LIMIT BY, LIMIT ... OFFSET, SETTINGS + +read -r -d '' QUERY <<'SQL' +WITH + recent AS (SELECT number AS n, number % 3 AS g FROM numbers(100) WHERE number > 1), + (SELECT max(n) FROM recent) AS max_n +SELECT DISTINCT + a.g AS grp, + a.n + b.v AS total, + arrayMap(e -> e * max_n, groupArray(a.n)) AS scaled, + sum(b.v) OVER (PARTITION BY a.g ORDER BY a.n ROWS BETWEEN 1 PRECEDING AND CURRENT ROW) AS running, + count(*) OVER w AS cnt, + CASE WHEN a.n > 10 THEN 'hi' ELSE 'lo' END AS bucket, + CAST(a.n AS Float64) AS nf +FROM recent AS a +INNER JOIN (SELECT n, n * 2 AS v FROM recent) AS b ON a.n = b.n +PREWHERE a.n != 0 +WHERE a.n IN (SELECT n FROM recent) AND b.v BETWEEN 1 AND 1000 +GROUP BY a.g, a.n WITH ROLLUP +HAVING sum(b.v) > 10 +WINDOW w AS (PARTITION BY a.g ORDER BY a.n DESC) +QUALIFY running >= 0 +ORDER BY total DESC NULLS LAST WITH FILL FROM 0 TO 100 STEP 10 INTERPOLATE (nf AS nf + 1) +LIMIT 5 BY a.g +LIMIT 100 OFFSET 10 +SETTINGS max_threads = 4, max_block_size = 1000 +SQL + +$CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $QUERY" diff --git a/tests/queries/0_stateless/03923_explain_ast_json_wrappers.reference b/tests/queries/0_stateless/03923_explain_ast_json_wrappers.reference new file mode 100644 index 000000000000..d951cdfe1d12 --- /dev/null +++ b/tests/queries/0_stateless/03923_explain_ast_json_wrappers.reference @@ -0,0 +1,25 @@ +-- INNER JOIN ... ON +{"type":"TableJoin","kind":"INNER","on":{"type":"Function","name":"equals","is_operator":true,"arguments":[{"type":"Identifier","name":"a.x","name_parts":["a","x"]},{"type":"Identifier","name":"b.x","name_parts":["b","x"]}]}} +-- LEFT JOIN ... USING +{"type":"TableJoin","kind":"LEFT","using":[{"type":"Identifier","name":"x"},{"type":"Identifier","name":"y"}]} +-- GLOBAL ANY join: strictness and locality +{"kind":"INNER","strictness":"ANY","locality":"GLOBAL"} +-- CROSS and COMMA joins +"CROSS" +["COMMA"] +-- LEFT ARRAY JOIN +{"type":"ArrayJoin","kind":"LEFT","expressions":[{"type":"Identifier","alias":"e","name":"arr"},{"type":"Identifier","name":"other"}]} +-- table function +{"type":"TableExpression","table_function":{"type":"Function","name":"numbers","arguments":[{"type":"Literal","value_type":"UInt64","value":"5"}]}} +-- subquery in FROM: collapsed wrapper chain +{"type":"TableExpression","subquery":{"type":"Subquery","query":{"type":"SelectWithUnionQuery","selects":[{"type":"SelectQuery","select":[{"type":"Literal","value_type":"UInt64","value":"1"}]}]}}} +-- table with FINAL and SAMPLE +{"database_and_table_name":"TableIdentifier","final":true,"sample_size":"SampleRatio"} +-- WITH element (named CTE): subquery collapses to query.selects +{"name":"cte","query_select":[{"type":"SelectQuery","select":[{"type":"Literal","alias":"a","value_type":"UInt64","value":"1"}]}]} +-- window definition with a RANGE frame +{"type":"WindowDefinition","partition_by":[{"type":"Identifier","name":"g"}],"order_by":[{"type":"OrderByElement","expression":{"type":"Identifier","name":"b"},"direction":"ASC"}],"frame_type":"RANGE","frame_begin":{"type":"Unbounded","preceding":true},"frame_end":{"type":"Unbounded"}} +-- UNION: selects inlined (no ExpressionList wrapper) +["SelectQuery","SelectQuery"] +-- INTERPOLATE element +{"type":"InterpolateElement","column":"y","expr":{"type":"Function","name":"plus","is_operator":true,"arguments":[{"type":"Identifier","name":"y"},{"type":"Literal","value_type":"UInt64","value":"1"}]}} diff --git a/tests/queries/0_stateless/03923_explain_ast_json_wrappers.sh b/tests/queries/0_stateless/03923_explain_ast_json_wrappers.sh new file mode 100755 index 000000000000..7f0b43bbf7a1 --- /dev/null +++ b/tests/queries/0_stateless/03923_explain_ast_json_wrappers.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` exposes the structural wrapper nodes through named +# slots too: table expressions, joins, array joins, subqueries, WITH elements, +# window definitions, and interpolate elements. `children` is left only on the +# homogeneous lists (ExpressionList, TablesInSelectQuery). + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- INNER JOIN ... ON" +ast "SELECT * FROM a INNER JOIN b ON a.x = b.x" | jq -c '.. | objects | select(.type == "TableJoin")' + +echo "-- LEFT JOIN ... USING" +ast "SELECT * FROM a LEFT JOIN b USING (x, y)" | jq -c '.. | objects | select(.type == "TableJoin")' + +echo "-- GLOBAL ANY join: strictness and locality" +ast "SELECT * FROM a GLOBAL ANY INNER JOIN b ON a.x = b.x" | jq -c '.. | objects | select(.type == "TableJoin") | {kind, strictness, locality}' + +echo "-- CROSS and COMMA joins" +ast "SELECT * FROM a CROSS JOIN b" | jq -c '.. | objects | select(.type == "TableJoin") | .kind' +ast "SELECT * FROM a, b" | jq -c '[.. | objects | select(.type == "TableJoin") | .kind]' + +echo "-- LEFT ARRAY JOIN" +ast "SELECT * FROM t LEFT ARRAY JOIN arr AS e, other" | jq -c '.. | objects | select(.type == "ArrayJoin")' + +echo "-- table function" +ast "SELECT * FROM numbers(5)" | jq -c '.. | objects | select(.type == "TableExpression")' + +echo "-- subquery in FROM: collapsed wrapper chain" +ast "SELECT * FROM (SELECT 1)" | jq -c '.. | objects | select(.type == "TableExpression")' + +echo "-- table with FINAL and SAMPLE" +ast "SELECT * FROM tbl FINAL SAMPLE 0.1" | jq -c '.. | objects | select(.type == "TableExpression") | {database_and_table_name: .database_and_table_name.type, final, sample_size: .sample_size.type}' + +echo "-- WITH element (named CTE): subquery collapses to query.selects" +ast "WITH cte AS (SELECT 1 AS a) SELECT a FROM cte" | jq -c '.. | objects | select(.type == "WithElement") | {name, query_select: .subquery.query.selects}' + +echo "-- window definition with a RANGE frame" +ast "SELECT sum(x) OVER (PARTITION BY g ORDER BY b RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) FROM t" \ + | jq -c '.. | objects | select(.type == "WindowDefinition")' + +echo "-- UNION: selects inlined (no ExpressionList wrapper)" +ast "SELECT 1 UNION ALL SELECT 2" | jq -c '.. | objects | select(.type == "SelectWithUnionQuery") | [.selects[].type]' + +echo "-- INTERPOLATE element" +ast "SELECT x FROM t ORDER BY x WITH FILL INTERPOLATE (y AS y + 1)" | jq -c '.. | objects | select(.type == "InterpolateElement")' diff --git a/tests/queries/0_stateless/03924_explain_ast_json_leaf_state.reference b/tests/queries/0_stateless/03924_explain_ast_json_leaf_state.reference new file mode 100644 index 000000000000..f93bf9775658 --- /dev/null +++ b/tests/queries/0_stateless/03924_explain_ast_json_leaf_state.reference @@ -0,0 +1,19 @@ +-- SETTINGS clause: changes as name -> value +-- SAMPLE ratio +{"type":"SampleRatio","numerator":"1","denominator":"10"} +-- plain asterisk stays empty +{"type":"Asterisk"} +-- asterisk with EXCEPT transformer +{"type":"Asterisk","transformers":[{"type":"ColumnsExceptTransformer","columns":[{"type":"Identifier","name":"a"},{"type":"Identifier","name":"b"}]}]} +-- asterisk with EXCEPT regexp pattern +{"type":"Asterisk","transformers":[{"type":"ColumnsExceptTransformer","pattern":"a.*"}]} +-- asterisk with APPLY transformer +{"type":"ColumnsApplyTransformer","func_name":"sum"} +-- asterisk with REPLACE transformer +{"type":"ColumnsReplaceTransformer::Replacement","name":"y","expression":{"type":"Function","name":"plus","is_operator":true,"arguments":[{"type":"Identifier","name":"x"},{"type":"Literal","value_type":"UInt64","value":"1"}]}} +-- qualified asterisk +{"type":"QualifiedAsterisk","qualifier":{"type":"Identifier","name":"t"}} +-- COLUMNS regexp matcher +{"type":"ColumnsRegexpMatcher","pattern":"a.*"} +-- COLUMNS list matcher +{"type":"ColumnsListMatcher","columns":[{"type":"Identifier","name":"a"},{"type":"Identifier","name":"b"}]} diff --git a/tests/queries/0_stateless/03924_explain_ast_json_leaf_state.sh b/tests/queries/0_stateless/03924_explain_ast_json_leaf_state.sh new file mode 100755 index 000000000000..a68d124f5d09 --- /dev/null +++ b/tests/queries/0_stateless/03924_explain_ast_json_leaf_state.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# Leaf-ish nodes that used to render as a bare `{"type": ...}` now expose their +# internal state: the SETTINGS clause (ASTSetQuery), SAMPLE ratio +# (ASTSampleRatio), asterisks with column transformers, and the COLUMNS +# matchers. `children` is left on the homogeneous column lists. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- SETTINGS clause: changes as name -> value" +ast "SELECT 1 SETTINGS max_threads = 4, max_block_size = 1000" | jq -c '.. | objects | select(.type == "Set")' + +echo "-- SAMPLE ratio" +ast "SELECT * FROM tbl SAMPLE 1/10" | jq -c '.. | objects | select(.type == "SampleRatio")' + +echo "-- plain asterisk stays empty" +ast "SELECT * FROM t" | jq -c '.. | objects | select(.type == "Asterisk")' + +echo "-- asterisk with EXCEPT transformer" +ast "SELECT * EXCEPT (a, b) FROM t" | jq -c '.. | objects | select(.type == "Asterisk")' + +echo "-- asterisk with EXCEPT regexp pattern" +ast "SELECT * EXCEPT 'a.*' FROM t" | jq -c '.. | objects | select(.type == "Asterisk")' + +echo "-- asterisk with APPLY transformer" +ast "SELECT * APPLY(sum) FROM t" | jq -c '.. | objects | select(.type == "ColumnsApplyTransformer")' + +echo "-- asterisk with REPLACE transformer" +ast "SELECT * REPLACE (x + 1 AS y) FROM t" | jq -c '.. | objects | select(.type == "ColumnsReplaceTransformer::Replacement")' + +echo "-- qualified asterisk" +ast "SELECT t.* FROM t" | jq -c '.. | objects | select(.type == "QualifiedAsterisk")' + +echo "-- COLUMNS regexp matcher" +ast "SELECT COLUMNS('a.*') FROM t" | jq -c '.. | objects | select(.type == "ColumnsRegexpMatcher")' + +echo "-- COLUMNS list matcher" +ast "SELECT COLUMNS(a, b) FROM t" | jq -c '.. | objects | select(.type == "ColumnsListMatcher")' diff --git a/tests/queries/0_stateless/03925_explain_ast_json_ddl.reference b/tests/queries/0_stateless/03925_explain_ast_json_ddl.reference new file mode 100644 index 000000000000..1dd5f39ff174 --- /dev/null +++ b/tests/queries/0_stateless/03925_explain_ast_json_ddl.reference @@ -0,0 +1,42 @@ +-- CREATE TABLE: columns, types, defaults, codec, comment +{"type":"ColumnDeclaration","name":"id","data_type":{"type":"DataType","name":"UInt64"}} +{"type":"ColumnDeclaration","name":"s","data_type":{"type":"DataType","name":"String"},"default_specifier":"DEFAULT","default_expression":{"type":"Literal","value_type":"String","value":"x"},"codec":{"type":"Function","name":"CODEC","kind":"CODEC","arguments":[{"type":"Function","name":"ZSTD","arguments":[]}]}} +{"type":"ColumnDeclaration","name":"n","data_type":{"type":"DataType","name":"Decimal","arguments":[{"type":"Literal","value_type":"UInt64","value":"10"},{"type":"Literal","value_type":"UInt64","value":"2"}]},"comment":{"type":"Literal","value_type":"String","value":"c"}} +-- storage +{"type":"Storage","engine":{"type":"Function","name":"MergeTree","kind":"TABLE_ENGINE","arguments":[]},"partition_by":{"type":"Function","name":"toYYYYMM","arguments":[{"type":"Identifier","name":"d"}]},"order_by":{"type":"Identifier","name":"id"},"settings":{"type":"Settings","changes":{"index_granularity":"8192"}}} +-- nested data types +[{"name":"Array","args":1},{"name":"String","args":0},{"name":"Map","args":2},{"name":"String","args":0},{"name":"UInt8","args":0}] +-- CREATE flags and target +{"is_materialized_view":true,"if_not_exists":true,"table":"mv","select":"SelectWithUnionQuery"} +-- CREATE TABLE AS +{"table":"t","as_table":"other"} +-- INSERT ... SELECT +{"table":"t","columns":["a","b"],"select":"SelectWithUnionQuery"} +-- INSERT ... VALUES +{"database":"db","table":"t"} +-- ATTACH: if_not_exists, uuid, cluster +{"attach":true,"if_not_exists":true,"uuid":"00000000-0000-0000-0000-000000000abc","cluster":"c","table":"t"} +-- ATTACH ... FROM path +{"attach":true,"attach_from_path":"/var/lib/p","table":"t"} +-- ATTACH ... AS NOT REPLICATED conversion marker +{"attach":true,"attach_as_replicated":false,"table":"t"} +-- Enum data type: explicit value pairs +{"type":"EnumDataType","name":"Enum8","values":[{"name":"a","value":1},{"name":"b","value":2}]} +-- Tuple data type: named element names +{"type":"TupleDataType","name":"Tuple","arguments":[{"type":"DataType","name":"UInt8"},{"type":"DataType","name":"String"}],"element_names":["a","b"]} +-- Tuple data type: unnamed (no element_names) +{"type":"TupleDataType","name":"Tuple","arguments":[{"type":"DataType","name":"UInt8"},{"type":"DataType","name":"String"}]} +-- column COLLATE +{"type":"Collation","name":"binary"} +-- JSON typed path / skip / parameter arguments +{"type":"ObjectTypeArgument","path_with_type":{"type":"ObjectTypedPath","name":"a.b","data_type":{"type":"DataType","name":"UInt32"}}} +{"type":"ObjectTypedPath","name":"a.b","data_type":{"type":"DataType","name":"UInt32"}} +{"type":"ObjectTypeArgument","skip_path":{"type":"Identifier","name":"x"}} +{"type":"ObjectTypeArgument","skip_path_regexp":{"type":"Literal","value_type":"String","value":"y.*"}} +{"type":"ObjectTypeArgument","parameter":{"type":"Function","name":"equals","is_operator":true,"arguments":[{"type":"Identifier","name":"max_dynamic_paths"},{"type":"Literal","value_type":"UInt64","value":"8"}]}} +-- refreshable materialized view +{"type":"RefreshStrategy","schedule_kind":"EVERY","append":true,"period":{"type":"TimeInterval","interval":[{"kind":"Day","value":"1"}]},"offset":{"type":"TimeInterval","interval":[{"kind":"Hour","value":"1"}]}} +{"type":"TimeInterval","interval":[{"kind":"Day","value":"1"}]} +{"type":"TimeInterval","interval":[{"kind":"Hour","value":"1"}]} +-- INSERT FROM INFILE ... COMPRESSION +{"table":"t","infile":"data.csv","compression":"gzip","format":"CSV"} diff --git a/tests/queries/0_stateless/03925_explain_ast_json_ddl.sh b/tests/queries/0_stateless/03925_explain_ast_json_ddl.sh new file mode 100755 index 000000000000..99ca7926bfa5 --- /dev/null +++ b/tests/queries/0_stateless/03925_explain_ast_json_ddl.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` named slots for the CREATE-TABLE family and INSERT: +# ASTCreateQuery, ASTColumns, ASTColumnDeclaration, ASTDataType, ASTStorage, +# ASTInsertQuery. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- CREATE TABLE: columns, types, defaults, codec, comment" +ast "CREATE TABLE db.t (id UInt64, s String DEFAULT 'x' CODEC(ZSTD), n Decimal(10, 2) COMMENT 'c') ENGINE = MergeTree ORDER BY id" \ + | jq -c '.. | objects | select(.type == "ColumnDeclaration")' + +echo "-- storage" +ast "CREATE TABLE t (id UInt64) ENGINE = MergeTree PARTITION BY toYYYYMM(d) ORDER BY id SETTINGS index_granularity = 8192" \ + | jq -c '.. | objects | select(.type == "Storage")' + +echo "-- nested data types" +ast "CREATE TABLE t (a Array(String), m Map(String, UInt8))" \ + | jq -c '[.. | objects | select(.type == "DataType") | {name, args: (.arguments | length)}]' + +echo "-- CREATE flags and target" +ast "CREATE MATERIALIZED VIEW IF NOT EXISTS mv ENGINE = Log AS SELECT * FROM src" \ + | jq -c '.. | objects | select(.type == "CreateQuery") | {is_materialized_view, if_not_exists, table: .table.name, select: .select.type}' + +echo "-- CREATE TABLE AS" +ast "CREATE TABLE t AS other" \ + | jq -c '.. | objects | select(.type == "CreateQuery") | {table: .table.name, as_table}' + +echo "-- INSERT ... SELECT" +ast "INSERT INTO t (a, b) SELECT 1, 2" \ + | jq -c '.. | objects | select(.type == "InsertQuery") | {table: .table.name, columns: [.columns[].name], select: .select.type}' + +echo "-- INSERT ... VALUES" +ast "INSERT INTO db.t VALUES (1, 2)" \ + | jq -c '.. | objects | select(.type == "InsertQuery") | {database: .database.name, table: .table.name}' + +echo "-- ATTACH: if_not_exists, uuid, cluster" +ast "ATTACH TABLE IF NOT EXISTS db.t UUID '00000000-0000-0000-0000-000000000abc' ON CLUSTER 'c'" \ + | jq -c '.. | objects | select(.type == "AttachQuery") | {attach, if_not_exists, uuid, cluster, table: .table.name}' + +echo "-- ATTACH ... FROM path" +ast "ATTACH TABLE db.t FROM '/var/lib/p'" \ + | jq -c '.. | objects | select(.type == "AttachQuery") | {attach, attach_from_path, table: .table.name}' + +echo "-- ATTACH ... AS NOT REPLICATED conversion marker" +ast "ATTACH TABLE db.t AS NOT REPLICATED" \ + | jq -c '.. | objects | select(.type == "AttachQuery") | {attach, attach_as_replicated, table: .table.name}' + +echo "-- Enum data type: explicit value pairs" +ast "CREATE TABLE t (e Enum8('a' = 1, 'b' = 2)) ENGINE = Memory" \ + | jq -c '.. | objects | select(.type == "EnumDataType")' + +echo "-- Tuple data type: named element names" +ast "CREATE TABLE t (x Tuple(a UInt8, b String)) ENGINE = Memory" \ + | jq -c '.. | objects | select(.type == "TupleDataType")' + +echo "-- Tuple data type: unnamed (no element_names)" +ast "CREATE TABLE t (x Tuple(UInt8, String)) ENGINE = Memory" \ + | jq -c '.. | objects | select(.type == "TupleDataType")' + +echo "-- column COLLATE" +ast "CREATE TABLE t (s String COLLATE binary) ENGINE = Memory" \ + | jq -c '.. | objects | select(.type == "Collation")' + +echo "-- JSON typed path / skip / parameter arguments" +ast "CREATE TABLE t (j JSON(a.b UInt32, SKIP x, SKIP REGEXP 'y.*', max_dynamic_paths = 8)) ENGINE = Memory" \ + | jq -c '.. | objects | select(.type == "ObjectTypeArgument" or .type == "ObjectTypedPath")' + +echo "-- refreshable materialized view" +ast "CREATE MATERIALIZED VIEW mv REFRESH EVERY 1 DAY OFFSET 1 HOUR APPEND (a UInt64) ENGINE = Memory AS SELECT 1 AS a" \ + | jq -c '.. | objects | select(.type == "RefreshStrategy" or .type == "TimeInterval")' + +echo "-- INSERT FROM INFILE ... COMPRESSION" +ast "INSERT INTO t FROM INFILE 'data.csv' COMPRESSION 'gzip' FORMAT CSV" \ + | jq -c '.. | objects | select(.type == "InsertQuery") | {table: .table.name, infile: .infile.value, compression: .compression.value, format}' diff --git a/tests/queries/0_stateless/03926_explain_ast_json_ddl_elements.reference b/tests/queries/0_stateless/03926_explain_ast_json_ddl_elements.reference new file mode 100644 index 000000000000..a9c38fbf78d2 --- /dev/null +++ b/tests/queries/0_stateless/03926_explain_ast_json_ddl_elements.reference @@ -0,0 +1,26 @@ +-- INDEX declaration +{"type":"Index","name":"idx","expression":{"type":"Identifier","name":"a"},"index_type":{"type":"Function","name":"minmax","arguments":[]},"granularity":4} +-- CONSTRAINT declaration +{"name":"c","constraint_type":"CHECK","expr":"greater"} +-- PROJECTION declaration +{"type":"ProjectionSelectQuery","select":[{"type":"Identifier","name":"a"}],"group_by":[{"type":"Identifier","name":"a"}]} +-- PROJECTION INDEX ... TYPE ... WITH SETTINGS +{"name":"p","index":"a","index_type":"minmax","settings":{"x":"1"}} +-- TTL DELETE +{"type":"TTLElement","mode":"DELETE","ttl":{"type":"Function","name":"plus","is_operator":true,"arguments":[{"type":"Identifier","name":"d"},{"type":"Function","name":"toIntervalDay","arguments":[{"type":"Literal","value_type":"UInt64","value":"1"}]}]}} +-- TTL MOVE TO DISK +{"mode":"MOVE","destination_type":"DISK","destination_name":"cold"} +-- TTL GROUP BY ... SET ... +{"mode":"GROUP_BY","group_by_key":["k"],"assignments":["a"]} +-- DELETE +{"table":"t","predicate":"greater"} +-- UPDATE with assignments +{"table":"t","assignments":["a","b"]} +-- DROP with flags +{"kind":"DROP","database":"db","table":"t","if_exists":true,"sync":true} +-- TRUNCATE (drop kind) +{"kind":"TRUNCATE","table":"t"} +-- TRUNCATE ALL TABLES FROM (with LIKE pattern) +{"kind":"TRUNCATE","database":"db","has_all":true,"has_tables":true,"like":"foo%","not_like":true,"case_insensitive_like":true} +-- OPTIMIZE with partition +{"table":"t","partition":"Partition","final":true,"deduplicate":true} diff --git a/tests/queries/0_stateless/03926_explain_ast_json_ddl_elements.sh b/tests/queries/0_stateless/03926_explain_ast_json_ddl_elements.sh new file mode 100755 index 000000000000..4276a4bc1826 --- /dev/null +++ b/tests/queries/0_stateless/03926_explain_ast_json_ddl_elements.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` named slots for CREATE-TABLE sub-elements (Index, +# Constraint, Projection, ProjectionSelectQuery, TTLElement, Partition) and the +# lightweight DML / table-op statements (DELETE, UPDATE, DROP, OPTIMIZE, +# TRUNCATE, Assignment). + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- INDEX declaration" +ast "CREATE TABLE t (a UInt64, INDEX idx a TYPE minmax GRANULARITY 4) ENGINE = MergeTree ORDER BY a" \ + | jq -c '.. | objects | select(.type == "Index")' + +echo "-- CONSTRAINT declaration" +ast "CREATE TABLE t (a UInt64, CONSTRAINT c CHECK a > 0) ENGINE = MergeTree ORDER BY a" \ + | jq -c '.. | objects | select(.type == "Constraint") | {name, constraint_type, expr: .expression.name}' + +echo "-- PROJECTION declaration" +ast "CREATE TABLE t (a UInt64, b String, PROJECTION p (SELECT a GROUP BY a)) ENGINE = MergeTree ORDER BY a" \ + | jq -c '.. | objects | select(.type == "ProjectionSelectQuery")' + +echo "-- PROJECTION INDEX ... TYPE ... WITH SETTINGS" +ast "ALTER TABLE t ADD PROJECTION p INDEX a TYPE minmax WITH SETTINGS (x = 1)" \ + | jq -c '.. | objects | select(.type == "Projection") | {name, index: .index.name, index_type: .index_type.name, settings: .settings.changes}' + +echo "-- TTL DELETE" +ast "CREATE TABLE t (a UInt64, d Date) ENGINE = MergeTree ORDER BY a TTL d + INTERVAL 1 DAY" \ + | jq -c '.. | objects | select(.type == "TTLElement")' + +echo "-- TTL MOVE TO DISK" +ast "ALTER TABLE t MODIFY TTL d + INTERVAL 1 MONTH TO DISK 'cold'" \ + | jq -c '.. | objects | select(.type == "TTLElement") | {mode, destination_type, destination_name}' + +echo "-- TTL GROUP BY ... SET ..." +ast "CREATE TABLE t (a UInt64, k UInt64, d Date) ENGINE = MergeTree ORDER BY (k, a) TTL d + INTERVAL 1 MONTH GROUP BY k SET a = max(a)" \ + | jq -c '.. | objects | select(.type == "TTLElement") | {mode, group_by_key: [.group_by_key[].name], assignments: [.group_by_assignments[].column]}' + +echo "-- DELETE" +ast "DELETE FROM t WHERE x > 1" \ + | jq -c '.. | objects | select(.type == "DeleteQuery") | {table: .table.name, predicate: .predicate.name}' + +echo "-- UPDATE with assignments" +ast "UPDATE t SET a = 1, b = b + 1 WHERE c > 0" \ + | jq -c '.. | objects | select(.type == "UpdateQuery") | {table: .table.name, assignments: [.assignments[].column]}' + +echo "-- DROP with flags" +ast "DROP TABLE IF EXISTS db.t SYNC" \ + | jq -c '.. | objects | select(.type == "DropQuery") | {kind, database: .database.name, table: .table.name, if_exists, sync}' + +echo "-- TRUNCATE (drop kind)" +ast "TRUNCATE TABLE t" \ + | jq -c '.. | objects | select(.type == "TruncateQuery") | {kind, table: .table.name}' + +echo "-- TRUNCATE ALL TABLES FROM (with LIKE pattern)" +ast "TRUNCATE ALL TABLES FROM db NOT ILIKE 'foo%'" \ + | jq -c '.. | objects | select(.type == "TruncateQuery") | {kind, database: .database.name, has_all, has_tables, like, not_like, case_insensitive_like}' + +echo "-- OPTIMIZE with partition" +ast "OPTIMIZE TABLE t PARTITION 7 FINAL DEDUPLICATE" \ + | jq -c '.. | objects | select(.type == "OptimizeQuery") | {table: .table.name, partition: .partition.type, final, deduplicate}' diff --git a/tests/queries/0_stateless/03927_explain_ast_json_alter_dict.reference b/tests/queries/0_stateless/03927_explain_ast_json_alter_dict.reference new file mode 100644 index 000000000000..6b3d5c74f589 --- /dev/null +++ b/tests/queries/0_stateless/03927_explain_ast_json_alter_dict.reference @@ -0,0 +1,33 @@ +-- ALTER multi-command: command types and key slots +{"command_type":"ADD_COLUMN","col":"x","rename_to":null} +{"command_type":"DROP_COLUMN","col":"z","rename_to":null} +{"command_type":"ADD_INDEX","col":null,"rename_to":null} +{"command_type":"RENAME_COLUMN","col":"p","rename_to":"q"} +-- ALTER UPDATE +{"command_type":"UPDATE","assignments":["a"],"predicate":"equals"} +-- ALTER MOVE PARTITION +{"command_type":"MOVE_PARTITION","partition":"Partition","move_destination_type":"DISK","move_destination_name":"cold"} +-- ALTER CLEAR STATISTICS (clear_statistics distinguishes it from DROP STATISTICS) +{"command_type":"DROP_STATISTICS","clear_statistics":true} +-- ALTER FREEZE PARTITION WITH NAME +{"command_type":"FREEZE_PARTITION","with_name":"backup1"} +-- ALTER REPLACE vs ATTACH PARTITION FROM (same command_type, differ by replace) +{"command_type":"REPLACE_PARTITION","replace":true,"from_table":"src"} +{"command_type":"REPLACE_PARTITION","replace":false,"from_table":"src"} +-- ALTER UNLOCK SNAPSHOT +{"command_type":"UNLOCK_SNAPSHOT","snapshot_name":"snap"} +-- AlterQuery wrapper +{"alter_object":"TABLE","table":"t","commands":["DROP_COLUMN"]} +-- CREATE FUNCTION +{"name":"lin","core":"lambda"} +-- CREATE FUNCTION ON CLUSTER +{"if_not_exists":true,"cluster":"c","name":"lin"} +-- DROP FUNCTION +{"function_name":"lin","if_exists":true,"cluster":"c"} +-- CREATE DICTIONARY: attributes +{"name":"id","data_type":"UInt64","hierarchical":null} +{"name":"val","data_type":"String","hierarchical":true} +-- CREATE DICTIONARY: source (key-value), layout, lifetime +{"name":"clickhouse","elements":[{"key":"table","value":"t"}]} +-- dictionary sub-elements get distinct type ids (not all 'Dictionary') +["DictionaryAttributeDeclaration","Dictionary","DictionaryLifetime","DictionaryLayout","DictionaryRange"] diff --git a/tests/queries/0_stateless/03927_explain_ast_json_alter_dict.sh b/tests/queries/0_stateless/03927_explain_ast_json_alter_dict.sh new file mode 100755 index 000000000000..ec8956d6c29a --- /dev/null +++ b/tests/queries/0_stateless/03927_explain_ast_json_alter_dict.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` named slots for the ALTER family (ASTAlterQuery / +# ASTAlterCommand) and the dictionary / CREATE FUNCTION nodes. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- ALTER multi-command: command types and key slots" +ast "ALTER TABLE db.t ADD COLUMN x UInt8 AFTER y, DROP COLUMN z, ADD INDEX idx a TYPE minmax GRANULARITY 1, RENAME COLUMN p TO q" \ + | jq -c '.. | objects | select(.type == "AlterCommand") | {command_type, col: (.column_declaration.name // .column.name), rename_to: .rename_to.name}' + +echo "-- ALTER UPDATE" +ast "ALTER TABLE t UPDATE a = 1 WHERE b = 2" \ + | jq -c '.. | objects | select(.type == "AlterCommand") | {command_type, assignments: [.assignments[].column], predicate: .predicate.name}' + +echo "-- ALTER MOVE PARTITION" +ast "ALTER TABLE t MOVE PARTITION 1 TO DISK 'cold'" \ + | jq -c '.. | objects | select(.type == "AlterCommand") | {command_type, partition: .partition.type, move_destination_type, move_destination_name}' + +echo "-- ALTER CLEAR STATISTICS (clear_statistics distinguishes it from DROP STATISTICS)" +ast "ALTER TABLE t CLEAR STATISTICS s" \ + | jq -c '.. | objects | select(.type == "AlterCommand") | {command_type, clear_statistics}' + +echo "-- ALTER FREEZE PARTITION WITH NAME" +ast "ALTER TABLE t FREEZE PARTITION 1 WITH NAME 'backup1'" \ + | jq -c '.. | objects | select(.type == "AlterCommand") | {command_type, with_name}' + +echo "-- ALTER REPLACE vs ATTACH PARTITION FROM (same command_type, differ by replace)" +ast "ALTER TABLE t REPLACE PARTITION 1 FROM src" \ + | jq -c '.. | objects | select(.type == "AlterCommand") | {command_type, replace, from_table}' +ast "ALTER TABLE t ATTACH PARTITION 1 FROM src" \ + | jq -c '.. | objects | select(.type == "AlterCommand") | {command_type, replace, from_table}' + +echo "-- ALTER UNLOCK SNAPSHOT" +ast "ALTER TABLE t UNLOCK SNAPSHOT 'snap'" \ + | jq -c '.. | objects | select(.type == "AlterCommand") | {command_type, snapshot_name}' + +echo "-- AlterQuery wrapper" +ast "ALTER TABLE t DROP COLUMN c" \ + | jq -c '.. | objects | select(.type == "AlterQuery") | {alter_object, table: .table.name, commands: [.commands[].command_type]}' + +echo "-- CREATE FUNCTION" +ast "CREATE FUNCTION lin AS (x, k, b) -> k * x + b" \ + | jq -c '.. | objects | select(.type == "CreateFunctionQuery") | {name: .function_name.name, core: .function_core.name}' + +echo "-- CREATE FUNCTION ON CLUSTER" +ast "CREATE FUNCTION IF NOT EXISTS lin ON CLUSTER 'c' AS (x) -> x" \ + | jq -c '.. | objects | select(.type == "CreateFunctionQuery") | {if_not_exists, cluster, name: .function_name.name}' + +echo "-- DROP FUNCTION" +ast "DROP FUNCTION IF EXISTS lin ON CLUSTER 'c'" \ + | jq -c '.. | objects | select(.type == "DropFunctionQuery") | {function_name, if_exists, cluster}' + +echo "-- CREATE DICTIONARY: attributes" +ast "CREATE DICTIONARY d (id UInt64, val String DEFAULT 'x' HIERARCHICAL) PRIMARY KEY id SOURCE(CLICKHOUSE(TABLE 't')) LAYOUT(HASHED()) LIFETIME(MIN 1 MAX 10)" \ + | jq -c '.. | objects | select(.type == "DictionaryAttributeDeclaration") | {name, data_type: .data_type.name, hierarchical}' + +echo "-- CREATE DICTIONARY: source (key-value), layout, lifetime" +ast "CREATE DICTIONARY d (id UInt64) PRIMARY KEY id SOURCE(CLICKHOUSE(TABLE 't')) LAYOUT(HASHED()) LIFETIME(MIN 1 MAX 10)" \ + | jq -c '.. | objects | select(.type == "FunctionWithKeyValueArguments") | {name, elements: [.elements[] | {key, value: .value.value}]}' + +echo "-- dictionary sub-elements get distinct type ids (not all 'Dictionary')" +ast "CREATE DICTIONARY d (id UInt64) PRIMARY KEY id SOURCE(CLICKHOUSE(TABLE 't')) LAYOUT(HASHED()) LIFETIME(MIN 1 MAX 10) RANGE(MIN s MAX e)" \ + | jq -c '[.. | objects | (.type // empty)] | map(select(test("^Dictionary")))' diff --git a/tests/queries/0_stateless/03928_explain_ast_json_misc_queries.reference b/tests/queries/0_stateless/03928_explain_ast_json_misc_queries.reference new file mode 100644 index 000000000000..4eaabeefc172 --- /dev/null +++ b/tests/queries/0_stateless/03928_explain_ast_json_misc_queries.reference @@ -0,0 +1,75 @@ +-- EXPLAIN (nested) +{"kind":"EXPLAIN SYNTAX","query":"SelectWithUnionQuery"} +-- DESCRIBE +{"table_expression":"TableExpression"} +-- SHOW TABLES +{"from":"db","like":"a%"} +-- CREATE INDEX +{"table":"t","index_name":"idx","decl":"Index"} +-- DROP INDEX +{"table":"t","index_name":"idx"} +-- CHECK TABLE +{"table":"t","part_name":"p1"} +-- USE +{"database":"mydb"} +-- KILL QUERY (SYNC) +{"kill_type":"QUERY","sync":true,"where":"equals"} +-- KILL MUTATION (TEST); ASYNC is sync=false/test=false +{"kill_type":"MUTATION","sync":false,"test":true} +-- transaction control: BEGIN / COMMIT / ROLLBACK / SET SNAPSHOT +{"type":"TransactionControl","action":"BEGIN"} +{"type":"TransactionControl","action":"COMMIT"} +{"type":"TransactionControl","action":"ROLLBACK"} +{"type":"TransactionControl","action":"SET_SNAPSHOT","snapshot":"42"} +-- RENAME +[{"from_table":"a","to_table":"b"},{"from_table":"c","to_table":"d"}] +-- SYSTEM +{"system_type":"RELOAD DICTIONARY","database":"db","table":"dict"} +-- qualified COLUMNS matcher +{"pattern":"a.*","qualifier":"t"} +-- EXISTS (generic table-target fallback) +{"database":"db","table":"t"} +-- SHOW CREATE (generic table-target fallback) +{"database":"db","table":"t"} +-- UNDROP TABLE with UUID and ON CLUSTER +{"database":"db","table":"t","uuid":"00000000-0000-0000-0000-000000000abc","cluster":"c"} +-- BACKUP TABLE: element rename, partitions, base_backup, cluster +{"kind":"BACKUP","cluster":"c","elements":[{"element_type":"TABLE","database":"db","table":"t","new_database":"db2","new_table":"t2","partitions":[{"type":"Partition","value":{"type":"Literal","value_type":"UInt64","value":"1"}},{"type":"Partition","value":{"type":"Literal","value_type":"UInt64","value":"2"}}]}],"backup":"Disk","base":"Disk"} +-- RESTORE DATABASE: rename and EXCEPT TABLES +{"kind":"RESTORE","elements":[{"element_type":"DATABASE","database":"db","new_database":"db2","except_tables":[{"database":"db","table":"x"}]}]} +-- BACKUP ALL EXCEPT +{"kind":"BACKUP","elements":[{"element_type":"ALL","except_databases":["sys"]}]} +-- trailing SETTINGS clause captured for table-output / describe / kill / rename +{"mutations_sync":"1"} +{"mutations_sync":"2"} +{"optimize_throw_if_noop":"1"} +{"describe_compact_output":"1"} +{"max_threads":"3"} +{"distributed_ddl_task_timeout":"5"} +-- a Map-typed setting value is a JSON object (not an array of key/value tuples) +{"additional_table_filters":{"t1":{"value_type":"String","value":"x > 1"},"t2":{"value_type":"String","value":"y < 2"}}} +-- trailing FORMAT clause captured (table-output / create / show / describe / kill) +"Null" +"JSON" +"JSONEachRow" +"TSV" +"Null" +-- trailing FORMAT captured for select-family / explain / access-entity SHOW +"JSON" +"TSV" +"JSONEachRow" +"JSON" +"JSON" +"JSON" +"JSON" +-- trailing INTO OUTFILE captured: filename, APPEND/TRUNCATE/AND STDOUT flags, COMPRESSION [LEVEL], and combined with FORMAT +{"out_file":"out.tsv"} +{"out_file":"out.tsv","outfile_append":true} +{"out_file":"out.tsv","outfile_truncate":true} +{"out_file":"out.tsv","outfile_with_stdout":true} +{"out_file":"out.gz","compression":"gz","compression_level":"3"} +{"out_file":"out.tsv","outfile_truncate":true,"format":"TSV"} +-- output-level SETTINGS (placed AFTER FORMAT) captured on the SelectWithUnionQuery wrapper +{"type":"SelectWithUnionQuery","wrapper_settings":{"max_threads":"5"},"inner_settings":null} +{"type":"SelectWithUnionQuery","wrapper_settings":{"max_threads":"5"},"inner_settings":null} +{"type":"SelectWithUnionQuery","wrapper_settings":null,"inner_settings":{"max_threads":"5"}} diff --git a/tests/queries/0_stateless/03928_explain_ast_json_misc_queries.sh b/tests/queries/0_stateless/03928_explain_ast_json_misc_queries.sh new file mode 100755 index 000000000000..0cebf684f9ba --- /dev/null +++ b/tests/queries/0_stateless/03928_explain_ast_json_misc_queries.sh @@ -0,0 +1,126 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` named slots for the long tail: EXPLAIN, DESCRIBE, +# SHOW TABLES, CREATE/DROP INDEX, CHECK, USE, KILL, RENAME, SYSTEM, the +# qualified COLUMNS matchers, and the simple table-target statements +# (EXISTS / SHOW CREATE) via the generic fallback. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- EXPLAIN (nested)" +ast "EXPLAIN SYNTAX SELECT 1" | jq -c '.. | objects | select(.type == "Explain") | {kind, query: .query.type}' + +echo "-- DESCRIBE" +ast "DESCRIBE TABLE t" | jq -c '.. | objects | select(.type == "DescribeQuery") | {table_expression: .table_expression.type}' + +echo "-- SHOW TABLES" +ast "SHOW TABLES FROM db LIKE 'a%'" | jq -c '.. | objects | select(.type == "ShowTables") | {from: .from.name, like}' + +echo "-- CREATE INDEX" +ast "CREATE INDEX idx ON t (a) TYPE minmax GRANULARITY 1" \ + | jq -c '.. | objects | select(.type == "CreateIndexQuery") | {table: .table.name, index_name: .index_name.name, decl: .index_declaration.type}' + +echo "-- DROP INDEX" +ast "DROP INDEX idx ON t" | jq -c '.. | objects | select(.type == "DropIndexQuery") | {table: .table.name, index_name: .index_name.name}' + +echo "-- CHECK TABLE" +ast "CHECK TABLE t PART 'p1'" | jq -c '.. | objects | select(.type == "CheckQuery") | {table: .table.name, part_name}' + +echo "-- USE" +ast "USE mydb" | jq -c '.. | objects | select(.type == "UseQuery") | {database: .database.name}' + +echo "-- KILL QUERY (SYNC)" +ast "KILL QUERY WHERE query_id = 'x' SYNC" | jq -c '.. | objects | select(.type == "KillQueryQuery") | {kill_type, sync, where: .where.name}' + +echo "-- KILL MUTATION (TEST); ASYNC is sync=false/test=false" +ast "KILL MUTATION WHERE 1 TEST" | jq -c '.. | objects | select(.type == "KillQueryQuery") | {kill_type, sync: (.sync // false), test: (.test // false)}' + +echo "-- transaction control: BEGIN / COMMIT / ROLLBACK / SET SNAPSHOT" +ast "BEGIN TRANSACTION" | jq -c '.. | objects | select(.type == "TransactionControl")' +ast "COMMIT" | jq -c '.. | objects | select(.type == "TransactionControl")' +ast "ROLLBACK" | jq -c '.. | objects | select(.type == "TransactionControl")' +ast "SET TRANSACTION SNAPSHOT 42" | jq -c '.. | objects | select(.type == "TransactionControl")' + +echo "-- RENAME" +ast "RENAME TABLE a TO b, c TO d" | jq -c '.. | objects | select(.type == "Rename") | .elements' + +echo "-- SYSTEM" +ast "SYSTEM RELOAD DICTIONARY db.dict" | jq -c '.. | objects | select(.type == "SYSTEM") | {system_type, database: .database.name, table: .table.name}' + +echo "-- qualified COLUMNS matcher" +ast "SELECT t.COLUMNS('a.*') FROM t" | jq -c '.. | objects | select(.type == "QualifiedColumnsRegexpMatcher") | {pattern, qualifier: .qualifier.name}' + +echo "-- EXISTS (generic table-target fallback)" +ast "EXISTS TABLE db.t" | jq -c '.. | objects | select(.type == "ExistsTableQuery") | {database: .database.name, table: .table.name}' + +echo "-- SHOW CREATE (generic table-target fallback)" +ast "SHOW CREATE TABLE db.t" | jq -c '.. | objects | select(.type == "ShowCreateTableQuery") | {database: .database.name, table: .table.name}' + +echo "-- UNDROP TABLE with UUID and ON CLUSTER" +ast "UNDROP TABLE db.t UUID '00000000-0000-0000-0000-000000000abc' ON CLUSTER 'c'" \ + | jq -c '.. | objects | select(.type == "UndropQuery") | {database: .database.name, table: .table.name, uuid, cluster}' + +echo "-- BACKUP TABLE: element rename, partitions, base_backup, cluster" +ast "BACKUP TABLE db.t AS db2.t2 PARTITIONS 1, 2 ON CLUSTER 'c' TO Disk('d', 'p') SETTINGS base_backup = Disk('d', 'base')" \ + | jq -c '.. | objects | select(.type == "BackupQuery") | {kind, cluster, elements, backup: .backup_name.name, base: .base_backup_name.name}' + +echo "-- RESTORE DATABASE: rename and EXCEPT TABLES" +ast "RESTORE DATABASE db AS db2 EXCEPT TABLES x FROM Disk('d', 'p')" \ + | jq -c '.. | objects | select(.type == "RestoreQuery") | {kind, elements}' + +echo "-- BACKUP ALL EXCEPT" +ast "BACKUP ALL EXCEPT DATABASES sys TO Disk('d', 'p')" \ + | jq -c '.. | objects | select(.type == "BackupQuery") | {kind, elements}' + +echo "-- trailing SETTINGS clause captured for table-output / describe / kill / rename" +settings() { ast "$1" | jq -c '[.. | objects | select(.type == "Settings") | .changes] | add'; } +settings "DELETE FROM t WHERE x SETTINGS mutations_sync = 1" +settings "UPDATE t SET a = 1 WHERE b SETTINGS mutations_sync = 2" +settings "OPTIMIZE TABLE t SETTINGS optimize_throw_if_noop = 1" +settings "DESCRIBE TABLE t SETTINGS describe_compact_output = 1" +settings "KILL QUERY WHERE 1 SETTINGS max_threads = 3" +settings "RENAME TABLE a TO b SETTINGS distributed_ddl_task_timeout = 5" + +echo "-- a Map-typed setting value is a JSON object (not an array of key/value tuples)" +settings "SELECT 1 SETTINGS additional_table_filters = {'t1': 'x > 1', 't2': 'y < 2'}" + +echo "-- trailing FORMAT clause captured (table-output / create / show / describe / kill)" +fmt() { ast "$1" | jq -c '[.. | objects | select(has("format")) | .format] | add'; } +fmt "DROP TABLE t FORMAT Null" +fmt "CREATE TABLE t (a UInt8) ENGINE = Memory AS SELECT 1 FORMAT JSON" +fmt "SHOW TABLES FORMAT JSONEachRow" +fmt "DESCRIBE TABLE t FORMAT TSV" +fmt "KILL QUERY WHERE 1 FORMAT Null" + +echo "-- trailing FORMAT captured for select-family / explain / access-entity SHOW" +fmt "SELECT 1 FORMAT JSON" +fmt "SELECT 1 UNION ALL SELECT 2 FORMAT TSV" +fmt "SELECT 1 INTERSECT SELECT 2 FORMAT JSONEachRow" +fmt "EXPLAIN PIPELINE SELECT 1 FORMAT JSON" +fmt "SHOW GRANTS FOR u FORMAT JSON" +fmt "SHOW CREATE USER u FORMAT JSON" +fmt "SHOW CREATE ROW POLICY p ON db.t FORMAT JSON" + +echo "-- trailing INTO OUTFILE captured: filename, APPEND/TRUNCATE/AND STDOUT flags, COMPRESSION [LEVEL], and combined with FORMAT" +outfile() { ast "$1" | jq -c '.. | objects | select(has("out_file")) | {out_file: .out_file.value, outfile_append, outfile_truncate, outfile_with_stdout, compression: .compression.value, compression_level: .compression_level.value, format} | with_entries(select(.value != null))'; } +outfile "SELECT 1 INTO OUTFILE 'out.tsv'" +outfile "SELECT 1 INTO OUTFILE 'out.tsv' APPEND" +outfile "SELECT 1 INTO OUTFILE 'out.tsv' TRUNCATE" +outfile "SELECT 1 INTO OUTFILE 'out.tsv' AND STDOUT" +outfile "SELECT 1 INTO OUTFILE 'out.gz' COMPRESSION 'gz' LEVEL 3" +outfile "SELECT 1 INTO OUTFILE 'out.tsv' TRUNCATE FORMAT TSV" + +echo "-- output-level SETTINGS (placed AFTER FORMAT) captured on the SelectWithUnionQuery wrapper" +wrap_settings() { ast "$1" | jq -c '.ast | {type, wrapper_settings: (.settings.changes // null), inner_settings: (.selects[0].settings.changes // null)}'; } +# SETTINGS after FORMAT -> wrapper (output-clause) settings +wrap_settings "SELECT 1 FORMAT TSV SETTINGS max_threads = 5" +# SETTINGS after FORMAT on a UNION -> wrapper settings +wrap_settings "SELECT 1 UNION ALL SELECT 2 FORMAT TSV SETTINGS max_threads = 5" +# SETTINGS before FORMAT -> consumed into the inner SelectQuery, not the wrapper +wrap_settings "SELECT 1 SETTINGS max_threads = 5 FORMAT TSV" diff --git a/tests/queries/0_stateless/03929_explain_ast_json_query_parameters.reference b/tests/queries/0_stateless/03929_explain_ast_json_query_parameters.reference new file mode 100644 index 000000000000..a2111590e114 --- /dev/null +++ b/tests/queries/0_stateless/03929_explain_ast_json_query_parameters.reference @@ -0,0 +1,4 @@ +-- top-level document carries a format version +{"version":2,"ast_type":"SelectWithUnionQuery"} +-- query parameters in value and identifier/table position +[{"name":"tbl","param_type":"Identifier"},{"name":"x","param_type":"UInt64"}] diff --git a/tests/queries/0_stateless/03929_explain_ast_json_query_parameters.sh b/tests/queries/0_stateless/03929_explain_ast_json_query_parameters.sh new file mode 100755 index 000000000000..0e24edc9e39d --- /dev/null +++ b/tests/queries/0_stateless/03929_explain_ast_json_query_parameters.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# Query parameters `{name:type}` survive substitution only inside a +# parameterized view, so EXPLAIN AST json = 1 over a CREATE VIEW is how the +# ASTQueryParameter nodes reach the JSON. They appear both in value position +# and in identifier/table position. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- top-level document carries a format version" +ast "SELECT 1" | jq -c '{version, ast_type: .ast.type}' + +echo "-- query parameters in value and identifier/table position" +ast "CREATE VIEW v AS SELECT id FROM {tbl:Identifier} WHERE id = {x:UInt64}" \ + | jq -c '[.. | objects | select(.type == "QueryParameter") | {name, param_type}]' diff --git a/tests/queries/0_stateless/03930_explain_ast_json_type_ids.reference b/tests/queries/0_stateless/03930_explain_ast_json_type_ids.reference new file mode 100644 index 000000000000..b677985ac700 --- /dev/null +++ b/tests/queries/0_stateless/03930_explain_ast_json_type_ids.reference @@ -0,0 +1,100 @@ +AlterCommand +AlterQuery +AlterSettingsProfileElements +ArrayJoin +Assignment +Asterisk +AuthenticationData +CheckGrantQuery +CheckQuery +Collation +ColumnDeclaration +Columns +ColumnsExceptTransformer +ColumnsRegexpMatcher +ColumnsReplaceTransformer +ColumnsReplaceTransformer::Replacement +Constraint +CreateFunctionQuery +CreateIndexQuery +CreateMaskingPolicyQuery +CreateQuery +CreateQuotaQuery +CreateRoleQuery +CreateRowPolicyQuery +CreateSettingsProfileQuery +CreateUserQuery +DataType +DatabaseOrNone +DeleteQuery +DescribeQuery +Dictionary +DictionaryAttributeDeclaration +DictionaryLayout +DictionaryLifetime +DictionaryRange +DictionarySettings +DropAccessEntityQuery +DropQuery +EnumDataType +ExecuteAsQuery +ExistsTableQuery +Explain +ExpressionList +Function +FunctionWithKeyValueArguments +GrantQuery +Identifier +Index +InsertQuery +InterpolateElement +KillQueryQuery +Literal +MoveAccessEntityQuery +ObjectTypeArgument +ObjectTypedPath +OptimizeQuery +OrderByElement +Partition +Projection +ProjectionSelectQuery +PublicSSHKey +QualifiedAsterisk +RefreshStrategy +Rename +RevokeQuery +RolesOrUsersSet +RowPolicyNames +SYSTEM +SampleRatio +SelectIntersectExceptQuery +SelectQuery +SelectWithUnionQuery +SetRoleQuery +Settings +SettingsProfileElement +SettingsProfileElements +ShowAccessEntitiesQuery +ShowCreateAccessEntityQuery +ShowCreateTableQuery +ShowGrantsQuery +ShowTables +Storage +Subquery +TTLElement +TableExpression +TableIdentifier +TableJoin +TablesInSelectQuery +TablesInSelectQueryElement +TimeInterval +TransactionControl +TupleDataType +UpdateQuery +UseQuery +UserNameWithHost +UserNamesWithHost +ViewTargets +WindowDefinition +WithElement +pair diff --git a/tests/queries/0_stateless/03930_explain_ast_json_type_ids.sh b/tests/queries/0_stateless/03930_explain_ast_json_type_ids.sh new file mode 100755 index 000000000000..402c1a4a299e --- /dev/null +++ b/tests/queries/0_stateless/03930_explain_ast_json_type_ids.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# Snapshot of the complete set of `type` ids (astTypeName outputs) emitted over +# a corpus that touches every enriched class. If a new getID contains a space +# it can silently collide on its trimmed prefix (the Dictionary* case) — this +# guards against that. The set is sorted and de-duplicated for stability. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" | jq -r '[.. | objects | (.type // empty)] | .[]' +} + +{ + ast "WITH cte AS (SELECT 1) SELECT DISTINCT a + b AS s, count() OVER (PARTITION BY g ORDER BY t ROWS BETWEEN 1 PRECEDING AND CURRENT ROW), f(x) IGNORE NULLS, CAST(x AS Int64), [1], (1,2), * EXCEPT (q) REPLACE (z + 1 AS z), COLUMNS('a.*') FROM r ARRAY JOIN arr AS e INNER JOIN s ON r.id = s.id PREWHERE p WHERE w GROUP BY g WITH ROLLUP HAVING h QUALIFY n ORDER BY t WITH FILL INTERPOLATE (y AS y + 1) LIMIT 1, 2 BY g SETTINGS max_threads = 1" + ast "SELECT 1 INTERSECT SELECT 2" + ast "SELECT t.* FROM t" + ast "CREATE TABLE c (a UInt64, b String DEFAULT 'x' CODEC(ZSTD), INDEX i a TYPE minmax GRANULARITY 1, CONSTRAINT ck CHECK a > 0, PROJECTION p (SELECT a)) ENGINE = MergeTree PARTITION BY a ORDER BY a TTL a + INTERVAL 1 DAY SETTINGS index_granularity = 8192" + ast "CREATE DICTIONARY d (id UInt64) PRIMARY KEY id SOURCE(CLICKHOUSE(TABLE 't')) LAYOUT(HASHED()) LIFETIME(MIN 1 MAX 2) RANGE(MIN s MAX e) SETTINGS(max_threads = 1)" + ast "CREATE FUNCTION fn AS (x) -> x + 1" + ast "INSERT INTO t (a) SELECT 1" + ast "ALTER TABLE t ADD COLUMN x UInt8, MOVE PARTITION 1 TO DISK 'd'" + ast "ALTER TABLE t UPDATE a = 1 WHERE b" + ast "DELETE FROM t WHERE x" + ast "UPDATE t SET a = 1 WHERE b" + ast "DROP TABLE IF EXISTS t" + ast "OPTIMIZE TABLE t FINAL" + ast "RENAME TABLE a TO b" + ast "KILL QUERY WHERE x SYNC" + ast "SYSTEM RELOAD DICTIONARY d" + ast "EXPLAIN SYNTAX SELECT 1" + ast "DESCRIBE TABLE t" + ast "SHOW TABLES" + ast "CHECK TABLE t" + ast "USE db" + ast "EXISTS TABLE t" + ast "SHOW CREATE TABLE t" + ast "CREATE INDEX i ON t (a) TYPE minmax GRANULARITY 1" + ast "SELECT 1 SETTINGS max_threads = 1" + ast "SELECT * FROM t SAMPLE 1/2" + ast "GRANT SELECT(x) ON db.t TO u WITH GRANT OPTION" + ast "REVOKE INSERT ON db.* FROM ALL EXCEPT u" + ast "CHECK GRANT SELECT ON db.t" + ast "CREATE USER u IDENTIFIED WITH ssh_key BY KEY 'AAAA' TYPE 'ssh-rsa' HOST IP '127.0.0.1' DEFAULT ROLE r SETTINGS max_threads = 1 DEFAULT DATABASE NONE GRANTEES ANY" + ast "ALTER USER u DROP SETTINGS max_threads" + ast "CREATE ROLE r SETTINGS PROFILE p" + ast "CREATE QUOTA q KEYED BY user_name FOR INTERVAL 1 HOUR MAX queries = 1 TO r" + ast "SET DEFAULT ROLE r TO u" + ast "CREATE ROW POLICY p ON db.t FOR SELECT USING x > 0 TO r" + ast "CREATE SETTINGS PROFILE sp SETTINGS max_threads = 1 TO ALL" + ast "CREATE MASKING POLICY m ON db.t UPDATE x = mask(x) TO r" + ast "DROP ROW POLICY p ON db.t" + ast "MOVE USER u TO storage" + ast "SHOW GRANTS FOR u" + ast "SHOW CREATE USER u" + ast "SHOW QUOTAS" + ast "EXECUTE AS u" + ast "CREATE TABLE en (e Enum8('a' = 1, 'b' = 2), tp Tuple(x UInt8, y String), s String COLLATE binary, j JSON(a.b UInt32, SKIP p)) ENGINE = Memory" + ast "CREATE MATERIALIZED VIEW mv REFRESH EVERY 1 DAY (a UInt64) ENGINE = Memory AS SELECT 1 AS a" + ast "COMMIT" +} | LC_ALL=C sort -u | grep -vxE 'Unbounded|Current|Offset' +# (Unbounded/Current/Offset are the frame_begin/frame_end `type` discriminator +# values, not node type ids — excluded so this snapshots only astTypeName output.) diff --git a/tests/queries/0_stateless/03931_explain_ast_json_datatype_elements.reference b/tests/queries/0_stateless/03931_explain_ast_json_datatype_elements.reference new file mode 100644 index 000000000000..7a374fddb793 --- /dev/null +++ b/tests/queries/0_stateless/03931_explain_ast_json_datatype_elements.reference @@ -0,0 +1,15 @@ +-- explicit Enum8 / Enum16 carry values +{"type":"EnumDataType","name":"Enum8","values":[{"name":"a","value":1},{"name":"b","value":2}]} +{"type":"EnumDataType","name":"Enum16","values":[{"name":"x","value":-1},{"name":"y","value":100}]} +-- auto-assigned enum falls back to a generic DataType with literal args +{"type":"DataType","name":"Enum8","arguments":[{"type":"Literal","value_type":"String","value":"a"},{"type":"Literal","value_type":"String","value":"b"}]} +-- named tuple carries element_names +{"type":"TupleDataType","name":"Tuple","arguments":[{"type":"DataType","name":"UInt8"},{"type":"DataType","name":"String"}],"element_names":["a","b"]} +-- unnamed tuple omits element_names +{"type":"TupleDataType","name":"Tuple","arguments":[{"type":"DataType","name":"UInt8"},{"type":"DataType","name":"String"}]} +-- mixed tuple keeps a placeholder for the unnamed element +["a",""] +-- Nested elements are NameTypePair nodes +[{"type":"NameTypePair","name":"k","data_type":"UInt8"},{"type":"NameTypePair","name":"v","data_type":"String"}] +-- Dynamic(max_types = N) argument +{"type":"Function","name":"equals","is_operator":true,"arguments":[{"type":"Identifier","name":"max_types"},{"type":"Literal","value_type":"UInt64","value":"5"}]} diff --git a/tests/queries/0_stateless/03931_explain_ast_json_datatype_elements.sh b/tests/queries/0_stateless/03931_explain_ast_json_datatype_elements.sh new file mode 100755 index 000000000000..9d64119ac602 --- /dev/null +++ b/tests/queries/0_stateless/03931_explain_ast_json_datatype_elements.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` data-type elements (format v2): the named slots that +# carry an enum's values and a named tuple's element names — ASTEnumDataType +# (`values`) and ASTTupleDataType (`element_names`) — plus the Nested +# NameTypePair elements and the auto-assigned-enum fallback to a generic +# DataType. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- explicit Enum8 / Enum16 carry values" +ast "CREATE TABLE t (e8 Enum8('a' = 1, 'b' = 2), e16 Enum16('x' = -1, 'y' = 100))" \ + | jq -c '.. | objects | select(.type == "EnumDataType")' + +echo "-- auto-assigned enum falls back to a generic DataType with literal args" +ast "CREATE TABLE t (e Enum8('a', 'b'))" \ + | jq -c '.. | objects | select(.type == "DataType" and .name == "Enum8")' + +echo "-- named tuple carries element_names" +ast "CREATE TABLE t (c Tuple(a UInt8, b String))" \ + | jq -c '.. | objects | select(.type == "TupleDataType")' + +echo "-- unnamed tuple omits element_names" +ast "CREATE TABLE t (c Tuple(UInt8, String))" \ + | jq -c '.. | objects | select(.type == "TupleDataType")' + +echo "-- mixed tuple keeps a placeholder for the unnamed element" +ast "CREATE TABLE t (c Tuple(a UInt8, String))" \ + | jq -c '.. | objects | select(.type == "TupleDataType") | .element_names' + +echo "-- Nested elements are NameTypePair nodes" +ast "CREATE TABLE t (n Nested(k UInt8, v String))" \ + | jq -c '.. | objects | select(.type == "DataType" and .name == "Nested") | [.arguments[] | {type, name, data_type: .data_type.name}]' + +echo "-- Dynamic(max_types = N) argument" +ast "CREATE TABLE t (d Dynamic(max_types = 5))" \ + | jq -c '.. | objects | select(.type == "Function" and .name == "equals")' diff --git a/tests/queries/0_stateless/03931_explain_ast_json_grant.reference b/tests/queries/0_stateless/03931_explain_ast_json_grant.reference new file mode 100644 index 000000000000..ead8ec53ed93 --- /dev/null +++ b/tests/queries/0_stateless/03931_explain_ast_json_grant.reference @@ -0,0 +1,14 @@ +-- GRANT privileges with columns and grant option +{"type":"GrantQuery","access_rights":[{"access_types":["SELECT"],"database":"db","table":"t","columns":["x","y"],"grant_option":true},{"access_types":["INSERT"],"database":"db","table":"t","grant_option":true}],"grantees":{"type":"RolesOrUsersSet","names":["user1"]}} +-- GRANT role to users +{"type":"GrantQuery","admin_option":true,"roles":{"type":"RolesOrUsersSet","names":["role1","role2"]},"grantees":{"type":"RolesOrUsersSet","names":["user1","user2"]}} +-- GRANT on all +[{"access_types":["SELECT"]}] +-- REVOKE +{"type":"RevokeQuery","access_rights":[{"access_types":["SELECT"],"database":"db","table":"t"}],"grantees":{"type":"RolesOrUsersSet","names":["user1"]}} +-- REVOKE from ALL EXCEPT +{"type":"RolesOrUsersSet","all":true,"except_names":["user1"]} +-- GRANT CURRENT GRANTS +{"type":"GrantQuery","current_grants":true} +-- CHECK GRANT +{"type":"CheckGrantQuery","access_rights":[{"access_types":["SELECT"],"database":"db","table":"t","columns":["x"]},{"access_types":["ALTER UPDATE"],"database":"db","table":"t"}]} diff --git a/tests/queries/0_stateless/03931_explain_ast_json_grant.sh b/tests/queries/0_stateless/03931_explain_ast_json_grant.sh new file mode 100755 index 000000000000..d5772878d7e9 --- /dev/null +++ b/tests/queries/0_stateless/03931_explain_ast_json_grant.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` named slots for GRANT / REVOKE / CHECK GRANT: +# ASTGrantQuery (split into GrantQuery / RevokeQuery), ASTCheckGrantQuery, +# the inlined AccessRightsElements privilege list, and ASTRolesOrUsersSet. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- GRANT privileges with columns and grant option" +ast "GRANT SELECT(x, y), INSERT ON db.t TO user1 WITH GRANT OPTION" \ + | jq -c '.ast | {type, access_rights, grantees}' + +echo "-- GRANT role to users" +ast "GRANT role1, role2 TO user1, user2 WITH ADMIN OPTION" \ + | jq -c '.ast | {type, admin_option, roles, grantees}' + +echo "-- GRANT on all" +ast "GRANT SELECT ON *.* TO user1" \ + | jq -c '.ast.access_rights' + +echo "-- REVOKE" +ast "REVOKE SELECT ON db.t FROM user1" \ + | jq -c '.ast | {type, access_rights, grantees}' + +echo "-- REVOKE from ALL EXCEPT" +ast "REVOKE INSERT ON db.* FROM ALL EXCEPT user1" \ + | jq -c '.ast.grantees' + +echo "-- GRANT CURRENT GRANTS" +ast "GRANT CURRENT GRANTS ON db.* TO user1" \ + | jq -c '.ast | {type, current_grants}' + +echo "-- CHECK GRANT" +ast "CHECK GRANT SELECT(x), UPDATE ON db.t" \ + | jq -c '.ast | {type, access_rights}' diff --git a/tests/queries/0_stateless/03932_explain_ast_json_users_roles.reference b/tests/queries/0_stateless/03932_explain_ast_json_users_roles.reference new file mode 100644 index 000000000000..df06d3366f8f --- /dev/null +++ b/tests/queries/0_stateless/03932_explain_ast_json_users_roles.reference @@ -0,0 +1,22 @@ +-- CREATE USER: name, auth, host, default role, settings, grantees +{"type":"CreateUserQuery","names":{"type":"UserNamesWithHost","users":[{"type":"UserNameWithHost","name":"u"}]},"authentication_methods":[{"type":"AuthenticationData","auth_type":"SHA256_PASSWORD","contains_password":true,"arguments":[{"type":"Literal","value_type":"String","value":"secret"}]}],"hosts":{"local_host":true},"default_roles":{"type":"RolesOrUsersSet","names":["r1"]},"settings":{"type":"SettingsProfileElements","elements":[{"type":"SettingsProfileElement","setting_name":"max_threads","value":"4","writability":"CONST"}]},"grantees":{"type":"RolesOrUsersSet","all":true,"use_keyword_any":true}} +-- CREATE USER: name@host +{"type":"UserNamesWithHost","users":[{"type":"UserNameWithHost","name":"u2","host_pattern":"192.168.%"}]} +-- auth: ssl_certificate +[{"type":"AuthenticationData","auth_type":"SSL_CERTIFICATE","ssl_cert_subject_type":"CN","arguments":[{"type":"Literal","value_type":"String","value":"cn1"},{"type":"Literal","value_type":"String","value":"cn2"}]}] +-- auth: ssh_key (PublicSSHKey) +[{"type":"AuthenticationData","auth_type":"SSH_KEY","arguments":[{"type":"PublicSSHKey","key_type":"ssh-rsa","key_base64":"AAAA"}]}] +-- auth: kerberos +[{"type":"AuthenticationData","auth_type":"KERBEROS","arguments":[{"type":"Literal","value_type":"String","value":"r"}]}] +-- default database NONE +{"type":"DatabaseOrNone","none":true} +-- ALTER USER: rename, add host, drop settings +{"type":"CreateUserQuery","alter":true,"new_name":"u2","add_hosts":{"subnets":["10.0.0.0/8"]},"alter_settings":{"type":"AlterSettingsProfileElements","drop_settings":{"type":"SettingsProfileElements","elements":[{"type":"SettingsProfileElement","setting_name":"max_threads"}]}}} +-- CREATE ROLE +{"type":"CreateRoleQuery","or_replace":true,"names":["r"],"settings":{"type":"SettingsProfileElements","elements":[{"type":"SettingsProfileElement","setting_name":"max_threads","value":"2"}]}} +-- ALTER ROLE +{"type":"CreateRoleQuery","alter":true,"names":["r"],"new_name":"r2"} +-- SET ROLE +{"type":"SetRoleQuery","kind":"SET_ROLE","roles":{"type":"RolesOrUsersSet","names":["r1","r2"]}} +-- SET DEFAULT ROLE +{"type":"SetRoleQuery","kind":"SET_DEFAULT_ROLE","roles":{"type":"RolesOrUsersSet","names":["r1"]},"to_users":{"type":"RolesOrUsersSet","names":["u1","u2"]}} diff --git a/tests/queries/0_stateless/03932_explain_ast_json_users_roles.sh b/tests/queries/0_stateless/03932_explain_ast_json_users_roles.sh new file mode 100755 index 000000000000..7213f1e8a9f3 --- /dev/null +++ b/tests/queries/0_stateless/03932_explain_ast_json_users_roles.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` named slots for CREATE/ALTER USER and ROLE and +# SET ROLE: ASTCreateUserQuery, ASTCreateRoleQuery, ASTSetRoleQuery, plus the +# helper nodes ASTUserNamesWithHost, ASTAuthenticationData, ASTRolesOrUsersSet, +# ASTSettingsProfileElements, ASTDatabaseOrNone, ASTPublicSSHKey. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- CREATE USER: name, auth, host, default role, settings, grantees" +ast "CREATE USER u IDENTIFIED WITH sha256_password BY 'secret' HOST IP '127.0.0.1' DEFAULT ROLE r1 SETTINGS max_threads = 4 READONLY GRANTEES ANY" \ + | jq -c '.ast | {type, names, authentication_methods, hosts, default_roles, settings, grantees}' + +echo "-- CREATE USER: name@host" +ast "CREATE USER u2@'192.168.%'" \ + | jq -c '.ast.names' + +echo "-- auth: ssl_certificate" +ast "CREATE USER u IDENTIFIED WITH ssl_certificate CN 'cn1', 'cn2'" \ + | jq -c '.ast.authentication_methods' + +echo "-- auth: ssh_key (PublicSSHKey)" +ast "CREATE USER u IDENTIFIED WITH ssh_key BY KEY 'AAAA' TYPE 'ssh-rsa'" \ + | jq -c '.ast.authentication_methods' + +echo "-- auth: kerberos" +ast "CREATE USER u IDENTIFIED WITH kerberos REALM 'r'" \ + | jq -c '.ast.authentication_methods' + +echo "-- default database NONE" +ast "CREATE USER u DEFAULT DATABASE NONE" \ + | jq -c '.ast.default_database' + +echo "-- ALTER USER: rename, add host, drop settings" +ast "ALTER USER u RENAME TO u2 ADD HOST IP '10.0.0.0/8' DROP SETTINGS max_threads" \ + | jq -c '.ast | {type, alter, new_name, add_hosts, alter_settings}' + +echo "-- CREATE ROLE" +ast "CREATE ROLE OR REPLACE r SETTINGS max_threads = 2" \ + | jq -c '.ast | {type, or_replace, names, settings}' + +echo "-- ALTER ROLE" +ast "ALTER ROLE r RENAME TO r2" \ + | jq -c '.ast | {type, alter, names, new_name}' + +echo "-- SET ROLE" +ast "SET ROLE r1, r2" \ + | jq -c '.ast | {type, kind, roles}' + +echo "-- SET DEFAULT ROLE" +ast "SET DEFAULT ROLE r1 TO u1, u2" \ + | jq -c '.ast | {type, kind, roles, to_users}' diff --git a/tests/queries/0_stateless/03933_explain_ast_json_quota_policy.reference b/tests/queries/0_stateless/03933_explain_ast_json_quota_policy.reference new file mode 100644 index 000000000000..a50530d56405 --- /dev/null +++ b/tests/queries/0_stateless/03933_explain_ast_json_quota_policy.reference @@ -0,0 +1,12 @@ +-- CREATE QUOTA: key type, limits, roles +{"type":"CreateQuotaQuery","names":["q"],"key_type":"USER_NAME","limits":[{"duration_sec":"3600","max":{"QUERIES":"100","RESULT_ROWS":"1000"}}],"roles":{"type":"RolesOrUsersSet","names":["r1"]}} +-- ALTER QUOTA: rename, tracking-only interval +{"type":"CreateQuotaQuery","alter":true,"new_name":"q2","limits":[{"duration_sec":"86400"}]} +-- CREATE ROW POLICY: restrictive filter +{"type":"CreateRowPolicyQuery","names":{"type":"RowPolicyNames","policies":[{"short_name":"p","database":"db","table":"t"}]},"is_restrictive":true,"filters":[{"filter_type":"SELECT_FILTER","condition":{"type":"Function","name":"greater","is_operator":true,"arguments":[{"type":"Identifier","name":"x"},{"type":"Literal","value_type":"UInt64","value":"0"}]}}],"roles":{"type":"RolesOrUsersSet","names":["r1"]}} +-- ALTER ROW POLICY: filter set to NONE +{"type":"CreateRowPolicyQuery","alter":true,"filters":[{"filter_type":"SELECT_FILTER"}]} +-- CREATE SETTINGS PROFILE +{"type":"CreateSettingsProfileQuery","names":["sp"],"settings":{"type":"SettingsProfileElements","elements":[{"type":"SettingsProfileElement","setting_name":"max_threads","value":"8","min_value":"1","max_value":"16"}]},"to_roles":{"type":"RolesOrUsersSet","all":true}} +-- CREATE MASKING POLICY +{"type":"CreateMaskingPolicyQuery","name":"m","database":"db","table":"t","update_assignments":[{"type":"Assignment","column":"x","expression":{"type":"Function","name":"mask","arguments":[{"type":"Identifier","name":"x"}]}}],"where_condition":{"type":"Function","name":"greater","is_operator":true,"arguments":[{"type":"Identifier","name":"y"},{"type":"Literal","value_type":"UInt64","value":"0"}]},"roles":{"type":"RolesOrUsersSet","names":["r1"]},"priority":"5"} diff --git a/tests/queries/0_stateless/03933_explain_ast_json_quota_policy.sh b/tests/queries/0_stateless/03933_explain_ast_json_quota_policy.sh new file mode 100755 index 000000000000..92a1e5c6396a --- /dev/null +++ b/tests/queries/0_stateless/03933_explain_ast_json_quota_policy.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` named slots for CREATE/ALTER QUOTA, ROW POLICY, +# SETTINGS PROFILE and MASKING POLICY: ASTCreateQuotaQuery (incl. limits), +# ASTCreateRowPolicyQuery (incl. filters), ASTCreateSettingsProfileQuery, +# ASTCreateMaskingPolicyQuery, and ASTRowPolicyNames / ASTSettingsProfileElement. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- CREATE QUOTA: key type, limits, roles" +ast "CREATE QUOTA q KEYED BY user_name FOR INTERVAL 1 HOUR MAX queries = 100, result_rows = 1000 TO r1" \ + | jq -c '.ast | {type, names, key_type, limits, roles}' + +echo "-- ALTER QUOTA: rename, tracking-only interval" +ast "ALTER QUOTA q RENAME TO q2 FOR INTERVAL 1 DAY TRACKING ONLY" \ + | jq -c '.ast | {type, alter, new_name, limits}' + +echo "-- CREATE ROW POLICY: restrictive filter" +ast "CREATE ROW POLICY p ON db.t AS restrictive FOR SELECT USING x > 0 TO r1" \ + | jq -c '.ast | {type, names, is_restrictive, filters, roles}' + +echo "-- ALTER ROW POLICY: filter set to NONE" +ast "ALTER ROW POLICY p ON db.t USING NONE" \ + | jq -c '.ast | {type, alter, filters}' + +echo "-- CREATE SETTINGS PROFILE" +ast "CREATE SETTINGS PROFILE sp SETTINGS max_threads = 8 MIN 1 MAX 16 TO ALL" \ + | jq -c '.ast | {type, names, settings, to_roles}' + +echo "-- CREATE MASKING POLICY" +ast "CREATE MASKING POLICY m ON db.t UPDATE x = mask(x) WHERE y > 0 TO r1 PRIORITY 5" \ + | jq -c '.ast | {type, name, database, table, update_assignments, where_condition, roles, priority}' diff --git a/tests/queries/0_stateless/03934_explain_ast_json_access_misc.reference b/tests/queries/0_stateless/03934_explain_ast_json_access_misc.reference new file mode 100644 index 000000000000..64db3c832dfd --- /dev/null +++ b/tests/queries/0_stateless/03934_explain_ast_json_access_misc.reference @@ -0,0 +1,18 @@ +-- DROP USER +{"type":"DropAccessEntityQuery","entity_type":"USER","if_exists":true,"names":["a","b"]} +-- DROP ROW POLICY +{"type":"DropAccessEntityQuery","entity_type":"ROW POLICY","row_policy_names":{"type":"RowPolicyNames","policies":[{"short_name":"p","database":"db","table":"t"}]}} +-- MOVE USER TO storage +{"type":"MoveAccessEntityQuery","entity_type":"USER","storage_name":"disk_storage","names":["u"]} +-- SHOW GRANTS +{"type":"ShowGrantsQuery","for_roles":{"type":"RolesOrUsersSet","names":["u"]},"with_implicit":true} +-- SHOW CREATE USER +{"type":"ShowCreateAccessEntityQuery","entity_type":"USER","names":["u"]} +-- SHOW CREATE ROW POLICY +{"type":"ShowCreateAccessEntityQuery","entity_type":"ROW POLICY","row_policy_names":{"type":"RowPolicyNames","policies":[{"short_name":"p","database":"db","table":"t"}]}} +-- SHOW USERS +{"type":"ShowAccessEntitiesQuery","entity_type":"USER","all":true} +-- SHOW QUOTAS +{"type":"ShowAccessEntitiesQuery","entity_type":"QUOTA"} +-- EXECUTE AS +{"type":"ExecuteAsQuery","target_user":{"type":"UserNameWithHost","name":"u"}} diff --git a/tests/queries/0_stateless/03934_explain_ast_json_access_misc.sh b/tests/queries/0_stateless/03934_explain_ast_json_access_misc.sh new file mode 100755 index 000000000000..5ba848c8ba59 --- /dev/null +++ b/tests/queries/0_stateless/03934_explain_ast_json_access_misc.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) +# shellcheck source=../shell_config.sh +. "$CURDIR"/../shell_config.sh + +# `EXPLAIN AST json = 1` named slots for the remaining access statements: +# ASTDropAccessEntityQuery, ASTMoveAccessEntityQuery, ASTShowGrantsQuery, +# ASTShowCreateAccessEntityQuery, ASTShowAccessEntitiesQuery, ASTExecuteAsQuery. + +ast() { + $CLICKHOUSE_CLIENT --format TSVRaw -q "EXPLAIN AST json = 1 $1" +} + +echo "-- DROP USER" +ast "DROP USER IF EXISTS a, b" \ + | jq -c '.ast | {type, entity_type, if_exists, names}' + +echo "-- DROP ROW POLICY" +ast "DROP ROW POLICY p ON db.t" \ + | jq -c '.ast | {type, entity_type, row_policy_names}' + +echo "-- MOVE USER TO storage" +ast "MOVE USER u TO disk_storage" \ + | jq -c '.ast | {type, entity_type, storage_name, names}' + +echo "-- SHOW GRANTS" +ast "SHOW GRANTS FOR u WITH IMPLICIT" \ + | jq -c '.ast | {type, for_roles, with_implicit}' + +echo "-- SHOW CREATE USER" +ast "SHOW CREATE USER u" \ + | jq -c '.ast | {type, entity_type, names}' + +echo "-- SHOW CREATE ROW POLICY" +ast "SHOW CREATE ROW POLICY p ON db.t" \ + | jq -c '.ast | {type, entity_type, row_policy_names}' + +echo "-- SHOW USERS" +ast "SHOW USERS" \ + | jq -c '.ast | {type, entity_type, all}' + +echo "-- SHOW QUOTAS" +ast "SHOW QUOTAS" \ + | jq -c '.ast | {type, entity_type}' + +echo "-- EXECUTE AS" +ast "EXECUTE AS u" \ + | jq -c '.ast | {type, target_user}'