File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
regression-test/suites/nereids_p0/sql_functions Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -319,6 +319,53 @@ suite("test_default") {
319319 exception " DEFAULT function requires a column reference"
320320 }
321321
322+ def baseDefault = sql """
323+ SELECT DEFAULT(c_bool)
324+ FROM ${ tableName}
325+ LIMIT 1
326+ """
327+ def tableAliasDefault = sql """
328+ SELECT DEFAULT(t.c_bool)
329+ FROM ${ tableName} t
330+ LIMIT 1
331+ """
332+ def aliasDefault = sql """
333+ SELECT DEFAULT(x)
334+ FROM (
335+ SELECT c_bool AS x
336+ FROM ${ tableName}
337+ ) t
338+ LIMIT 1
339+ """
340+ def nestedAliasDefault = sql """
341+ SELECT DEFAULT(x)
342+ FROM (
343+ SELECT x
344+ FROM (
345+ SELECT c_bool AS x
346+ FROM ${ tableName}
347+ ) inner_view
348+ ) outer_view
349+ LIMIT 1
350+ """
351+ def cteAliasDefault = sql """
352+ WITH cte AS (
353+ SELECT c_bool AS x
354+ FROM ${ tableName}
355+ )
356+ SELECT DEFAULT(x)
357+ FROM cte
358+ LIMIT 1
359+ """
360+ assertTrue (aliasDefault == baseDefault,
361+ " DEFAULT() should return the same value for aliased columns in subqueries" )
362+ assertTrue (tableAliasDefault == baseDefault,
363+ " DEFAULT() should return the same value when referenced through a table alias" )
364+ assertTrue (nestedAliasDefault == baseDefault,
365+ " DEFAULT() should return the same value for nested aliased subqueries" )
366+ assertTrue (cteAliasDefault == baseDefault,
367+ " DEFAULT() should return the same value when alias comes from a CTE" )
368+
322369 sql " SET enable_fold_constant_by_be = false;"
323370 test {
324371 sql " SELECT DEFAULT(c_bool, c_int) FROM ${ tableName} LIMIT 1"
You can’t perform that action at this time.
0 commit comments