| 192 | } |
| 193 | |
| 194 | void testPartitionedTableImpl( |
| 195 | const std::string& filePath, |
| 196 | const TypePtr& partitionType, |
| 197 | const std::optional<std::string>& partitionValue) { |
| 198 | auto split = HiveConnectorSplitBuilder(filePath) |
| 199 | .connectorId(kHiveConnectorId) |
| 200 | .fileFormat(dwio::common::FileFormat::DWRF) |
| 201 | .partitionKey("pkey", partitionValue) |
| 202 | .build(); |
| 203 | auto outputType = |
| 204 | ROW({"pkey", "c0", "c1"}, {partitionType, BIGINT(), DOUBLE()}); |
| 205 | ColumnHandleMap assignments = { |
| 206 | {"pkey", partitionKey("pkey", partitionType)}, |
| 207 | {"c0", regularColumn("c0", BIGINT())}, |
| 208 | {"c1", regularColumn("c1", DOUBLE())}}; |
| 209 | |
| 210 | auto op = PlanBuilder() |
| 211 | .startTableScan() |
| 212 | .outputType(outputType) |
| 213 | .assignments(assignments) |
| 214 | .endTableScan() |
| 215 | .planNode(); |
| 216 | |
| 217 | std::string partitionValueStr = |
| 218 | partitionValue.has_value() ? "'" + *partitionValue + "'" : "null"; |
| 219 | assertQuery( |
| 220 | op, split, fmt::format("SELECT {}, * FROM tmp", partitionValueStr)); |
| 221 | |
| 222 | outputType = ROW({"c0", "pkey", "c1"}, {BIGINT(), partitionType, DOUBLE()}); |
| 223 | op = PlanBuilder() |
| 224 | .startTableScan() |
| 225 | .outputType(outputType) |
| 226 | .assignments(assignments) |
| 227 | .endTableScan() |
| 228 | .planNode(); |
| 229 | assertQuery( |
| 230 | op, |
| 231 | split, |
| 232 | fmt::format("SELECT c0, {}, c1 FROM tmp", partitionValueStr)); |
| 233 | outputType = ROW({"c0", "c1", "pkey"}, {BIGINT(), DOUBLE(), partitionType}); |
| 234 | op = PlanBuilder() |
| 235 | .startTableScan() |
| 236 | .outputType(outputType) |
| 237 | .assignments(assignments) |
| 238 | .endTableScan() |
| 239 | .planNode(); |
| 240 | assertQuery( |
| 241 | op, |
| 242 | split, |
| 243 | fmt::format("SELECT c0, c1, {} FROM tmp", partitionValueStr)); |
| 244 | |
| 245 | // select only partition key |
| 246 | assignments = {{"pkey", partitionKey("pkey", partitionType)}}; |
| 247 | outputType = ROW({"pkey"}, {partitionType}); |
| 248 | op = PlanBuilder() |
| 249 | .startTableScan() |
| 250 | .outputType(outputType) |
| 251 | .assignments(assignments) |
nothing calls this directly
no test coverage detected