Perseus commented on code in PR #47:
URL: https://github.com/apache/datafusion-iceberg/pull/47#discussion_r4200063211


##########
crates/datafusion/tests/integration_datafusion_test.rs:
##########
@@ -470,6 +455,114 @@ async fn test_metadata_table() -> Result<(), Box<dyn 
Error>> {
     Ok(())
 }
 
+#[tokio::test]
+async fn test_metadata_table_projections() -> Result<(), Box<dyn Error>> {
+    let iceberg_catalog = get_iceberg_catalog().await;
+    let namespace = NamespaceIdent::new("ns".to_string());
+    set_test_namespace(&iceberg_catalog, &namespace).await?;
+
+    let schema = Schema::builder()
+        .with_schema_id(0)
+        .with_fields(vec![
+            NestedField::required(1, "foo", 
Type::Primitive(PrimitiveType::Int)).into(),
+            NestedField::optional(2, "bar", 
Type::Primitive(PrimitiveType::String))
+                .into(),
+        ])
+        .build()?;
+    let creation = get_table_creation(temp_path(), "t1", Some(schema))?;
+    iceberg_catalog.create_table(&namespace, creation).await?;
+
+    let client = Arc::new(iceberg_catalog);
+    let catalog = Arc::new(IcebergCatalogProvider::try_new(client).await?);
+
+    let ctx = SessionContext::new();
+    ctx.register_catalog("catalog", catalog);
+
+    // commit twice to create two snapshots
+    ctx.sql("INSERT INTO catalog.ns.t1 VALUES (1, 'foo')")
+        .await
+        .unwrap()
+        .collect()
+        .await
+        .unwrap();
+
+    ctx.sql("INSERT INTO catalog.ns.t1 VALUES (2, 'bar')")
+        .await
+        .unwrap()
+        .collect()
+        .await
+        .unwrap();
+
+    let single_projected_column_result = ctx
+        .sql("SELECT operation FROM catalog.ns.t1$snapshots")
+        .await
+        .unwrap()
+        .collect()
+        .await
+        .unwrap();
+
+    check_record_batches(
+        single_projected_column_result,
+        expect![[
+            r#"Field { "operation": nullable Utf8, metadata: 
{"PARQUET:field_id": "4"} }"#
+        ]],
+        expect![[r#"
+            operation: StringArray
+            [
+              "append",
+              "append",
+            ]"#]],
+        &[],
+        None,
+    );
+
+    let multiple_projected_columns_result = ctx
+        .sql("SELECT operation, snapshot_id FROM catalog.ns.t1$snapshots")
+        .await
+        .unwrap()
+        .collect()
+        .await
+        .unwrap();
+
+    check_record_batches(
+        multiple_projected_columns_result,
+        expect![[r#"
+            Field { "operation": nullable Utf8, metadata: {"PARQUET:field_id": 
"4"} },

Review Comment:
   I'm not entirely sure if we should be committing these - I see that other 
tests don't have them, but while running tests locally it asked me to run `env 
UPDATE_EXPECT=1 cargo test` so that these expect sections get populated 
correctly



-- 
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