Skip to content

Conversation

@vgvoleg
Copy link
Collaborator

@vgvoleg vgvoleg commented Oct 29, 2025

No description provided.

CREATE TABLE table \
( \
id Uint64 NOT NULL, \
name String, \
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

а мы можем тут проверить маппинг каких-нибудь типов, не поддерживающихся в YDB? типа BigInt и прочие

weight Double,
is_active Bool DEFAULT true,
created_at Timestamp,
balance Decimal(15, 2) DEFAULT 0.00,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

а, я не видел этот тест. в целом Decimal у нас тоже поддержан и непонятно, почему он должен превратиться в Double. В этом тесте хочется видеть еще и какие-нибудь нетипичные типы по возможности

Copy link

Copilot AI left a 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 introduces support for the YDB SQL dialect to sqlglot, enabling SQL translation to and from YDB's query language syntax.

Key Changes:

  • Adds comprehensive YDB dialect implementation with SQL generation and parsing capabilities
  • Implements YDB-specific transformations for date/time functions, CTEs, subqueries, and data types
  • Includes extensive test coverage with 616 lines of test cases covering various SQL operations

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 22 comments.

File Description
sqlglot/dialects/ydb.py Core implementation of YDB dialect with tokenizer, parser, and generator classes handling YDB-specific SQL syntax transformations
tests/dialects/test_ydb.py Comprehensive test suite covering date functions, CTEs, subqueries, joins, data types, and identity validations
sqlglot/dialects/init.py Registers "YDB" dialect in the DIALECTS list for discoverability
Comments suppressed due to low confidence (2)

sqlglot/dialects/ydb.py:572

  • This comment appears to contain commented-out code.
        # def _wrap_non_optional(self, expr: exp.Expression) -> exp.Expression:
        #     """
        #     Helper to wrap non-Optional types using the YQL lambda function.
        #     Uses the $wrap_non_optional_in_comparisons lambda function.
        #
        #     Args:
        #         expr: The expression to potentially wrap
        #
        #     Returns:
        #         Expression wrapped using the lambda function
        #     """
        #     # Use the lambda function: $wrap_non_optional_in_comparisons(expr)
        #     return exp.Anonymous(this="$wrap_non_optional_in_comparisons", expressions=[expr])
        #
        # def eq_sql(self, expression: exp.EQ) -> str:
        #     """
        #     Generate SQL for EQ (equals) with Just() for non-Optional types.
        #     Wraps non-Optional values with Just() to make them Optional.
        #
        #     Args:
        #         expression: The EQ expression
        #
        #     Returns:
        #         Generated SQL string with Just() wrapping for non-Optional types
        #     """
        #     left = self._wrap_non_optional(expression.this)
        #     right = self._wrap_non_optional(expression.expression)
        #     return self.binary(exp.EQ(this=left, expression=right), "=")
        #
        # def neq_sql(self, expression: exp.NEQ) -> str:
        #     """
        #     Generate SQL for NEQ (not equals) with Just() for non-Optional types.
        #     Wraps non-Optional values with Just() to make them Optional.
        #
        #     Args:
        #         expression: The NEQ expression
        #
        #     Returns:
        #         Generated SQL string with Just() wrapping for non-Optional types
        #     """
        #     left = self._wrap_non_optional(expression.this)
        #     right = self._wrap_non_optional(expression.expression)
        #     return self.binary(exp.NEQ(this=left, expression=right), "<>")
        #
        # def gt_sql(self, expression: exp.GT) -> str:
        #     """
        #     Generate SQL for GT (greater than) with Just() for non-Optional types.
        #     Wraps non-Optional values with Just() to make them Optional.
        #
        #     Args:
        #         expression: The GT expression
        #
        #     Returns:
        #         Generated SQL string with Just() wrapping for non-Optional types
        #     """
        #     left = self._wrap_non_optional(expression.this)
        #     right = self._wrap_non_optional(expression.expression)
        #     return self.binary(exp.GT(this=left, expression=right), ">")
        #
        # def gte_sql(self, expression: exp.GTE) -> str:
        #     """
        #     Generate SQL for GTE (greater than or equal) with Just() for non-Optional types.
        #     Wraps non-Optional values with Just() to make them Optional.
        #
        #     Args:
        #         expression: The GTE expression
        #
        #     Returns:
        #         Generated SQL string with Just() wrapping for non-Optional types
        #     """
        #     left = self._wrap_non_optional(expression.this)
        #     right = self._wrap_non_optional(expression.expression)
        #     return self.binary(exp.GTE(this=left, expression=right), ">=")
        #
        # def lt_sql(self, expression: exp.LT) -> str:
        #     """
        #     Generate SQL for LT (less than) with Just() for non-Optional types.
        #     Wraps non-Optional values with Just() to make them Optional.
        #
        #     Args:
        #         expression: The LT expression
        #
        #     Returns:
        #         Generated SQL string with Just() wrapping for non-Optional types
        #     """
        #     left = self._wrap_non_optional(expression.this)
        #     right = self._wrap_non_optional(expression.expression)
        #     return self.binary(exp.LT(this=left, expression=right), "<")
        #
        # def lte_sql(self, expression: exp.LTE) -> str:
        #     """
        #     Generate SQL for LTE (less than or equal) with Just() for non-Optional types.
        #     Wraps non-Optional values with Just() to make them Optional.
        #
        #     Args:
        #         expression: The LTE expression
        #
        #     Returns:
        #         Generated SQL string with Just() wrapping for non-Optional types
        #     """
        #     left = self._wrap_non_optional(expression.this)
        #     right = self._wrap_non_optional(expression.expression)
        #     return self.binary(exp.LTE(this=left, expression=right), "<=")

sqlglot/dialects/ydb.py:807

  • This comment appears to contain commented-out code.
            # if isinstance(expression, (exp.Select, exp.Insert, exp.Update, exp.Delete, exp.Create)):
            #     pragma_statements = ['PRAGMA AnsiImplicitCrossJoin;',
            #                          'PRAGMA AnsiInForEmptyOrNullableItemsCollections;']

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants