adriangb commented on code in PR #19483:
URL: https://github.com/apache/datafusion/pull/19483#discussion_r2647143472


##########
datafusion/core/tests/sql/orderby.rs:
##########
@@ -0,0 +1,78 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use datafusion::catalog::MemTable;
+use datafusion::common::test_util::batches_to_string;
+use datafusion::sql::unparser::plan_to_sql;
+
+use super::*;
+
+#[tokio::test]
+async fn roundtrip_group_by_alias_with_execution() -> Result<()> {
+    let ctx = SessionContext::new();
+
+    // Create table schema
+    let t1_schema =
+        Arc::new(Schema::new(vec![Field::new("col", DataType::Int32, false)]));
+
+    // Create test data: rows (3), (2), (1)
+    let batch = RecordBatch::try_new(
+        t1_schema.clone(),
+        vec![Arc::new(Int32Array::from(vec![3, 2, 1]))],
+    )?;
+
+    // Register table with data
+    ctx.register_table(
+        "t1",
+        Arc::new(MemTable::try_new(t1_schema, vec![vec![batch]])?),
+    )?;
+
+    // Original query
+    let original_sql = r#"
+        SELECT
+          col * 2 as x_bucket,
+          count(*)
+        FROM t1
+        GROUP BY x_bucket
+        ORDER BY x_bucket, count(*)

Review Comment:
   We can probably move this to a test in `plan_to_sql.rs` but I struggled a 
bit translating it since there's limited functions available (e.g. `count(*)`). 
I do also think e2e tests with data are useful in that they don't require a 
specific SQL representation as long as query semantics are maintained. But I 
will try to port again once we get some initial feedback here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to