Skip to content

Commit 0b5d343

Browse files
deepyamancpcloud
authored andcommitted
fix(flink): customize the list of base idenitifers
1 parent e135682 commit 0b5d343

File tree

7 files changed

+573
-24
lines changed

7 files changed

+573
-24
lines changed

ibis/backends/base/sql/registry/helpers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ def format_call(translator, func, *args):
1414
return "{}({})".format(func, ", ".join(formatted_args))
1515

1616

17-
def quote_identifier(name, quotechar="`", force=False):
17+
def quote_identifier(
18+
name, quotechar="`", force=False, base_identifiers=identifiers.base_identifiers
19+
):
1820
"""Add quotes to the `name` identifier if needed."""
19-
if force or name.count(" ") or name in identifiers.base_identifiers:
21+
if force or name.count(" ") or name in base_identifiers:
2022
return f"{quotechar}{name}{quotechar}"
2123
else:
2224
return name

ibis/backends/base/sql/registry/identifiers.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
11
from __future__ import annotations
22

3-
# Copyright 2014 Cloudera Inc.
4-
#
5-
# Licensed under the Apache License, Version 2.0 (the "License");
6-
# you may not use this file except in compliance with the License.
7-
# You may obtain a copy of the License at
8-
#
9-
# http://www.apache.org/licenses/LICENSE-2.0
10-
#
11-
# Unless required by applicable law or agreed to in writing, software
12-
# distributed under the License is distributed on an "AS IS" BASIS,
13-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
# See the License for the specific language governing permissions and
15-
# limitations under the License.
16-
17-
# Base identifiers
18-
193
base_identifiers = [
204
"add",
215
"aggregate",

ibis/backends/flink/compiler/core.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,14 @@
1414
TableSetFormatter,
1515
)
1616
from ibis.backends.base.sql.registry import quote_identifier
17+
from ibis.backends.flink import identifiers
1718
from ibis.backends.flink.translator import FlinkExprTranslator
1819

1920

2021
class FlinkTableSetFormatter(TableSetFormatter):
22+
def _quote_identifier(self, name):
23+
return quote_identifier(name, base_identifiers=identifiers.base_identifiers)
24+
2125
def _format_in_memory_table(self, op):
2226
names = op.schema.names
2327
raw_rows = []
@@ -121,7 +125,7 @@ def _tumble_window_params(
121125
filter(
122126
None,
123127
[
124-
f"TABLE {quote_identifier(op.table.name)}",
128+
f"TABLE {formatter._quote_identifier(op.table.name)}",
125129
f"DESCRIPTOR({formatter._translate(op.time_col)})",
126130
formatter._translate(op.window_size),
127131
formatter._translate(op.offset) if op.offset else None,
@@ -136,7 +140,7 @@ def _hop_window_params(op: ops.HopWindowingTVF, formatter: TableSetFormatter) ->
136140
filter(
137141
None,
138142
[
139-
f"TABLE {quote_identifier(op.table.name)}",
143+
f"TABLE {formatter._quote_identifier(op.table.name)}",
140144
f"DESCRIPTOR({formatter._translate(op.time_col)})",
141145
formatter._translate(op.window_slide),
142146
formatter._translate(op.window_size),
@@ -154,7 +158,7 @@ def _cumulate_window_params(
154158
filter(
155159
None,
156160
[
157-
f"TABLE {quote_identifier(op.table.name)}",
161+
f"TABLE {formatter._quote_identifier(op.table.name)}",
158162
f"DESCRIPTOR({formatter._translate(op.time_col)})",
159163
formatter._translate(op.window_step),
160164
formatter._translate(op.window_size),

0 commit comments

Comments
 (0)