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
15 changes: 15 additions & 0 deletions rust/cubesql/cubesql/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16333,4 +16333,19 @@ LIMIT {{ limit }}{% endif %}"#.to_string(),
.sql;
assert!(sql.contains(" IS NULL DESC, "));
}

#[tokio::test]
async fn test_values_literal_table() -> Result<(), CubeError> {
insta::assert_snapshot!(
"values_literal_table",
execute_query(
r#"SELECT a AS a, b AS b FROM (VALUES (1, 2), (3, 4), (5, 6)) AS t(a, b)"#
.to_string(),
DatabaseProtocol::PostgreSQL
)
.await?
);

Ok(())
}
}
14 changes: 10 additions & 4 deletions rust/cubesql/cubesql/src/compile/rewrite/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use crate::{
SortExprAsc, SortExprNullsFirst, SubqueryTypes, TableScanFetch, TableScanProjection,
TableScanSourceTableName, TableScanTableName, TableUDFExprFun, TimeDimensionDateRange,
TimeDimensionGranularity, TimeDimensionName, TryCastExprDataType, UnionAlias,
WindowFunctionExprFun, WindowFunctionExprWindowFrame, WrappedSelectAlias,
ValuesValues, WindowFunctionExprFun, WindowFunctionExprWindowFrame, WrappedSelectAlias,
WrappedSelectDistinct, WrappedSelectJoinJoinType, WrappedSelectLimit,
WrappedSelectOffset, WrappedSelectPushToCube, WrappedSelectSelectType,
WrappedSelectType,
Expand Down Expand Up @@ -772,12 +772,13 @@ impl LogicalPlanToLanguageConverter {
self.graph
.add(LogicalPlanLanguage::Limit([skip, fetch, input]))
}
LogicalPlan::Values(values) => {
let values = add_data_node!(self, values.values, ValuesValues);
self.graph.add(LogicalPlanLanguage::Values([values]))
}
LogicalPlan::CreateExternalTable { .. } => {
panic!("CreateExternalTable is not supported");
}
LogicalPlan::Values { .. } => {
panic!("Values is not supported");
}
LogicalPlan::Explain { .. } => {
panic!("Explain is not supported");
}
Expand Down Expand Up @@ -2283,6 +2284,11 @@ impl LanguageToLogicalPlanConverter {

LogicalPlan::Distinct(Distinct { input })
}
LogicalPlanLanguage::Values(values) => {
let values = match_data_node!(node_by_id, values[0], ValuesValues);

LogicalPlanBuilder::values(values)?.build()?
}
x => panic!("Unexpected logical plan node: {:?}", x),
})
}
Expand Down
3 changes: 3 additions & 0 deletions rust/cubesql/cubesql/src/compile/rewrite/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ crate::plan_to_language! {
location: String,
has_header: bool,
},
Values {
values: Vec<Vec<Expr>>,
},
Extension {
node: Arc<LogicalPlan>,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
source: cubesql/src/compile/mod.rs
expression: "execute_query(r#\"SELECT a AS a, b AS b FROM (VALUES (1, 2), (3, 4), (5, 6)) AS t(a, b)\"#.to_string(),\nDatabaseProtocol::PostgreSQL).await?"
---
+---+---+
| a | b |
+---+---+
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |
+---+---+
Loading