-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #333 from yilinxia/duckdb
DuckDB Implementation
- Loading branch information
Showing
5 changed files
with
161 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/python | ||
# | ||
# Copyright 2023 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. | ||
|
||
from decimal import Decimal | ||
import sqlite3 | ||
|
||
def SqliteConnect(): | ||
con = sqlite3.connect(':memory:') | ||
return con |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/python | ||
# | ||
# 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. | ||
|
||
library = """ | ||
->(left:, right:) = {arg: left, value: right}; | ||
`=`(left:, right:) = right :- left == right; | ||
Arrow(left, right) = arrow :- | ||
left == arrow.arg, | ||
right == arrow.value; | ||
PrintToConsole(message) :- 1 == SqlExpr("PrintToConsole({message})", {message:}); | ||
ArgMin(arr) = SqlExpr( | ||
"argmin({a}, {v})", {a:, v:}) :- Arrow(a, v) == arr; | ||
ArgMax(arr) = SqlExpr( | ||
"argmax({a}, {v})", {a:, v:}) :- Arrow(a, v) == arr; | ||
ArgMaxK(a, l) = SqlExpr( | ||
"(array_agg({arg_1} order by {value_1} desc))[1:{lim}]", | ||
{arg_1: a.arg, value_1: a.value, lim: l}); | ||
ArgMinK(a, l) = SqlExpr( | ||
"(array_agg({arg_1} order by {value_1}))[1:{lim}]", | ||
{arg_1: a.arg, value_1: a.value, lim: l}); | ||
Array(arr) = | ||
SqlExpr("ArgMin({v}, {a})", {a:, v:}) :- Arrow(a, v) == arr; | ||
RecordAsJson(r) = SqlExpr( | ||
"ROW_TO_JSON({r})", {r:}); | ||
Fingerprint(s) = SqlExpr("('x' || substr(md5({s}), 1, 16))::bit(64)::bigint", {s:}); | ||
ReadFile(filename) = SqlExpr("pg_read_file({filename})", {filename:}); | ||
Chr(x) = SqlExpr("Chr({x})", {x:}); | ||
Num(a) = a; | ||
Str(a) = a; | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters