From 1cb6af74d71309241374867435024efb8c63779c Mon Sep 17 00:00:00 2001 From: Evgeny Skvortsov <71790359+EvgSkv@users.noreply.github.com> Date: Wed, 15 Jan 2025 19:37:32 -0800 Subject: [PATCH] Make propositional implication to always be available. --- .../propositional_implication_test.l | 34 +++++++++++++++++++ .../propositional_implication_test.txt | 6 ++++ integration_tests/run_tests.py | 2 ++ parser_py/parse.py | 6 ++-- 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 integration_tests/propositional_implication_test.l create mode 100644 integration_tests/propositional_implication_test.txt diff --git a/integration_tests/propositional_implication_test.l b/integration_tests/propositional_implication_test.l new file mode 100644 index 0000000..2998f9d --- /dev/null +++ b/integration_tests/propositional_implication_test.l @@ -0,0 +1,34 @@ +# +# Copyright 2025 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. + +# Testing propositional implication. + +Bird("duck"); +Bird("sparrow"); + +Animal("dog"); + +Dragon("wyvern"); + +Flies("duck"); +Flies("sparrow"); +Flies("wyvern"); + +WhoFiles("animal") :- Animal(x) => Flies(x); +WhoFiles("bird") :- Bird(x) => Flies(x); +WhoFiles("dragon") :- Dragon(x) => Flies(x); + +@OrderBy(Test, "col0"); +Test(x) :- WhoFiles(x); diff --git a/integration_tests/propositional_implication_test.txt b/integration_tests/propositional_implication_test.txt new file mode 100644 index 0000000..bb0c904 --- /dev/null +++ b/integration_tests/propositional_implication_test.txt @@ -0,0 +1,6 @@ ++--------+ +| col0 | ++--------+ +| bird | +| dragon | ++--------+ \ No newline at end of file diff --git a/integration_tests/run_tests.py b/integration_tests/run_tests.py index 6e2e586..2248458 100755 --- a/integration_tests/run_tests.py +++ b/integration_tests/run_tests.py @@ -65,6 +65,8 @@ def RunAll(test_presto=False, test_trino=False): RunTest("dialects/trino/joins_test") RunTest("dialects/trino/joins_test") + RunTest("propositional_implication_test") + RunTest("duckdb_negation_test") RunTest("duckdb_is_default") diff --git a/parser_py/parse.py b/parser_py/parse.py index d69cbd5..63ac57d 100755 --- a/parser_py/parse.py +++ b/parser_py/parse.py @@ -942,9 +942,9 @@ def ParseProposition(s): c = ParsePropositionalEquivalence(s) if c: return {'conjunction': {'conjunct': [c]}} - c = ParsePropositionalImplication(s) - if c: - return {'conjunction': {'conjunct': [c]}} + c = ParsePropositionalImplication(s) + if c: + return {'conjunction': {'conjunct': [c]}} c = ParseImplication(s) if c: