MCPcopy Create free account
hub / github.com/bytedance/bolt / TEST_P

Function TEST_P

bolt/exec/tests/TableWriteTest.cpp:1650–1702  ·  view source on GitHub ↗

Runs a pipeline with read + filter + project (with substr) + write.

Source from the content-addressed store, hash-verified

1648
1649// Runs a pipeline with read + filter + project (with substr) + write.
1650TEST_P(AllTableWriterTest, scanFilterProjectWrite) {
1651 auto filePaths = makeFilePaths(5);
1652 auto vectors = makeVectors(filePaths.size(), 500);
1653 for (int i = 0; i < filePaths.size(); i++) {
1654 writeToFile(filePaths[i]->path, vectors[i]);
1655 }
1656
1657 createDuckDbTable(vectors);
1658
1659 auto outputDirectory = TempDirectoryPath::create();
1660
1661 auto planBuilder = PlanBuilder();
1662 auto project = planBuilder.tableScan(rowType_).filter("c2 <> 0").project(
1663 {"c0", "c1", "c3", "c5", "c2 + c3", "substr(c5, 1, 1)"});
1664
1665 auto intputTypes = project.planNode()->outputType()->children();
1666 std::vector<std::string> tableColumnNames = {
1667 "c0", "c1", "c3", "c5", "c2_plus_c3", "substr_c5"};
1668 const auto outputType =
1669 ROW(std::move(tableColumnNames), std::move(intputTypes));
1670
1671 auto plan = createInsertPlan(
1672 project,
1673 outputType,
1674 outputDirectory->path,
1675 partitionedBy_,
1676 bucketProperty_,
1677 compressionKind_,
1678 getNumWriters(),
1679 connector::hive::LocationHandle::TableType::kNew,
1680 commitStrategy_);
1681
1682 assertQueryWithWriterConfigs(
1683 plan, filePaths, "SELECT count(*) FROM tmp WHERE c2 <> 0");
1684
1685 // To test the correctness of the generated output,
1686 // We create a new plan that only read that file and then
1687 // compare that against a duckDB query that runs the whole query.
1688 if (partitionedBy_.size() > 0) {
1689 auto newOutputType = getNonPartitionsColumns(partitionedBy_, outputType);
1690 assertQuery(
1691 PlanBuilder().tableScan(newOutputType).planNode(),
1692 makeHiveConnectorSplits(outputDirectory),
1693 "SELECT c3, c5, c2 + c3, substr(c5, 1, 1) FROM tmp WHERE c2 <> 0");
1694 verifyTableWriterOutput(outputDirectory->path, newOutputType, false);
1695 } else {
1696 assertQuery(
1697 PlanBuilder().tableScan(outputType).planNode(),
1698 makeHiveConnectorSplits(outputDirectory),
1699 "SELECT c0, c1, c3, c5, c2 + c3, substr(c5, 1, 1) FROM tmp WHERE c2 <> 0");
1700 verifyTableWriterOutput(outputDirectory->path, outputType, false);
1701 }
1702}
1703
1704TEST_P(AllTableWriterTest, renameAndReorderColumns) {
1705 auto filePaths = makeFilePaths(5);

Callers

nothing calls this directly

Calls 15

PlanBuilderClass · 0.85
ROWFunction · 0.85
getNonPartitionsColumnsFunction · 0.85
assertQueryFunction · 0.85
TableScanBuilderClass · 0.85
readCursorFunction · 0.85
is_emptyFunction · 0.85
assertEqualResultsFunction · 0.85
commitStrategyToStringFunction · 0.85
getRowCountFunction · 0.85
MAPFunction · 0.85

Tested by

no test coverage detected