Skip to content
Draft
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
14 changes: 10 additions & 4 deletions datafusion/expr/src/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,7 @@ impl Expr {

/// Return `self AS name` alias expression
pub fn alias(self, name: impl Into<String>) -> Expr {
Expr::Alias(Alias::new(self, None::<&str>, name.into()))
Expr::Alias(Alias::new(self.unalias(), None::<TableReference>, name))
}

/// Return `self AS name` alias expression with metadata
Expand Down Expand Up @@ -1881,7 +1881,7 @@ impl Expr {
relation: Option<impl Into<TableReference>>,
name: impl Into<String>,
) -> Expr {
Expr::Alias(Alias::new(self, relation, name.into()))
Expr::Alias(Alias::new(self.unalias(), relation, name))
}

/// Return `self AS name` alias expression with a specific qualifier and metadata
Expand Down Expand Up @@ -1915,7 +1915,8 @@ impl Expr {
///
/// # Example
/// ```
/// # use datafusion_expr::col;
/// # use datafusion_expr::{col, Expr};
/// # use datafusion_expr::expr::Alias;
/// // `foo as "bar"` is unaliased to `foo`
/// let expr = col("foo").alias("bar");
/// assert_eq!(expr.unalias(), col("foo"));
Expand All @@ -1925,7 +1926,12 @@ impl Expr {
/// assert_eq!(expr.clone().unalias(), expr);
///
/// // `foo as "bar" as "baz" is unaliased to foo as "bar"
/// let expr = col("foo").alias("bar").alias("baz");
/// let expr = Expr::Alias(Alias {
/// expr: Box::new(col("foo").alias("bar")),
/// name: "baz".to_owned(),
/// relation: None,
/// metadata: None
/// });
/// assert_eq!(expr.unalias(), col("foo").alias("bar"));
/// ```
pub fn unalias(self) -> Expr {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/optimizer/src/analyzer/type_coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,7 @@ fn project_with_column_index(
.enumerate()
.map(|(i, e)| match e {
Expr::Alias(Alias { ref name, .. }) if name != schema.field(i).name() => {
Ok(e.unalias().alias(schema.field(i).name()))
Ok(e.alias(schema.field(i).name()))
}
Expr::Column(Column {
relation: _,
Expand Down
2 changes: 1 addition & 1 deletion datafusion/optimizer/tests/optimizer_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ fn eliminate_redundant_null_check_on_count() {
assert_snapshot!(
format!("{plan}"),
@r"
Projection: test.col_int32, count(Int64(1)) AS count(*) AS c
Projection: test.col_int32, count(Int64(1)) AS c
Aggregate: groupBy=[[test.col_int32]], aggr=[[count(Int64(1))]]
TableScan: test projection=[col_int32]
"
Expand Down
15 changes: 10 additions & 5 deletions datafusion/sql/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,12 +703,13 @@ mod tests {
use arrow::datatypes::{DataType as ArrowDataType, Field, Fields, Schema};
use datafusion_common::{Column, DFSchema, Result};
use datafusion_expr::{
ColumnUnnestList, EmptyRelation, LogicalPlan, col, lit, unnest,
ColumnUnnestList, EmptyRelation, Expr, LogicalPlan, col, lit, unnest,
};
use datafusion_functions::core::expr_ext::FieldAccessor;
use datafusion_functions_aggregate::expr_fn::count;

use crate::utils::{resolve_positions_to_exprs, rewrite_recursive_unnest_bottom_up};
use datafusion_expr::expr::Alias;
use indexmap::IndexMap;

fn column_unnests_eq(
Expand Down Expand Up @@ -813,10 +814,14 @@ mod tests {

assert_eq!(
transformed_exprs,
vec![
(col("__unnest_placeholder(3d_col,depth=1)").alias("UNNEST(3d_col)"))
.alias("2d_col")
]
vec![Expr::Alias(Alias {
expr: Box::new(
col("__unnest_placeholder(3d_col,depth=1)").alias("UNNEST(3d_col)")
),
relation: None,
name: "2d_col".to_owned(),
metadata: None,
})]
);
column_unnests_eq(
vec![
Expand Down
36 changes: 18 additions & 18 deletions datafusion/sqllogictest/test_files/clickbench.slt
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ EXPLAIN SELECT "RegionID", SUM("AdvEngineID"), COUNT(*) AS c, AVG("ResolutionWid
----
logical_plan
01)Sort: c DESC NULLS FIRST, fetch=10
02)--Projection: hits.RegionID, sum(hits.AdvEngineID), count(Int64(1)) AS count(*) AS c, avg(hits.ResolutionWidth), count(DISTINCT hits.UserID)
02)--Projection: hits.RegionID, sum(hits.AdvEngineID), count(Int64(1)) AS c, avg(hits.ResolutionWidth), count(DISTINCT hits.UserID)
03)----Aggregate: groupBy=[[hits.RegionID]], aggr=[[sum(CAST(hits.AdvEngineID AS Int64)), count(Int64(1)), avg(CAST(hits.ResolutionWidth AS Float64)), count(DISTINCT hits.UserID)]]
04)------SubqueryAlias: hits
05)--------TableScan: hits_raw projection=[RegionID, UserID, ResolutionWidth, AdvEngineID]
Expand Down Expand Up @@ -350,7 +350,7 @@ EXPLAIN SELECT "SearchPhrase", COUNT(*) AS c FROM hits WHERE "SearchPhrase" <> '
----
logical_plan
01)Sort: c DESC NULLS FIRST, fetch=10
02)--Projection: hits.SearchPhrase, count(Int64(1)) AS count(*) AS c
02)--Projection: hits.SearchPhrase, count(Int64(1)) AS c
03)----Aggregate: groupBy=[[hits.SearchPhrase]], aggr=[[count(Int64(1))]]
04)------SubqueryAlias: hits
05)--------Filter: hits_raw.SearchPhrase != Utf8View("")
Expand Down Expand Up @@ -406,7 +406,7 @@ EXPLAIN SELECT "SearchEngineID", "SearchPhrase", COUNT(*) AS c FROM hits WHERE "
----
logical_plan
01)Sort: c DESC NULLS FIRST, fetch=10
02)--Projection: hits.SearchEngineID, hits.SearchPhrase, count(Int64(1)) AS count(*) AS c
02)--Projection: hits.SearchEngineID, hits.SearchPhrase, count(Int64(1)) AS c
03)----Aggregate: groupBy=[[hits.SearchEngineID, hits.SearchPhrase]], aggr=[[count(Int64(1))]]
04)------SubqueryAlias: hits
05)--------Filter: hits_raw.SearchPhrase != Utf8View("")
Expand Down Expand Up @@ -590,7 +590,7 @@ EXPLAIN SELECT "SearchPhrase", MIN("URL"), COUNT(*) AS c FROM hits WHERE "URL" L
----
logical_plan
01)Sort: c DESC NULLS FIRST, fetch=10
02)--Projection: hits.SearchPhrase, min(hits.URL), count(Int64(1)) AS count(*) AS c
02)--Projection: hits.SearchPhrase, min(hits.URL), count(Int64(1)) AS c
03)----Aggregate: groupBy=[[hits.SearchPhrase]], aggr=[[min(hits.URL), count(Int64(1))]]
04)------SubqueryAlias: hits
05)--------Filter: hits_raw.URL LIKE Utf8View("%google%") AND hits_raw.SearchPhrase != Utf8View("")
Expand All @@ -616,7 +616,7 @@ EXPLAIN SELECT "SearchPhrase", MIN("URL"), MIN("Title"), COUNT(*) AS c, COUNT(DI
----
logical_plan
01)Sort: c DESC NULLS FIRST, fetch=10
02)--Projection: hits.SearchPhrase, min(hits.URL), min(hits.Title), count(Int64(1)) AS count(*) AS c, count(DISTINCT hits.UserID)
02)--Projection: hits.SearchPhrase, min(hits.URL), min(hits.Title), count(Int64(1)) AS c, count(DISTINCT hits.UserID)
03)----Aggregate: groupBy=[[hits.SearchPhrase]], aggr=[[min(hits.URL), min(hits.Title), count(Int64(1)), count(DISTINCT hits.UserID)]]
04)------SubqueryAlias: hits
05)--------Filter: hits_raw.Title LIKE Utf8View("%Google%") AND hits_raw.URL NOT LIKE Utf8View("%.google.%") AND hits_raw.SearchPhrase != Utf8View("")
Expand Down Expand Up @@ -730,7 +730,7 @@ EXPLAIN SELECT "CounterID", AVG(length("URL")) AS l, COUNT(*) AS c FROM hits WHE
----
logical_plan
01)Sort: l DESC NULLS FIRST, fetch=25
02)--Projection: hits.CounterID, avg(length(hits.URL)) AS l, count(Int64(1)) AS count(*) AS c
02)--Projection: hits.CounterID, avg(length(hits.URL)) AS l, count(Int64(1)) AS c
03)----Filter: count(Int64(1)) > Int64(100000)
04)------Aggregate: groupBy=[[hits.CounterID]], aggr=[[avg(CAST(character_length(hits.URL) AS length(hits.URL) AS Float64)), count(Int64(1))]]
05)--------SubqueryAlias: hits
Expand Down Expand Up @@ -758,7 +758,7 @@ EXPLAIN SELECT REGEXP_REPLACE("Referer", '^https?://(?:www\.)?([^/]+)/.*$', '\1'
----
logical_plan
01)Sort: l DESC NULLS FIRST, fetch=25
02)--Projection: regexp_replace(hits.Referer,Utf8("^https?://(?:www\.)?([^/]+)/.*$"),Utf8("\1")) AS k, avg(length(hits.Referer)) AS l, count(Int64(1)) AS count(*) AS c, min(hits.Referer)
02)--Projection: regexp_replace(hits.Referer,Utf8("^https?://(?:www\.)?([^/]+)/.*$"),Utf8("\1")) AS k, avg(length(hits.Referer)) AS l, count(Int64(1)) AS c, min(hits.Referer)
03)----Filter: count(Int64(1)) > Int64(100000)
04)------Aggregate: groupBy=[[regexp_replace(hits.Referer, Utf8View("^https?://(?:www\.)?([^/]+)/.*$"), Utf8View("\1")) AS regexp_replace(hits.Referer,Utf8("^https?://(?:www\.)?([^/]+)/.*$"),Utf8("\1"))]], aggr=[[avg(CAST(character_length(hits.Referer) AS length(hits.Referer) AS Float64)), count(Int64(1)), min(hits.Referer)]]
05)--------SubqueryAlias: hits
Expand Down Expand Up @@ -807,7 +807,7 @@ EXPLAIN SELECT "SearchEngineID", "ClientIP", COUNT(*) AS c, SUM("IsRefresh"), AV
----
logical_plan
01)Sort: c DESC NULLS FIRST, fetch=10
02)--Projection: hits.SearchEngineID, hits.ClientIP, count(Int64(1)) AS count(*) AS c, sum(hits.IsRefresh), avg(hits.ResolutionWidth)
02)--Projection: hits.SearchEngineID, hits.ClientIP, count(Int64(1)) AS c, sum(hits.IsRefresh), avg(hits.ResolutionWidth)
03)----Aggregate: groupBy=[[hits.SearchEngineID, hits.ClientIP]], aggr=[[count(Int64(1)), sum(CAST(hits.IsRefresh AS Int64)), avg(CAST(hits.ResolutionWidth AS Float64))]]
04)------SubqueryAlias: hits
05)--------Projection: hits_raw.ClientIP, hits_raw.IsRefresh, hits_raw.ResolutionWidth, hits_raw.SearchEngineID
Expand All @@ -834,7 +834,7 @@ EXPLAIN SELECT "WatchID", "ClientIP", COUNT(*) AS c, SUM("IsRefresh"), AVG("Reso
----
logical_plan
01)Sort: c DESC NULLS FIRST, fetch=10
02)--Projection: hits.WatchID, hits.ClientIP, count(Int64(1)) AS count(*) AS c, sum(hits.IsRefresh), avg(hits.ResolutionWidth)
02)--Projection: hits.WatchID, hits.ClientIP, count(Int64(1)) AS c, sum(hits.IsRefresh), avg(hits.ResolutionWidth)
03)----Aggregate: groupBy=[[hits.WatchID, hits.ClientIP]], aggr=[[count(Int64(1)), sum(CAST(hits.IsRefresh AS Int64)), avg(CAST(hits.ResolutionWidth AS Float64))]]
04)------SubqueryAlias: hits
05)--------Projection: hits_raw.WatchID, hits_raw.ClientIP, hits_raw.IsRefresh, hits_raw.ResolutionWidth
Expand All @@ -861,7 +861,7 @@ EXPLAIN SELECT "WatchID", "ClientIP", COUNT(*) AS c, SUM("IsRefresh"), AVG("Reso
----
logical_plan
01)Sort: c DESC NULLS FIRST, fetch=10
02)--Projection: hits.WatchID, hits.ClientIP, count(Int64(1)) AS count(*) AS c, sum(hits.IsRefresh), avg(hits.ResolutionWidth)
02)--Projection: hits.WatchID, hits.ClientIP, count(Int64(1)) AS c, sum(hits.IsRefresh), avg(hits.ResolutionWidth)
03)----Aggregate: groupBy=[[hits.WatchID, hits.ClientIP]], aggr=[[count(Int64(1)), sum(CAST(hits.IsRefresh AS Int64)), avg(CAST(hits.ResolutionWidth AS Float64))]]
04)------SubqueryAlias: hits
05)--------TableScan: hits_raw projection=[WatchID, ClientIP, IsRefresh, ResolutionWidth]
Expand Down Expand Up @@ -894,7 +894,7 @@ EXPLAIN SELECT "URL", COUNT(*) AS c FROM hits GROUP BY "URL" ORDER BY c DESC LIM
----
logical_plan
01)Sort: c DESC NULLS FIRST, fetch=10
02)--Projection: hits.URL, count(Int64(1)) AS count(*) AS c
02)--Projection: hits.URL, count(Int64(1)) AS c
03)----Aggregate: groupBy=[[hits.URL]], aggr=[[count(Int64(1))]]
04)------SubqueryAlias: hits
05)--------TableScan: hits_raw projection=[URL]
Expand Down Expand Up @@ -981,7 +981,7 @@ EXPLAIN SELECT "URL", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND
----
logical_plan
01)Sort: pageviews DESC NULLS FIRST, fetch=10
02)--Projection: hits.URL, count(Int64(1)) AS count(*) AS pageviews
02)--Projection: hits.URL, count(Int64(1)) AS pageviews
03)----Aggregate: groupBy=[[hits.URL]], aggr=[[count(Int64(1))]]
04)------SubqueryAlias: hits
05)--------Projection: hits_raw.URL
Expand All @@ -1008,7 +1008,7 @@ EXPLAIN SELECT "Title", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 A
----
logical_plan
01)Sort: pageviews DESC NULLS FIRST, fetch=10
02)--Projection: hits.Title, count(Int64(1)) AS count(*) AS pageviews
02)--Projection: hits.Title, count(Int64(1)) AS pageviews
03)----Aggregate: groupBy=[[hits.Title]], aggr=[[count(Int64(1))]]
04)------SubqueryAlias: hits
05)--------Projection: hits_raw.Title
Expand Down Expand Up @@ -1036,7 +1036,7 @@ EXPLAIN SELECT "URL", COUNT(*) AS PageViews FROM hits WHERE "CounterID" = 62 AND
logical_plan
01)Limit: skip=1000, fetch=10
02)--Sort: pageviews DESC NULLS FIRST, fetch=1010
03)----Projection: hits.URL, count(Int64(1)) AS count(*) AS pageviews
03)----Projection: hits.URL, count(Int64(1)) AS pageviews
04)------Aggregate: groupBy=[[hits.URL]], aggr=[[count(Int64(1))]]
05)--------SubqueryAlias: hits
06)----------Projection: hits_raw.URL
Expand Down Expand Up @@ -1065,7 +1065,7 @@ EXPLAIN SELECT "TraficSourceID", "SearchEngineID", "AdvEngineID", CASE WHEN ("Se
logical_plan
01)Limit: skip=1000, fetch=10
02)--Sort: pageviews DESC NULLS FIRST, fetch=1010
03)----Projection: hits.TraficSourceID, hits.SearchEngineID, hits.AdvEngineID, CASE WHEN hits.SearchEngineID = Int64(0) AND hits.AdvEngineID = Int64(0) THEN hits.Referer ELSE Utf8("") END AS src, hits.URL AS dst, count(Int64(1)) AS count(*) AS pageviews
03)----Projection: hits.TraficSourceID, hits.SearchEngineID, hits.AdvEngineID, CASE WHEN hits.SearchEngineID = Int64(0) AND hits.AdvEngineID = Int64(0) THEN hits.Referer ELSE Utf8("") END AS src, hits.URL AS dst, count(Int64(1)) AS pageviews
04)------Aggregate: groupBy=[[hits.TraficSourceID, hits.SearchEngineID, hits.AdvEngineID, CASE WHEN hits.SearchEngineID = Int16(0) AND hits.AdvEngineID = Int16(0) THEN hits.Referer ELSE Utf8View("") END AS CASE WHEN hits.SearchEngineID = Int64(0) AND hits.AdvEngineID = Int64(0) THEN hits.Referer ELSE Utf8("") END, hits.URL]], aggr=[[count(Int64(1))]]
05)--------SubqueryAlias: hits
06)----------Projection: hits_raw.URL, hits_raw.Referer, hits_raw.TraficSourceID, hits_raw.SearchEngineID, hits_raw.AdvEngineID
Expand Down Expand Up @@ -1094,7 +1094,7 @@ EXPLAIN SELECT "URLHash", "EventDate", COUNT(*) AS PageViews FROM hits WHERE "Co
logical_plan
01)Limit: skip=100, fetch=10
02)--Sort: pageviews DESC NULLS FIRST, fetch=110
03)----Projection: hits.URLHash, hits.EventDate, count(Int64(1)) AS count(*) AS pageviews
03)----Projection: hits.URLHash, hits.EventDate, count(Int64(1)) AS pageviews
04)------Aggregate: groupBy=[[hits.URLHash, hits.EventDate]], aggr=[[count(Int64(1))]]
05)--------SubqueryAlias: hits
06)----------Projection: hits_raw.URLHash, CAST(CAST(hits_raw.EventDate AS Int32) AS Date32) AS EventDate
Expand Down Expand Up @@ -1124,7 +1124,7 @@ EXPLAIN SELECT "WindowClientWidth", "WindowClientHeight", COUNT(*) AS PageViews
logical_plan
01)Limit: skip=10000, fetch=10
02)--Sort: pageviews DESC NULLS FIRST, fetch=10010
03)----Projection: hits.WindowClientWidth, hits.WindowClientHeight, count(Int64(1)) AS count(*) AS pageviews
03)----Projection: hits.WindowClientWidth, hits.WindowClientHeight, count(Int64(1)) AS pageviews
04)------Aggregate: groupBy=[[hits.WindowClientWidth, hits.WindowClientHeight]], aggr=[[count(Int64(1))]]
05)--------SubqueryAlias: hits
06)----------Projection: hits_raw.WindowClientWidth, hits_raw.WindowClientHeight
Expand Down Expand Up @@ -1153,7 +1153,7 @@ EXPLAIN SELECT DATE_TRUNC('minute', to_timestamp_seconds("EventTime")) AS M, COU
logical_plan
01)Limit: skip=1000, fetch=10
02)--Sort: date_trunc(Utf8("minute"), m) ASC NULLS LAST, fetch=1010
03)----Projection: date_trunc(Utf8("minute"),to_timestamp_seconds(hits.EventTime)) AS m, count(Int64(1)) AS count(*) AS pageviews
03)----Projection: date_trunc(Utf8("minute"),to_timestamp_seconds(hits.EventTime)) AS m, count(Int64(1)) AS pageviews
04)------Aggregate: groupBy=[[date_trunc(Utf8("minute"), to_timestamp_seconds(hits.EventTime))]], aggr=[[count(Int64(1))]]
05)--------SubqueryAlias: hits
06)----------Projection: hits_raw.EventTime
Expand Down
4 changes: 2 additions & 2 deletions datafusion/sqllogictest/test_files/count_star_rule.slt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ query TT
EXPLAIN SELECT t1.a, COUNT() AS cnt FROM t1 GROUP BY t1.a HAVING COUNT() > 0;
----
logical_plan
01)Projection: t1.a, count(Int64(1)) AS count() AS cnt
01)Projection: t1.a, count(Int64(1)) AS cnt
02)--Filter: count(Int64(1)) > Int64(0)
03)----Aggregate: groupBy=[[t1.a]], aggr=[[count(Int64(1))]]
04)------TableScan: t1 projection=[a]
Expand All @@ -78,7 +78,7 @@ query TT
EXPLAIN SELECT a, COUNT() OVER (PARTITION BY a) AS count_a FROM t1;
----
logical_plan
01)Projection: t1.a, count(Int64(1)) PARTITION BY [t1.a] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS count() PARTITION BY [t1.a] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS count_a
01)Projection: t1.a, count(Int64(1)) PARTITION BY [t1.a] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING AS count_a
02)--WindowAggr: windowExpr=[[count(Int64(1)) PARTITION BY [t1.a] ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING]]
03)----TableScan: t1 projection=[a]
physical_plan
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/insert.slt
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ logical_plan
01)Dml: op=[Insert Into] table=[table_without_values]
02)--Projection: a1, a2
03)----Sort: aggregate_test_100.c1 ASC NULLS LAST
04)------Projection: sum(aggregate_test_100.c4) PARTITION BY [aggregate_test_100.c1] ORDER BY [aggregate_test_100.c9 ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING AS a1, count(Int64(1)) PARTITION BY [aggregate_test_100.c1] ORDER BY [aggregate_test_100.c9 ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING AS count(*) PARTITION BY [aggregate_test_100.c1] ORDER BY [aggregate_test_100.c9 ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING AS a2, aggregate_test_100.c1
04)------Projection: sum(aggregate_test_100.c4) PARTITION BY [aggregate_test_100.c1] ORDER BY [aggregate_test_100.c9 ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING AS a1, count(Int64(1)) PARTITION BY [aggregate_test_100.c1] ORDER BY [aggregate_test_100.c9 ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING AS a2, aggregate_test_100.c1
05)--------WindowAggr: windowExpr=[[sum(CAST(aggregate_test_100.c4 AS Int64)) PARTITION BY [aggregate_test_100.c1] ORDER BY [aggregate_test_100.c9 ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING, count(Int64(1)) PARTITION BY [aggregate_test_100.c1] ORDER BY [aggregate_test_100.c9 ASC NULLS LAST] ROWS BETWEEN 1 PRECEDING AND 1 FOLLOWING]]
06)----------TableScan: aggregate_test_100 projection=[c1, c4, c9]
physical_plan
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/tpch/plans/q1.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ explain select
----
logical_plan
01)Sort: lineitem.l_returnflag ASC NULLS LAST, lineitem.l_linestatus ASC NULLS LAST
02)--Projection: lineitem.l_returnflag, lineitem.l_linestatus, sum(lineitem.l_quantity) AS sum_qty, sum(lineitem.l_extendedprice) AS sum_base_price, sum(lineitem.l_extendedprice * Int64(1) - lineitem.l_discount) AS sum_disc_price, sum(lineitem.l_extendedprice * Int64(1) - lineitem.l_discount * Int64(1) + lineitem.l_tax) AS sum_charge, avg(lineitem.l_quantity) AS avg_qty, avg(lineitem.l_extendedprice) AS avg_price, avg(lineitem.l_discount) AS avg_disc, count(Int64(1)) AS count(*) AS count_order
02)--Projection: lineitem.l_returnflag, lineitem.l_linestatus, sum(lineitem.l_quantity) AS sum_qty, sum(lineitem.l_extendedprice) AS sum_base_price, sum(lineitem.l_extendedprice * Int64(1) - lineitem.l_discount) AS sum_disc_price, sum(lineitem.l_extendedprice * Int64(1) - lineitem.l_discount * Int64(1) + lineitem.l_tax) AS sum_charge, avg(lineitem.l_quantity) AS avg_qty, avg(lineitem.l_extendedprice) AS avg_price, avg(lineitem.l_discount) AS avg_disc, count(Int64(1)) AS count_order
03)----Aggregate: groupBy=[[lineitem.l_returnflag, lineitem.l_linestatus]], aggr=[[sum(lineitem.l_quantity), sum(lineitem.l_extendedprice), sum(__common_expr_1) AS sum(lineitem.l_extendedprice * Int64(1) - lineitem.l_discount), sum(__common_expr_1 * (Decimal128(Some(1),20,0) + lineitem.l_tax)) AS sum(lineitem.l_extendedprice * Int64(1) - lineitem.l_discount * Int64(1) + lineitem.l_tax), avg(lineitem.l_quantity), avg(lineitem.l_extendedprice), avg(lineitem.l_discount), count(Int64(1))]]
04)------Projection: lineitem.l_extendedprice * (Decimal128(Some(1),20,0) - lineitem.l_discount) AS __common_expr_1, lineitem.l_quantity, lineitem.l_extendedprice, lineitem.l_discount, lineitem.l_tax, lineitem.l_returnflag, lineitem.l_linestatus
05)--------Filter: lineitem.l_shipdate <= Date32("1998-09-02")
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/tpch/plans/q13.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ limit 10;
----
logical_plan
01)Sort: custdist DESC NULLS FIRST, c_orders.c_count DESC NULLS FIRST, fetch=10
02)--Projection: c_orders.c_count, count(Int64(1)) AS count(*) AS custdist
02)--Projection: c_orders.c_count, count(Int64(1)) AS custdist
03)----Aggregate: groupBy=[[c_orders.c_count]], aggr=[[count(Int64(1))]]
04)------SubqueryAlias: c_orders
05)--------Projection: count(orders.o_orderkey) AS c_count
Expand Down
2 changes: 1 addition & 1 deletion datafusion/sqllogictest/test_files/tpch/plans/q21.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ order by
----
logical_plan
01)Sort: numwait DESC NULLS FIRST, supplier.s_name ASC NULLS LAST
02)--Projection: supplier.s_name, count(Int64(1)) AS count(*) AS numwait
02)--Projection: supplier.s_name, count(Int64(1)) AS numwait
03)----Aggregate: groupBy=[[supplier.s_name]], aggr=[[count(Int64(1))]]
04)------Projection: supplier.s_name
05)--------LeftAnti Join: l1.l_orderkey = __correlated_sq_2.l_orderkey Filter: __correlated_sq_2.l_suppkey != l1.l_suppkey
Expand Down
Loading
Loading