From ce7eece7242029543ff7632e15d1da3440dabf78 Mon Sep 17 00:00:00 2001 From: robot-clickhouse Date: Thu, 10 Oct 2024 08:11:12 +0000 Subject: [PATCH] Backport #69831 to 24.9: fix `getSubcolumn` with `LowCardinality` columns --- src/Functions/getSubcolumn.cpp | 1 + .../02731_analyzer_join_resolve_nested.reference | 8 ++++---- .../03237_get_subcolumn_low_cardinality_column.reference | 1 + .../03237_get_subcolumn_low_cardinality_column.sql | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 tests/queries/0_stateless/03237_get_subcolumn_low_cardinality_column.reference create mode 100644 tests/queries/0_stateless/03237_get_subcolumn_low_cardinality_column.sql diff --git a/src/Functions/getSubcolumn.cpp b/src/Functions/getSubcolumn.cpp index f041165385e..a284963fa71 100644 --- a/src/Functions/getSubcolumn.cpp +++ b/src/Functions/getSubcolumn.cpp @@ -23,6 +23,7 @@ public: size_t getNumberOfArguments() const override { return 2; } bool isSuitableForShortCircuitArgumentsExecution(const DataTypesWithConstInfo &) const override { return true; } bool useDefaultImplementationForConstants() const override { return true; } + bool useDefaultImplementationForLowCardinalityColumns() const override { return false; } ColumnNumbers getArgumentsThatAreAlwaysConstant() const override { return {1}; } DataTypePtr getReturnTypeImpl(const ColumnsWithTypeAndName & arguments) const override diff --git a/tests/queries/0_stateless/02731_analyzer_join_resolve_nested.reference b/tests/queries/0_stateless/02731_analyzer_join_resolve_nested.reference index 5f1b7e8b1fe..e72893e9638 100644 --- a/tests/queries/0_stateless/02731_analyzer_join_resolve_nested.reference +++ b/tests/queries/0_stateless/02731_analyzer_join_resolve_nested.reference @@ -140,14 +140,14 @@ [[[([(1,'d')],'d')]]] Array(Array(Nested(t Nested(t Int32, s String), s String))) [[[[1]]]] Array(Array(Array(Array(Int32)))) [[[([(1,'d')],'d')]]] [['s']] Array(Array(Array(Tuple(Array(Tuple(Int64, String)), String)))) Array(Array(String)) -[[[[(1,'d')]]]] [[['d']]] Array(Array(Array(Array(Tuple(\n t Int32,\n s String))))) Array(Array(Array(String))) +[[[[(1,'d')]]]] [[['d']]] Array(Array(Array(Nested(t Int32, s String)))) Array(Array(Array(String))) [[[[1]]]] [[[['d']]]] Array(Array(Array(Array(Int32)))) Array(Array(Array(Array(String)))) [([([([(1,'d')],'d')],'s')],'s')] Array(Tuple(\n t Array(Tuple(\n t Array(Tuple(\n t Array(Tuple(\n t Int32,\n s String)),\n s String)),\n s String)),\n s String)) [[([([(1,'d')],'d')],'s')]] Array(Nested(t Nested(t Nested(t Int32, s String), s String), s String)) [[[([(1,'d')],'d')]]] Array(Array(Array(Tuple(Array(Tuple(Int64, String)), String)))) [[[[1]]]] Array(Array(Array(Array(Int32)))) [[([([(1,'d')],'d')],'s')]] ['s'] Array(Array(Tuple(\n t Array(Tuple(\n t Array(Tuple(\n t Int32,\n s String)),\n s String)),\n s String))) Array(String) -[[[([(1,'d')],'d')]]] [['s']] Array(Array(Array(Tuple(\n t Array(Tuple(\n t Int32,\n s String)),\n s String)))) Array(Array(String)) +[[[([(1,'d')],'d')]]] [['s']] Array(Array(Nested(t Nested(t Int32, s String), s String))) Array(Array(String)) [[[[(1,'d')]]]] [[['d']]] Array(Array(Array(Array(Tuple(Int64, String))))) Array(Array(Array(String))) [[[[1]]]] [[[['d']]]] Array(Array(Array(Array(Int32)))) Array(Array(Array(Array(String)))) [([([([(1,'d')],'d')],'s')],'s')] Array(Tuple(\n t Array(Tuple(\n t Array(Tuple(\n t Array(Tuple(\n t Int32,\n s String)),\n s String)),\n s String)),\n s String)) @@ -297,14 +297,14 @@ [[[([(1,'d')],'d')]]] Array(Array(Nested(t Nested(t Int32, s String), s String))) [[[[1]]]] Array(Array(Array(Array(Int32)))) [[[([(1,'d')],'d')]]] [['s']] Array(Array(Array(Tuple(Array(Tuple(Int64, String)), String)))) Array(Array(String)) -[[[[(1,'d')]]]] [[['d']]] Array(Array(Array(Array(Tuple(\n t Int32,\n s String))))) Array(Array(Array(String))) +[[[[(1,'d')]]]] [[['d']]] Array(Array(Array(Nested(t Int32, s String)))) Array(Array(Array(String))) [[[[1]]]] [[[['d']]]] Array(Array(Array(Array(Int32)))) Array(Array(Array(Array(String)))) [([([([(1,'d')],'d')],'s')],'s')] Array(Tuple(\n t Array(Tuple(\n t Array(Tuple(\n t Array(Tuple(\n t Int32,\n s String)),\n s String)),\n s String)),\n s String)) [[([([(1,'d')],'d')],'s')]] Array(Nested(t Nested(t Nested(t Int32, s String), s String), s String)) [[[([(1,'d')],'d')]]] Array(Array(Array(Tuple(Array(Tuple(Int64, String)), String)))) [[[[1]]]] Array(Array(Array(Array(Int32)))) [[([([(1,'d')],'d')],'s')]] ['s'] Array(Array(Tuple(\n t Array(Tuple(\n t Array(Tuple(\n t Int32,\n s String)),\n s String)),\n s String))) Array(String) -[[[([(1,'d')],'d')]]] [['s']] Array(Array(Array(Tuple(\n t Array(Tuple(\n t Int32,\n s String)),\n s String)))) Array(Array(String)) +[[[([(1,'d')],'d')]]] [['s']] Array(Array(Nested(t Nested(t Int32, s String), s String))) Array(Array(String)) [[[[(1,'d')]]]] [[['d']]] Array(Array(Array(Array(Tuple(Int64, String))))) Array(Array(Array(String))) [[[[1]]]] [[[['d']]]] Array(Array(Array(Array(Int32)))) Array(Array(Array(Array(String)))) [([([([(1,'d')],'d')],'s')],'s')] Array(Tuple(\n t Array(Tuple(\n t Array(Tuple(\n t Array(Tuple(\n t Int32,\n s String)),\n s String)),\n s String)),\n s String)) diff --git a/tests/queries/0_stateless/03237_get_subcolumn_low_cardinality_column.reference b/tests/queries/0_stateless/03237_get_subcolumn_low_cardinality_column.reference new file mode 100644 index 00000000000..50c25a86b2f --- /dev/null +++ b/tests/queries/0_stateless/03237_get_subcolumn_low_cardinality_column.reference @@ -0,0 +1 @@ +LowCardinality(String) diff --git a/tests/queries/0_stateless/03237_get_subcolumn_low_cardinality_column.sql b/tests/queries/0_stateless/03237_get_subcolumn_low_cardinality_column.sql new file mode 100644 index 00000000000..4d4755541f5 --- /dev/null +++ b/tests/queries/0_stateless/03237_get_subcolumn_low_cardinality_column.sql @@ -0,0 +1 @@ +SELECT toTypeName(getSubcolumn(tuple('str')::Tuple(a LowCardinality(String)), 'a'))