Skip to content
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

fix(flink): quote SQL identifiers indiscriminately #7605

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 0 additions & 16 deletions ibis/backends/base/sql/registry/identifiers.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
from __future__ import annotations

# Copyright 2014 Cloudera Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Base identifiers

base_identifiers = [
"add",
"aggregate",
Expand Down
9 changes: 6 additions & 3 deletions ibis/backends/flink/compiler/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@


class FlinkTableSetFormatter(TableSetFormatter):
def _quote_identifier(self, name):
return quote_identifier(name, force=True)

Check warning on line 22 in ibis/backends/flink/compiler/core.py

View check run for this annotation

Codecov / codecov/patch

ibis/backends/flink/compiler/core.py#L22

Added line #L22 was not covered by tests

def _format_in_memory_table(self, op):
names = op.schema.names
raw_rows = []
Expand Down Expand Up @@ -121,7 +124,7 @@
filter(
None,
[
f"TABLE {quote_identifier(op.table.name)}",
f"TABLE {formatter._quote_identifier(op.table.name)}",
f"DESCRIPTOR({formatter._translate(op.time_col)})",
formatter._translate(op.window_size),
formatter._translate(op.offset) if op.offset else None,
Expand All @@ -136,7 +139,7 @@
filter(
None,
[
f"TABLE {quote_identifier(op.table.name)}",
f"TABLE {formatter._quote_identifier(op.table.name)}",
f"DESCRIPTOR({formatter._translate(op.time_col)})",
formatter._translate(op.window_slide),
formatter._translate(op.window_size),
Expand All @@ -154,7 +157,7 @@
filter(
None,
[
f"TABLE {quote_identifier(op.table.name)}",
f"TABLE {formatter._quote_identifier(op.table.name)}",
f"DESCRIPTOR({formatter._translate(op.time_col)})",
formatter._translate(op.window_step),
formatter._translate(op.window_size),
Expand Down
1 change: 0 additions & 1 deletion ibis/backends/tests/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,6 @@ def test_agg_name_in_output_column(alltypes):
assert "max" in df.columns[1].lower()


@pytest.mark.notimpl(["flink"], "WIP", raises=Py4JError)
def test_grouped_case(backend, con):
table = ibis.memtable({"key": [1, 1, 2, 2], "value": [10, 30, 20, 40]})

Expand Down
2 changes: 1 addition & 1 deletion ibis/backends/tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ def test_first_last(backend):
raises=com.OperationNotDefinedError,
reason="not support by the backend",
)
@pytest.mark.notyet(["flink"], raises=Py4JJavaError, reason="not supported by Flink")
@pytest.mark.broken(["flink"], raises=Py4JJavaError, reason="bug in Flink")
Copy link
Contributor Author

@deepyaman deepyaman Nov 22, 2023

Choose a reason for hiding this comment

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

There were two issues here:

  1. time is a reserved keyword
  2. Even then, there seems to be an issue: https://apache-flink.slack.com/archives/C03G7LJTS2G/p1700675938430139

The stack trace on the second results in:

Caused by: org.apache.flink.util.FlinkRuntimeException: org.apache.flink.api.common.InvalidProgramException: Table program cannot be compiled. This is a bug. Please file an issue.

I'm still discussing with somebody on the Flink side; may update later with a Jira ref.

def test_range_expression_bounds(backend):
t = ibis.memtable(
{
Expand Down