Skip to content

HIVE-26441: Expand GenericJdbcDatabaseAccessor unit test coverage#6587

Open
hemanthumashankar0511 wants to merge 8 commits into
apache:masterfrom
hemanthumashankar0511:database_accessor_unit_tests
Open

HIVE-26441: Expand GenericJdbcDatabaseAccessor unit test coverage#6587
hemanthumashankar0511 wants to merge 8 commits into
apache:masterfrom
hemanthumashankar0511:database_accessor_unit_tests

Conversation

@hemanthumashankar0511

@hemanthumashankar0511 hemanthumashankar0511 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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

@hemanthumashankar0511
hemanthumashankar0511 marked this pull request as draft July 10, 2026 10:39
@hemanthumashankar0511 hemanthumashankar0511 changed the title HIVE-26441: Expand GenericJdbcDatabaseAccessor unit test coverage [WIP]HIVE-26441: Expand GenericJdbcDatabaseAccessor unit test coverage Jul 10, 2026
@hemanthumashankar0511
hemanthumashankar0511 force-pushed the database_accessor_unit_tests branch from c813e9c to 7e698ab Compare July 13, 2026 06:35
@hemanthumashankar0511
hemanthumashankar0511 marked this pull request as ready for review July 13, 2026 07:51
@hemanthumashankar0511 hemanthumashankar0511 changed the title [WIP]HIVE-26441: Expand GenericJdbcDatabaseAccessor unit test coverage HIVE-26441: Expand GenericJdbcDatabaseAccessor unit test coverage Jul 13, 2026
@ayushtkn
ayushtkn requested review from Copilot and zabetak July 15, 2026 06:23

Copilot AI 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.

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 TestGenericJdbcDatabaseAccessor for 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 across DatabaseTypes.
  • Extended the SQL fixture (test_script.sql) with a new test_writer table 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()

@ayushtkn ayushtkn 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.

Thanx @hemanthumashankar0511 dropped some comments

Comment on lines +1 to +3
/*
*
* Licensed under the Apache License, Version 2.0 (the "License");

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.

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.
 */

@hemanthumashankar0511 hemanthumashankar0511 Jul 22, 2026

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.

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

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.

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

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.

yeah sure!!

assertThat(rs.getString("name"), is(equalTo("written")));
assertThat(rs.next(), is(false));
}
statement.execute("SHUTDOWN");

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.

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");

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.

same as above, it should be in finally or maybe the cleanup should be in After block

Comment on lines +428 to +429
private static Object[] row(Object... values) {
return values;

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.

what is this for?

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.

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

@hemanthumashankar0511

Copy link
Copy Markdown
Contributor Author

Thanks @ayushtkn for the review. I have addressed the review comments. PTAL whenever possible

@sonarqubecloud

Copy link
Copy Markdown

@ayushtkn ayushtkn 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

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.

4 participants