Skip to content

feat(risingwave): add support for include in create_source #11220

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

Merged
Merged
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
28 changes: 18 additions & 10 deletions ibis/backends/risingwave/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,7 @@
create_stmt = sge.Create(
kind="TABLE",
this=target,
properties=sge.Properties(
expressions=sge.Properties.from_dict(connector_properties)
),
properties=sge.Properties.from_dict(connector_properties),
)
create_stmt = create_stmt.sql(self.dialect) + data_and_encode_format(
data_format, encode_format, encode_properties
Expand Down Expand Up @@ -744,6 +742,7 @@
data_format: str,
encode_format: str,
encode_properties: dict | None = None,
includes: dict[str, str] | None = None,
) -> ir.Table:
"""Creating a source.

Expand All @@ -764,23 +763,32 @@
The encode format for the new source, e.g., "JSON". data_format and encode_format must be specified at the same time.
encode_properties
The properties of encode format, providing information like schema registry url. Refer https://docs.risingwave.com/docs/current/sql-create-source/ for more details.
includes
A dict of `INCLUDE` clauses of the form `{field: alias, ...}`.
Set value(s) to `None` if no alias is needed. Refer to https://docs.risingwave.com/docs/current/sql-create-source/ for more details.

Returns
-------
Table
Table expression
"""
table = sg.table(name, db=database, quoted=self.compiler.quoted)
quoted = self.compiler.quoted
table = sg.table(name, db=database, quoted=quoted)

Check warning on line 776 in ibis/backends/risingwave/__init__.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/risingwave/__init__.py#L775-L776

Added lines #L775 - L776 were not covered by tests
target = sge.Schema(this=table, expressions=schema.to_sqlglot(self.dialect))

create_stmt = sge.Create(
kind="SOURCE",
this=target,
properties=sge.Properties(
expressions=sge.Properties.from_dict(connector_properties)
),
properties = sge.Properties.from_dict(connector_properties)
properties.expressions.extend(

Check warning on line 780 in ibis/backends/risingwave/__init__.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/risingwave/__init__.py#L779-L780

Added lines #L779 - L780 were not covered by tests
sge.IncludeProperty(
this=sg.to_identifier(include_type),
alias=sg.to_identifier(column_name, quoted=quoted)
if column_name
else None,
)
for include_type, column_name in (includes or {}).items()
)

create_stmt = sge.Create(kind="SOURCE", this=target, properties=properties)

Check warning on line 790 in ibis/backends/risingwave/__init__.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/risingwave/__init__.py#L790

Added line #L790 was not covered by tests

create_stmt = create_stmt.sql(self.dialect) + data_and_encode_format(
data_format, encode_format, encode_properties
)
Expand Down
Loading