Skip to content

Commit

Permalink
[BUG]: sql nested and wildcard (Eventual-Inc#2937)
Browse files Browse the repository at this point in the history
  • Loading branch information
universalmind303 authored and sagiahrac committed Oct 7, 2024
1 parent 029875d commit c956db7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/daft-sql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ mod tests {
JoinType::Inner,
None,
)?
.select(vec![col("*")])?
.build();
assert_eq!(plan, expected);
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions src/daft-sql/src/planner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,9 @@ impl SQLPlanner {
.collect::<Vec<_>>()
})
.map_err(|e| e.into());
} else {
Ok(vec![col("*")])
}

Ok(vec![])
}
_ => todo!(),
}
Expand Down Expand Up @@ -621,7 +621,7 @@ impl SQLPlanner {
SQLExpr::Trim { .. } => unsupported_sql_err!("TRIM"),
SQLExpr::Overlay { .. } => unsupported_sql_err!("OVERLAY"),
SQLExpr::Collate { .. } => unsupported_sql_err!("COLLATE"),
SQLExpr::Nested(_) => unsupported_sql_err!("NESTED"),
SQLExpr::Nested(e) => self.plan_expr(e),
SQLExpr::IntroducedString { .. } => unsupported_sql_err!("INTRODUCED STRING"),
SQLExpr::TypedString { data_type, value } => match data_type {
sqlparser::ast::DataType::Date => Ok(to_date(lit(value.as_str()), "%Y-%m-%d")),
Expand Down
22 changes: 22 additions & 0 deletions tests/sql/test_exprs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import daft


def test_nested():
df = daft.from_pydict(
{
"A": [1, 2, 3, 4],
"B": [1.5, 2.5, 3.5, 4.5],
"C": [True, True, False, False],
"D": [None, None, None, None],
}
)

actual = daft.sql("SELECT (A + 1) AS try_this FROM df").collect()
expected = df.select((daft.col("A") + 1).alias("try_this")).collect()

assert actual.to_pydict() == expected.to_pydict()

actual = daft.sql("SELECT *, (A + 1) AS try_this FROM df").collect()
expected = df.with_column("try_this", df["A"] + 1).collect()

assert actual.to_pydict() == expected.to_pydict()

0 comments on commit c956db7

Please sign in to comment.