Skip to content

Commit 2c8f1c2

Browse files
committed
Add TestParsePlanNodeDetail
1 parent 6417020 commit 2c8f1c2

File tree

1 file changed

+106
-24
lines changed

1 file changed

+106
-24
lines changed

presto/plan_node/details_test.go

Lines changed: 106 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ func TestParseAssignment(t *testing.T) {
179179
`array_agg_51 := "presto.default.array_agg"((name_35)) ORDER BY OrderingScheme {orderBy='[Ordering {variable='name_35', sortOrder='ASC_NULLS_LAST'}]', orderings='{name_35=ASC_NULLS_LAST}'} (6:21)`,
180180
`branded_car_enrollment.target_id := car_id (22:5)`,
181181
`expr_5 := ((b) + (INTEGER'1')) - ((INTEGER'2') * (abs(c))) (10:6)`,
182-
`date_format_5 := date_format(CAST(CAST(period_hour_local_date AS date) AS timestamp), VARCHAR'%Y-%m-%d') (8:12)`,
183182
},
184183
[]plan_node.Assignment{
185184
{ // case 0
@@ -292,29 +291,6 @@ func TestParseAssignment(t *testing.T) {
292291
ColumnNumber: 6,
293292
},
294293
},
295-
{ // case 7
296-
Identifier: plan_node.IdentRef{Ident: "date_format_5"},
297-
AssignedValue: &plan_node.FunctionCall{
298-
FunctionName: "date_format",
299-
Parameters: []plan_node.Value{
300-
&plan_node.TypeCastedValue{
301-
OriginalValue: &plan_node.TypeCastedValue{
302-
OriginalValue: &plan_node.IdentRef{Ident: "period_hour_local_date"},
303-
CastedType: "date",
304-
},
305-
CastedType: "timestamp",
306-
},
307-
&plan_node.TypedValue{
308-
DataType: "VARCHAR",
309-
ValueLiteral: "%Y-%m-%d",
310-
},
311-
},
312-
},
313-
Loc: &plan_node.SourceLocation{
314-
RowNumber: 8,
315-
ColumnNumber: 12,
316-
},
317-
},
318294
})
319295
}
320296

@@ -346,3 +322,109 @@ func TestParseFunctionCall(t *testing.T) {
346322
},
347323
})
348324
}
325+
326+
func TestParsePlanNodeDetail(t *testing.T) {
327+
testParsing[plan_node.PlanNodeDetails](t, plan_node.PlanNodeDetailParserOptions,
328+
[]string{`expr_4 := CAST(city_id_0 AS varchar) (8:12)
329+
date_format_5 := date_format(CAST(CAST(period_hour_local_date AS date) AS timestamp), VARCHAR'%Y-%m-%d') (8:12)
330+
LAYOUT: ng_public.etl_city_kpi_hourly{}
331+
city_id_0 := city_id:bigint:1:REGULAR (8:11)
332+
period_hour_local_date := period_hour_local_date:string:-13:PARTITION_KEY (8:11)
333+
:: [["2023-03-01", "2024-05-31"]]
334+
has_order_h := has_order_h:decimal(10,2):37:REGULAR (8:11)
335+
`},
336+
[]plan_node.PlanNodeDetails{
337+
{
338+
Stmts: []plan_node.PlanNodeDetailStmt{
339+
&plan_node.Assignment{
340+
Identifier: plan_node.IdentRef{Ident: "expr_4"},
341+
AssignedValue: &plan_node.TypeCastedValue{
342+
OriginalValue: &plan_node.IdentRef{Ident: "city_id_0"},
343+
CastedType: "varchar",
344+
},
345+
Loc: &plan_node.SourceLocation{
346+
RowNumber: 8,
347+
ColumnNumber: 12,
348+
},
349+
},
350+
&plan_node.Assignment{
351+
Identifier: plan_node.IdentRef{Ident: "date_format_5"},
352+
AssignedValue: &plan_node.FunctionCall{
353+
FunctionName: "date_format",
354+
Parameters: []plan_node.Value{
355+
&plan_node.TypeCastedValue{
356+
OriginalValue: &plan_node.TypeCastedValue{
357+
OriginalValue: &plan_node.IdentRef{Ident: "period_hour_local_date"},
358+
CastedType: "date",
359+
},
360+
CastedType: "timestamp",
361+
},
362+
&plan_node.TypedValue{
363+
DataType: "VARCHAR",
364+
ValueLiteral: "%Y-%m-%d",
365+
},
366+
},
367+
},
368+
Loc: &plan_node.SourceLocation{
369+
RowNumber: 8,
370+
ColumnNumber: 12,
371+
},
372+
},
373+
&plan_node.Layout{
374+
LayoutString: "ng_public.etl_city_kpi_hourly{}",
375+
},
376+
&plan_node.Assignment{
377+
Identifier: plan_node.IdentRef{Ident: "city_id_0"},
378+
AssignedValue: &plan_node.HiveColumnHandle{
379+
ColumnName: plan_node.IdentRef{Ident: "city_id"},
380+
DataType: "bigint",
381+
ColumnIndex: 1,
382+
ColumnType: "REGULAR",
383+
Loc: &plan_node.SourceLocation{
384+
RowNumber: 8,
385+
ColumnNumber: 11,
386+
},
387+
},
388+
},
389+
&plan_node.Assignment{
390+
Identifier: plan_node.IdentRef{Ident: "period_hour_local_date"},
391+
AssignedValue: &plan_node.HiveColumnHandle{
392+
ColumnName: plan_node.IdentRef{Ident: "period_hour_local_date"},
393+
DataType: "string",
394+
ColumnIndex: -13,
395+
ColumnType: "PARTITION_KEY",
396+
Loc: &plan_node.SourceLocation{
397+
RowNumber: 8,
398+
ColumnNumber: 11,
399+
},
400+
Ranges: []plan_node.Range{
401+
{
402+
LowValue: &plan_node.Marker{
403+
Bound: plan_node.EXACTLY,
404+
Value: "2023-03-01",
405+
},
406+
HighValue: &plan_node.Marker{
407+
Bound: plan_node.EXACTLY,
408+
Value: "2024-05-31",
409+
},
410+
},
411+
},
412+
},
413+
},
414+
&plan_node.Assignment{
415+
Identifier: plan_node.IdentRef{Ident: "has_order_h"},
416+
AssignedValue: &plan_node.HiveColumnHandle{
417+
ColumnName: plan_node.IdentRef{Ident: "has_order_h"},
418+
DataType: "decimal(10,2)",
419+
ColumnIndex: 37,
420+
ColumnType: "REGULAR",
421+
Loc: &plan_node.SourceLocation{
422+
RowNumber: 8,
423+
ColumnNumber: 11,
424+
},
425+
},
426+
},
427+
},
428+
},
429+
})
430+
}

0 commit comments

Comments
 (0)