From e8e1e75e7c37e4fb2776b6e5fc97cbbc65516c1f Mon Sep 17 00:00:00 2001 From: Gian Merlino Date: Thu, 20 Sep 2018 10:14:47 -0700 Subject: [PATCH] Fix indexes introduced in #6348. The indexes introduced in #6348 were on the wrong table. The tests did not catch them due to retries on the create table steps (the first try created the table but not the bogus indexes; the second try noticed that the table already existed and did nothing). This patch doesn't fix the issue with the tests, since the best way to do that would be to do the table and index creation in a transaction; but, this is not supported by all of our supported database engines. --- .../apache/druid/metadata/SQLMetadataConnector.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java b/server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java index 688409e3cf9b..86c4fb44b7c2 100644 --- a/server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java +++ b/server/src/main/java/org/apache/druid/metadata/SQLMetadataConnector.java @@ -217,9 +217,13 @@ public void createPendingSegmentsTable(final String tableName) tableName, getPayloadType(), getQuoteString() ), StringUtils.format( - "CREATE INDEX idx_%1$s_datasource_used_end ON %1$s(dataSource, used, %2$send%2$s)", + "CREATE INDEX idx_%1$s_datasource_end ON %1$s(dataSource, %2$send%2$s)", tableName, getQuoteString() + ), + StringUtils.format( + "CREATE INDEX idx_%1$s_datasource_sequence ON %1$s(dataSource, sequence_name)", + tableName ) ) ); @@ -264,14 +268,11 @@ public void createSegmentTable(final String tableName) + ")", tableName, getPayloadType(), getQuoteString() ), + StringUtils.format("CREATE INDEX idx_%1$s_used ON %1$s(used)", tableName), StringUtils.format( - "CREATE INDEX idx_%1$s_datasource_end ON %1$s(dataSource, %2$send%2$s)", + "CREATE INDEX idx_%1$s_datasource_used_end ON %1$s(dataSource, used, %2$send%2$s)", tableName, getQuoteString() - ), - StringUtils.format( - "CREATE INDEX idx_%1$s_datasource_sequence ON %1$s(dataSource, sequence_name)", - tableName ) ) );