Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Added support for WHERE ... IS NOT NULL for indexes" #1892

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public abstract class Index implements Serializable {
// restricted for gsql
abstract boolean nullFiltered();

// restricted for pg
@Nullable
abstract String filter();

Expand Down Expand Up @@ -178,11 +179,6 @@ private void prettyPrintGsql(Appendable appendable) throws IOException {
if (interleaveIn() != null) {
appendable.append(", INTERLEAVE IN ").append(quoteIdentifier(interleaveIn(), dialect()));
}

if (!nullFiltered() && filter() != null && !filter().isEmpty()) {
appendable.append(" WHERE ").append(filter());
}

if (options() != null) {
String optionsString = String.join(",", options());
if (!optionsString.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -399,23 +399,26 @@ private void listIndexes(Map<String, NavigableMap<String, Index.Builder>> indexe
(dialect == Dialect.GOOGLE_STANDARD_SQL)
? resultSet.getBoolean(5)
: resultSet.getString(5).equalsIgnoreCase("YES");
String filter = resultSet.isNull(6) ? null : resultSet.getString(6);
String filter =
(dialect == Dialect.GOOGLE_STANDARD_SQL || resultSet.isNull(6))
? null
: resultSet.getString(6);

// Note that 'type' is only queried from GoogleSQL and is not from Postgres and
// the number of columns will be different.
String type =
(dialect == Dialect.GOOGLE_STANDARD_SQL && !resultSet.isNull(7))
? resultSet.getString(7)
(dialect == Dialect.GOOGLE_STANDARD_SQL && !resultSet.isNull(6))
? resultSet.getString(6)
: null;

ImmutableList<String> searchPartitionBy =
(dialect == Dialect.GOOGLE_STANDARD_SQL && !resultSet.isNull(8))
? ImmutableList.<String>builder().addAll(resultSet.getStringList(8)).build()
(dialect == Dialect.GOOGLE_STANDARD_SQL && !resultSet.isNull(7))
? ImmutableList.<String>builder().addAll(resultSet.getStringList(7)).build()
: null;

ImmutableList<String> searchOrderBy =
(dialect == Dialect.GOOGLE_STANDARD_SQL && !resultSet.isNull(9))
? ImmutableList.<String>builder().addAll(resultSet.getStringList(9)).build()
(dialect == Dialect.GOOGLE_STANDARD_SQL && !resultSet.isNull(8))
? ImmutableList.<String>builder().addAll(resultSet.getStringList(8)).build()
: null;

Map<String, Index.Builder> tableIndexes =
Expand All @@ -442,7 +445,7 @@ Statement listIndexesSQL() {
case GOOGLE_STANDARD_SQL:
return Statement.of(
"SELECT t.table_schema, t.table_name, t.index_name, t.parent_table_name, t.is_unique,"
+ " t.is_null_filtered, t.filter, t.index_type, t.search_partition_by, t.search_order_by"
+ " t.is_null_filtered, t.index_type, t.search_partition_by, t.search_order_by"
+ " FROM information_schema.indexes AS t"
+ " WHERE t.table_schema NOT IN"
+ " ('INFORMATION_SCHEMA', 'SPANNER_SYS') AND"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ public void indexes() throws Exception {
+ " ) PRIMARY KEY (`id` ASC)",
" CREATE UNIQUE NULL_FILTERED INDEX `a_last_name_idx` ON "
+ " `Users`(`last_name` ASC) STORING (`first_name`)",
" CREATE INDEX `b_age_idx` ON `Users`(`age` DESC) WHERE age IS NOT NULL",
" CREATE INDEX `b_age_idx` ON `Users`(`age` DESC)",
" CREATE UNIQUE INDEX `c_first_name_idx` ON `Users`(`first_name` ASC)");

SPANNER_SERVER.createDatabase(dbId, statements);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void testListIndexesSQL() {
googleSQLInfoScanner.listIndexesSQL().getSql(),
equalToCompressingWhiteSpace(
"SELECT t.table_schema, t.table_name, t.index_name, t.parent_table_name, t.is_unique,"
+ " t.is_null_filtered, t.filter, t.index_type, t.search_partition_by, t.search_order_by"
+ " t.is_null_filtered, t.index_type, t.search_partition_by, t.search_order_by"
+ " FROM information_schema.indexes AS t"
+ " WHERE t.table_schema NOT IN"
+ " ('INFORMATION_SCHEMA', 'SPANNER_SYS') AND"
Expand Down
Loading