11---------- Input ----------
2- LET cost := 100.0
2+ LET cost FLOAT
33---------- Output ---------
4- LET cost := 100.0
4+ LET cost Float32
55---------- AST ------------
66LetVar {
77 declare: DeclareVar {
88 span: Some(
9- 4..17 ,
9+ 4..14 ,
1010 ),
1111 name: Identifier {
1212 span: Some(
@@ -16,16 +16,119 @@ LetVar {
1616 quote: None,
1717 ident_type: None,
1818 },
19- default: Literal {
19+ data_type: Some(
20+ Float32,
21+ ),
22+ default: None,
23+ },
24+ }
25+
26+
27+ ---------- Input ----------
28+ LET cost FLOAT default 3.0
29+ ---------- Output ---------
30+ LET cost Float32 := 3.0
31+ ---------- AST ------------
32+ LetVar {
33+ declare: DeclareVar {
34+ span: Some(
35+ 4..26,
36+ ),
37+ name: Identifier {
2038 span: Some(
21- 12..17 ,
39+ 4..8 ,
2240 ),
23- value: Decimal256 {
24- value: 1000,
25- precision: 76,
26- scale: 1,
41+ name: "cost",
42+ quote: None,
43+ ident_type: None,
44+ },
45+ data_type: Some(
46+ Float32,
47+ ),
48+ default: Some(
49+ Literal {
50+ span: Some(
51+ 23..26,
52+ ),
53+ value: Decimal256 {
54+ value: 30,
55+ precision: 76,
56+ scale: 1,
57+ },
2758 },
59+ ),
60+ },
61+ }
62+
63+
64+ ---------- Input ----------
65+ LET cost FLOAT := 100.0
66+ ---------- Output ---------
67+ LET cost Float32 := 100.0
68+ ---------- AST ------------
69+ LetVar {
70+ declare: DeclareVar {
71+ span: Some(
72+ 4..23,
73+ ),
74+ name: Identifier {
75+ span: Some(
76+ 4..8,
77+ ),
78+ name: "cost",
79+ quote: None,
80+ ident_type: None,
81+ },
82+ data_type: Some(
83+ Float32,
84+ ),
85+ default: Some(
86+ Literal {
87+ span: Some(
88+ 18..23,
89+ ),
90+ value: Decimal256 {
91+ value: 1000,
92+ precision: 76,
93+ scale: 1,
94+ },
95+ },
96+ ),
97+ },
98+ }
99+
100+
101+ ---------- Input ----------
102+ LET cost := 100.0
103+ ---------- Output ---------
104+ LET cost := 100.0
105+ ---------- AST ------------
106+ LetVar {
107+ declare: DeclareVar {
108+ span: Some(
109+ 4..17,
110+ ),
111+ name: Identifier {
112+ span: Some(
113+ 4..8,
114+ ),
115+ name: "cost",
116+ quote: None,
117+ ident_type: None,
28118 },
119+ data_type: None,
120+ default: Some(
121+ Literal {
122+ span: Some(
123+ 12..17,
124+ ),
125+ value: Decimal256 {
126+ value: 1000,
127+ precision: 76,
128+ scale: 1,
129+ },
130+ },
131+ ),
29132 },
30133}
31134
@@ -120,6 +223,99 @@ LetStatement {
120223}
121224
122225
226+ ---------- Input ----------
227+ LET t1 cursor FOR SELECT * FROM numbers(100)
228+ ---------- Output ---------
229+ LET t1 CURSOR FOR SELECT * FROM numbers(100)
230+ ---------- AST ------------
231+ LetCursor {
232+ declare: DeclareCursor {
233+ span: Some(
234+ 4..44,
235+ ),
236+ name: Identifier {
237+ span: Some(
238+ 4..6,
239+ ),
240+ name: "t1",
241+ quote: None,
242+ ident_type: None,
243+ },
244+ stmt: Some(
245+ Query(
246+ Query {
247+ span: Some(
248+ 18..44,
249+ ),
250+ with: None,
251+ body: Select(
252+ SelectStmt {
253+ span: Some(
254+ 18..44,
255+ ),
256+ hints: None,
257+ distinct: false,
258+ top_n: None,
259+ select_list: [
260+ StarColumns {
261+ qualified: [
262+ Star(
263+ Some(
264+ 25..26,
265+ ),
266+ ),
267+ ],
268+ column_filter: None,
269+ },
270+ ],
271+ from: [
272+ TableFunction {
273+ span: Some(
274+ 32..44,
275+ ),
276+ lateral: false,
277+ name: Identifier {
278+ span: Some(
279+ 32..39,
280+ ),
281+ name: "numbers",
282+ quote: None,
283+ ident_type: None,
284+ },
285+ params: [
286+ Literal {
287+ span: Some(
288+ 40..43,
289+ ),
290+ value: UInt64(
291+ 100,
292+ ),
293+ },
294+ ],
295+ named_params: [],
296+ alias: None,
297+ sample: None,
298+ },
299+ ],
300+ selection: None,
301+ group_by: None,
302+ having: None,
303+ window_list: None,
304+ qualify: None,
305+ },
306+ ),
307+ order_by: [],
308+ limit: [],
309+ offset: None,
310+ ignore_result: false,
311+ },
312+ ),
313+ ),
314+ resultset: None,
315+ },
316+ }
317+
318+
123319---------- Input ----------
124320profit := revenue - cost
125321---------- Output ---------
@@ -2094,14 +2290,17 @@ ScriptBlock {
20942290 quote: None,
20952291 ident_type: None,
20962292 },
2097- default: Literal {
2098- span: Some(
2099- 17..18,
2100- ),
2101- value: UInt64(
2102- 1,
2103- ),
2104- },
2293+ data_type: None,
2294+ default: Some(
2295+ Literal {
2296+ span: Some(
2297+ 17..18,
2298+ ),
2299+ value: UInt64(
2300+ 1,
2301+ ),
2302+ },
2303+ ),
21052304 },
21062305 ),
21072306 ],
0 commit comments