Skip to content

HIVE-27855: Create external tables for Hive and Tez protologging events - #5036

Merged
deniskuzZ merged 1 commit into
apache:masterfrom
KiranVelumuri:HIVE-27855
Feb 3, 2025
Merged

deniskuzZ merged 1 commit into
apache:masterfrom
KiranVelumuri:HIVE-27855

Conversation

@KiranVelumuri

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

HiveProtoLoggingHook in Hive and ProtoHistoryLoggingService in Tez logs details, such as query execution, query plan, runtime statistics, serialised as protobuf files. This PR exposes these protobuf log files as external tables. This would be done during the information schema upgrade to the next Hive version, which is 4.0.0-beta-2 in this case.

Why are the changes needed?

By exposing the protobuf log files as external tables, it can be useful for debugging, performance tuning and auditing purposes.

Does this PR introduce any user-facing change?

No

Is the change a dependency upgrade?

No

How was this patch tested?

This patch was tested by upgrading the information schema version and validating that the external tables have been created pointing to the correct specified locations.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

4 New issues
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

while ((line = reader.readLine()) != null) {
for (String s: replacements.keySet()) {
if (line.contains(s)) {
line = line.replace(s, replacements.get(s));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please elaborate why it needs to replace? I guess it has a business logic part, but from review perspective hard to understand.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The table locations for protologging events is populated from config variables in Hive and Tez. So, in the sql file, placeholders are used which are being replaced with the corresponding table locations from the config variables in Hive and Tez.

@okumin okumin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know this nice feature of Hive and Tez.
I'm pretty sure that it is a good idea to make the tables queryable from Hive.

}

Map<String, String> replacements = new HashMap<>();
replacements.put("_REPLACE_WITH_QUERY_DATA_LOCATION_", "hdfs:///" + hiveProtoBaseDir);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say we may avoid hardcoding the prefix, i.e., following the logic using HIVE_PROTO_EVENTS_BASE_PATH.
https://github.com/apache/hive/blob/rel/release-4.0.0-beta-1/ql/src/java/org/apache/tez/dag/history/logging/proto/DatePartitionedLogger.java#L67

As far as I tested, hive.hook.proto.base-directory can accept hdfs://path/to/proto or s3a://bucket/path/to/proto.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late update as I was away due to personal issues. I have updated the files by working on your suggestions.

replacements.put("_REPLACE_WITH_QUERY_DATA_LOCATION_", "hdfs:///" + hiveProtoBaseDir);
replacements.put("_REPLACE_WITH_APP_DATA_LOCATION_", "hdfs:///" + tezProtoBaseDir + "/app_data");
replacements.put("_REPLACE_WITH_DAG_DATA_LOCATION_", "hdfs:///" + tezProtoBaseDir + "/dag_data");
replacements.put("_REPLACE_WITH_DAG_META_LOCATION_", "hdfs:///" + tezProtoBaseDir + "/dag_meta");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I presume we may also avoid hardcoding it for TEZ_HISTORY_LOGGING_PROTO_BASE_DIR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late update as I was away due to personal issues. I have updated the files by working on your suggestions.

@sonarqubecloud

sonarqubecloud Bot commented Apr 8, 2024

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed

Issues
3 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2024

Copy link
Copy Markdown

@deniskuzZ

deniskuzZ commented Nov 1, 2024 •

Copy link
Copy Markdown
Member

@KiranVelumuri, @okumin sorry for the late jump-in, I overlooked that PR.
Changes look good to me, however, I have 1 concern regarding the location of the proto events - it's fixed in sys tables after the schema initialization. What if the end-user decides to change it? Should we move these configs to the hidden / restricted lists?

Also, could we add a qtest that generates the events and then output the select * from the new tables?

@KiranVelumuri

Copy link
Copy Markdown
Contributor Author

@KiranVelumuri, @okumin sorry for the late jump-in, I overlooked that PR. Changes look good to me, however, I have 1 concern regarding the location of the proto events - it's fixed in sys tables after the schema initialization. What if the end-user decides to change it? Should we move these configs to the hidden / restricted lists?

Also, could we add a qtest that generates the events and then output the select * from the new tables?

Thank you @deniskuzZ for the review.

The table location was based on the location of protologging events, which is in the sys db. This was done in order to standardise the table location for it to be consistent across versions. In my opinion, these tables' location in db is not meant to be changed by the end user, but instead query from it. The other option available was in INFORMATION_SCHEMA, but SYS db seems appropriate.

I will work on adding the related qtest you mentioned.

@deniskuzZ

Copy link
Copy Markdown
Member

@KiranVelumuri, @okumin sorry for the late jump-in, I overlooked that PR. Changes look good to me, however, I have 1 concern regarding the location of the proto events - it's fixed in sys tables after the schema initialization. What if the end-user decides to change it? Should we move these configs to the hidden / restricted lists?
Also, could we add a qtest that generates the events and then output the select * from the new tables?

Thank you @deniskuzZ for the review.

The table location was based on the location of protologging events, which is in the sys db. This was done in order to standardise the table location for it to be consistent across versions. In my opinion, these tables' location in db is not meant to be changed by the end user, but instead query from it. The other option available was in INFORMATION_SCHEMA, but SYS db seems appropriate.

I will work on adding the related qtest you mentioned.

@KiranVelumuri, HIVE_PROTO_EVENTS_BASE_PATH is a Hive conf. Can't it be changed after the schema initialization?

@KiranVelumuri

Copy link
Copy Markdown
Contributor Author

Yes, the protologging location for both Hive and Tez can be changed after schema initialization. In that case, the tables' location would have to be updated manually.

@deniskuzZ

Copy link
Copy Markdown
Member

Yes, the protologging location for both Hive and Tez can be changed after schema initialization. In that case, the tables' location would have to be updated manually.

in that case could we at least make the configs protected (i.e do not allow changes on the session level)?

@deniskuzZ

deniskuzZ commented Jan 9, 2025 •

Copy link
Copy Markdown
Member

hi @KiranVelumuri, please ping me when you'll be ready for the final review. thanks!

@KiranVelumuri

Copy link
Copy Markdown
Contributor Author

hi @KiranVelumuri, please ping me when you'll be ready for the final review. thanks!

hi @deniskuzZ, I will be done with changes by this weekend and ping you then.

@sonarqubecloud

sonarqubecloud Bot commented Jan 9, 2025

Copy link
Copy Markdown

@KiranVelumuri

Copy link
Copy Markdown
Contributor Author

@deniskuzZ sorry for the slight delay. I have made the requested changes and ready for review.
As for the qtest, the proto events are not written immediately and there would be a slight delay. So, I could not get the qtest to list the proto events.

@deniskuzZ deniskuzZ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM +1

@deniskuzZ

Copy link
Copy Markdown
Member

hi @KiranVelumuri, sorry I missed the update, I'll merge it today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants