Skip to content

Commit

Permalink
Fixing rendering.
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgSkv committed Jan 11, 2025
1 parent 23c2c17 commit 8638d25
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion compiler/expr_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def ListLiteral(self, literal, element_type_name,
if self.dialect.IsPostgreSQLish() and not element_type_name:
raise self.exception_maker(
'Type is needed, but not determined for %s. Please give hints with ~ operator!' %
color.Warn(full_expression['expression_heritage']))
color.Warn(full_expression.get('expression_heritage', str(full_expression))))

suffix = ('::' + element_type_name + '[]'
if self.dialect.IsPostgreSQLish()
Expand Down
13 changes: 7 additions & 6 deletions compiler/universe.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,20 +335,21 @@ def Engine(self):
self.annotations['@Engine'][engine])
return engine

def EngineTypechecksByDefault(self, engine):
return engine in ['psql', 'duckdb']

def ShouldTypecheck(self):
engine = self.Engine()
typechecks_by_default = self.EngineTypechecksByDefault(engine)

if '@Engine' not in self.annotations:
return engine == 'psql'
return typechecks_by_default
if len(self.annotations['@Engine'].values()) == 0:
return engine == 'psql'
return typechecks_by_default

engine_annotation = list(self.annotations['@Engine'].values())[0]
if 'type_checking' not in engine_annotation:
if engine in ['psql', 'duckdb']:
return True
else:
return False
return typechecks_by_default
return engine_annotation['type_checking']

def ExtractSingleton(self, annotation_name, default_value):
Expand Down
18 changes: 18 additions & 0 deletions integration_tests/duckdb_negation_test.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright 2020 Google LLC
#
# 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.

Even(2 * x) :- x in Range(5);
@OrderBy(Test, "col0");
Test(x) :- x in Range(10), ~Even(x);
9 changes: 9 additions & 0 deletions integration_tests/duckdb_negation_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
+------+
| col0 |
+------+
| 1 |
| 3 |
| 5 |
| 7 |
| 9 |
+------+
1 change: 1 addition & 0 deletions integration_tests/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def RunAll(test_presto=False, test_trino=False):
RunTest("dialects/trino/joins_test")
RunTest("dialects/trino/joins_test")

RunTest("duckdb_negation_test")
RunTest("duckdb_is_default")

RunTest("bq_plusplus_test")
Expand Down

0 comments on commit 8638d25

Please sign in to comment.