Skip to content
Open
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
12 changes: 10 additions & 2 deletions docs.feldera.com/docs/sql/grammar.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,14 @@ orderItem
```
projectItem
: expression [ [ AS ] columnAlias ]
| ROW(*) [ [ AS ] columnAlias ]
| tableAlias . *
| ROW(rowStarItem [, projectItem ]* [ [ AS columnAlias ] ]
| tableAlias . '*'

rowStarItem
: '*'
| tableAlias . '*'
| '*' { EXCLUDE | EXCEPT } '(' column [, column ]* ')'
| tableAlias . '*' { EXCLUDE | EXCEPT } '(' column [, column ]* ')'
```

The following forms of `SELECT` are supported:
Expand All @@ -409,6 +415,8 @@ The following forms of `SELECT` are supported:
- `SELECT * EXCLUDE a, b FROM T`: select all columns of table `T` except the ones named `a` and `b`
- `SELECT * EXCEPT a, b FROM T`: `EXCEPT` is a synonym for `EXCLUDE`; this statement is equivalent to the previous statement
- `SELECT * REPLACE (a+b AS a) FROM T`: Select all columns of table `T` and replace column `a` with the expression `a+b`
- `SELECT ROW(T.*) FROM T`: Create a `ROW`-typed column with all columns of table `T`
- `SELECT ROW(T.* EXCLUDE(a, b)) FROM T: Create a `ROW`-typed column with all columns of table `T` except columns `a` and `b`
- `SELECT` supports [lateral column aliasing](identifiers.md#lateral-column-aliasing), where
an identifier defined in a `SELECT` statement can be immediately used in the same statement
or in the associated `GROUP BY` and `HAVING` statements.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,13 @@ CompilerMessages run() {
}
}

String dotFormat = (this.options.ioOptions.emitJpeg ? "jpg"
: this.options.ioOptions.emitPng ? "png"
: null);
String dotFormat = null;
if (this.options.ioOptions.emitJpeg)
dotFormat = "jpg";
else if (this.options.ioOptions.emitPng)
dotFormat = "png";
else if (this.options.ioOptions.emitSvg)
dotFormat = "svg";
if (dotFormat != null) {
if (this.options.ioOptions.outputFile.isEmpty()) {
compiler.reportError(SourcePositionRange.INVALID, "Invalid output",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ public static class IO implements IDiff<IO>, IValidate {
public boolean emitJpeg = false;
@Parameter(names = {"--png", "-png"}, description = "Emit a png image of the circuit instead of Rust")
public boolean emitPng = false;
@Parameter(names = {"--svg", "-svg"}, description = "Emit an svg image of the circuit instead of Rust")
public boolean emitSvg = false;
@Parameter(names="--jit", description = "Emit a JSON representation suitable for an interpreter")
public boolean interpreterJson = false;
@Nullable @Parameter(names = "--plan", description = "Emit the Calcite plan of the program in the specified JSON file")
Expand Down Expand Up @@ -242,9 +244,16 @@ public boolean multiCrates() {

@Override
public boolean validate(IErrorReporter reporter) {
if (this.emitJpeg && this.emitPng) {
int count = 0;
if (this.emitJpeg)
count++;
if (this.emitSvg)
count++;
if (this.emitPng)
count++;
if (count > 1) {
reporter.reportError(SourcePositionRange.INVALID, "Invalid options",
"Options -png and -jpg cannot be used at the same time");
"Options -png/-jpg/-svg cannot be used at the same time");
return false;
}
return true;
Expand All @@ -258,6 +267,7 @@ public String toString() {
",\n\tcrates=" + this.crates +
",\n\temitHandles=" + this.emitHandles +
",\n\temitJpeg=" + this.emitJpeg +
",\n\temitSvg=" + this.emitSvg +
Comment thread
mihaibudiu marked this conversation as resolved.
",\n\tinterpreterJson=" + this.interpreterJson +
",\n\temitJsonErrors=" + this.emitJsonErrors +
",\n\temitJsonSchema=" + Utilities.singleQuote(this.emitJsonSchema) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,9 @@ Use handles (true) or Catalog (false) in the emitted Rust code
--streaming
Compiling a streaming program, where only inserts are allowed
Default: false
--svg, -svg
Emit an svg image of the circuit instead of Rust
Default: false
--trimInputs
Do not ingest unused fields of input tables
Default: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,6 @@ public void testCompareTz() {
"Operation < between TIMESTAMP and TIMESTAMP WITH TIME ZONE not supported");
this.statementsFailingInCompilation(
"CREATE VIEW V AS SELECT TIMESTAMP '2020-01-01 10:00:00' - TIMESTAMP WITH TIME ZONE '2020-01-01 10:00:00 UTC'",
"Cannot apply '-' to arguments of type '<TIMESTAMP(0)> - <TIMESTAMP_TZ(0)>'");
"Cannot apply '-' to arguments of type '<TIMESTAMP(0)> - <TIMESTAMP WITH TIME ZONE(0)>'");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.dbsp.sqlCompiler.compiler.sql.tools.SqlIoTest;
import org.dbsp.sqlCompiler.compiler.visitors.outer.CircuitVisitor;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;

public class Regression3Tests extends SqlIoTest {
Expand All @@ -30,6 +31,44 @@ public void issue6400() {
^^^""");
}

@Test
public void issue6342() {
this.getCC("""
CREATE TABLE dept_nested (
employees ROW(
detail ROW(
skills ROW(
desc VARCHAR
) ARRAY
)
) ARRAY
);
create view v as select * from dept_nested order by employees[1].detail.skills[2+3].desc""");

this.getCC("""
CREATE TABLE T (
id INT,
col ROW(field1 VARCHAR, field2 INT)
);

CREATE VIEW V AS
SELECT id FROM T t ORDER BY (t.col).field2;""");
}

@Test
public void issue5398() {
var ccs = this.getCCS("""
CREATE TABLE T(x INT, y INT, z INT);
CREATE TABLE S(a INT, b INT);
CREATE LOCAL VIEW V AS SELECT ROW(T.* EXCLUDE(x), ROW(S.* EXCLUDE(a))) AS R FROM T, S;
CREATE VIEW W AS SELECT R[1], R[2], R[3][1] FROM V;""");
ccs.stepWeightOne("""
INSERT INTO T VALUES(0, 1, 2); INSERT INTO S VALUES(3, 4);""", """
y | z | b
-----------
1 | 2 | 4""");
}

@Test
public void issue5806() {
// Temporal filters and joins can be swapped by Calcite optimizer
Expand Down
2 changes: 1 addition & 1 deletion sql-to-dbsp-compiler/calcite_version.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ CALCITE_REPO="https://github.com/apache/calcite.git"
#CALCITE_REPO="https://github.com/mihaibudiu/calcite"
CALCITE_BRANCH="main"
CALCITE_CURRENT="1.42.0"
CALCITE_NEXT_COMMIT="fda2874d73250c373f1e74b445547f1c0b0debd8"
CALCITE_NEXT_COMMIT="1a3173d52a41683acca60fb09a31ad6ee25e587e"
CALCITE_NEXT="1.43.0"
3 changes: 3 additions & 0 deletions sql-to-dbsp-compiler/using.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ Usage: sql-to-dbsp [options] Input file to compile
--streaming
Compiling a streaming program, where only inserts are allowed
Default: false
--svg, -svg
Emit an svg image of the circuit instead of Rust
Default: false
--trimInputs
Do not ingest unused fields of input tables
Default: false
Expand Down