kevinjqliu commented on code in PR #338:
URL: https://github.com/apache/iceberg-go/pull/338#discussion_r2000145624
##########
table/snapshots.go:
##########
@@ -306,6 +307,37 @@ func (s Snapshot) Manifests(fio iceio.IO)
([]iceberg.ManifestFile, error) {
return nil, nil
}
+func (s Snapshot) files(fio iceio.IO, fileFilter
set[iceberg.ManifestEntryContent]) iter.Seq2[iceberg.DataFile, error] {
Review Comment:
nit: rename this to `data_files` since this is only returns data files
##########
table/table_test.go:
##########
@@ -367,6 +409,326 @@ func (t *TableWritingTestSuite)
TestAddFilesFailsSchemaMismatch() {
`)
}
+func (t *TableWritingTestSuite) TestAddFilesPartitionedTable() {
+ ident := table.Identifier{"default", "partitioned_table_v" +
strconv.Itoa(t.formatVersion)}
+ spec := iceberg.NewPartitionSpec(
+ iceberg.PartitionField{SourceID: 4, FieldID: 1000, Transform:
iceberg.IdentityTransform{}, Name: "baz"},
+ iceberg.PartitionField{SourceID: 10, FieldID: 1001, Transform:
iceberg.MonthTransform{}, Name: "qux_month"})
+
+ tbl := t.createTable(ident, t.formatVersion,
+ spec, t.tableSchema)
+
+ t.NotNil(tbl)
+
+ dates := []string{
+ "2024-03-07", "2024-03-08", "2024-03-16", "2024-03-18",
"2024-03-19",
+ }
+
+ files := make([]string, 0)
+ for i := range 5 {
+ filePath := fmt.Sprintf("%s/partitioned_table/test-%d.parquet",
t.location, i)
+ table, err := array.TableFromJSON(memory.DefaultAllocator,
t.arrSchema, []string{
+ `[{"foo": true, "bar": "bar_string", "baz": 123, "qux":
"` + dates[i] + `"}]`,
+ })
+ t.Require().NoError(err)
+ defer table.Release()
+
+ t.writeParquet(tbl.FS().(iceio.WriteFileIO), filePath, table)
+ files = append(files, filePath)
+ }
+
+ tx := tbl.NewTransaction()
+ t.Require().NoError(tx.AddFiles(files, nil, false))
+
+ stagedTbl, err := tx.StagedTable()
+ t.Require().NoError(err)
+ t.NotNil(stagedTbl.NameMapping())
+
+ t.Equal(stagedTbl.CurrentSnapshot().Summary,
+ &table.Summary{
+ Operation: table.OpAppend,
+ Properties: iceberg.Properties{
+ "added-data-files": "5",
+ "added-files-size": "3660",
+ "added-records": "5",
+ "changed-partition-count": "1",
Review Comment:
ah okay, this is `1` instead of `5` because all the dates are in March and
we have a MonthTransform
--
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]