-
Notifications
You must be signed in to change notification settings - Fork 0
Add support for AlterTable::drop_columns
#106
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
Conversation
|
Warning Rate limit exceeded@amotl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 16 minutes and 6 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
WalkthroughThe PR extends the AlterTable operation to support column deletion. When Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
79d20ea to
6d6678d
Compare
6d6678d to
680b033
Compare
| "change_column_data_type": [ | ||
| { | ||
| "table": "transaction", | ||
| "column": "amount", | ||
| "data_type": "STRING" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The target data type should actually be DOUBLE, but that currently fails.
| "change_column_data_type": [ | |
| { | |
| "table": "transaction", | |
| "column": "amount", | |
| "data_type": "STRING" | |
| "change_column_data_type": [ | |
| { | |
| "table": "transaction", | |
| "column": "amount", | |
| "data_type": "DOUBLE" |
| for column in columns_deleted: | ||
| connection.execute( | ||
| sa.text( | ||
| f'ALTER TABLE {table_info.fullname} DROP COLUMN "{column.name}"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CrateDB supports dropping multiple columns at once, see https://cratedb.com/docs/crate/reference/en/latest/sql/statements/alter-table.html#drop-column.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improved with a60831c, thanks.
CHANGES.md
Outdated
| - Added support for `AlterTable::drop_columns`, satisfying | ||
| SDK tester's `schema_migrations_input_ddl.json` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this more about adding support for changing data types as a user visible change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've compressed the statement.
680b033 to
a60831c
Compare
This satisfies SDK tester's `schema_migrations_input_ddl.json`. Co-authored-by: Sebastian Utz <[email protected]>
a60831c to
1ce0df3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
tests/test_adapter.py (1)
223-260: Good test coverage for the nothing-changed path.The test correctly verifies that when
drop_columns=Truebut no columns are actually removed, the operation succeeds with the appropriate log message.Address the static analysis hint: prefix the unused
errvariable with an underscore:# Check log output. - out, err = capsys.readouterr() + out, _ = capsys.readouterr() assert format_log_message("AlterTable (drop columns): Nothing changed", newline=True) in outtests/test_integration.py (1)
143-153: Integration test correctly validates migrations DDL workflow.The test appropriately verifies that the Fivetran destination tester completes the migrations DDL scenario.
Address the static analysis hint: prefix the unused
outvariable with an underscore:# Read out stdout and stderr. - out, err = capfd.readouterr() + _, err = capfd.readouterr() assert "Describe Table: transaction" in errNote: The static analysis warning about unused
servicesparameter is a false positive—it's consumed by the pytest fixture mechanism.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
CHANGES.md(1 hunks)src/cratedb_fivetran_destination/main.py(2 hunks)tests/data/fivetran_migrations_ddl/configuration.json(1 hunks)tests/data/fivetran_migrations_ddl/schema_migrations_input_ddl.json(1 hunks)tests/test_adapter.py(1 hunks)tests/test_integration.py(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tests/test_adapter.py (3)
tests/conftest.py (1)
engine(6-17)src/cratedb_fivetran_destination/main.py (2)
CrateDBDestinationImpl(31-351)AlterTable(94-199)src/cratedb_fivetran_destination/util.py (1)
format_log_message(14-19)
src/cratedb_fivetran_destination/main.py (3)
tests/conftest.py (1)
engine(6-17)src/cratedb_fivetran_destination/model.py (2)
execute(196-198)fullname(177-178)src/cratedb_fivetran_destination/util.py (1)
log_message(10-11)
🪛 Ruff (0.14.6)
tests/test_adapter.py
258-258: Unpacked variable err is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
tests/test_integration.py
144-144: Unused function argument: services
(ARG001)
150-150: Unpacked variable out is never used
Prefix it with an underscore or any other dummy variable pattern
(RUF059)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: oci
- GitHub Check: Build for OS macos-15-intel
🔇 Additional comments (3)
CHANGES.md (1)
9-9: LGTM!The changelog entry accurately describes the new feature.
tests/data/fivetran_migrations_ddl/configuration.json (1)
1-11: LGTM!Test configuration is properly structured for the migrations DDL test scenario.
tests/data/fivetran_migrations_ddl/schema_migrations_input_ddl.json (1)
1-53: LGTM!The DDL migration test data appropriately exercises the new drop_columns functionality along with other schema migration operations.
| # Validate outcome. | ||
| assert response.success is True | ||
| assert response.warning.message == "" | ||
|
|
||
| # Check log output. | ||
| out, err = capsys.readouterr() | ||
| assert format_log_message("AlterTable (drop columns): Nothing changed", newline=True) in out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "nothing changed" should converge into a warning message instead? Let's track this on behalf of an "API polishing" ticket, please. /cc @coderabbitai
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Create a GitHub issue to track the API polishing suggestion
gh issue create \
--title "API polishing: Convert 'nothing changed' messages to warnings" \
--body "## Context
During review of PR #106, a suggestion was made to convert 'nothing changed' log messages into warning messages for better API consistency.
Currently, when \`AlterTable\` operations result in no changes (e.g., when \`drop_columns=True\` but no columns are actually dropped), the system logs informational messages like:
- \`AlterTable: Nothing changed\`
- \`AlterTable (drop columns): Nothing changed\`
## Suggestion
These 'nothing changed' scenarios should converge into warning messages instead of informational log messages, to better signal to users that the operation had no effect.
## References
- PR: https://github.com/crate/cratedb-fivetran-destination/pull/106
- Comment: https://github.com/crate/cratedb-fivetran-destination/pull/106#discussion_r2571402896
- Requested by: @amotl" \
--assignee amotl
Length of output: 64
@amotl, I've created issue #108 to track this API polishing suggestion: #108
The issue captures the idea of converting "nothing changed" messages to warnings for better API consistency and has been assigned to you.
About
This patch, adding the implementation for the
drop_columnsoperation, satisfies SDK tester'sschema_migrations_input_ddl.json.