Skip to content

Commit

Permalink
adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
pdet committed Sep 25, 2024
1 parent 3fa6609 commit 2b2a187
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions src/from_substrait.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ unique_ptr<TableDescription> TableInfo(ClientContext &context, const string &sch
shared_ptr<Relation> SubstraitToDuckDB::TransformReadOp(const substrait::Rel &sop) {
auto &sget = sop.read();
shared_ptr<Relation> scan;

Check failure on line 544 in src/from_substrait.cpp

View workflow job for this annotation

GitHub Actions / Build extension binaries / MacOS (osx_arm64, arm64, arm64-osx)

unknown type name 'RelationContextWrapper'; did you mean 'ClientContextWrapper'?

Check failure on line 544 in src/from_substrait.cpp

View workflow job for this annotation

GitHub Actions / Build extension binaries / MacOS (osx_amd64, x86_64, x64-osx)

unknown type name 'RelationContextWrapper'; did you mean 'ClientContextWrapper'?

Check failure on line 544 in src/from_substrait.cpp

View workflow job for this annotation

GitHub Actions / Build extension binaries / MacOS (osx_arm64, arm64, arm64-osx)

unknown type name 'RelationContextWrapper'; did you mean 'ClientContextWrapper'?

Check failure on line 544 in src/from_substrait.cpp

View workflow job for this annotation

GitHub Actions / Build extension binaries / MacOS (osx_amd64, x86_64, x64-osx)

unknown type name 'RelationContextWrapper'; did you mean 'ClientContextWrapper'?

Check failure on line 544 in src/from_substrait.cpp

View workflow job for this annotation

GitHub Actions / Build extension binaries / Linux (linux_amd64_gcc4, quay.io/pypa/manylinux2014_x86_64, x64-linux)

‘RelationContextWrapper’ was not declared in this scope; did you mean ‘ClientContextWrapper’?

Check failure on line 544 in src/from_substrait.cpp

View workflow job for this annotation

GitHub Actions / Build extension binaries / Linux (linux_amd64_gcc4, quay.io/pypa/manylinux2014_x86_64, x64-linux)

no matching function for call to ‘make_shared_ptr<<expression error> >(duckdb::shared_ptr<duckdb::ClientContext, true>&)’

Check failure on line 544 in src/from_substrait.cpp

View workflow job for this annotation

GitHub Actions / Build extension binaries / Linux (linux_amd64_gcc4, quay.io/pypa/manylinux2014_x86_64, x64-linux)

template argument 1 is invalid
auto context_wrapper = make_shared_ptr<RelationContextWrapper>(context);
if (sget.has_named_table()) {
auto table_name = sget.named_table().names(0);
// If we can't find a table with that name, let's try a view.
Expand All @@ -550,9 +551,19 @@ shared_ptr<Relation> SubstraitToDuckDB::TransformReadOp(const substrait::Rel &so
if (!table_info) {
throw CatalogException("Table '%s' does not exist!", table_name);
}
scan = make_shared_ptr<TableRelation>(context, std::move(table_info), acquire_lock);
if (acquire_lock) {
scan = make_shared_ptr<TableRelation>(context, std::move(table_info));

} else {
scan = make_shared_ptr<TableRelation>(context_wrapper, std::move(table_info));
}
} catch (...) {
scan = make_shared_ptr<ViewRelation>(context, DEFAULT_SCHEMA, table_name, acquire_lock);
if (acquire_lock) {
scan = make_shared_ptr<ViewRelation>(context, DEFAULT_SCHEMA, table_name);

} else {
scan = make_shared_ptr<ViewRelation>(context_wrapper, DEFAULT_SCHEMA, table_name);
}
}
} else if (sget.has_local_files()) {
vector<Value> parquet_files;
Expand All @@ -574,8 +585,15 @@ shared_ptr<Relation> SubstraitToDuckDB::TransformReadOp(const substrait::Rel &so
string name = "parquet_" + StringUtil::GenerateRandomName();
named_parameter_map_t named_parameters({{"binary_as_string", Value::BOOLEAN(false)}});
vector<Value> parameters {Value::LIST(parquet_files)};
auto scan_rel = make_shared_ptr<TableFunctionRelation>(
context, "parquet_scan", parameters, std::move(named_parameters), nullptr, true, acquire_lock);
shared_ptr<TableFunctionRelation> scan_rel;
if (acquire_lock) {
scan_rel = make_shared_ptr<TableFunctionRelation>(context, "parquet_scan", parameters,
std::move(named_parameters));
} else {
scan_rel = make_shared_ptr<TableFunctionRelation>(context_wrapper, "parquet_scan", parameters,
std::move(named_parameters));
}

auto rel = static_cast<Relation *>(scan_rel.get());
scan = rel->Alias(name);
} else if (sget.has_virtual_table()) {
Expand All @@ -591,7 +609,12 @@ shared_ptr<Relation> SubstraitToDuckDB::TransformReadOp(const substrait::Rel &so
expression_rows.emplace_back(expression_row);
}
vector<string> column_names;
scan = make_shared_ptr<ValueRelation>(context, expression_rows, column_names, "values", acquire_lock);
if (acquire_lock) {
scan = make_shared_ptr<ValueRelation>(context, expression_rows, column_names);

} else {
scan = make_shared_ptr<ValueRelation>(context_wrapper, expression_rows, column_names);
}
} else {
throw NotImplementedException("Unsupported type of read operator for substrait");
}
Expand Down

0 comments on commit 2b2a187

Please sign in to comment.