Skip to content

Commit 89d06c4

Browse files
committed
de-couple types of to_pyton style calls by having consumers call str() on them
1 parent 0fec47a commit 89d06c4

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

data_algebra/MySQL.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def _MySQL_concat_expr(dbmodel, expression):
4343

4444
# map from op-name to special SQL formatting code
4545
MySQL_formatters = {
46-
"___": lambda dbmodel, expression: expression.to_python(),
46+
"___": lambda dbmodel, expression: str(expression.to_python()),
4747
"is_bad": _MySQL_is_bad_expr,
4848
"concat": _MySQL_concat_expr,
4949
}

data_algebra/PostgreSQL.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
# map from op-name to special SQL formatting code
1616
PostgreSQL_formatters = {
17-
"___": lambda dbmodel, expression: expression.to_python(),
17+
"___": lambda dbmodel, expression: str(expression.to_python()),
1818
}
1919

2020

data_algebra/SparkSQL.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def coalesce_step(x):
5555

5656
# map from op-name to special SQL formatting code
5757
SparkSQL_formatters = {
58-
"___": lambda dbmodel, expression: expression.to_python(),
58+
"___": lambda dbmodel, expression: str(expression.to_python()),
5959
"is_bad": _sparksql_is_bad_expr,
6060
"coalesce": _sparksql_coalesce_expr,
6161
}

data_algebra/db_model.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -879,9 +879,9 @@ def extend_to_sql(
879879
oi.get_column_names(cols_used_in_term)
880880
cols_used_in_term.update(window_vars)
881881
declared_term_dependencies[ci] = cols_used_in_term
882-
annotation = extend_node.to_python_implementation(
882+
annotation = str(extend_node.to_python_implementation(
883883
print_sources=False, indent=-1
884-
)
884+
))
885885
# TODO: see if we can merge with subsql instead of building a new one
886886
if (
887887
self.allow_extend_merges
@@ -978,9 +978,9 @@ def project_to_sql(
978978
quoted_query_name=self.quote_identifier(view_name),
979979
sub_sql=subsql.to_bound_near_sql(columns=subusing),
980980
suffix=suffix,
981-
annotation=project_node.to_python_implementation(
981+
annotation=str(project_node.to_python_implementation(
982982
print_sources=False, indent=-1
983-
),
983+
)),
984984
)
985985
return near_sql
986986

@@ -1018,9 +1018,9 @@ def select_rows_to_sql(
10181018
quoted_query_name=self.quote_identifier(view_name),
10191019
sub_sql=subsql.to_bound_near_sql(columns=subusing),
10201020
suffix=suffix,
1021-
annotation=select_rows_node.to_python_implementation(
1021+
annotation=str(select_rows_node.to_python_implementation(
10221022
print_sources=False, indent=-1
1023-
),
1023+
)),
10241024
)
10251025
return near_sql
10261026

@@ -1127,9 +1127,9 @@ def order_to_sql(
11271127
quoted_query_name=self.quote_identifier(view_name),
11281128
sub_sql=subsql.to_bound_near_sql(columns=subusing),
11291129
suffix=suffix,
1130-
annotation=order_node.to_python_implementation(
1130+
annotation=str(order_node.to_python_implementation(
11311131
print_sources=False, indent=-1
1132-
),
1132+
)),
11331133
)
11341134
return near_sql
11351135

@@ -1162,9 +1162,9 @@ def rename_to_sql(
11621162
terms=terms,
11631163
quoted_query_name=self.quote_identifier(view_name),
11641164
sub_sql=subsql.to_bound_near_sql(columns=subusing),
1165-
annotation=rename_node.to_python_implementation(
1165+
annotation=str(rename_node.to_python_implementation(
11661166
print_sources=False, indent=-1
1167-
),
1167+
)),
11681168
)
11691169
return near_sql
11701170

@@ -1259,9 +1259,9 @@ def natural_join_to_sql(
12591259
joiner=jointype + " JOIN",
12601260
sub_sql2=sql_right.to_bound_near_sql(columns=using_right, force_sql=False),
12611261
suffix=on_terms,
1262-
annotation=join_node.to_python_implementation(
1262+
annotation=str(join_node.to_python_implementation(
12631263
print_sources=False, indent=-1
1264-
),
1264+
)),
12651265
)
12661266
return near_sql
12671267

@@ -1315,9 +1315,9 @@ def concat_rows_to_sql(
13151315
sub_sql2=sql_right.to_bound_near_sql(
13161316
columns=using_left, force_sql=True, constants=constants_right,
13171317
),
1318-
annotation=concat_node.to_python_implementation(
1318+
annotation=str(concat_node.to_python_implementation(
13191319
print_sources=False, indent=-1
1320-
),
1320+
)),
13211321
)
13221322
return near_sql
13231323

0 commit comments

Comments
 (0)