forked from MaterializeInc/materialize
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathid
More file actions
89 lines (78 loc) · 5.38 KB
/
Copy pathid
File metadata and controls
89 lines (78 loc) · 5.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License in the LICENSE file at the
# root of this repository, or online at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
parse-statement
SELECT * FROM [u123 AS materialize.public.foo]
----
SELECT * FROM [u123 AS materialize.public.foo]
=>
Select(SelectStatement { query: Query { ctes: Simple([]), body: Select(Select { distinct: None, projection: [Wildcard], from: [TableWithJoins { relation: Table { name: Id("u123", UnresolvedItemName([Ident("materialize"), Ident("public"), Ident("foo")]), None), alias: None }, joins: [] }], selection: None, group_by: [], having: None, qualify: None, options: [] }), order_by: [], limit: None, offset: None }, as_of: None })
parse-statement
SELECT [u123 AS materialize.public.foo](1)
----
SELECT [u123 AS materialize.public.foo](1)
=>
Select(SelectStatement { query: Query { ctes: Simple([]), body: Select(Select { distinct: None, projection: [Expr { expr: Function(Function { name: Id("u123", UnresolvedItemName([Ident("materialize"), Ident("public"), Ident("foo")]), None), args: Args { args: [Value(Number("1"))], order_by: [] }, filter: None, over: None, distinct: false }), alias: None }], from: [], selection: None, group_by: [], having: None, qualify: None, options: [] }), order_by: [], limit: None, offset: None }, as_of: None })
parse-statement
SELECT * FROM [u123 AS foo]
----
error: table name in square brackets must be fully qualified
SELECT * FROM [u123 AS foo]
^
parse-statement
SELECT * FROM [u123]
----
error: Expected AS, found right square bracket
SELECT * FROM [u123]
^
parse-statement
SELECT * FROM [u123 AS materialize.public.foo
----
error: Expected right square bracket, found EOF
SELECT * FROM [u123 AS materialize.public.foo
^
parse-statement
CREATE VIEW v1 AS SELECT * FROM [ u1 as materialize.public.t1 VERSION 5]
----
CREATE VIEW v1 AS SELECT * FROM [u1 AS materialize.public.t1 VERSION 5]
=>
CreateView(CreateViewStatement { if_exists: Error, temporary: false, definition: ViewDefinition { name: UnresolvedItemName([Ident("v1")]), columns: [], query: Query { ctes: Simple([]), body: Select(Select { distinct: None, projection: [Wildcard], from: [TableWithJoins { relation: Table { name: Id("u1", UnresolvedItemName([Ident("materialize"), Ident("public"), Ident("t1")]), Some(Version(5))), alias: None }, joins: [] }], selection: None, group_by: [], having: None, qualify: None, options: [] }), order_by: [], limit: None, offset: None } } })
parse-statement
CREATE VIEW "materialize"."public"."v3" AS SELECT * FROM [u1 AS "materialize"."public"."t1" VERSION 3]
----
CREATE VIEW materialize.public.v3 AS SELECT * FROM [u1 AS materialize.public.t1 VERSION 3]
=>
CreateView(CreateViewStatement { if_exists: Error, temporary: false, definition: ViewDefinition { name: UnresolvedItemName([Ident("materialize"), Ident("public"), Ident("v3")]), columns: [], query: Query { ctes: Simple([]), body: Select(Select { distinct: None, projection: [Wildcard], from: [TableWithJoins { relation: Table { name: Id("u1", UnresolvedItemName([Ident("materialize"), Ident("public"), Ident("t1")]), Some(Version(3))), alias: None }, joins: [] }], selection: None, group_by: [], having: None, qualify: None, options: [] }), order_by: [], limit: None, offset: None } } })
parse-statement
CREATE VIEW "materialize"."public"."v3" AS SELECT * FROM [u1 AS "materialize"."public"."t1" VERSION foobar]
----
error: Expected literal unsigned integer, found identifier "foobar"
CREATE VIEW "materialize"."public"."v3" AS SELECT * FROM [u1 AS "materialize"."public"."t1" VERSION foobar]
^
parse-statement
CREATE VIEW "materialize"."public"."v3" AS SELECT * FROM [u1 AS "materialize"."public"."t1" VERSION -101]
----
error: Expected literal unsigned integer, found operator "-"
CREATE VIEW "materialize"."public"."v3" AS SELECT * FROM [u1 AS "materialize"."public"."t1" VERSION -101]
^
# An id with a multi-byte leading character parses fine; it is name resolution
# that rejects it as an invalid id. Previously this id panicked the server while
# resolving the name because `CatalogItemId::from_str` sliced off a single byte,
# landing inside the multi-byte char (SQL-195).
parse-statement
SELECT * FROM [ü1 AS materialize.public.foo]
----
SELECT * FROM ["ü1" AS materialize.public.foo]
=>
Select(SelectStatement { query: Query { ctes: Simple([]), body: Select(Select { distinct: None, projection: [Wildcard], from: [TableWithJoins { relation: Table { name: Id("ü1", UnresolvedItemName([Ident("materialize"), Ident("public"), Ident("foo")]), None), alias: None }, joins: [] }], selection: None, group_by: [], having: None, qualify: None, options: [] }), order_by: [], limit: None, offset: None }, as_of: None })