HIVE-26441: Expand GenericJdbcDatabaseAccessor unit test coverage#6587
HIVE-26441: Expand GenericJdbcDatabaseAccessor unit test coverage#6587hemanthumashankar0511 wants to merge 8 commits into
Conversation
…essorByDatabaseType
c813e9c to
7e698ab
Compare
There was a problem hiding this comment.
Pull request overview
This PR expands test coverage for GenericJdbcDatabaseAccessor and DatabaseAccessorFactory in the jdbc-handler module, validating SQL generation behaviors across dialect-specific accessors and adding H2-backed smoke/integration coverage.
Changes:
- Added additional unit tests in
TestGenericJdbcDatabaseAccessorfor boundary queries, bounds retrieval, accessor quoting behavior, and record-writer persistence. - Introduced a new parameterized test suite (
TestDatabaseAccessorByDatabaseType) to validate limit/offset SQL generation, factory routing, Hive column-name stripping, and H2-compatible integration checks acrossDatabaseTypes. - Extended the SQL fixture (
test_script.sql) with a newtest_writertable used by record-writer tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| jdbc-handler/src/test/resources/test_script.sql | Adds test_writer table fixture for record-writer tests. |
| jdbc-handler/src/test/java/org/apache/hive/storage/jdbc/dao/TestGenericJdbcDatabaseAccessor.java | Expands unit/integration coverage for bounds, boundary SQL rewriting, quoting behavior, close behavior, and record writing. |
| jdbc-handler/src/test/java/org/apache/hive/storage/jdbc/dao/TestDatabaseAccessorByDatabaseType.java | New parameterized suite validating per-dialect SQL generation, factory routing, and H2-backed smoke tests across database types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| config.set(JdbcStorageConfig.DATABASE_TYPE.getPropertyName(), databaseType.name()); | ||
| config.set(JdbcStorageConfig.JDBC_DRIVER_CLASS.getPropertyName(), H2_DRIVER); | ||
| config.set(JdbcStorageConfig.JDBC_URL.getPropertyName(), | ||
| "jdbc:h2:mem:test_dbtype_integration_" + databaseType.name().toLowerCase() |
| /* | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); |
There was a problem hiding this comment.
Is this licence right? I think line-2 shouldn't be there, I think the content is also diffrent from othe rfiles
/*
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.
*/
There was a problem hiding this comment.
Hey I checked the jdbc-handler module and the licence differs from file to file..some files have 2 lines of space and some have one line space in the beginning
There was a problem hiding this comment.
hmm, that doesn't look very cheesy to me, we should ideally use one single pattern for ASF Header in the entire project, can you create a ticket to make it uniform across the project with what is mentioned over here:
https://www.apache.org/legal/src-headers.html
lets use the one mentioned in the doc for this new class
There was a problem hiding this comment.
yeah sure!!
| assertThat(rs.getString("name"), is(equalTo("written"))); | ||
| assertThat(rs.next(), is(false)); | ||
| } | ||
| statement.execute("SHUTDOWN"); |
There was a problem hiding this comment.
this should have been in the finally block, if any assertion fails, this would leak, shutdown won't be called
|
|
||
| assertThat(rs.next(), is(false)); | ||
| } | ||
| statement.execute("SHUTDOWN"); |
There was a problem hiding this comment.
same as above, it should be in finally or maybe the cleanup should be in After block
| private static Object[] row(Object... values) { | ||
| return values; |
There was a problem hiding this comment.
It was a tiny helper to build parameterized test rows for JUnit’s @parameters data provider, but it didn’t add any real logic. I'll remove it
480abe7 to
c7bba65
Compare
|
Thanks @ayushtkn for the review. I have addressed the review comments. PTAL whenever possible |
|



What changes were proposed in this pull request?
Adds JDBC DatabaseAccessor unit and integration tests in TestGenericJdbcDatabaseAccessor and TestDatabaseAccessorByDatabaseType, plus test_script.sql fixture data, covering dialect SQL generation, factory routing, boundary queries, Hive column stripping, and H2 smoke tests across database types.
Why are the changes needed?
To improve DatabaseAccessor test coverage for GenericJdbcDatabaseAccessor as part of HIVE-26441.
Does this PR introduce any user-facing change?
No
How was this patch tested?
mvn test -pl jdbc-handler -Dtest=TestGenericJdbcDatabaseAccessor,TestDatabaseAccessorByDatabaseType