|
7 | 7 | import java.sql.SQLException;
|
8 | 8 | import java.sql.SQLWarning;
|
9 | 9 | import java.sql.Statement;
|
10 |
| -import java.util.Arrays; |
11 | 10 | import java.util.HashMap;
|
12 | 11 | import java.util.Map;
|
13 | 12 | import java.util.Properties;
|
|
17 | 16 | import org.junit.jupiter.api.Assertions;
|
18 | 17 | import org.junit.jupiter.api.BeforeAll;
|
19 | 18 | import org.junit.jupiter.api.BeforeEach;
|
20 |
| -import org.junit.jupiter.api.Disabled; |
21 | 19 | import org.junit.jupiter.api.DisplayName;
|
22 | 20 | import org.junit.jupiter.api.Test;
|
23 | 21 | import org.junit.jupiter.api.extension.RegisterExtension;
|
|
31 | 29 | import tech.ydb.jdbc.impl.helper.JdbcConnectionExtention;
|
32 | 30 | import tech.ydb.jdbc.impl.helper.SqlQueries;
|
33 | 31 | import tech.ydb.jdbc.impl.helper.TableAssert;
|
34 |
| -import tech.ydb.table.values.ListType; |
35 |
| -import tech.ydb.table.values.ListValue; |
36 |
| -import tech.ydb.table.values.PrimitiveType; |
37 |
| -import tech.ydb.table.values.PrimitiveValue; |
38 | 32 | import tech.ydb.test.junit5.YdbHelperExtension;
|
39 | 33 |
|
40 | 34 | public class YdbQueryConnectionImplTest {
|
@@ -667,39 +661,30 @@ public void testDDLInsideTransaction() throws SQLException {
|
667 | 661 | }
|
668 | 662 |
|
669 | 663 | @Test
|
670 |
| - @Disabled |
671 |
| - public void testWarningInIndexUsage() throws SQLException { |
| 664 | + public void testWarningsInQuery() throws SQLException { |
| 665 | + String createTempTable = QUERIES.withTableName( |
| 666 | + "CREATE TABLE #tableName_idx(id Int32, value Int32, PRIMARY KEY(id), INDEX idx_value GLOBAL ON(value))" |
| 667 | + ); |
| 668 | + String dropTempTable = QUERIES.withTableName("DROP TABLE #tableName_idx"); |
| 669 | + |
672 | 670 | try (Statement statement = jdbc.connection().createStatement()) {
|
673 |
| - statement.execute("" + |
674 |
| - "create table unit_0_indexed (" + |
675 |
| - "id Int32, value Int32, " + |
676 |
| - "primary key (id), " + |
677 |
| - "index idx_value global on (value))"); |
678 |
| - |
679 |
| - String query = "--!syntax_v1\n" + |
680 |
| - "declare $list as List<Int32>;\n" + |
681 |
| - "select * from unit_0_indexed view idx_value where value in $list;"; |
682 |
| - |
683 |
| - ListValue value = ListType.of(PrimitiveType.Int32).newValue( |
684 |
| - Arrays.asList(PrimitiveValue.newInt32(1), PrimitiveValue.newInt32(2))); |
685 |
| - try (PreparedStatement ps = jdbc.connection().prepareStatement(query)) { |
686 |
| - ps.setObject(1, value); |
687 |
| - |
688 |
| - ResultSet rs = ps.executeQuery(); |
689 |
| - Assertions.assertFalse(rs.next()); |
690 |
| - |
691 |
| - SQLWarning warnings = ps.getWarnings(); |
692 |
| - Assertions.assertNotNull(warnings); |
693 |
| - |
694 |
| - Assertions.assertEquals("#1030 Type annotation (S_WARNING)\n" |
695 |
| - + " 1:3 - 1:3: At function: RemovePrefixMembers, At function: RemoveSystemMembers, " |
696 |
| - + "At function: PersistableRepr, At function: SqlProject (S_WARNING)\n" |
697 |
| - + " 35:3 - 35:3: At function: Filter, At function: Coalesce (S_WARNING)\n" |
698 |
| - + " 51:3 - 51:3: At function: SqlIn (S_WARNING)\n" |
699 |
| - + " 51:3 - 51:3: #1108 IN may produce unexpected result when used with nullable arguments. " |
700 |
| - + "Consider adding 'PRAGMA AnsiInForEmptyOrNullableItemsCollections;' (S_WARNING)", |
701 |
| - warnings.getMessage()); |
702 |
| - Assertions.assertNull(warnings.getNextWarning()); |
| 671 | + statement.execute(createTempTable); |
| 672 | + |
| 673 | + try { |
| 674 | + String query = QUERIES.withTableName("SELECT * FROM #tableName_idx VIEW idx_value WHERE id = 1;"); |
| 675 | + try (ResultSet rs = statement.executeQuery(query)) { |
| 676 | + Assertions.assertFalse(rs.next()); |
| 677 | + |
| 678 | + SQLWarning warnings = statement.getWarnings(); |
| 679 | + Assertions.assertNotNull(warnings); |
| 680 | + |
| 681 | + Assertions.assertEquals("#1060 Execution (S_WARNING)\n " |
| 682 | + + "1:1 - 1:1: #2503 Given predicate is not suitable for used index: idx_value (S_WARNING)", |
| 683 | + warnings.getMessage()); |
| 684 | + Assertions.assertNull(warnings.getNextWarning()); |
| 685 | + } |
| 686 | + } finally { |
| 687 | + statement.execute(dropTempTable); |
703 | 688 | }
|
704 | 689 | }
|
705 | 690 | }
|
|
0 commit comments