Skip to content

Tests: Add integration tests with CrateDB#192

Draft
amotl wants to merge 2 commits into
mainfrom
cratedb
Draft

Tests: Add integration tests with CrateDB#192
amotl wants to merge 2 commits into
mainfrom
cratedb

Conversation

@amotl

@amotl amotl commented Jul 10, 2026

Copy link
Copy Markdown
Member

About

CrateDB is an emerging open-source data warehouse that can store data in the terabyte ranges and is largely compatible with PostgreSQL.

Details

An earlier attempt to validate CrateDB caused too much noise, because the database didn't support the DATE type. Now that this has changed recently, warehouse operations become actually viable.

@DHRUV6029: Thank you very much for submitting the relevant patch to CrateDB. 👍

Status

The adjusted test suite currently needs to skip a few test cases that raise the venerable DestinationSchemaTampered exception of dlt. We think dlt-cratedb might need further adjustments beyond the patch recently submitted by @florinutz.

pytest --no-cov -k cratedb
87 passed, 71 skipped, 54 warnings in 124.39s (0:02:04)

References

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • coderabbit-review

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4e181141-902f-4d57-ae27-bda6fa313eeb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cratedb

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@amotl
amotl force-pushed the cratedb branch 4 times, most recently from 49dd807 to 190f1af Compare July 11, 2026 21:56
@codecov

codecov Bot commented Jul 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.36%. Comparing base (dc5aa50) to head (116d76d).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #192      +/-   ##
==========================================
+ Coverage   54.33%   54.36%   +0.03%     
==========================================
  Files         203      203              
  Lines        9574     9574              
==========================================
+ Hits         5202     5205       +3     
+ Misses       4372     4369       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread pyproject.toml
"pytest-cov<8",
"pytest-xdist[psutil]<4",
"testcontainers[mysql,postgres]>=4.9.1,<4.15",
"testcontainers[cratedb,mysql,postgres] @ git+https://github.com/testcontainers/testcontainers-python.git@main",

@amotl amotl Jul 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for adding a native CrateDB adapter to Testcontainers for Python. With testcontainers 4.15, we will be able to use it in downstream packages swiftly.

Suggested change
"testcontainers[cratedb,mysql,postgres] @ git+https://github.com/testcontainers/testcontainers-python.git@main",
"testcontainers[cratedb,mysql,postgres]>=4.15,<4.16",

/cc @florinutz, @alexanderankin

Comment thread pyproject.toml
"dataclasses-json<0.7",
"dlt<1.29",
"dlt-cratedb<0.2",
"dlt-cratedb @ git+https://github.com/zerotired/dlt-cratedb.git@fix-dynamic-install",

@amotl amotl Jul 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@florinutz: It looks like even when using the newest updates in the dlt-cratedb repository, including yours, the venerable DestinationSchemaTampered error is still present across the board.

Comment on lines +58 to +63
if dest_uri.startswith("cratedb://"):
pytest.skip(
"Fails on CrateDB with `DestinationSchemaTampered`, see "
"https://github.com/crate/dlt-cratedb/issues/14"
)

@amotl amotl Jul 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@florinutz: It looks like even when using the newest updates in the dlt-cratedb repository, including yours, the venerable DestinationSchemaTampered error is still present across the board.

Like demonstrated here, we had to skip all test cases that are still failing on CrateDB. It would be so sweet to resolve them in one way or another, so CrateDB can become a premium-grade data warehouse within omniload and other applications using dlt. 🙏

@read-the-docs-community

Copy link
Copy Markdown

@amotl amotl left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me flag two more errors.

