Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump MySQL scanner to v0.10.1 and handle new limit nodes #46

Merged
merged 7 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/MainDistributionPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,30 @@ concurrency:
jobs:
duckdb-stable-build:
name: Build extension binaries
uses: duckdb/duckdb/.github/workflows/_extension_distribution.yml@0e784765f6f87bd1ce9034afcce1e7f89fcd8777
uses: duckdb/duckdb/.github/workflows/_extension_distribution.yml@4a89d97db8a5a23a15f3025c8d2d2885337c2637
with:
duckdb_version: v0.10.0
duckdb_version: v0.10.1
extension_name: mysql_scanner
exclude_archs: 'osx_amd64;osx_arm64;wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools'
vcpkg_commit: a42af01b72c28a8e1d7b48107b33e4f286a55ef6
build_duckdb_shell: false

# Note: this workaround is required for building MacOS where extra toolchain config is required
duckdb-stable-build-macos:
name: Build extension binaries
uses: ./.github/workflows/_extension_distribution_macos.yml
with:
duckdb_version: v0.10.0
duckdb_version: v0.10.1
extension_name: mysql_scanner
vcpkg_commit: a42af01b72c28a8e1d7b48107b33e4f286a55ef6

duckdb-stable-deploy:
name: Deploy extension binaries
needs: [duckdb-stable-build, duckdb-stable-build-macos]
uses: duckdb/duckdb/.github/workflows/_extension_deploy.yml@0e784765f6f87bd1ce9034afcce1e7f89fcd8777
uses: duckdb/duckdb/.github/workflows/_extension_deploy.yml@4a89d97db8a5a23a15f3025c8d2d2885337c2637
secrets: inherit
with:
duckdb_version: v0.10.0
duckdb_version: v0.10.1
extension_name: mysql_scanner
exclude_archs: 'wasm_mvp;wasm_eh;wasm_threads;windows_amd64_rtools'
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ endif
ifneq ("${VCPKG_TARGET_TRIPLET}", "")
TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DVCPKG_TARGET_TRIPLET='${VCPKG_TARGET_TRIPLET}'
endif
ifeq (${BUILD_SHELL},0)
TOOLCHAIN_FLAGS:=${TOOLCHAIN_FLAGS} -DBUILD_SHELL=0
endif

ifeq ($(GEN),ninja)
GENERATOR=-G "Ninja"
Expand Down
24 changes: 18 additions & 6 deletions src/storage/mysql_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,28 @@ void OptimizeMySQLScan(unique_ptr<LogicalOperator> &op) {
if (!IsMySQLScan(get.function.name)) {
return;
}
if (limit.limit || limit.offset) {
// not a constant limit
switch (limit.limit_val.Type()) {
case LimitNodeType::CONSTANT_VALUE:
case LimitNodeType::UNSET:
break;
default:
// not a constant or unset limit
return;
}
switch (limit.offset_val.Type()) {
case LimitNodeType::CONSTANT_VALUE:
case LimitNodeType::UNSET:
break;
default:
// not a constant or unset offset
return;
}
auto &bind_data = get.bind_data->Cast<MySQLBindData>();
if (limit.limit_val > 0) {
bind_data.limit += " LIMIT " + to_string(limit.limit_val);
if (limit.limit_val.Type() != LimitNodeType::UNSET) {
bind_data.limit += " LIMIT " + to_string(limit.limit_val.GetConstantValue());
}
if (limit.offset_val > 0) {
bind_data.limit += " OFFSET " + to_string(limit.offset_val);
if (limit.offset_val.Type() != LimitNodeType::UNSET) {
bind_data.limit += " OFFSET " + to_string(limit.offset_val.GetConstantValue());
}
// remove the limit
op = std::move(op->children[0]);
Expand Down
3 changes: 2 additions & 1 deletion test/sql/attach_types.test
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ NULL NULL NULL NULL
# test all types
statement ok
CREATE TABLE all_types_tbl AS SELECT *
EXCLUDE (float, double, ubigint, hugeint, uhugeint, int_array, double_array, date_array, timestamp_array, timestamptz_array, varchar_array, nested_int_array, struct, struct_of_arrays, array_of_structs, map, "union")
EXCLUDE (float, double, ubigint, hugeint, uhugeint, int_array, double_array, date_array, timestamp_array, timestamptz_array, varchar_array, nested_int_array, struct, struct_of_arrays, array_of_structs, map, "union",fixed_int_array,fixed_varchar_array,fixed_nested_varchar_array,list_of_fixed_int_array,fixed_array_of_int_list,fixed_nested_int_array,struct_of_fixed_array,fixed_struct_array
)
REPLACE(
CASE WHEN int IS NOT NULL THEN '2000-01-01' ELSE NULL END AS date,
CASE WHEN int IS NOT NULL THEN '2000-01-01 01:02:03' ELSE NULL END AS timestamp,
Expand Down
Loading