Revanth14 commented on code in PR #1505: URL: https://github.com/apache/iceberg-go/pull/1505#discussion_r3781100482
########## catalog/rest/scan_planning_integration_test.go: ########## @@ -0,0 +1,321 @@ +// 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. + +//go:build integration + +package rest_test + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + stdio "io" + "net/http" + "net/url" + "os" + "strings" + "sync" + "time" + + "github.com/apache/arrow-go/v18/arrow/array" + "github.com/apache/arrow-go/v18/arrow/memory" + "github.com/apache/arrow-go/v18/parquet/pqarrow" + "github.com/apache/iceberg-go" + "github.com/apache/iceberg-go/catalog" + "github.com/apache/iceberg-go/catalog/rest" + iceio "github.com/apache/iceberg-go/io" + "github.com/apache/iceberg-go/table" +) + +const ( + runIntegrationTestsEnv = "RUN_INTEGRATION_TESTS" + integrationAccessDelegation = "vended-credentials" + integrationAccessDelegationHeader = "X-Iceberg-Access-Delegation" + integrationGCSToken = "scan-planning-integration-token" + integrationGCSTokenKey = "gcs.oauth2.token" +) + +func (s *RestIntegrationSuite) TestScanPlanningJavaSynchronousInteroperability() { + s.requireScanPlanningIntegration() + + transport := newScanPlanningCaptureTransport() + s.T().Cleanup(transport.CloseIdleConnections) + planningCatalog, err := rest.NewCatalog(s.ctx, "scan-planning-java-wire", "http://localhost:8181", + rest.WithCustomTransport(transport)) + s.Require().NoError(err) + s.T().Cleanup(func() { s.Require().NoError(planningCatalog.Close()) }) + s.requireJavaScanPlanningCapabilities(planningCatalog) + + ident := catalog.ToIdentifier(TestNamespaceIdent, "scan-planning-java-wire") + tbl, dataPath := s.createScanPlanningTable(ident) + + filter, err := json.Marshal(iceberg.EqualTo(iceberg.Reference("foo"), "hello")) + s.Require().NoError(err) + snapshotID := tbl.CurrentSnapshot().SnapshotID + caseSensitive := true + useSnapshotSchema := false + minRowsRequested := int64(1) + + response, err := planningCatalog.PlanTableScan(s.ctx, ident, rest.PlanTableScanRequest{ + AccessDelegation: stringPointer(integrationAccessDelegation), + SnapshotID: &snapshotID, + Select: []string{"foo", "bar"}, + Filter: filter, + MinRowsRequested: &minRowsRequested, + CaseSensitive: &caseSensitive, + UseSnapshotSchema: &useSnapshotSchema, + StatsFields: []string{"foo", "bar"}, + }) + s.Require().NoError(err) + s.Require().Equal(rest.PlanStatusCompleted, response.Status) + s.Require().NotNil(response.PlanID) + s.Require().NotEmpty(*response.PlanID) + planID := *response.PlanID + planCancelled := false + s.T().Cleanup(func() { + if planCancelled { + return + } + + _ = cancelPlanningWithTimeout(planningCatalog, ident, planID) + }) + s.Empty(response.PlanTasks) + s.Require().Len(response.FileScanTasks, 1) + s.Empty(response.DeleteFiles) + s.assertJavaPlanningCredentials(response.StorageCredentials) + + rawResponses := transport.PlanResponses() + s.Require().Len(rawResponses, 1) + requestHeaders := transport.PlanRequestHeaders() + s.Require().Len(requestHeaders, 1) + s.Equal(integrationAccessDelegation, requestHeaders[0].Get(integrationAccessDelegationHeader)) + raw := parseRawPlanningFixture(s.T(), string(rawResponses[0])) + s.Equal("completed", raw.Status) + s.Equal(*response.PlanID, raw.PlanID) + s.Empty(raw.PlanTasks) + s.Require().Len(raw.FileScanTasks, 1) + s.Empty(raw.DeleteFiles) + + task := raw.FileScanTasks[0] + s.Equal("data", task.DataFile.Content) + s.Equal(dataPath, task.DataFile.FilePath) + s.Require().Len(task.DataFile.Partition, 1) + s.Equal("17", string(task.DataFile.Partition[0]), + "Java partitions must remain typed JSON values, not binary-bound strings") + s.JSONEq(`{"type":"eq","term":"foo","value":"hello"}`, string(task.ResidualFilter)) + s.Empty(task.DeleteFileReferences) + + lowerBounds := valueMapByFieldID(s, task.DataFile.LowerBounds) + upperBounds := valueMapByFieldID(s, task.DataFile.UpperBounds) + s.ElementsMatch([]int{1, 2}, task.DataFile.LowerBounds.Keys) + s.ElementsMatch([]int{1, 2}, task.DataFile.UpperBounds.Keys) + s.Equal("68656C6C6F", lowerBounds[1], "Java string lower bounds must be uppercase hexadecimal") + s.Equal("68656C6C6F", upperBounds[1], "Java string upper bounds must be uppercase hexadecimal") + s.Equal("11000000", lowerBounds[2], "Java int lower bounds must use Iceberg little-endian binary") + s.Equal("11000000", upperBounds[2], "Java int upper bounds must use Iceberg little-endian binary") + + s.Require().Len(raw.StorageCredentials, 1) + s.Equal("gcp", raw.StorageCredentials[0].Prefix) Review Comment: Good point. I added a comment explaining that `"gcp"` is a known fixture quirk, why it does not resolve for real `gs://` paths, and that the assertion intentionally acts as a canary for a future fixture fix. -- 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]