Comment on lines +365 to +370
if dest_uri.startswith("cratedb://"):
pytest.skip(
'Fails on CrateDB with `"_id" conflicts with system column`, '
"see https://github.com/crate/dlt-cratedb/issues/19"
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently we need to skip the MongoDB -> CrateDB integration tests, because of the venerable “_id” conflicts with system column pattern error that apparently still happens.

/cc @florinutz

Comment on lines 123 to +129
def append_test(dest_uri, dynamodb, schema: str):

if dest_uri.startswith("cratedb://"):
pytest.skip(
"Fails on CrateDB with twice the amount of expected results: AssertionError: assert 6 == 3"
)

@amotl amotl Jul 11, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is another type of error we haven't seen before with dlt and CrateDB. It needs to be investigated.

Comment on lines -55 to +63
assert res[0] == ("message1",)
assert res[1] == ("message2",)
assert res[2] == ("message3",)
if dest_uri.startswith("cratedb://"):
messages_db = [res[0][0], res[1][0], res[2][0]]
assert "message1" in messages_db
assert "message2" in messages_db
assert "message3" in messages_db
else:
assert res[0] == ("message1",)
assert res[1] == ("message2",)
assert res[2] == ("message3",)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: Maybe adjust the database query instead to emit ordered results?

@amotl amotl changed the title CrateDB integration tests Tests: Add integration tests with CrateDB Jul 15, 2026
@amotl amotl added quality All things quality assurance and software tests. help wanted Extra attention is needed labels Jul 15, 2026
@amotl amotl mentioned this pull request Jul 15, 2026

@kimberly-WY kimberly-WY left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement overall. One edge case: empty string vs null aren't treated the same downstream — might need a normalization step.

@hampsterx

Copy link
Copy Markdown
Contributor

The DestinationSchemaTampered skips are release-lag; there's a separate merge-semantics gap underneath.

Reproduced against CrateDB 6.3.0 nightly with a minimal dlt pipeline (timestamp + primary key):

write disposition dlt-cratedb 0.1.1 (released) dlt-cratedb main
append OK OK
merge DestinationSchemaTampered OK
merge (delete-insert) DestinationSchemaTampered OK

Root cause is exactly #51: the released 0.1.1 (2026-03-10) predates crate/dlt-cratedb#49 / crate/dlt-cratedb#51, so to_db_datetime_type still mutates the live schema column in place, tripping the tamper guard on the merge staging pass. main renders against a copy. Both fixes are in CHANGES.md under "Unreleased", so a dlt-cratedb 0.1.2 release removes the crash with no further schema work.

But a release won't turn all five skips green. A 2-run merge on main (run 1 {1,2}, run 2 {2,3}) leaves {2,3}: merge and delete-insert are both redirected to full replace (CrateDbStagingReplaceJob; true upsert tracked by crate/dlt-cratedb#6). So db_to_db_merge_with_primary_key and db_to_db_delete_insert_*, which assert an earlier row surviving, will move from crash to a real-upsert mismatch.

Suggest: after the release, drop the skips on any case that only needs the load to complete, and re-point the rest from crate/dlt-cratedb#14 (fixed) to crate/dlt-cratedb#6 (the real open item) as xfail.

@amotl

amotl commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

@hampsterx: Thanks for the detailed report about why and where dlt-cratedb might need further improvements.
@florinutz: Can you possibly fix one or two other issues of dlt-cratedb if the suggestions by @hampsterx make sense to you?

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="crate/dlt-cratedb"
for endpoint in \
  "repos/$repo/issues/6" \
  "repos/$repo/issues/14" \
  "repos/$repo/pulls/49" \
  "repos/$repo/pulls/51" \
  "repos/$repo/releases?per_page=10"
do
  echo "===== $endpoint ====="
  gh api "$endpoint" --jq '
    if type == "array" then
      .[] | {tag_name, name, published_at, prerelease, draft}
    else
      {number, title, state, merged_at, closed_at, html_url, body}
    end
  ' || true
done

Length of output: 7160


@amotl, @hampsterx’s suggestions make sense and are supported by the current upstream state:

  • crate/dlt-cratedb#51 was merged and closed #14, but it has not yet been released—the latest release remains v0.1.1.
  • After a release containing #51, remove skips for cases that only verify that merge, delete-insert, or refresh="drop_resources" complete without crashing.
  • Keep the tests that assert actual merge/upsert retention semantics as xfail, referencing the still-open crate/dlt-cratedb#6. The current full-replace fallback is intentionally not equivalent to a real merge.

@florinutz, the highest-value follow-up would be #6: implement CrateDB-compatible merge/delete SQL (or another correct upsert strategy), then convert those remaining semantic xfails into passing integration tests.

🐇 ✅

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@amotl: Yes—the suggestions make sense.

@florinutz, the most impactful follow-ups in dlt-cratedb would be:

  1. Release the schema-tamper fix currently on main (the non-mutating datetime-type handling from #49/Kafka: Expand default_msg_processor into a miniature decoding unit #51). This should unblock merge staging runs that presently fail with DestinationSchemaTampered.
  2. Implement true merge/upsert semantics rather than redirecting merge and delete-insert to full replacement (tracked in #6). That is the remaining blocker for tests that verify existing primary-key rows survive a subsequent merge.

Once the first item is released, this PR can unskip load-completion cases. The stateful merge assertions should remain xfail and reference #6 until upsert behavior is available.

🐇👍

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@amotl: Yes, those follow-ups make sense.

@florinutz: The two highest-impact improvements in dlt-cratedb would be:

  1. Release the already-merged schema-tamper fix from #51, so merge staging no longer raises DestinationSchemaTampered.
  2. Implement true merge/upsert semantics for merge and delete-insert (tracked by #6), replacing the current full-replace fallback.

After the release, this PR can unskip tests that only require successful loads. Tests asserting preservation of existing primary-key rows should remain xfail until #6 is resolved.

🐇👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

help wanted Extra attention is needed quality All things quality assurance and software tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants