-
Notifications
You must be signed in to change notification settings - Fork 40
feat(connectors): BI-6611 DB_CAST for YDB without ARRAY support #1261
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
base: main
Are you sure you want to change the base?
Conversation
234fada to
a0f6652
Compare
4156d76 to
01e92a0
Compare
636eec7 to
6d54f1d
Compare
574a010 to
9575ee3
Compare
9575ee3 to
333c80c
Compare
e843d79 to
f7b7ddc
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.
Pull request overview
This PR implements the DB_CAST function for YDB connector without ARRAY support, enabling YDB-specific type casting operations based on YDB's native type system and casting rules.
- Adds comprehensive DB_CAST implementation with YDB-specific type specifications and casting whitelists
- Implements extensive test coverage for various type casting combinations (bool, integer, float, string, date)
- Corrects the path to the dl-sqlalchemy-ydb dependency
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/dl_connector_ydb/pyproject.toml | Fixed dependency path for dl-sqlalchemy-ydb |
| lib/dl_connector_ydb/dl_connector_ydb_tests/db/formula/test_functions_type_conversion.py | Added comprehensive test suite for DB_CAST functionality with multiple type conversion scenarios |
| lib/dl_connector_ydb/dl_connector_ydb/formula/definitions/functions_type.py | Implemented DB_CAST function with YDB type specifications and casting whitelists based on YDB documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| source_column: str, | ||
| ) -> None: | ||
| if cast_args: | ||
| cast_args_str = ", ".join(cast_args) |
Copilot
AI
Dec 10, 2025
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 cast_args parameter is typed as tuple[int, int] | None, but str.join() expects an iterable of strings. This will fail at runtime when cast_args contains integers. Convert the integers to strings using cast_args_str = ', '.join(str(arg) for arg in cast_args) or cast_args_str = ', '.join(map(str, cast_args)).
| cast_args_str = ", ".join(cast_args) | |
| cast_args_str = ", ".join(str(arg) for arg in cast_args) |
| # TODO: JsonDocument | ||
| # TODO: Yson | ||
| # TODO: Cast Integer to Interval | ||
| # Commented - not supported |
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.
By the look at the table above I assume that this is not supported by YDB rather than us. Do we really need both the table and the commented lines? I would suggest removing those commented TYPES_SPECs and add a comment that all mappings are based on the table above
| @pytest.fixture(scope="function") | ||
| def ydb_data_test_table_field_types_patch(self, monkeypatch) -> None: | ||
| ydb_field_types = {**self.YDB_TYPE_FIELD_TYPES} | ||
|
|
||
| monkeypatch.setattr("dl_formula_testing.evaluator.FIELD_TYPES", ydb_field_types) | ||
|
|
||
| return ydb_field_types |
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 think this monkeypatch can be easily avoided by modifying the DbEvaluator in such way that it would accept type overrides. DbEvaluator.translate_formula() already accepts field_types, but it is not used at the moment. If I am wrong and it turns out that it's not an easy fix, then you may just leave a TODO here, we still would want to get rid of this monkeypatch eventually.
No description provided.