Skip to content

Commit

Permalink
test: add concat function
Browse files Browse the repository at this point in the history
  • Loading branch information
richtia committed May 4, 2023
1 parent a8fddcb commit 4557c0f
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bft/testers/postgres/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def run_sql_case(self, case: Case, mapping: SqlMapping) -> SqlCaseResult:
arg_vals = ",".join(
[
"'" + literal_to_str(arg) + "'"
if arg.type == "string"
if arg.type == "string" and arg.value is not None
else literal_to_str(arg)
for arg in case.args
]
Expand Down
2 changes: 1 addition & 1 deletion bft/testers/sqlite/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def run_sql_case(self, case: Case, mapping: SqlMapping) -> SqlCaseResult:
arg_vals = ",".join(
[
"'" + literal_to_str(arg) + "'"
if arg.type == "string"
if arg.type == "string" and arg.value is not None
else literal_to_str(arg)
for arg in case.args
]
Expand Down
42 changes: 42 additions & 0 deletions cases/string/concat.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
function: concat
cases:
- group:
id: basic
description: Basic examples without any special cases
args:
- value: 'abcd'
type: string
- value: 'efg'
type: string
result:
value: 'abcdefg'
type: string
- group:
id: null_input
description: Examples with null as input
args:
- value: 'abcd'
type: string
- value: null
type: string
result:
value: null
type: string
- group: null_input
args:
- value: null
type: string
- value: 'abcd'
type: string
result:
value: null
type: string
- group: null_input
args:
- value: null
type: string
- value: null
type: string
result:
value: null
type: string
5 changes: 4 additions & 1 deletion dialects/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ scalar_functions:
infix: False
- name: substring
local_name: substring
infix: False
infix: False
- name: concat
local_name: "||"
infix: True
5 changes: 4 additions & 1 deletion dialects/sqlite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,7 @@ scalar_functions:
infix: False
- name: substring
local_name: substring
infix: False
infix: False
- name: concat
local_name: "||"
infix: True
5 changes: 4 additions & 1 deletion dialects/velox_presto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,7 @@ scalar_functions:
infix: False
- name: substring
local_name: substring
infix: False
infix: False
- name: concat
local_name: concat
infix: False

0 comments on commit 4557c0f

Please sign in to comment.