Skip to content

Conversation

@shreeyasand
Copy link
Contributor

…th a syntax error in a HQL File

What changes were proposed in this pull request?

In the Beeline class:

  • A new method executeReader() has been introduced specifically to read hql files. It makes one string out of all the contents of the hql file separated by newline characters (the comments are excluded).

In the Commands class:

  • Since handling multiple lines of query for hql files has already been addressed in the executeReader method, we limit the handleMultipleLineCmd() method to every other scenario besides when reading an hql file.

In both Beeline.java and Commands.java:

  • Trimming of the string/sql has been removed while reading hql file contents. This is achieved whenever getOpts().getScriptFile() equals null (ie this is for every situation except when reading an hql file). This is done so that the whitespaces and empty lines are not ignored while counting the line numbers.

Why are the changes needed?

  • Hive Cli throws error line number correctly when reading HQL files, but Beeline does not. These changes are needed so that the error line number is thrown correctly and there is no discrepancy between the functioning of Beeline and Hive Cli.

Does this PR introduce any user-facing change?

  • Error message in Beeline was not representing the correct line number prior to the changes. Now Beeline prints the correct error line number.

How was this patch tested?

  • The testing was done locally on Beeline with multiple scenarios. The test were verified against the correctly functioning Hive Cli.
  • As an example, for the given hql file:

Screenshot 2023-03-05 at 11 12 29 PM

Error message prior to the changes:

Screenshot 2023-03-05 at 11 12 05 PM

Error message after the changes:

Screenshot 2023-03-05 at 11 10 57 PM

@sonarqubecloud
Copy link

sonarqubecloud bot commented Apr 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@shreeyasand shreeyasand closed this Apr 2, 2023
@shreeyasand shreeyasand deleted the HIVE-26900 branch April 2, 2023 17:47
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.

2 participants