Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@

**Features**:

- Add a very early `sql.oracle` dialect. It currently only forces identifier
quoting to accommodate Oracle's case-folding rules; most other features fall
back to generic SQL. (@julien-pinchelimouroux, #5821)

**Fixes**:

**Documentation**:
Expand Down
3 changes: 2 additions & 1 deletion prqlc/bindings/elixir/lib/prql.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule PRQL do
| :clickhouse
| :duckdb
| :glaredb
| :oracle
| :redshift
| :sqlite
| :snowflake
Expand All @@ -39,7 +40,7 @@ defmodule PRQL do

* `:target` - Dialect used for generate SQL. Accepted values are
`:generic`, `:mssql`, `:mysql`, `:postgres`, `:ansi`, `:bigquery`,
`:clickhouse`, `:duckdb`, `:glaredb`, `:redshift`, `:sqlite`, `:snowflake`
`:clickhouse`, `:duckdb`, `:glaredb`, `:oracle`, `:redshift`, `:sqlite`, `:snowflake`

* `:format` - Formats the output, defaults to `true`

Expand Down
1 change: 1 addition & 0 deletions prqlc/bindings/elixir/lib/prql/native.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ defmodule PRQL.Native.CompileOptions do
| :bigquery
| :clickhouse
| :glaredb
| :oracle
| :redshift
| :sqlite
| :snowflake
Expand Down
3 changes: 3 additions & 0 deletions prqlc/bindings/elixir/native/prql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mod atoms {
generic,
mssql,
mysql,
oracle,
postgres,
redshift,
sqlite,
Expand Down Expand Up @@ -63,6 +64,8 @@ fn target_from_atom(a: Atom) -> prqlc::Target {
MsSql
} else if a == atoms::mysql() {
MySql
} else if a == atoms::oracle() {
Oracle
} else if a == atoms::postgres() {
Postgres
} else if a == atoms::redshift() {
Expand Down
1 change: 1 addition & 0 deletions prqlc/prqlc/src/cli/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ fn get_targets() {
sql.glaredb
sql.mssql
sql.mysql
sql.oracle
sql.postgres
sql.redshift
sql.sqlite
Expand Down
20 changes: 17 additions & 3 deletions prqlc/prqlc/src/sql/dialect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub enum Dialect {
GlareDb,
MsSql,
MySql,
Oracle,
Postgres,
Redshift,
SQLite,
Expand All @@ -112,6 +113,7 @@ impl Dialect {
Dialect::Postgres => Box::new(PostgresDialect),
Dialect::Redshift => Box::new(RedshiftDialect),
Dialect::GlareDb => Box::new(GlareDbDialect),
Dialect::Oracle => Box::new(OracleDialect),
Dialect::Ansi | Dialect::Generic => Box::new(GenericDialect),
}
}
Expand All @@ -126,9 +128,11 @@ impl Dialect {
| Dialect::Generic
| Dialect::GlareDb
| Dialect::ClickHouse => SupportLevel::Supported,
Dialect::MsSql | Dialect::Ansi | Dialect::BigQuery | Dialect::Snowflake => {
SupportLevel::Unsupported
}
Dialect::MsSql
| Dialect::Ansi
| Dialect::BigQuery
| Dialect::Snowflake
| Dialect::Oracle => SupportLevel::Unsupported,
}
}

Expand Down Expand Up @@ -166,6 +170,8 @@ pub struct PostgresDialect;
pub struct RedshiftDialect;
#[derive(Debug)]
pub struct GlareDbDialect;
#[derive(Debug)]
pub struct OracleDialect;

pub(super) enum ColumnExclude {
Exclude,
Expand Down Expand Up @@ -736,6 +742,14 @@ impl DialectHandler for DuckDbDialect {
}
}

impl DialectHandler for OracleDialect {
fn ident_quoting_style(&self) -> IdentQuotingStyle {
// Due to oraclesql identifier casing rules, identifiers are always quoted
// https://docs.oracle.com/en/database/oracle/oracle-database/26/sqlrf/Database-Object-Names-and-Qualifiers.html
IdentQuotingStyle::AlwaysQuoted
}
}

#[cfg(test)]
mod tests {
use std::str::FromStr;
Expand Down
11 changes: 11 additions & 0 deletions prqlc/prqlc/tests/integration/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ FROM
"employees"
"#
)]
#[case::oracle(
sql::Dialect::Oracle,
r#"
SELECT
"a",
"b",
"col space"
FROM
"employees"
"#
)]
fn test_quoting_style(#[case] dialect: sql::Dialect, #[case] expected_sql: &'static str) {
let query = r#"
from employees
Expand Down
3 changes: 3 additions & 0 deletions web/book/src/project/target.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ additional dialects.
- `sql.ansi`
- `sql.bigquery`
- `sql.snowflake`
- `sql.oracle` — very early; currently only ensures identifiers are quoted to
accommodate Oracle's case-folding rules. Most other language features fall
back to generic SQL and may not execute correctly against Oracle.

## Priority of targets

Expand Down
Loading