Conversation
7e54757 to
769a954
Compare
|
There were already discussions happening under HIVE-29599 for server side planning? |
769a954 to
3ef3d65
Compare
This is different - this PR is about adding client-side support. |
tanishq-chugh
left a comment
There was a problem hiding this comment.
Hi @difin
Checked out the PR, great improvement 🚀
| */ | ||
| public static Table resolveTableForScanPlanning(Configuration conf, String tableIdentifier) { | ||
| if (shouldReloadForServerSideScanPlanning(conf)) { | ||
| Table table = Catalogs.loadTable(conf); |
There was a problem hiding this comment.
I believe this will create a new RestCatalog Object/HttpClient on every call, curious if this can cause any connection leak?
There was a problem hiding this comment.
Yes - Catalogs.loadTable creates a new REST catalog (and HTTP client) on each call, and we don’t close it on this path today. That’s the same pattern as other Catalogs.loadTable usages in the handler. Here it runs once per getSplits during split planning, not per input split. A reload only happens when shouldReloadForServerSideScanPlanning is true.
8ef09d9 to
0db254a
Compare
0db254a to
e4ef113
Compare
81f40f7 to
19151e4
Compare
| "If this is set to true the URI for auth will have the default location masked with DEFAULT_TABLE_LOCATION"), | ||
| HIVE_ICEBERG_ALLOW_DATAFILES_IN_TABLE_LOCATION_ONLY("hive.iceberg.allow.datafiles.in.table.location.only", false, | ||
| "If this is set to true, then all the data files being read should be withing the table location"), | ||
| HIVE_ICEBERG_REST_SERVER_SIDE_SCAN_PLANNING_ENABLED( |
There was a problem hiding this comment.
hive.iceberg.rest.scan-planning-mode {client, server} ?
There was a problem hiding this comment.
Renamed to hive.iceberg.rest.scan-planning-mode with client/server to mirror Iceberg REST catalog property naming; default client preserves prior opt-in behavior.
| setCommonJobConf(jobConf); | ||
| configureOutputTableJobConf(tableDesc, jobConf); | ||
| if (tableDesc != null && tableDesc.getProperties() != null) { | ||
| String catalogName = tableDesc.getProperties().getProperty(InputFormatConfig.CATALOG_NAME); |
There was a problem hiding this comment.
why not move helper into tableDesc? i.e. tableDesc.getCatalogName()?
There was a problem hiding this comment.
If we move this to If we move this ti tableDesc we will add Iceberg-specific code to hive-exec module.
How about tableDesc.getProperty(InputFormatConfig.CATALOG_NAME) instead?
| <!-- Upgrade roaringbit version whenever upgrading iceberg version --> | ||
| <iceberg.version>1.11.0</iceberg.version> | ||
| <!-- Jetty 12 for Iceberg REST catalog embedded-server tests (Hive uses jetty.version 9.x elsewhere). --> | ||
| <iceberg.rest.test.jetty.version>12.1.8</iceberg.rest.test.jetty.version> |
There was a problem hiding this comment.
Two Jetty stacks are required (9 for Hive, 12 for Iceberg REST embedded-server tests). Putting it in the root pom.xml was wrong since it's used only in one test module. Fixed.
| import static org.mockito.Mockito.verify; | ||
|
|
||
| /** Embedded REST server tests for the Hive executor reload path for server-side scan planning. */ | ||
| class TestHiveIcebergServerSideScanPlanningServerIT extends TestBaseWithRESTServer { |
There was a problem hiding this comment.
don't we use HiveRESTCatalogServerExtension restCatalogExtension = getHiveRESTCatalogServerExtension() do decorate with additional fixtures?
There was a problem hiding this comment.
We use HiveRESTCatalogServerExtension for tests that hit the HMS-backed REST catalog servlet. These scan-planning Server ITs intentionally use Iceberg’s TestBaseWithRESTServer, an in-process Iceberg REST harness, not the HMS servlet, so we can spy RESTCatalogAdapter, drive HiveTableUtil.resolveTableForScanPlanning / job-conf propagation, and keep the unshaded Iceberg + Jetty 12 classpath this module needs. Different server, different layer under test.
| import static org.mockito.Mockito.verify; | ||
|
|
||
| /** Embedded REST server tests for the Hive executor reload path for server-side scan planning. */ | ||
| class TestHiveIcebergServerSideScanPlanningServerIT extends TestBaseWithRESTServer { |
There was a problem hiding this comment.
is this a test framefork class or a test class?
There was a problem hiding this comment.
Test class. It’s a concrete JUnit tests. It uses the framework base TestBaseWithRESTServer (from iceberg-core tests); it isn’t a reusable fixture or extension itself.
| * | ||
| * @see <a href="https://iceberg.apache.org/docs/latest/catalog-properties/">REST catalog properties</a> | ||
| */ | ||
| public final class RestCatalogScanPlanning { |
There was a problem hiding this comment.
should it be in util package or have util in the name?
There was a problem hiding this comment.
Moved this class to iceberg-handler (because it's not rest client specific) and added Util to the class name.
| } | ||
|
|
||
| public static String catalogPropertyKey(String catalogName) { | ||
| return IcebergCatalogProperties.catalogPropertyConfigKey( |
There was a problem hiding this comment.
i see you use mix of static imports, catalogPropertyKey in setScanPlanningMode
| setScanPlanningMode(conf, catalogName, RESTCatalogProperties.ScanPlanningMode.fromString(mode)); | ||
| } | ||
|
|
||
| public static RESTCatalogProperties.ScanPlanningMode getScanPlanningMode( |
There was a problem hiding this comment.
naming seems to repeat class name
| /** | ||
| * Resolves the catalog name from per-table {@code iceberg.catalog} or the session default catalog. | ||
| */ | ||
| public static String resolveCatalogName(Configuration conf, String catalogNameFromTable) { |
There was a problem hiding this comment.
this seem to be a repeated functionality
| * Called from {@code configureJobConf} so split generation sees catalog URI/type/scan-planning-mode | ||
| * even when job properties were not copied yet. | ||
| */ | ||
| public static void propagateCatalogPropertiesToJob( |
There was a problem hiding this comment.
please check visibility modifiers in public methods if the actually need thos
| * {@link HiveTableUtil#resolveTableForScanPlanning}. Embedded REST server coverage is in | ||
| * {@code TestHiveIcebergServerSideScanPlanningServerIT} in {@code itests/hive-iceberg-rest-server}. | ||
| */ | ||
| class TestHiveIcebergServerSideScanPlanning { |
There was a problem hiding this comment.
does it test ServerSideScanPlanning? usesDeserializedTable
| String tableIdentifier = conf.get(InputFormatConfig.TABLE_IDENTIFIER); | ||
| Table table = HiveTableUtil.resolveTableForScanPlanning(conf, tableIdentifier); | ||
| String executorTableId = tableIdentifier != null ? tableIdentifier : table.name(); | ||
| if (tableIdentifier == null) { |
There was a problem hiding this comment.
you check tableIdentifier and set executorTableId, that is inconsistent.
| }); | ||
| String tableIdentifier = conf.get(InputFormatConfig.TABLE_IDENTIFIER); | ||
| Table table = HiveTableUtil.resolveTableForScanPlanning(conf, tableIdentifier); | ||
| String executorTableId = tableIdentifier != null ? tableIdentifier : table.name(); |
| * uses the deserialized snapshot so uncommitted metadata is visible. | ||
| */ | ||
| public static Table resolveTableForScanPlanning(Configuration conf, String tableIdentifier) { | ||
| if (shouldReloadForServerSideScanPlanning(conf)) { |
There was a problem hiding this comment.
what is this reload, isn't it expensive? what if we have multiple requests in same query/session?
|



What changes were proposed in this pull request?
Hive wires up Iceberg REST server-side scan planning: when
scan-planning-mode=server, split planning can go through the REST catalog (POST /plan) instead of only the serialized table snapshot on Tez/MR workers. Adds a smallRestCatalogScanPlanninghelper for config and copying catalog settings into job conf, and updates the Iceberg storage handler / input path to reload a live REST table on executors where appropriate. Tests cover configuration, job propagation, and embedded REST planning behavior.Why are the changes needed?
Iceberg REST catalogs can plan scans on the catalog service instead of on every client. That keeps planning close to authoritative metadata and catalog credentials, can reduce work on HiveServer2 and task containers, and lets the REST service apply catalog-side optimizations as Iceberg evolves.
Hive today mostly plans reads from a serialized table snapshot shipped in the job configuration, which fits local/Hadoop catalogs but does not use the REST server’s planning API. For deployments that already run a REST catalog with scan planning, operators expect
scan-planning-mode=serverto work for Hive queries on Tez/MR - not only for single-node Iceberg clients. This change closes that gap so Hive participates in the same server-side planning model as the rest of the Iceberg REST ecosystem.Does this PR introduce any user-facing change?
Yes. For REST Iceberg catalogs, operators can set
iceberg.catalog.<catalog>.scan-planning-mode=server(viahive-site.xmlor session SET) alongside existing REST catalog properties. When enabled, read jobs that use the Iceberg input format can use server-side scan planning instead of local planning from the serialized snapshot. Default behavior is unchanged when the property is unset or not server. Hive and non-REST catalogs are unaffected.How was this patch tested?
TestRestCatalogScanPlanning— Tests config keys, server-mode detection, job propagation gating and copying.TestRestCatalogScanPlanningServerIT— Uses embedded REST catalog; Verifies thatRESTTable/RESTTableScanandPlanTableScanRequest on planTasks()are used when file planning is on.TestHiveIcebergServerSideScanPlanning— Checks that Hive only reloads a table from the REST catalog for split planning when server mode is on and it is safe to do so - not when planning stays local or when the job must use uncommitted metadata from the same transaction.TestHiveIcebergServerSideScanPlanningServerIT— Tests that executor job conf with/without propagated catalog props and table reload over REST.