Skip to content

Commit

Permalink
switch back to lite default for sake of docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
drizk1 committed Apr 1, 2024
1 parent bbfe34b commit fead5e1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ Supported helper functions include
- `!` negation
- `across`

DuckDB is the default SQL backend.
SQLite is the default SQL backend.

Switch to Postgres using
`set_sql_mode(:postgres)`

Switch to MySQL using
`set_sql_mode(:mysql)`

Switch to SQLite using
`set_sql_mode(:lite)`
Switch to DuckDB using
`set_sql_mode(:duckdb)`

DuckDB support enables:
- directly reading in .parquet, .json, and .csv files paths.
Expand Down
2 changes: 1 addition & 1 deletion src/TidierDB.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ include("joins_sq.jl")
include("slices_sq.jl")


current_sql_mode = Ref(:duckdb)
current_sql_mode = Ref(:lite)

# Function to switch modes
function set_sql_mode(mode::Symbol)
Expand Down
6 changes: 3 additions & 3 deletions src/db_parsing.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
names_to_modify = ["str_replace", "str_replace_all", "str_remove", "str_remove_all", "replace_missing", "missing_if",
"floor_date", "is_missing", "starts_with", "ends_with"]
"floor_date", "is_missing"]
#this function allows for @capture to capture names that would have an underscore, ie str_replace
function exc_capture_bug(expr, names_to_modify::Vector{String})
names_set = Set(names_to_modify)
Expand Down Expand Up @@ -176,9 +176,9 @@ function parse_char_matching(expr)
func_name = pattern_func.args[1]
pattern = pattern_func.args[2]

like_expr = if func_name == :starts_with || func_name == :startswith
like_expr = if func_name == :starts_with
"$(column) LIKE '$(pattern)%'"
elseif func_name == :ends_with || func_name == :endswith
elseif func_name == :ends_with
"$(column) LIKE '%$(pattern)'"
elseif func_name == :contains
"$(column) LIKE '%$(pattern)%'"
Expand Down
7 changes: 1 addition & 6 deletions src/parsing_duckdb.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function expr_to_sql_duckdb(expr, sq; from_summarize::Bool)
expr = parse_char_matching(expr)
expr = exc_capture_bug(expr, names_to_modify)
MacroTools.postwalk(expr) do x
# Handle basic arithmetic and functions
Expand Down Expand Up @@ -90,12 +91,6 @@ function expr_to_sql_duckdb(expr, sq; from_summarize::Bool)
return :(REGEXP_REPLACE($str, $pattern, "g"))
elseif @capture(x, strremove(str_, pattern_))
return :(REGEXP_REPLACE($str, $pattern, ""))
elseif @capture(x, startswith(str_, pattern_))
return :(starts_with($str, $pattern))
elseif @capture(x, endswith(str_, pattern_))
return :(ends_with($str, $pattern))
elseif @capture(x, contains(str_, pattern_))
return :(contains($str, $pattern))
elseif @capture(x, ismissing(a_))
return "($(string(a)) IS NULL)"
# Date extraction functions
Expand Down

0 comments on commit fead5e1

Please sign in to comment.