andygrove commented on code in PR #3258:
URL: https://github.com/apache/arrow-datafusion/pull/3258#discussion_r956014831


##########
datafusion/core/src/datasource/view.rs:
##########
@@ -342,6 +355,65 @@ mod tests {
         Ok(())
     }
 
+    #[tokio::test]
+    async fn query_view_with_filter_and_limit() -> Result<()> {
+        let session_ctx = SessionContext::with_config(
+            SessionConfig::new().with_information_schema(true),
+        );
+
+        session_ctx
+            .sql("CREATE TABLE abc AS VALUES (1,2,3), (4,5,6), (7,8,9)")
+            .await?
+            .collect()
+            .await?;
+
+        let view_sql = "CREATE VIEW xyz AS SELECT column1, column2 FROM abc";
+        session_ctx.sql(view_sql).await?.collect().await?;
+
+        let results = session_ctx.sql("SELECT * FROM information_schema.tables 
WHERE table_type='VIEW' AND table_name = 'xyz'").await?.collect().await?;
+        assert_eq!(results[0].num_rows(), 1);
+
+        let result_plan = session_ctx
+            .sql("EXPLAIN CREATE VIEW efg as SELECT column1 FROM xyz WHERE 
column2 % 2 = 0 OFFSET 1 LIMIT 2")

Review Comment:
   When we select from a view, it will cause the `TableView::scan` method to be 
called.



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to