Commit c21e25b
authored
Test/withtable extra properties (#539)
* test: support extra TBLPROPERTIES in withTable helper
Adds an `extraProperties: Map[String, String]` parameter to the
`withTable` test helper across all four Spark module versions
(3.3, 3.4, 3.5, 4.0). Each pair is rendered as a quoted
`'key' = 'value'` entry in the generated CREATE TABLE
TBLPROPERTIES block, alongside the existing `engine` and
`order_by` properties.
This unblocks tests that need ClickHouse `settings.*` overrides
(e.g. `settings.allow_nullable_key`) or connector-specific
options (e.g. `clickhouse.column.data.variant_types`) that
the helper previously couldn't express, forcing those tests
to open-code their own CREATE/DROP cycle.
The TBLPROPERTIES block is now assembled from a Seq joined
with `,\n `, which also incidentally cleans up the leading
blank line emitted when `sortKeys` was empty.
* test: migrate manual try/finally tests in ClickHouseWriterTestBase to withTable
Refactors all tests in `ClickHouseWriterTestBase` that previously open-coded
their CREATE DATABASE / CREATE TABLE / DROP TABLE / DROP DATABASE cycle
inside a try/finally to use the shared `withTable` test helper instead.
- spark-3.3, spark-3.4, spark-3.5: migrates the
`write StructType - full round-trip with Spark-created table` test.
- spark-4.0: additionally migrates the StructType round-trip test plus
every VariantType write test in the file (simple/nested/arrays/NULLs/
round-trip, Array/Map/Struct/Array-of-Struct of VariantType, and the
five `variant_types` option variants), all of which need the new
`extraProperties` parameter on `withTable` to express
`settings.allow_nullable_key` and the connector-specific
`clickhouse.column.data.variant_types` table property.
For the three tests that require ClickHouse's experimental JSON type as
a Variant subtype, the prerequisite `SET allow_experimental_json_type = 1`
is hoisted to immediately before the `withTable(...)` call (it's a Spark
session conf, so it remains in effect for the helper's CREATE TABLE).
The PROBE debug block in `write Map of String to VariantType` is
preserved as-is (only `\$db`/`\$tbl` rewritten to `\$actualDb`/`\$actualTbl`).
No tests are added or removed; this is a pure migration to the helper.1 parent 4f81e20 commit c21e25b
8 files changed
Lines changed: 193 additions & 394 deletions
File tree
- spark-3.3/clickhouse-spark-it/src/test/scala/org/apache/spark/sql/clickhouse/single
- spark-3.4/clickhouse-spark-it/src/test/scala/org/apache/spark/sql/clickhouse/single
- spark-3.5/clickhouse-spark-it/src/test/scala/org/apache/spark/sql/clickhouse/single
- spark-4.0/clickhouse-spark-it/src/test/scala/org/apache/spark/sql/clickhouse/single
Lines changed: 4 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
974 | 974 | | |
975 | 975 | | |
976 | 976 | | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
982 | 977 | | |
983 | 978 | | |
984 | 979 | | |
| |||
1001 | 996 | | |
1002 | 997 | | |
1003 | 998 | | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
| 999 | + | |
1022 | 1000 | | |
1023 | 1001 | | |
1024 | 1002 | | |
| |||
1042 | 1020 | | |
1043 | 1021 | | |
1044 | 1022 | | |
1045 | | - | |
| 1023 | + | |
1046 | 1024 | | |
1047 | | - | |
1048 | | - | |
| 1025 | + | |
1049 | 1026 | | |
1050 | 1027 | | |
1051 | | - | |
| 1028 | + | |
1052 | 1029 | | |
1053 | 1030 | | |
1054 | 1031 | | |
1055 | 1032 | | |
1056 | 1033 | | |
1057 | | - | |
1058 | 1034 | | |
1059 | 1035 | | |
1060 | | - | |
1061 | 1036 | | |
1062 | 1037 | | |
1063 | 1038 | | |
| |||
1069 | 1044 | | |
1070 | 1045 | | |
1071 | 1046 | | |
1072 | | - | |
1073 | 1047 | | |
1074 | 1048 | | |
1075 | 1049 | | |
| |||
1081 | 1055 | | |
1082 | 1056 | | |
1083 | 1057 | | |
1084 | | - | |
1085 | 1058 | | |
1086 | 1059 | | |
1087 | 1060 | | |
| |||
1092 | 1065 | | |
1093 | 1066 | | |
1094 | 1067 | | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | 1068 | | |
1101 | 1069 | | |
1102 | 1070 | | |
| |||
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
116 | 125 | | |
117 | 126 | | |
118 | 127 | | |
119 | 128 | | |
120 | 129 | | |
121 | 130 | | |
122 | | - | |
123 | | - | |
| 131 | + | |
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
| |||
Lines changed: 4 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
974 | 974 | | |
975 | 975 | | |
976 | 976 | | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
982 | 977 | | |
983 | 978 | | |
984 | 979 | | |
| |||
1001 | 996 | | |
1002 | 997 | | |
1003 | 998 | | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
| 999 | + | |
1022 | 1000 | | |
1023 | 1001 | | |
1024 | 1002 | | |
| |||
1042 | 1020 | | |
1043 | 1021 | | |
1044 | 1022 | | |
1045 | | - | |
| 1023 | + | |
1046 | 1024 | | |
1047 | | - | |
1048 | | - | |
| 1025 | + | |
1049 | 1026 | | |
1050 | 1027 | | |
1051 | | - | |
| 1028 | + | |
1052 | 1029 | | |
1053 | 1030 | | |
1054 | 1031 | | |
1055 | 1032 | | |
1056 | 1033 | | |
1057 | | - | |
1058 | 1034 | | |
1059 | 1035 | | |
1060 | | - | |
1061 | 1036 | | |
1062 | 1037 | | |
1063 | 1038 | | |
| |||
1069 | 1044 | | |
1070 | 1045 | | |
1071 | 1046 | | |
1072 | | - | |
1073 | 1047 | | |
1074 | 1048 | | |
1075 | 1049 | | |
| |||
1081 | 1055 | | |
1082 | 1056 | | |
1083 | 1057 | | |
1084 | | - | |
1085 | 1058 | | |
1086 | 1059 | | |
1087 | 1060 | | |
| |||
1092 | 1065 | | |
1093 | 1066 | | |
1094 | 1067 | | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | 1068 | | |
1101 | 1069 | | |
1102 | 1070 | | |
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
| 107 | + | |
| 108 | + | |
108 | 109 | | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
115 | 124 | | |
116 | 125 | | |
117 | 126 | | |
118 | 127 | | |
119 | 128 | | |
120 | 129 | | |
121 | | - | |
122 | | - | |
| 130 | + | |
123 | 131 | | |
124 | 132 | | |
125 | 133 | | |
| |||
Lines changed: 4 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
974 | 974 | | |
975 | 975 | | |
976 | 976 | | |
977 | | - | |
978 | | - | |
979 | | - | |
980 | | - | |
981 | | - | |
982 | 977 | | |
983 | 978 | | |
984 | 979 | | |
| |||
1001 | 996 | | |
1002 | 997 | | |
1003 | 998 | | |
1004 | | - | |
1005 | | - | |
1006 | | - | |
1007 | | - | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
1020 | | - | |
1021 | | - | |
| 999 | + | |
1022 | 1000 | | |
1023 | 1001 | | |
1024 | 1002 | | |
| |||
1042 | 1020 | | |
1043 | 1021 | | |
1044 | 1022 | | |
1045 | | - | |
| 1023 | + | |
1046 | 1024 | | |
1047 | | - | |
1048 | | - | |
| 1025 | + | |
1049 | 1026 | | |
1050 | 1027 | | |
1051 | | - | |
| 1028 | + | |
1052 | 1029 | | |
1053 | 1030 | | |
1054 | 1031 | | |
1055 | 1032 | | |
1056 | 1033 | | |
1057 | | - | |
1058 | 1034 | | |
1059 | 1035 | | |
1060 | | - | |
1061 | 1036 | | |
1062 | 1037 | | |
1063 | 1038 | | |
| |||
1069 | 1044 | | |
1070 | 1045 | | |
1071 | 1046 | | |
1072 | | - | |
1073 | 1047 | | |
1074 | 1048 | | |
1075 | 1049 | | |
| |||
1081 | 1055 | | |
1082 | 1056 | | |
1083 | 1057 | | |
1084 | | - | |
1085 | 1058 | | |
1086 | 1059 | | |
1087 | 1060 | | |
| |||
1092 | 1065 | | |
1093 | 1066 | | |
1094 | 1067 | | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
1098 | | - | |
1099 | | - | |
1100 | 1068 | | |
1101 | 1069 | | |
1102 | 1070 | | |
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
| 108 | + | |
| 109 | + | |
109 | 110 | | |
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
115 | 116 | | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
116 | 125 | | |
117 | 126 | | |
118 | 127 | | |
119 | 128 | | |
120 | 129 | | |
121 | 130 | | |
122 | | - | |
123 | | - | |
| 131 | + | |
124 | 132 | | |
125 | 133 | | |
126 | 134 | | |
| |||
0 commit comments