diff --git a/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/BooleanStreamReader.java b/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/BooleanStreamReader.java index feb5a190c..c972772c7 100644 --- a/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/BooleanStreamReader.java +++ b/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/BooleanStreamReader.java @@ -58,8 +58,9 @@ public class BooleanStreamReader @Override public void putBytes(int rowId, int count, byte[] src, int srcIndex) { + int srcIdx = srcIndex; for (int i = 0; i < count; i++) { - type.writeBoolean(builder, src[srcIndex++] == 1); + type.writeBoolean(builder, src[srcIdx++] == 1); } } diff --git a/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/DecimalSliceStreamReader.java b/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/DecimalSliceStreamReader.java index 8f5e8cb6f..fe07f724b 100644 --- a/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/DecimalSliceStreamReader.java +++ b/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/DecimalSliceStreamReader.java @@ -76,8 +76,9 @@ public class DecimalSliceStreamReader @Override public void putDecimals(int rowId, int count, BigDecimal value, int precision) { + int id = rowId; for (int i = 0; i < count; i++) { - putDecimal(rowId++, value, precision); + putDecimal(id++, value, precision); } } diff --git a/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/IntegerStreamReader.java b/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/IntegerStreamReader.java index b173ece33..ef34093f2 100644 --- a/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/IntegerStreamReader.java +++ b/hetu-carbondata/src/main/java/io/hetu/core/plugin/carbondata/readers/IntegerStreamReader.java @@ -58,8 +58,9 @@ public class IntegerStreamReader @Override public void putInts(int rowId, int count, int value) { + int id = rowId; for (int i = 0; i < count; i++) { - putInt(rowId++, value); + putInt(id++, value); } } diff --git a/hetu-carbondata/src/test/java/io/hetu/core/plugin/carbondata/server/HetuTestServer.java b/hetu-carbondata/src/test/java/io/hetu/core/plugin/carbondata/server/HetuTestServer.java index 457a46b32..4b968d978 100644 --- a/hetu-carbondata/src/test/java/io/hetu/core/plugin/carbondata/server/HetuTestServer.java +++ b/hetu-carbondata/src/test/java/io/hetu/core/plugin/carbondata/server/HetuTestServer.java @@ -91,11 +91,11 @@ public class HetuTestServer carbonProperties.putAll(properties); logger.info("------------ Starting Presto Server -------------"); - DistributedQueryRunner queryRunner = createQueryRunner(hetuProperties); + DistributedQueryRunner distributedQueryRunner = createQueryRunner(hetuProperties); Connection connection = createJdbcConnection(dbName); statement = (PrestoStatement) connection.createStatement(); - logger.info("STARTED SERVER AT :" + queryRunner.getCoordinator().getBaseUrl()); + logger.info("STARTED SERVER AT :" + distributedQueryRunner.getCoordinator().getBaseUrl()); } public void stopServer() throws SQLException @@ -192,7 +192,7 @@ public class HetuTestServer { try { queryRunner.installPlugin(new CarbondataPlugin()); - Map carbonProperties = ImmutableMap.builder() + Map carbonPropertiesMap = ImmutableMap.builder() .putAll(this.carbonProperties) .put("carbon.unsafe.working.memory.in.mb", "512") .build(); @@ -203,7 +203,7 @@ public class HetuTestServer .build(); // CreateCatalog will create a catalog for CarbonData in etc/catalog. - queryRunner.createCatalog(carbonDataCatalog, carbonDataConnector, carbonProperties); + queryRunner.createCatalog(carbonDataCatalog, carbonDataConnector, carbonPropertiesMap); queryRunner.createCatalog(carbonDataCatalogLocationDisabled, carbonDataConnector, carbonPropertiesLocationDisabled); } catch (RuntimeException e) { diff --git a/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/ClickHouseClient.java b/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/ClickHouseClient.java index c4cab968a..597c2f2bf 100644 --- a/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/ClickHouseClient.java +++ b/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/ClickHouseClient.java @@ -345,8 +345,9 @@ public class ClickHouseClient } @Override - public void renameColumn(JdbcIdentity identity, JdbcTableHandle handle, JdbcColumnHandle jdbcColumn, String newColumnName) + public void renameColumn(JdbcIdentity identity, JdbcTableHandle handle, JdbcColumnHandle jdbcColumn, String inputNewColumnName) { + String newColumnName = inputNewColumnName; try (Connection connection = connectionFactory.openConnection(identity)) { if (connection.getMetaData().storesUpperCaseIdentifiers()) { newColumnName = newColumnName.toUpperCase(ENGLISH); diff --git a/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/optimization/ClickHouseApplyRemoteFunctionPushDown.java b/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/optimization/ClickHouseApplyRemoteFunctionPushDown.java index 9e455fc1f..935f17131 100644 --- a/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/optimization/ClickHouseApplyRemoteFunctionPushDown.java +++ b/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/optimization/ClickHouseApplyRemoteFunctionPushDown.java @@ -41,6 +41,7 @@ public class ClickHouseApplyRemoteFunctionPushDown /** * rewrite the remote function to a executable function in the data source. */ + @Override public Optional rewriteRemoteFunction(CallExpression callExpression, BaseJdbcRowExpressionConverter rowExpressionConverter, JdbcConverterContext jdbcConverterContext) { if (!isConnectorSupportedRemoteFunction(callExpression)) { diff --git a/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/optimization/ClickHouseSqlStatementWriter.java b/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/optimization/ClickHouseSqlStatementWriter.java index 67b1b00a7..e3c886d16 100644 --- a/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/optimization/ClickHouseSqlStatementWriter.java +++ b/hetu-clickhouse/src/main/java/io/hetu/core/plugin/clickhouse/optimization/ClickHouseSqlStatementWriter.java @@ -37,8 +37,9 @@ public class ClickHouseSqlStatementWriter } @Override - public String aggregation(String functionName, List arguments, boolean isDistinct) + public String aggregation(String inputFunctionName, List arguments, boolean isDistinct) { + String functionName = inputFunctionName; if (functionName.toUpperCase(Locale.ENGLISH).equals("VARIANCE")) { functionName = "varPop"; } diff --git a/hetu-clickhouse/src/test/java/io/hetu/core/plugin/clickhouse/ClickHouseServerTest.java b/hetu-clickhouse/src/test/java/io/hetu/core/plugin/clickhouse/ClickHouseServerTest.java index 52f70f948..125a87302 100644 --- a/hetu-clickhouse/src/test/java/io/hetu/core/plugin/clickhouse/ClickHouseServerTest.java +++ b/hetu-clickhouse/src/test/java/io/hetu/core/plugin/clickhouse/ClickHouseServerTest.java @@ -205,7 +205,7 @@ public final class ClickHouseServerTest { String actualTable = tablePattern; - for (String table : tables) { //tableName + _ + UUID + for (String table : tables) { int lastIndex = table.lastIndexOf("_"); if (lastIndex == -1) { continue; diff --git a/hetu-common/src/test/java/io/hetu/core/common/filesystem/TestTempFolder.java b/hetu-common/src/test/java/io/hetu/core/common/filesystem/TestTempFolder.java index 4bf2fdd45..c7fa67e68 100644 --- a/hetu-common/src/test/java/io/hetu/core/common/filesystem/TestTempFolder.java +++ b/hetu-common/src/test/java/io/hetu/core/common/filesystem/TestTempFolder.java @@ -34,9 +34,9 @@ public class TestTempFolder root = folder.getRoot(); assertTrue(root.exists()); File newFile = folder.newFile("aNewFile"); - assertEquals(newFile.getAbsolutePath(), folder.getRoot().getAbsolutePath() + "/aNewFile"); + assertEquals(newFile.getCanonicalPath(), folder.getRoot().getCanonicalPath() + "/aNewFile"); File newFolder = folder.newFile("aNewFolder"); - assertEquals(newFolder.getAbsolutePath(), folder.getRoot().getAbsolutePath() + "/aNewFolder"); + assertEquals(newFolder.getCanonicalPath(), folder.getRoot().getCanonicalPath() + "/aNewFolder"); } assertFalse(root.exists()); } diff --git a/hetu-cube/src/main/java/io/hetu/core/spi/cube/CubeFilter.java b/hetu-cube/src/main/java/io/hetu/core/spi/cube/CubeFilter.java index 84351f703..901834730 100644 --- a/hetu-cube/src/main/java/io/hetu/core/spi/cube/CubeFilter.java +++ b/hetu-cube/src/main/java/io/hetu/core/spi/cube/CubeFilter.java @@ -36,8 +36,7 @@ public class CubeFilter public CubeFilter(String sourceTablePredicate) { - this.sourceTablePredicate = sourceTablePredicate; - this.cubePredicate = null; + this(sourceTablePredicate, null); } public String getSourceTablePredicate() diff --git a/hetu-cube/src/main/java/io/hetu/core/spi/cube/CubeStatement.java b/hetu-cube/src/main/java/io/hetu/core/spi/cube/CubeStatement.java index 9254d3e06..ddd75a1b5 100644 --- a/hetu-cube/src/main/java/io/hetu/core/spi/cube/CubeStatement.java +++ b/hetu-cube/src/main/java/io/hetu/core/spi/cube/CubeStatement.java @@ -140,13 +140,13 @@ public class CubeStatement return this; } - public Builder groupBy(String column) + public Builder groupByAddString(String column) { this.groupBy.add(column); return this; } - public Builder groupBy(String... columns) + public Builder groupByAddStringList(String... columns) { this.groupBy.addAll(Arrays.asList(columns)); return this; diff --git a/hetu-cube/src/test/java/io/hetu/core/spi/cube/TestCubeStatement.java b/hetu-cube/src/test/java/io/hetu/core/spi/cube/TestCubeStatement.java index 5eed74383..bd3f8bbb5 100644 --- a/hetu-cube/src/test/java/io/hetu/core/spi/cube/TestCubeStatement.java +++ b/hetu-cube/src/test/java/io/hetu/core/spi/cube/TestCubeStatement.java @@ -34,8 +34,8 @@ public class TestCubeStatement .select("name", "address", "nationkey") .aggregate(AggregationSignature.count()) .from("tpch.tiny.customer") - .groupBy("address") - .groupBy("name", "nationkey") + .groupByAddString("address") + .groupByAddStringList("name", "nationkey") .build(); assertEquals(statement.getFrom(), "tpch.tiny.customer", "incorrect from table"); diff --git a/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/DataCenterColumnHandle.java b/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/DataCenterColumnHandle.java index 412bea3db..4a87bd69f 100644 --- a/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/DataCenterColumnHandle.java +++ b/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/DataCenterColumnHandle.java @@ -55,6 +55,7 @@ public final class DataCenterColumnHandle } @JsonProperty + @Override public String getColumnName() { return columnName; diff --git a/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/DataCenterTableHandle.java b/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/DataCenterTableHandle.java index 713c9c7ae..884b5d27d 100644 --- a/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/DataCenterTableHandle.java +++ b/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/DataCenterTableHandle.java @@ -56,11 +56,11 @@ public final class DataCenterTableHandle */ public DataCenterTableHandle(String catalogName, String schemaName, String tableName, OptionalLong limit) { - this.catalogName = catalogName; - this.schemaName = requireNonNull(schemaName, "schemaName is null"); - this.tableName = requireNonNull(tableName, "tableName is null"); - this.limit = requireNonNull(limit, "limit is null"); - this.pushDownSql = ""; + this(catalogName, + requireNonNull(schemaName, "schemaName is null"), + requireNonNull(tableName, "tableName is null"), + requireNonNull(limit, "limit is null"), + ""); } /** @@ -125,6 +125,7 @@ public final class DataCenterTableHandle return new SchemaTableName(schemaName, tableName); } + @Override public String getSchemaPrefixedTableName() { return catalogName + SPLIT_DOT + schemaName + SPLIT_DOT + tableName; diff --git a/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/optimization/DataCenterPlanOptimizer.java b/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/optimization/DataCenterPlanOptimizer.java index 1a99aedb2..9b54eede1 100644 --- a/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/optimization/DataCenterPlanOptimizer.java +++ b/hetu-datacenter/src/main/java/io/hetu/core/plugin/datacenter/optimization/DataCenterPlanOptimizer.java @@ -179,7 +179,7 @@ public class DataCenterPlanOptimizer List pushable = new ArrayList<>(); List nonPushable = new ArrayList<>(); - for (RowExpression conjunct : logicalRowExpressions.extractConjuncts(node.getPredicate())) { + for (RowExpression conjunct : LogicalRowExpressions.extractConjuncts(node.getPredicate())) { try { conjunct.accept(queryGenerator.getConverter(), new JdbcConverterContext()); pushable.add(conjunct); diff --git a/hetu-datacenter/src/test/java/io/hetu/core/plugin/datacenter/TestCrossRegionDynamicFilter.java b/hetu-datacenter/src/test/java/io/hetu/core/plugin/datacenter/TestCrossRegionDynamicFilter.java index 598e83e9b..6fbbe0a73 100644 --- a/hetu-datacenter/src/test/java/io/hetu/core/plugin/datacenter/TestCrossRegionDynamicFilter.java +++ b/hetu-datacenter/src/test/java/io/hetu/core/plugin/datacenter/TestCrossRegionDynamicFilter.java @@ -1392,24 +1392,24 @@ public class TestCrossRegionDynamicFilter hetuServer.installPlugin(new StateStoreManagerPlugin()); hetuServer.loadStateSotre(); - DistributedQueryRunner queryRunner = null; + DistributedQueryRunner distributedQueryRunner = null; try { - queryRunner = DistributedQueryRunner.builder(testSessionBuilder().build()) + distributedQueryRunner = DistributedQueryRunner.builder(testSessionBuilder().build()) .setNodeCount(1) .build(); Map connectorProperties = new HashMap<>(properties); connectorProperties.putIfAbsent("connection-url", hetuServer.getBaseUrl().toString()); connectorProperties.putIfAbsent("connection-user", "root"); - queryRunner.installPlugin(new DataCenterPlugin()); - queryRunner.createDCCatalog("dc", "dc", connectorProperties); - queryRunner.installPlugin(new TpchPlugin()); - queryRunner.createCatalog("tpch", "tpch", properties); + distributedQueryRunner.installPlugin(new DataCenterPlugin()); + distributedQueryRunner.createDCCatalog("dc", "dc", connectorProperties); + distributedQueryRunner.installPlugin(new TpchPlugin()); + distributedQueryRunner.createCatalog("tpch", "tpch", properties); - return queryRunner; + return distributedQueryRunner; } catch (Throwable e) { - closeAllSuppress(e, queryRunner); + closeAllSuppress(e, distributedQueryRunner); throw e; } } diff --git a/hetu-datacenter/src/test/java/io/hetu/core/plugin/datacenter/TestDataCenterClient.java b/hetu-datacenter/src/test/java/io/hetu/core/plugin/datacenter/TestDataCenterClient.java index 18a2b824f..3585060b3 100644 --- a/hetu-datacenter/src/test/java/io/hetu/core/plugin/datacenter/TestDataCenterClient.java +++ b/hetu-datacenter/src/test/java/io/hetu/core/plugin/datacenter/TestDataCenterClient.java @@ -212,31 +212,31 @@ public class TestDataCenterClient @Test(expectedExceptions = RuntimeException.class) public void testPasswordWithoutSSL() { - DataCenterConfig config = new DataCenterConfig().setConnectionUrl(this.baseUri) + DataCenterConfig dataCenterConfig = new DataCenterConfig().setConnectionUrl(this.baseUri) .setConnectionUser("root") .setConnectionPassword("root") .setSsl(false); - DataCenterStatementClientFactory.newHttpClient(config); + DataCenterStatementClientFactory.newHttpClient(dataCenterConfig); } @Test(expectedExceptions = RuntimeException.class) public void testKerberosWithoutSSL() { - DataCenterConfig config = new DataCenterConfig().setConnectionUrl(this.baseUri) + DataCenterConfig dataCenterConfig = new DataCenterConfig().setConnectionUrl(this.baseUri) .setConnectionUser("root") .setKerberosRemoteServiceName("kerberos") .setSsl(false); - DataCenterStatementClientFactory.newHttpClient(config); + DataCenterStatementClientFactory.newHttpClient(dataCenterConfig); } @Test(expectedExceptions = RuntimeException.class) public void testAccessTokenWithoutSSL() { - DataCenterConfig config = new DataCenterConfig().setConnectionUrl(this.baseUri) + DataCenterConfig dataCenterConfig = new DataCenterConfig().setConnectionUrl(this.baseUri) .setConnectionUser("root") .setAccessToken("token") .setSsl(false); - DataCenterStatementClientFactory.newHttpClient(config); + DataCenterStatementClientFactory.newHttpClient(dataCenterConfig); } @Test(expectedExceptions = RuntimeException.class) diff --git a/hetu-filesystem-client/src/test/java/io/hetu/core/filesystem/utils/DockerizedHive.java b/hetu-filesystem-client/src/test/java/io/hetu/core/filesystem/utils/DockerizedHive.java index 1210f8184..0d6e94081 100644 --- a/hetu-filesystem-client/src/test/java/io/hetu/core/filesystem/utils/DockerizedHive.java +++ b/hetu-filesystem-client/src/test/java/io/hetu/core/filesystem/utils/DockerizedHive.java @@ -113,7 +113,7 @@ public class DockerizedHive "Please refer to READMD.md for set up guide. ##", testName)); System.out.println("Error message:"); - e.printStackTrace(); + System.out.println(e.getStackTrace()); return null; } } @@ -165,8 +165,8 @@ public class DockerizedHive { // if the service is not up, this will throw an error this.hostPortProvider = hostPortProvider; - FileSystem fs = getFs(); - fs.exists(new Path("/")); + FileSystem fileSystem = getFs(); + fileSystem.exists(new Path("/")); } private void checkHostnameResolution(String hostname) @@ -248,9 +248,9 @@ public class DockerizedHive DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder(); Document coreXml = documentBuilder.parse(coreIs); coreXml.getDocumentElement().normalize(); - NodeList properties = coreXml.getElementsByTagName("property"); - for (int i = 0; i < properties.getLength(); i++) { - Node node = properties.item(i); + NodeList localProperties = coreXml.getElementsByTagName("property"); + for (int i = 0; i < localProperties.getLength(); i++) { + Node node = localProperties.item(i); node.normalize(); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; diff --git a/hetu-function-namespace-managers/src/main/java/io/hetu/core/plugin/functionnamespace/AbstractSqlInvokedFunctionNamespaceManager.java b/hetu-function-namespace-managers/src/main/java/io/hetu/core/plugin/functionnamespace/AbstractSqlInvokedFunctionNamespaceManager.java index fcead54e6..b32bd545e 100644 --- a/hetu-function-namespace-managers/src/main/java/io/hetu/core/plugin/functionnamespace/AbstractSqlInvokedFunctionNamespaceManager.java +++ b/hetu-function-namespace-managers/src/main/java/io/hetu/core/plugin/functionnamespace/AbstractSqlInvokedFunctionNamespaceManager.java @@ -89,11 +89,11 @@ public abstract class AbstractSqlInvokedFunctionNamespaceManager @ParametersAreNonnullByDefault public Collection load(QualifiedObjectName functionName) { - Collection functions = fetchFunctionsDirect(functionName); - for (SqlInvokedFunction function : functions) { + Collection sqlInvokedFunctions = fetchFunctionsDirect(functionName); + for (SqlInvokedFunction function : sqlInvokedFunctions) { metadataByHandle.put(function.getRequiredFunctionHandle(), sqlInvokedFunctionToMetadata(function)); } - return functions; + return sqlInvokedFunctions; } }); @@ -302,9 +302,9 @@ public abstract class AbstractSqlInvokedFunctionNamespaceManager public synchronized List loadAndGetFunctionsTransactional(QualifiedObjectName functionName) { - Collection functions = this.functions.computeIfAbsent(functionName, AbstractSqlInvokedFunctionNamespaceManager.this::fetchFunctions); - functionHandles.putAll(functions.stream().collect(toImmutableMap(SqlInvokedFunction::getFunctionId, SqlInvokedFunction::getRequiredFunctionHandle))); - return new ArrayList<>(functions); + Collection sqlInvokedFunctions = this.functions.computeIfAbsent(functionName, AbstractSqlInvokedFunctionNamespaceManager.this::fetchFunctions); + functionHandles.putAll(sqlInvokedFunctions.stream().collect(toImmutableMap(SqlInvokedFunction::getFunctionId, SqlInvokedFunction::getRequiredFunctionHandle))); + return new ArrayList<>(sqlInvokedFunctions); } public synchronized FunctionHandle getFunctionHandle(SqlFunctionId functionId) diff --git a/hetu-greenplum/src/main/java/io/hetu/core/plugin/greenplum/GreenPlumSqlClient.java b/hetu-greenplum/src/main/java/io/hetu/core/plugin/greenplum/GreenPlumSqlClient.java index 7a977a9a5..0ddebd9e2 100644 --- a/hetu-greenplum/src/main/java/io/hetu/core/plugin/greenplum/GreenPlumSqlClient.java +++ b/hetu-greenplum/src/main/java/io/hetu/core/plugin/greenplum/GreenPlumSqlClient.java @@ -406,6 +406,8 @@ public class GreenPlumSqlClient case "timestamptz": // PostgreSQL's "timestamp with time zone" is reported as Types.TIMESTAMP rather than Types.TIMESTAMP_WITH_TIMEZONE return Optional.of(timestampWithTimeZoneColumnMapping()); + default: + break; } if (typeHandle.getJdbcType() == Types.VARCHAR && !jdbcTypeName.equals("varchar")) { // This can be e.g. an ENUM @@ -604,7 +606,7 @@ public class GreenPlumSqlClient byte[] in = slice.getBytes(); SliceOutput dynamicSliceOutput = new DynamicSliceOutput(in.length); SORTED_MAPPER.writeValue((OutputStream) dynamicSliceOutput, SORTED_MAPPER.readValue(parser, Object.class)); - // nextToken() returns null if the input is parsed correctly, + // the function nextToken() returns null if the input is parsed correctly, // but will throw an exception if there are trailing characters. parser.nextToken(); return dynamicSliceOutput.slice(); diff --git a/hetu-greenplum/src/test/java/io/hetu/core/plugin/greenplum/GreenPlumQueryRunner.java b/hetu-greenplum/src/test/java/io/hetu/core/plugin/greenplum/GreenPlumQueryRunner.java index b822a7a29..572b5154c 100644 --- a/hetu-greenplum/src/test/java/io/hetu/core/plugin/greenplum/GreenPlumQueryRunner.java +++ b/hetu-greenplum/src/test/java/io/hetu/core/plugin/greenplum/GreenPlumQueryRunner.java @@ -59,15 +59,15 @@ public final class GreenPlumQueryRunner queryRunner.installPlugin(new TpchPlugin()); queryRunner.createCatalog("tpch", "tpch"); - connectorProperties = new HashMap<>(ImmutableMap.copyOf(connectorProperties)); - connectorProperties.putIfAbsent("connection-url", server.getJdbcUrl()); - connectorProperties.putIfAbsent("allow-drop-table", "true"); - connectorProperties.putIfAbsent("jdbc.pushdown-enabled", "false"); + Map connectorPropertiesMap = new HashMap<>(ImmutableMap.copyOf(connectorProperties)); + connectorPropertiesMap.putIfAbsent("connection-url", server.getJdbcUrl()); + connectorPropertiesMap.putIfAbsent("allow-drop-table", "true"); + connectorPropertiesMap.putIfAbsent("jdbc.pushdown-enabled", "false"); createSchema(server.getJdbcUrl(), "tpch"); queryRunner.installPlugin(new GreenPlumSqlPlugin()); - queryRunner.createCatalog(GREENPLUM_CONNECTOR_NAME, GREENPLUM_CONNECTOR_NAME, connectorProperties); + queryRunner.createCatalog(GREENPLUM_CONNECTOR_NAME, GREENPLUM_CONNECTOR_NAME, connectorPropertiesMap); copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables); diff --git a/hetu-greenplum/src/test/java/io/hetu/core/plugin/greenplum/TestGreenPlumTypeMapping.java b/hetu-greenplum/src/test/java/io/hetu/core/plugin/greenplum/TestGreenPlumTypeMapping.java index bf20478dc..f957a23a4 100644 --- a/hetu-greenplum/src/test/java/io/hetu/core/plugin/greenplum/TestGreenPlumTypeMapping.java +++ b/hetu-greenplum/src/test/java/io/hetu/core/plugin/greenplum/TestGreenPlumTypeMapping.java @@ -398,10 +398,10 @@ public class TestGreenPlumTypeMapping private DataTypeTest arrayDateTest(Function, DataType>> arrayTypeFactory) { - ZoneId jvmZone = ZoneId.systemDefault(); - checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone"); + ZoneId localJvmZone = ZoneId.systemDefault(); + checkState(localJvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone"); LocalDate dateOfLocalTimeChangeForwardAtMidnightInJvmZone = LocalDate.of(1970, 1, 1); - checkIsGap(jvmZone, dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()); + checkIsGap(localJvmZone, dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()); ZoneId someZone = ZoneId.of("Europe/Vilnius"); LocalDate dateOfLocalTimeChangeForwardAtMidnightInSomeZone = LocalDate.of(1983, 4, 1); @@ -471,10 +471,10 @@ public class TestGreenPlumTypeMapping { // Note: there is identical test for MySQL - ZoneId jvmZone = ZoneId.systemDefault(); - checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone"); + ZoneId localJvmZone = ZoneId.systemDefault(); + checkState(localJvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone"); LocalDate dateOfLocalTimeChangeForwardAtMidnightInJvmZone = LocalDate.of(1970, 1, 1); - checkIsGap(jvmZone, dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()); + checkIsGap(localJvmZone, dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()); ZoneId someZone = ZoneId.of("Europe/Vilnius"); LocalDate dateOfLocalTimeChangeForwardAtMidnightInSomeZone = LocalDate.of(1983, 4, 1); @@ -492,7 +492,7 @@ public class TestGreenPlumTypeMapping .addRoundTrip(dateDataType(), dateOfLocalTimeChangeForwardAtMidnightInSomeZone) .addRoundTrip(dateDataType(), dateOfLocalTimeChangeBackwardAtMidnightInSomeZone); - for (String timeZoneId : ImmutableList.of(UTC_KEY.getId(), jvmZone.getId(), someZone.getId())) { + for (String timeZoneId : ImmutableList.of(UTC_KEY.getId(), localJvmZone.getId(), someZone.getId())) { Session session = Session.builder(getQueryRunner().getDefaultSession()) .setTimeZoneKey(TimeZoneKey.getTimeZoneKey(timeZoneId)) .build(); @@ -667,7 +667,8 @@ public class TestGreenPlumTypeMapping try { assertQuery( "SELECT column_name FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = 'test_unsupported_data_type'", - "VALUES 'key'"); // no 'unsupported_column' + "VALUES 'key'"); + // no unsupported_column } finally { jdbcSqlExecutor.execute("DROP TABLE tpch.test_unsupported_data_type"); diff --git a/hetu-hana/src/main/java/io/hetu/core/plugin/hana/optimization/HanaSqlStatementWriter.java b/hetu-hana/src/main/java/io/hetu/core/plugin/hana/optimization/HanaSqlStatementWriter.java index 8bf39def9..41005bca1 100644 --- a/hetu-hana/src/main/java/io/hetu/core/plugin/hana/optimization/HanaSqlStatementWriter.java +++ b/hetu-hana/src/main/java/io/hetu/core/plugin/hana/optimization/HanaSqlStatementWriter.java @@ -38,8 +38,9 @@ public class HanaSqlStatementWriter } @Override - public String aggregation(String functionName, List arguments, boolean isDistinct) + public String aggregation(String inputFunctionName, List arguments, boolean isDistinct) { + String functionName = inputFunctionName; if (functionName.toUpperCase(Locale.ENGLISH).equals("VARIANCE")) { functionName = "VAR"; } diff --git a/hetu-hazelcast/src/test/java/io/hetu/core/security/authentication/TestHazelcastAuthenticationDisabled.java b/hetu-hazelcast/src/test/java/io/hetu/core/security/authentication/TestHazelcastAuthenticationDisabled.java index c0ef648a2..7e037d8d0 100644 --- a/hetu-hazelcast/src/test/java/io/hetu/core/security/authentication/TestHazelcastAuthenticationDisabled.java +++ b/hetu-hazelcast/src/test/java/io/hetu/core/security/authentication/TestHazelcastAuthenticationDisabled.java @@ -68,12 +68,12 @@ public class TestHazelcastAuthenticationDisabled String value2 = "bbb"; Config config = new Config(); - HazelcastInstance hazelcastInstance1 = Hazelcast.newHazelcastInstance(config); - Map clusterMap1 = hazelcastInstance1.getMap("MyMap"); + HazelcastInstance newHazelcastInstance1 = Hazelcast.newHazelcastInstance(config); + Map clusterMap1 = newHazelcastInstance1.getMap("MyMap"); clusterMap1.put(1, value1); - HazelcastInstance hazelcastInstance2 = Hazelcast.newHazelcastInstance(config); - Map clusterMap2 = hazelcastInstance2.getMap("MyMap"); + HazelcastInstance newHazelcastInstance2 = Hazelcast.newHazelcastInstance(config); + Map clusterMap2 = newHazelcastInstance2.getMap("MyMap"); clusterMap2.put(2, value2); assertEquals(clusterMap1.get(2), value2); diff --git a/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/HBasePlugin.java b/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/HBasePlugin.java index b513f4dac..6bd03fac3 100644 --- a/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/HBasePlugin.java +++ b/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/HBasePlugin.java @@ -59,7 +59,6 @@ public class HBasePlugin @Override public Iterable getConnectorFactories() { - // connector.name return ImmutableList.of(new HBaseConnectorFactory(this.connectorId, module, getClassLoader())); } diff --git a/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseColumnHandle.java b/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseColumnHandle.java index 41b0ac99e..34031e40b 100644 --- a/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseColumnHandle.java +++ b/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseColumnHandle.java @@ -141,6 +141,7 @@ public class HBaseColumnHandle * * @return name */ + @Override public String getColumnName() { return name; diff --git a/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseConnection.java b/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseConnection.java index 2d1acef5d..0af1f7208 100644 --- a/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseConnection.java +++ b/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseConnection.java @@ -679,7 +679,7 @@ public class HBaseConnection List splitKeys = new ArrayList<>(); allRanges.forEach(range -> { for (char index = range.getStart(); index <= range.getEnd(); index += 1) { - splitKeys.add(String.valueOf(index).getBytes()); + splitKeys.add(String.valueOf(index).getBytes(UTF_8)); } }); diff --git a/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseConnector.java b/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseConnector.java index ab504c999..94a43ea20 100644 --- a/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseConnector.java +++ b/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/connector/HBaseConnector.java @@ -150,6 +150,6 @@ public class HBaseConnector @Override public List> getColumnProperties() { - return hBaseColumnProperties.getColumnProperties(); + return HBaseColumnProperties.getColumnProperties(); } } diff --git a/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/utils/serializers/StringRowSerializer.java b/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/utils/serializers/StringRowSerializer.java index a8e591913..b8e6f2f75 100644 --- a/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/utils/serializers/StringRowSerializer.java +++ b/hetu-hbase/src/main/java/io/hetu/core/plugin/hbase/utils/serializers/StringRowSerializer.java @@ -67,6 +67,7 @@ public class StringRowSerializer * * @param columnHandleList columnHandleList */ + @Override public void setColumnHandleList(List columnHandleList) { this.columnHandles = columnHandleList; @@ -108,6 +109,7 @@ public class StringRowSerializer * @param result Entry to deserialize * @param defaultValue defaultValue */ + @Override public void deserialize(Result result, String defaultValue) { if (!columnValues.containsKey(rowIdName)) { @@ -134,7 +136,7 @@ public class StringRowSerializer } catch (CharacterCodingException e) { LOG.error("bytes decode to string error, cause by %s", e.getMessage()); - e.printStackTrace(); + LOG.error("Error message: " + e.getStackTrace()); } } columnValues.put(familyQualifierColumnMap.get(family).get(qualifer), value); @@ -205,6 +207,7 @@ public class StringRowSerializer * @param Type * @return read from HBase, set into output */ + @Override public T getBytesObject(Type type, String columnName) { String fieldValue = getFieldValue(columnName); diff --git a/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/TestHBase.java b/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/TestHBase.java index dc2006b5d..b54828076 100644 --- a/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/TestHBase.java +++ b/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/TestHBase.java @@ -342,9 +342,9 @@ public class TestHBase { HBaseConnectorId h1 = new HBaseConnectorId(); HBaseConnectorId h2 = new HBaseConnectorId(); - h1.setConnectorId("hbase"); - h2.setConnectorId("hbase"); - assertEquals(true, h1.getConnectorId().equals(h2.getConnectorId())); + HBaseConnectorId.setConnectorId("hbase"); + HBaseConnectorId.setConnectorId("hbase"); + assertEquals(true, HBaseConnectorId.getConnectorId().equals(HBaseConnectorId.getConnectorId())); assertEquals(h1.hashCode(), h2.hashCode()); assertEquals(h1.toString(), h2.toString()); } diff --git a/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/client/TestHBaseConnection.java b/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/client/TestHBaseConnection.java index f111f9b96..3dec4a976 100644 --- a/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/client/TestHBaseConnection.java +++ b/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/client/TestHBaseConnection.java @@ -14,6 +14,7 @@ */ package io.hetu.core.plugin.hbase.client; +import io.airlift.log.Logger; import io.hetu.core.plugin.hbase.utils.TestSliceUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.HBaseConfiguration; @@ -70,6 +71,8 @@ public class TestHBaseConnection */ public static Table htable; + private static final Logger LOG = Logger.get(TestHBaseConnection.class); + static { Configuration conf = HBaseConfiguration.create(); conf.set("hbase.client.retries.number", "1"); @@ -108,7 +111,7 @@ public class TestHBaseConnection Mockito.when(admin.listNamespaceDescriptors()).thenReturn(listNamespaceDescriptors()); } catch (IOException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } htable = Mockito.mock(Table.class); @@ -120,7 +123,7 @@ public class TestHBaseConnection }).when(htable).put(Mockito.anyListOf(Put.class)); } catch (IOException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } } diff --git a/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/client/TestUtils.java b/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/client/TestUtils.java index ca53a64df..d3199a872 100644 --- a/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/client/TestUtils.java +++ b/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/client/TestUtils.java @@ -14,6 +14,7 @@ */ package io.hetu.core.plugin.hbase.client; +import io.airlift.log.Logger; import io.hetu.core.plugin.hbase.connector.HBaseColumnHandle; import io.hetu.core.plugin.hbase.connector.HBaseTableHandle; import io.hetu.core.plugin.hbase.metadata.HBaseTable; @@ -47,6 +48,8 @@ import static io.prestosql.spi.type.VarcharType.VARCHAR; */ public class TestUtils { + private static final Logger LOG = Logger.get(TestUtils.class); + private TestUtils() {} /** @@ -266,7 +269,7 @@ public class TestUtils } } catch (NullPointerException | JSONException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } return hTableMetaMemory; } @@ -289,7 +292,7 @@ public class TestUtils } } catch (ClassNotFoundException | IllegalArgumentException | IllegalAccessException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } Type typeNull = null; diff --git a/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/connector/TestHBaseClientConnection.java b/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/connector/TestHBaseClientConnection.java index 9c42f8fad..4b1bb8a76 100644 --- a/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/connector/TestHBaseClientConnection.java +++ b/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/connector/TestHBaseClientConnection.java @@ -14,6 +14,7 @@ */ package io.hetu.core.plugin.hbase.connector; +import io.airlift.log.Logger; import io.hetu.core.plugin.hbase.client.TestHBaseConnection; import io.hetu.core.plugin.hbase.conf.HBaseConfig; import io.hetu.core.plugin.hbase.metadata.HBaseMetastore; @@ -30,6 +31,8 @@ import java.io.IOException; public class TestHBaseClientConnection extends HBaseConnection { + private static final Logger LOG = Logger.get(TestHBaseClientConnection.class); + public TestHBaseClientConnection(HBaseConfig conf, HBaseMetastore metastore) { super(metastore, conf); @@ -47,7 +50,7 @@ public class TestHBaseClientConnection } } catch (IOException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } return conn; } diff --git a/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/connector/TestHBaseConnector.java b/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/connector/TestHBaseConnector.java index 5f2f3aafc..0f6af1c32 100644 --- a/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/connector/TestHBaseConnector.java +++ b/hetu-hbase/src/test/java/io/hetu/core/plugin/hbase/connector/TestHBaseConnector.java @@ -390,8 +390,8 @@ public class TestHBaseConnector public void testhBaseConnectorIdGetConnectorId() { HBaseConnectorId hBCnnId = new HBaseConnectorId(); - hBCnnId.setConnectorId("hbase"); - assertEquals("hbase", hBCnnId.getConnectorId()); + HBaseConnectorId.setConnectorId("hbase"); + assertEquals("hbase", HBaseConnectorId.getConnectorId()); } /** @@ -401,7 +401,7 @@ public class TestHBaseConnector public void testHBaseConnectorIdEquals() { HBaseConnectorId hBCnnId = new HBaseConnectorId(); - hBCnnId.setConnectorId("hbase"); + HBaseConnectorId.setConnectorId("hbase"); assertEquals(true, hBCnnId.equals(hBCnnId)); assertEquals(false, hBCnnId.equals(null)); } diff --git a/hetu-heuristic-index/src/main/java/io/hetu/core/heuristicindex/util/IndexServiceUtils.java b/hetu-heuristic-index/src/main/java/io/hetu/core/heuristicindex/util/IndexServiceUtils.java index ef7da4292..3d97c08fe 100644 --- a/hetu-heuristic-index/src/main/java/io/hetu/core/heuristicindex/util/IndexServiceUtils.java +++ b/hetu-heuristic-index/src/main/java/io/hetu/core/heuristicindex/util/IndexServiceUtils.java @@ -318,6 +318,8 @@ public class IndexServiceUtils return Serializer.BIG_DECIMAL; case "Date": return Serializer.DATE; + default: + break; } throw new RuntimeException("Index is not supported for type: (" + type + ")"); } diff --git a/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/bitmap/BitmapIndex.java b/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/bitmap/BitmapIndex.java index 63f19b9e4..d574754c0 100644 --- a/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/bitmap/BitmapIndex.java +++ b/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/bitmap/BitmapIndex.java @@ -230,7 +230,6 @@ public class BitmapIndex ConcurrentNavigableMap concurrentNavigableMap = null; if (highBoundless && !lowBoundless) { - // >= or > Object low = getActualValue(predicate.getType(), range.getLow().getValue()); Object high = getBtreeReadOptimized().lastKey(); boolean fromInclusive = range.getLow().getBound().equals(Marker.Bound.EXACTLY); diff --git a/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/bloom/BloomIndex.java b/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/bloom/BloomIndex.java index 05da3a590..1618c8daa 100644 --- a/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/bloom/BloomIndex.java +++ b/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/bloom/BloomIndex.java @@ -32,6 +32,7 @@ import java.io.OutputStream; import java.io.RandomAccessFile; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; import java.util.HashSet; import java.util.List; import java.util.Properties; @@ -90,7 +91,7 @@ public class BloomIndex HashSet columnIdxValue = new HashSet<>(values.get(0).getSecond()); for (Object value : columnIdxValue) { if (value != null) { - getFilterFromMemory().add(value.toString().getBytes()); + getFilterFromMemory().add(value.toString().getBytes(StandardCharsets.UTF_8)); } } return true; @@ -104,12 +105,12 @@ public class BloomIndex Domain predicate = (Domain) expression; if (predicate.isSingleValue()) { Object value = getActualValue(predicate.getType(), predicate.getSingleValue()); - return getFilter().test(value.toString().getBytes()); + return getFilter().test(value.toString().getBytes(StandardCharsets.UTF_8)); } } else if (expression instanceof CallExpression) { // test ComparisonExpression matching - return matchCallExpEqual(expression, object -> getFilter().test(object.toString().getBytes())); + return matchCallExpEqual(expression, object -> getFilter().test(object.toString().getBytes(StandardCharsets.UTF_8))); } throw new UnsupportedOperationException("Expression not supported by " + ID + " index."); } diff --git a/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/btree/BTreeIndex.java b/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/btree/BTreeIndex.java index 3c4933a39..a251a30fe 100644 --- a/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/btree/BTreeIndex.java +++ b/hetu-heuristic-index/src/main/java/io/hetu/core/plugin/heuristicindex/index/btree/BTreeIndex.java @@ -347,9 +347,9 @@ public class BTreeIndex IOUtils.copy(new SnappyInputStream(in), out); } setupDB(); - Properties properties = getProperties(); - if (properties.getProperty(PartitionIndexWriter.SYMBOL_TABLE_KEY_NAME) != null) { - this.symbolTable = SerializationUtils.deserializeMap(properties.getProperty(PartitionIndexWriter.SYMBOL_TABLE_KEY_NAME), s -> s, s -> s); + Properties localProperties = getProperties(); + if (localProperties.getProperty(PartitionIndexWriter.SYMBOL_TABLE_KEY_NAME) != null) { + this.symbolTable = SerializationUtils.deserializeMap(localProperties.getProperty(PartitionIndexWriter.SYMBOL_TABLE_KEY_NAME), s -> s, s -> s); } return this; } diff --git a/hetu-hive-functions/src/main/java/io/hetu/core/hive/dynamicfunctions/FunctionMetadata.java b/hetu-hive-functions/src/main/java/io/hetu/core/hive/dynamicfunctions/FunctionMetadata.java index f32432d32..7cedaba79 100644 --- a/hetu-hive-functions/src/main/java/io/hetu/core/hive/dynamicfunctions/FunctionMetadata.java +++ b/hetu-hive-functions/src/main/java/io/hetu/core/hive/dynamicfunctions/FunctionMetadata.java @@ -55,7 +55,7 @@ public class FunctionMetadata this.methodByName = new HashMap<>(); } - // Return [funcName, className] + // Return funcName and className public static String[] parseFunctionClassName(String metadata) { Matcher matcher = FUNCTION_METADATA_PATTERN.matcher(metadata); diff --git a/hetu-hive-functions/src/main/java/io/hetu/core/hive/dynamicfunctions/utils/HiveTypeTranslator.java b/hetu-hive-functions/src/main/java/io/hetu/core/hive/dynamicfunctions/utils/HiveTypeTranslator.java index cde34d981..7c133e6b9 100644 --- a/hetu-hive-functions/src/main/java/io/hetu/core/hive/dynamicfunctions/utils/HiveTypeTranslator.java +++ b/hetu-hive-functions/src/main/java/io/hetu/core/hive/dynamicfunctions/utils/HiveTypeTranslator.java @@ -35,6 +35,8 @@ import org.apache.hadoop.hive.serde2.typeinfo.PrimitiveTypeInfo; import org.apache.hadoop.hive.serde2.typeinfo.TypeInfo; import org.apache.hadoop.hive.serde2.typeinfo.VarcharTypeInfo; +import java.util.Locale; + import static io.prestosql.spi.StandardErrorCode.NOT_SUPPORTED; import static io.prestosql.spi.type.BigintType.BIGINT; import static io.prestosql.spi.type.BooleanType.BOOLEAN; @@ -186,7 +188,7 @@ public class HiveTypeTranslator return getVarcharTypeInfo(varcharType.getBoundedLength()); } throw new PrestoException(NOT_SUPPORTED, - String.format("Unsupported Hive type: %s. Supported VARCHAR types: VARCHAR(<=%d), VARCHAR.", + String.format(Locale.ROOT, "Unsupported Hive type: %s. Supported VARCHAR types: VARCHAR(<=%d), VARCHAR.", type, HiveVarchar.MAX_VARCHAR_LENGTH)); } if (type instanceof CharType) { diff --git a/hetu-hive-functions/src/test/java/io/hetu/core/hive/dynamicfunctions/examples/udf/EvaluateOverloadUDF.java b/hetu-hive-functions/src/test/java/io/hetu/core/hive/dynamicfunctions/examples/udf/EvaluateOverloadUDF.java index 935194baf..ae11a17aa 100644 --- a/hetu-hive-functions/src/test/java/io/hetu/core/hive/dynamicfunctions/examples/udf/EvaluateOverloadUDF.java +++ b/hetu-hive-functions/src/test/java/io/hetu/core/hive/dynamicfunctions/examples/udf/EvaluateOverloadUDF.java @@ -26,7 +26,7 @@ public class EvaluateOverloadUDF return x; } - public int evaluate(Integer x) + public int evaluateByInteger(Integer x) { return x; } diff --git a/hetu-kylin/src/main/java/io/hetu/core/plugin/kylin/KylinClient.java b/hetu-kylin/src/main/java/io/hetu/core/plugin/kylin/KylinClient.java index a0a84e3bc..6b6d7759f 100644 --- a/hetu-kylin/src/main/java/io/hetu/core/plugin/kylin/KylinClient.java +++ b/hetu-kylin/src/main/java/io/hetu/core/plugin/kylin/KylinClient.java @@ -193,6 +193,7 @@ public class KylinClient } catch (Exception e) { log.debug("There is a problem %s", e.getLocalizedMessage()); + log.debug("Error message: " + e.getStackTrace()); e.printStackTrace(); // No need to raise an error. // This method is used inside applySubQuery method to extract the column types from a sub-query. diff --git a/hetu-kylin/src/main/java/io/hetu/core/plugin/kylin/optimization/KylinKeywords.java b/hetu-kylin/src/main/java/io/hetu/core/plugin/kylin/optimization/KylinKeywords.java index dd562deb3..19254b789 100644 --- a/hetu-kylin/src/main/java/io/hetu/core/plugin/kylin/optimization/KylinKeywords.java +++ b/hetu-kylin/src/main/java/io/hetu/core/plugin/kylin/optimization/KylinKeywords.java @@ -38,7 +38,7 @@ public final class KylinKeywords public static String getAlias(String name) { if (getKeywords().contains(name.toLowerCase(Locale.ENGLISH))) { - return KylinConstants.KYLIN_IDENTIFIER_QUOTE + name.toUpperCase() + KylinConstants.KYLIN_IDENTIFIER_QUOTE; + return KylinConstants.KYLIN_IDENTIFIER_QUOTE + name.toUpperCase(Locale.ROOT) + KylinConstants.KYLIN_IDENTIFIER_QUOTE; } return name; } diff --git a/hetu-listener/src/main/java/io/hetu/core/eventlistener/HetuEventListenerFactory.java b/hetu-listener/src/main/java/io/hetu/core/eventlistener/HetuEventListenerFactory.java index e53f95d17..b026dd27b 100644 --- a/hetu-listener/src/main/java/io/hetu/core/eventlistener/HetuEventListenerFactory.java +++ b/hetu-listener/src/main/java/io/hetu/core/eventlistener/HetuEventListenerFactory.java @@ -24,6 +24,7 @@ import java.util.Map; public class HetuEventListenerFactory implements EventListenerFactory { + @Override public String getName() { return "hetu-listener"; @@ -35,6 +36,7 @@ public class HetuEventListenerFactory * @param properties properties * @return event listener */ + @Override public EventListener create(Map properties) { ConfigurationFactory configurationFactory = new ConfigurationFactory(properties); diff --git a/hetu-listener/src/main/java/io/hetu/core/eventlistener/HetuEventListenerPlugin.java b/hetu-listener/src/main/java/io/hetu/core/eventlistener/HetuEventListenerPlugin.java index 79b07598b..8cc9db7eb 100644 --- a/hetu-listener/src/main/java/io/hetu/core/eventlistener/HetuEventListenerPlugin.java +++ b/hetu-listener/src/main/java/io/hetu/core/eventlistener/HetuEventListenerPlugin.java @@ -21,6 +21,7 @@ import io.prestosql.spi.eventlistener.EventListenerFactory; public class HetuEventListenerPlugin implements Plugin { + @Override public Iterable getEventListenerFactories() { return ImmutableList.of(new HetuEventListenerFactory()); diff --git a/hetu-listener/src/main/java/io/hetu/core/eventlistener/listeners/AuditEventLogger.java b/hetu-listener/src/main/java/io/hetu/core/eventlistener/listeners/AuditEventLogger.java index a4f7bcd4a..380d43353 100644 --- a/hetu-listener/src/main/java/io/hetu/core/eventlistener/listeners/AuditEventLogger.java +++ b/hetu-listener/src/main/java/io/hetu/core/eventlistener/listeners/AuditEventLogger.java @@ -48,13 +48,13 @@ class AuditEventLogger private static java.util.logging.Logger createLogger(Path filePath, int limit, int count) { - java.util.logging.Logger logger = java.util.logging.Logger.getLogger(AuditEventLogger.class.getName()); + java.util.logging.Logger localLogger = java.util.logging.Logger.getLogger(AuditEventLogger.class.getName()); try { FileHandler fileHandler = new FileHandler(filePath.toAbsolutePath().toString(), limit, count, true); fileHandler.setFormatter(new SimpleFormatter()); - logger.addHandler(fileHandler); - logger.setUseParentHandlers(false); - return logger; + localLogger.addHandler(fileHandler); + localLogger.setUseParentHandlers(false); + return localLogger; } catch (IOException ex) { throw new PrestoException(ListenerErrorCode.LOCAL_FILE_FILESYSTEM_ERROR, diff --git a/hetu-listener/src/main/java/io/hetu/core/eventlistener/listeners/QueryEventLogger.java b/hetu-listener/src/main/java/io/hetu/core/eventlistener/listeners/QueryEventLogger.java index f57e92f74..125bf1aa4 100644 --- a/hetu-listener/src/main/java/io/hetu/core/eventlistener/listeners/QueryEventLogger.java +++ b/hetu-listener/src/main/java/io/hetu/core/eventlistener/listeners/QueryEventLogger.java @@ -48,13 +48,13 @@ class QueryEventLogger private static java.util.logging.Logger createLogger(Path filePath, int limit, int count) { - java.util.logging.Logger logger = java.util.logging.Logger.getLogger(QueryEventLogger.class.getName()); + java.util.logging.Logger localLogger = java.util.logging.Logger.getLogger(QueryEventLogger.class.getName()); try { FileHandler fileHandler = new FileHandler(filePath.toAbsolutePath().toString(), limit, count, true); fileHandler.setFormatter(new SimpleFormatter()); - logger.addHandler(fileHandler); - logger.setUseParentHandlers(false); - return logger; + localLogger.addHandler(fileHandler); + localLogger.setUseParentHandlers(false); + return localLogger; } catch (IOException ex) { throw new PrestoException(ListenerErrorCode.LOCAL_FILE_FILESYSTEM_ERROR, diff --git a/hetu-listener/src/test/java/io/hetu/core/eventlistener/listeners/TestAuditEventLogger.java b/hetu-listener/src/test/java/io/hetu/core/eventlistener/listeners/TestAuditEventLogger.java index 0c0bcc4f1..b7d29f3ef 100644 --- a/hetu-listener/src/test/java/io/hetu/core/eventlistener/listeners/TestAuditEventLogger.java +++ b/hetu-listener/src/test/java/io/hetu/core/eventlistener/listeners/TestAuditEventLogger.java @@ -16,6 +16,7 @@ package io.hetu.core.eventlistener.listeners; import com.google.common.collect.ImmutableMap; import com.google.inject.Key; +import io.airlift.log.Logger; import io.hetu.core.eventlistener.HetuEventListenerPlugin; import io.prestosql.Session; import io.prestosql.plugin.tpch.TpchPlugin; @@ -37,6 +38,7 @@ import static org.testng.Assert.assertTrue; @Test(singleThreaded = true) public class TestAuditEventLogger { + private static final Logger LOG = Logger.get(TestAuditEventLogger.class); private static final Path path = Paths.get("/tmp/hetu_audit_test.log"); private final DistributedQueryRunner queryRunner; @@ -91,7 +93,7 @@ public class TestAuditEventLogger } catch (RuntimeException ex) { // Query should fail but the listener should log the query - ex.printStackTrace(); + LOG.info("Error message: " + ex.getStackTrace()); assertLog("UserName", "UserIp", "queryId", "operation", "stmt={select * from tpch.tiny.fake_customer}", "status"); } } diff --git a/hetu-listener/src/test/java/io/hetu/core/eventlistener/listeners/TestQueryEventLogger.java b/hetu-listener/src/test/java/io/hetu/core/eventlistener/listeners/TestQueryEventLogger.java index 3f4fc1433..dba6ca948 100644 --- a/hetu-listener/src/test/java/io/hetu/core/eventlistener/listeners/TestQueryEventLogger.java +++ b/hetu-listener/src/test/java/io/hetu/core/eventlistener/listeners/TestQueryEventLogger.java @@ -16,6 +16,7 @@ package io.hetu.core.eventlistener.listeners; import com.google.common.collect.ImmutableMap; import com.google.inject.Key; +import io.airlift.log.Logger; import io.hetu.core.eventlistener.HetuEventListenerPlugin; import io.prestosql.Session; import io.prestosql.plugin.tpch.TpchPlugin; @@ -37,6 +38,7 @@ import static org.testng.Assert.assertTrue; @Test(singleThreaded = true) public class TestQueryEventLogger { + private static final Logger LOG = Logger.get(TestQueryEventLogger.class); private static final Path path = Paths.get("/tmp/hetu_listener.log"); private final DistributedQueryRunner queryRunner; @@ -86,7 +88,7 @@ public class TestQueryEventLogger } catch (RuntimeException ex) { // Query should fail but the listener should log the query - ex.printStackTrace(); + LOG.info("Error message: " + ex.getStackTrace()); assertLog("Query Created", "select * from tpch.tiny.fake_customer"); } } diff --git a/hetu-metastore/src/main/java/io/hetu/core/metastore/HetuLocalCache.java b/hetu-metastore/src/main/java/io/hetu/core/metastore/HetuLocalCache.java index 8898d33d4..b952a0e7d 100644 --- a/hetu-metastore/src/main/java/io/hetu/core/metastore/HetuLocalCache.java +++ b/hetu-metastore/src/main/java/io/hetu/core/metastore/HetuLocalCache.java @@ -16,6 +16,7 @@ package io.hetu.core.metastore; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; +import io.airlift.log.Logger; import io.prestosql.spi.metastore.HetuCache; import java.time.Duration; @@ -25,6 +26,7 @@ import java.util.concurrent.ExecutionException; public class HetuLocalCache implements HetuCache { + private static final Logger LOG = Logger.get(HetuLocalCache.class); private final Cache localCache; public HetuLocalCache(HetuMetastoreCacheConfig hetuMetastoreCacheConfig) @@ -53,7 +55,7 @@ public class HetuLocalCache return localCache.get(key, loader); } catch (ExecutionException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } return null; } diff --git a/hetu-metastore/src/main/java/io/hetu/core/metastore/jdbc/JdbcHetuMetastoreFactory.java b/hetu-metastore/src/main/java/io/hetu/core/metastore/jdbc/JdbcHetuMetastoreFactory.java index da67fd962..017f3490c 100644 --- a/hetu-metastore/src/main/java/io/hetu/core/metastore/jdbc/JdbcHetuMetastoreFactory.java +++ b/hetu-metastore/src/main/java/io/hetu/core/metastore/jdbc/JdbcHetuMetastoreFactory.java @@ -41,8 +41,9 @@ public class JdbcHetuMetastoreFactory @Override public HetuMetastore create(String name, Map config, HetuFileSystemClient client, - StateStore stateStore, String type) + StateStore stateStore, String inputType) { + String type = inputType; requireNonNull(config, "config is null"); Bootstrap app; try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { diff --git a/hetu-metastore/src/main/java/io/hetu/core/metastore/jdbc/JdbcMetastoreModule.java b/hetu-metastore/src/main/java/io/hetu/core/metastore/jdbc/JdbcMetastoreModule.java index fcabdd3ed..14dc663dc 100644 --- a/hetu-metastore/src/main/java/io/hetu/core/metastore/jdbc/JdbcMetastoreModule.java +++ b/hetu-metastore/src/main/java/io/hetu/core/metastore/jdbc/JdbcMetastoreModule.java @@ -45,7 +45,7 @@ public class JdbcMetastoreModule public JdbcMetastoreModule(String type) { - this.type = type; + this(null, type); } @Override diff --git a/hetu-metastore/src/test/java/io/hetu/core/metastore/TestHetuMetastoreCacheLocal.java b/hetu-metastore/src/test/java/io/hetu/core/metastore/TestHetuMetastoreCacheLocal.java index 7033de8e2..055781d33 100644 --- a/hetu-metastore/src/test/java/io/hetu/core/metastore/TestHetuMetastoreCacheLocal.java +++ b/hetu-metastore/src/test/java/io/hetu/core/metastore/TestHetuMetastoreCacheLocal.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.io.Resources; import com.google.inject.Injector; import io.airlift.bootstrap.Bootstrap; +import io.airlift.log.Logger; import io.hetu.core.filesystem.HetuLocalFileSystemClient; import io.hetu.core.filesystem.LocalConfig; import io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreModule; @@ -70,6 +71,7 @@ public class TestHetuMetastoreCacheLocal private DatabaseEntity defaultDatabase; private String path = Resources.getResource("").getPath() + File.separator + "metastoreCache"; + private static final Logger LOG = Logger.get(TestHetuMetastoreCacheLocal.class); private static final String TESTING_HOST = "127.0.0.1"; private static final String TESTING_PORT = "8090"; @@ -182,7 +184,7 @@ public class TestHetuMetastoreCacheLocal client.deleteRecursively(Paths.get(path)); } catch (IOException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } } diff --git a/hetu-metastore/src/test/java/io/hetu/core/metastore/TestHetuMetastoreGlobalCache.java b/hetu-metastore/src/test/java/io/hetu/core/metastore/TestHetuMetastoreGlobalCache.java index 3a939a8f0..952db2e2d 100644 --- a/hetu-metastore/src/test/java/io/hetu/core/metastore/TestHetuMetastoreGlobalCache.java +++ b/hetu-metastore/src/test/java/io/hetu/core/metastore/TestHetuMetastoreGlobalCache.java @@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.io.Resources; import com.google.inject.Injector; import io.airlift.bootstrap.Bootstrap; +import io.airlift.log.Logger; import io.hetu.core.filesystem.HetuLocalFileSystemClient; import io.hetu.core.filesystem.LocalConfig; import io.hetu.core.metastore.hetufilesystem.HetuFsMetastoreModule; @@ -84,6 +85,7 @@ public class TestHetuMetastoreGlobalCache private DatabaseEntity defaultDatabase; private String path = Resources.getResource("").getPath() + File.separator + "metastoreCache"; + private static final Logger LOG = Logger.get(TestHetuMetastoreGlobalCache.class); private static final String LOCALHOST = "127.0.0.1"; private static final String PORT1 = "7980"; private static final String PORT3 = "5991"; @@ -241,7 +243,7 @@ public class TestHetuMetastoreGlobalCache client.deleteRecursively(Paths.get(path)); } catch (IOException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } } diff --git a/hetu-metastore/src/test/java/io/hetu/core/metastore/hetufilesystem/TestHetuFsMetastore.java b/hetu-metastore/src/test/java/io/hetu/core/metastore/hetufilesystem/TestHetuFsMetastore.java index 870bb9afc..7c30040c6 100644 --- a/hetu-metastore/src/test/java/io/hetu/core/metastore/hetufilesystem/TestHetuFsMetastore.java +++ b/hetu-metastore/src/test/java/io/hetu/core/metastore/hetufilesystem/TestHetuFsMetastore.java @@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet; import com.google.common.io.Resources; import com.google.inject.Injector; import io.airlift.bootstrap.Bootstrap; +import io.airlift.log.Logger; import io.hetu.core.filesystem.HetuLocalFileSystemClient; import io.hetu.core.filesystem.LocalConfig; import io.prestosql.plugin.base.jmx.MBeanServerModule; @@ -67,6 +68,7 @@ import static org.testng.Assert.fail; public class TestHetuFsMetastore { + private static final Logger LOG = Logger.get(TestHetuFsMetastore.class); private HetuMetastore metastore; private HetuFileSystemClient client; private CatalogEntity defaultCatalog; @@ -144,7 +146,7 @@ public class TestHetuFsMetastore client.deleteRecursively(Paths.get(path)); } catch (IOException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } } diff --git a/hetu-mongodb/src/main/java/io/hetu/core/plugin/mongodb/MongoIndex.java b/hetu-mongodb/src/main/java/io/hetu/core/plugin/mongodb/MongoIndex.java index 164c05422..b7b44d6ec 100644 --- a/hetu-mongodb/src/main/java/io/hetu/core/plugin/mongodb/MongoIndex.java +++ b/hetu-mongodb/src/main/java/io/hetu/core/plugin/mongodb/MongoIndex.java @@ -36,13 +36,13 @@ public class MongoIndex for (Document index : indexes) { // TODO: v, ns, sparse fields Document key = (Document) index.get("key"); - String name = index.getString("name"); - boolean unique = index.getBoolean("unique", false); + String localName = index.getString("name"); + boolean localUnique = index.getBoolean("unique", false); if (key.containsKey("_fts")) { // Full Text Search continue; } - builder.add(new MongoIndex(name, parseKey(key), unique)); + builder.add(new MongoIndex(localName, parseKey(key), localUnique)); } return builder.build(); diff --git a/hetu-mongodb/src/main/java/io/hetu/core/plugin/mongodb/MongoMetadata.java b/hetu-mongodb/src/main/java/io/hetu/core/plugin/mongodb/MongoMetadata.java index b887f6997..a57bdd0e0 100644 --- a/hetu-mongodb/src/main/java/io/hetu/core/plugin/mongodb/MongoMetadata.java +++ b/hetu-mongodb/src/main/java/io/hetu/core/plugin/mongodb/MongoMetadata.java @@ -131,6 +131,7 @@ public class MongoMetadata } catch (NotFoundException e) { // table disappeared during listing operation + log.debug("table disappeared during listing operation"); } } return columns.build(); diff --git a/hetu-oracle/src/main/java/io/hetu/core/plugin/oracle/OracleClient.java b/hetu-oracle/src/main/java/io/hetu/core/plugin/oracle/OracleClient.java index ca9ec5398..9d09943cc 100644 --- a/hetu-oracle/src/main/java/io/hetu/core/plugin/oracle/OracleClient.java +++ b/hetu-oracle/src/main/java/io/hetu/core/plugin/oracle/OracleClient.java @@ -440,6 +440,7 @@ public class OracleClient * @param tableName tableName * @param newTable newTable */ + @Override protected void renameTable(JdbcIdentity identity, String catalogName, String schemaName, String tableName, SchemaTableName newTable) { @@ -924,8 +925,9 @@ public class OracleClient } @Override - public void renameColumn(JdbcIdentity identity, JdbcTableHandle handle, JdbcColumnHandle jdbcColumn, String newColumnName) + public void renameColumn(JdbcIdentity identity, JdbcTableHandle handle, JdbcColumnHandle jdbcColumn, String inputNewColumnName) { + String newColumnName = inputNewColumnName; try (Connection connection = connectionFactory.openConnection(identity)) { if (connection.getMetaData().storesUpperCaseIdentifiers()) { newColumnName = newColumnName.toUpperCase(ENGLISH); diff --git a/hetu-seed-store/src/main/java/io/hetu/core/seedstore/filebased/FileBasedSeedStore.java b/hetu-seed-store/src/main/java/io/hetu/core/seedstore/filebased/FileBasedSeedStore.java index e0b272433..8c72d052f 100644 --- a/hetu-seed-store/src/main/java/io/hetu/core/seedstore/filebased/FileBasedSeedStore.java +++ b/hetu-seed-store/src/main/java/io/hetu/core/seedstore/filebased/FileBasedSeedStore.java @@ -27,6 +27,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; @@ -54,7 +55,7 @@ public class FileBasedSeedStore private Map config; // seed dir private String name; - // seedFilePath = //seeds.txt + private Path seedDir; private Path seedFilePath; @@ -181,7 +182,7 @@ public class FileBasedSeedStore StringBuilder content = new StringBuilder(0); if (fs.exists(seedFilePath)) { - try (BufferedReader br = new BufferedReader(new InputStreamReader(fs.newInputStream(seedFilePath)))) { + try (BufferedReader br = new BufferedReader(new InputStreamReader(fs.newInputStream(seedFilePath), StandardCharsets.UTF_8))) { br.lines().forEach(content::append); } } @@ -204,7 +205,7 @@ public class FileBasedSeedStore throws IOException { try (OutputStream os = (overwrite) ? fs.newOutputStream(file) : fs.newOutputStream(file, CREATE_NEW)) { - os.write(content.getBytes()); + os.write(content.getBytes(StandardCharsets.UTF_8)); } } } diff --git a/hetu-seed-store/src/main/java/io/hetu/core/seedstore/filebased/FileBasedSeedStoreOnYarn.java b/hetu-seed-store/src/main/java/io/hetu/core/seedstore/filebased/FileBasedSeedStoreOnYarn.java index 09b3b6a2c..c5ea9cb2b 100644 --- a/hetu-seed-store/src/main/java/io/hetu/core/seedstore/filebased/FileBasedSeedStoreOnYarn.java +++ b/hetu-seed-store/src/main/java/io/hetu/core/seedstore/filebased/FileBasedSeedStoreOnYarn.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Collection; @@ -228,7 +229,7 @@ public class FileBasedSeedStoreOnYarn throws IOException { StringBuilder content = new StringBuilder(0); - try (BufferedReader br = new BufferedReader(new InputStreamReader(fs.newInputStream(file)))) { + try (BufferedReader br = new BufferedReader(new InputStreamReader(fs.newInputStream(file), StandardCharsets.UTF_8))) { br.lines().forEach(content::append); } return content.toString(); diff --git a/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/HiveAstBuilder.java b/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/HiveAstBuilder.java index a9ac56356..03c3b9105 100644 --- a/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/HiveAstBuilder.java +++ b/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/HiveAstBuilder.java @@ -2107,7 +2107,7 @@ public class HiveAstBuilder String fieldString = context.identifier().getText(); Extract.Field field; try { - field = Extract.Field.valueOf(fieldString.toUpperCase()); + field = Extract.Field.valueOf(fieldString.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException e) { throw parseError("Invalid EXTRACT field: " + fieldString, context); diff --git a/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/ImpalaAstBuilder.java b/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/ImpalaAstBuilder.java index cdb72d4e6..04a55a1d1 100644 --- a/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/ImpalaAstBuilder.java +++ b/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/ImpalaAstBuilder.java @@ -1921,7 +1921,7 @@ public class ImpalaAstBuilder { String fieldString = context.identifier().getText(); Extract.Field field; - field = Extract.Field.valueOf(fieldString.toUpperCase()); + field = Extract.Field.valueOf(fieldString.toUpperCase(Locale.ROOT)); return new Extract(getLocation(context), (Expression) visit(context.valueExpression()), field); } diff --git a/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/ParserDiffs.java b/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/ParserDiffs.java index 12aab1033..ac1a3e8b4 100644 --- a/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/ParserDiffs.java +++ b/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/migration/parser/ParserDiffs.java @@ -31,12 +31,7 @@ public class ParserDiffs public ParserDiffs(DiffType diffType, Optional source, Optional target, Optional message) { - this.diffType = diffType; - this.source = source; - this.sourcePosition = Optional.empty(); - this.target = target; - this.targetPosition = Optional.empty(); - this.message = message; + this(diffType, source, Optional.empty(), target, Optional.empty(), message); } public ParserDiffs(DiffType diffType, Optional source, Optional sourcePosition, Optional target, Optional targetPosition, Optional message) diff --git a/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/util/SqlResultHandleUtils.java b/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/util/SqlResultHandleUtils.java index e2b801634..caf32b825 100644 --- a/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/util/SqlResultHandleUtils.java +++ b/hetu-sql-migration-tool/src/main/java/io/hetu/core/sql/util/SqlResultHandleUtils.java @@ -47,7 +47,7 @@ public class SqlResultHandleUtils { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try (InputStream is = classLoader.getResourceAsStream(HTML_TMPLATE_FILE_NAME); - InputStreamReader isr = new InputStreamReader(is); + InputStreamReader isr = new InputStreamReader(is, UTF_8); BufferedReader reader = new BufferedReader(isr); OutputStream out = new FileOutputStream(outputFile + ".html"); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(out, UTF_8), BUFFER_SIZE)) { diff --git a/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/AggregateColumn.java b/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/AggregateColumn.java index c805a62fe..f895a420a 100644 --- a/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/AggregateColumn.java +++ b/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/AggregateColumn.java @@ -56,6 +56,7 @@ public class AggregateColumn } @JsonIgnore + @Override public String getUserFriendlyName() { return aggregateFunction + "(" + originalColumn + ")"; diff --git a/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/DimensionColumn.java b/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/DimensionColumn.java index 182470e8b..adfd1aa9e 100644 --- a/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/DimensionColumn.java +++ b/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/DimensionColumn.java @@ -44,6 +44,7 @@ public class DimensionColumn } @JsonIgnore + @Override public String getUserFriendlyName() { return "(" + originalColumn + ")"; diff --git a/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/StarTreeMetadata.java b/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/StarTreeMetadata.java index d96ec22fc..41132f903 100644 --- a/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/StarTreeMetadata.java +++ b/hetu-startree/src/main/java/io/hetu/core/cube/startree/tree/StarTreeMetadata.java @@ -115,6 +115,7 @@ public class StarTreeMetadata } @JsonProperty + @Override public CubeFilter getCubeFilter() { return cubeFilter; diff --git a/hetu-startree/src/test/java/io/hetu/core/cube/startree/tree/TestStarTreeMetadata.java b/hetu-startree/src/test/java/io/hetu/core/cube/startree/tree/TestStarTreeMetadata.java index 7a1984e91..6c5a807eb 100644 --- a/hetu-startree/src/test/java/io/hetu/core/cube/startree/tree/TestStarTreeMetadata.java +++ b/hetu-startree/src/test/java/io/hetu/core/cube/startree/tree/TestStarTreeMetadata.java @@ -154,7 +154,7 @@ public class TestStarTreeMetadata .select("returnflag", "linestatus") .aggregate(avg("quantity", false)) .from("tpch.tiny.lineitem") - .groupBy("returnflag", "linestatus") + .groupByAddStringList("returnflag", "linestatus") .build(); assertTrue(metadata.matches(statement), "failed to match a valid cube statement"); } @@ -178,7 +178,7 @@ public class TestStarTreeMetadata .select("returnflag", "linestatus") .aggregate(sum("quantity", false)) .from("tpch.tiny.lineitem2") - .groupBy("returnflag", "linestatus") + .groupByAddStringList("returnflag", "linestatus") .build(); assertTrue(metadataWithoutAvg.matches(statement), "failed to match a valid cube statement"); } @@ -190,7 +190,7 @@ public class TestStarTreeMetadata .select("returnflag", "linestatus") .aggregate(avg("unknown", false)) .from("tpch.tiny.lineitem") - .groupBy("returnflag", "linestatus") + .groupByAddStringList("returnflag", "linestatus") .build(); assertFalse(metadata.matches(statement), "failed to detect an invalid cube statement"); } @@ -225,7 +225,7 @@ public class TestStarTreeMetadata .aggregate(avg("quantity", false)) .aggregate(avg("discount", false)) .from("tpch.tiny.lineitem3") - .groupBy("returnflag", "linestatus") + .groupByAddStringList("returnflag", "linestatus") .build(); assertTrue(metadataWithAvg.matches(statement), "failed to match a valid cube statement"); } @@ -237,7 +237,7 @@ public class TestStarTreeMetadata .select("returnflag", "linestatus") .aggregate(avg("quantity", false)) .from("tpch.tiny.lineitem4") - .groupBy("returnflag", "linestatus") + .groupByAddStringList("returnflag", "linestatus") .build(); assertFalse(metadataWithAvgWithoutSumCount.matches(statement), "failed to match a valid cube statement"); } diff --git a/hetu-transport/src/main/java/io/hetu/core/transport/execution/buffer/PagesSerde.java b/hetu-transport/src/main/java/io/hetu/core/transport/execution/buffer/PagesSerde.java index fa800d7d6..49a380d15 100644 --- a/hetu-transport/src/main/java/io/hetu/core/transport/execution/buffer/PagesSerde.java +++ b/hetu-transport/src/main/java/io/hetu/core/transport/execution/buffer/PagesSerde.java @@ -60,6 +60,7 @@ public class PagesSerde this.spillCipher = requireNonNull(spillCipher, "spillCipher is null"); } + @Override public SerializedPage serialize(Page page) { if (page instanceof MarkerPage) { @@ -68,6 +69,7 @@ public class PagesSerde return serializeImpl(page); } + @Override public Page deserialize(SerializedPage page) { if (page.isMarkerPage()) { diff --git a/hetu-vdm/src/test/java/io/hetu/core/plugin/vdm/VdmQueryRunner.java b/hetu-vdm/src/test/java/io/hetu/core/plugin/vdm/VdmQueryRunner.java index 30ae5397c..da4ee0368 100644 --- a/hetu-vdm/src/test/java/io/hetu/core/plugin/vdm/VdmQueryRunner.java +++ b/hetu-vdm/src/test/java/io/hetu/core/plugin/vdm/VdmQueryRunner.java @@ -16,6 +16,7 @@ package io.hetu.core.plugin.vdm; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import io.airlift.log.Logger; import io.airlift.testing.mysql.TestingMySqlServer; import io.airlift.tpch.TpchTable; import io.hetu.core.metastore.HetuMetastorePlugin; @@ -39,6 +40,8 @@ public final class VdmQueryRunner { protected static final SqlParserOptions DEFAULT_SQL_PARSER_OPTIONS = new SqlParserOptions(); + private static final Logger LOG = Logger.get(VdmQueryRunner.class); + private VdmQueryRunner() { } @@ -81,7 +84,7 @@ public final class VdmQueryRunner file2.createNewFile(); } catch (IOException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } } try (BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(hetumetastoreConfig))) { diff --git a/presto-array/src/main/java/io/prestosql/array/IntBigArrays.java b/presto-array/src/main/java/io/prestosql/array/IntBigArrays.java index 2034a5939..509b2d535 100644 --- a/presto-array/src/main/java/io/prestosql/array/IntBigArrays.java +++ b/presto-array/src/main/java/io/prestosql/array/IntBigArrays.java @@ -161,8 +161,10 @@ public class IntBigArrays private static void vecSwap(final int[][] x, long a, long b, final long n) { - for (int i = 0; i < n; i++, a++, b++) { - swap(x, a, b); + long tmpA = a; + long tmpB = b; + for (int i = 0; i < n; i++, tmpA++, tmpB++) { + swap(x, tmpA, tmpB); } } diff --git a/presto-atop/src/main/java/io/prestosql/plugin/atop/AtopProcessFactory.java b/presto-atop/src/main/java/io/prestosql/plugin/atop/AtopProcessFactory.java index 40df9bea9..85e04f74a 100644 --- a/presto-atop/src/main/java/io/prestosql/plugin/atop/AtopProcessFactory.java +++ b/presto-atop/src/main/java/io/prestosql/plugin/atop/AtopProcessFactory.java @@ -26,6 +26,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -113,7 +114,7 @@ public class AtopProcessFactory private AtopProcess(Process process, Duration readTimeout, ExecutorService executor) { this.process = requireNonNull(process, "process is null"); - underlyingReader = new BufferedReader(new InputStreamReader(process.getInputStream())); + underlyingReader = new BufferedReader(new InputStreamReader(process.getInputStream(), StandardCharsets.UTF_8)); TimeLimiter limiter = SimpleTimeLimiter.create(executor); this.reader = limiter.newProxy(underlyingReader::readLine, LineReader.class, readTimeout.toMillis(), MILLISECONDS); try { diff --git a/presto-atop/src/main/java/io/prestosql/plugin/atop/AtopTable.java b/presto-atop/src/main/java/io/prestosql/plugin/atop/AtopTable.java index 8b4417a3c..c2c4ddb18 100644 --- a/presto-atop/src/main/java/io/prestosql/plugin/atop/AtopTable.java +++ b/presto-atop/src/main/java/io/prestosql/plugin/atop/AtopTable.java @@ -84,18 +84,18 @@ public enum AtopTable private static List baseColumnsAnd(AtopColumn... additionalColumns) { - ImmutableList.Builder columns = ImmutableList.builder(); - columns.add(HOST_IP); + ImmutableList.Builder atopColumnBuilder = ImmutableList.builder(); + atopColumnBuilder.add(HOST_IP); // 0th field is the label (i.e. table name) // 1st field is the name of the host, but isn't fully qualified - columns.add(START_TIME); + atopColumnBuilder.add(START_TIME); // 2nd field is the end timestamp as unix time - columns.add(END_TIME); + atopColumnBuilder.add(END_TIME); // 3rd field is the date, but we already have the epoch // 4th field is the time, but we already have the epoch // 5th field is the duration, and will be combined with 2 to compute start_time - columns.addAll(Arrays.asList(additionalColumns)); - return columns.build(); + atopColumnBuilder.addAll(Arrays.asList(additionalColumns)); + return atopColumnBuilder.build(); } public String getName() diff --git a/presto-atop/src/test/java/io/prestosql/plugin/atop/TestingAtopFactory.java b/presto-atop/src/test/java/io/prestosql/plugin/atop/TestingAtopFactory.java index 4df48d81b..a1ba51f3d 100644 --- a/presto-atop/src/test/java/io/prestosql/plugin/atop/TestingAtopFactory.java +++ b/presto-atop/src/test/java/io/prestosql/plugin/atop/TestingAtopFactory.java @@ -21,6 +21,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; @@ -51,7 +52,7 @@ public class TestingAtopFactory private TestingAtop(InputStream dataStream, ZonedDateTime date) { this.date = date; - this.reader = new BufferedReader(new InputStreamReader(dataStream)); + this.reader = new BufferedReader(new InputStreamReader(dataStream, StandardCharsets.UTF_8)); try { line = reader.readLine(); } diff --git a/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/JdbcPlanOptimizer.java b/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/JdbcPlanOptimizer.java index 38929ea12..8fd0c207a 100644 --- a/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/JdbcPlanOptimizer.java +++ b/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/JdbcPlanOptimizer.java @@ -175,7 +175,7 @@ public class JdbcPlanOptimizer List pushable = new ArrayList<>(); List nonPushable = new ArrayList<>(); - for (RowExpression conjunct : logicalRowExpressions.extractConjuncts(node.getPredicate())) { + for (RowExpression conjunct : LogicalRowExpressions.extractConjuncts(node.getPredicate())) { try { JdbcConverterContext jdbcConverterContext = new JdbcConverterContext(); conjunct.accept(queryGenerator.get().getConverter(), jdbcConverterContext); diff --git a/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/JdbcPlanOptimizerUtils.java b/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/JdbcPlanOptimizerUtils.java index fe5b5b49d..588327f12 100644 --- a/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/JdbcPlanOptimizerUtils.java +++ b/presto-base-jdbc/src/main/java/io/prestosql/plugin/jdbc/optimization/JdbcPlanOptimizerUtils.java @@ -93,8 +93,9 @@ public class JdbcPlanOptimizerUtils throw new PrestoException(JDBC_QUERY_GENERATOR_FAILURE, "unhandled type: " + type); } - public static String quote(String quote, String name) + public static String quote(String quote, String inputName) { + String name = inputName; name = name.replace(quote, quote + quote); return quote + name + quote; } diff --git a/presto-base-jdbc/src/main/java/io/prestosql/sql/builder/functioncall/functions/config/DefaultConnectorConfigFunctionRewriter.java b/presto-base-jdbc/src/main/java/io/prestosql/sql/builder/functioncall/functions/config/DefaultConnectorConfigFunctionRewriter.java index 3ca6c67db..f6d014171 100644 --- a/presto-base-jdbc/src/main/java/io/prestosql/sql/builder/functioncall/functions/config/DefaultConnectorConfigFunctionRewriter.java +++ b/presto-base-jdbc/src/main/java/io/prestosql/sql/builder/functioncall/functions/config/DefaultConnectorConfigFunctionRewriter.java @@ -77,6 +77,7 @@ public class DefaultConnectorConfigFunctionRewriter * @param functionCallArgsPackage the package of SqlQueryWriter's function call methods args * @return result string */ + @Override public String rewriteFunctionCall(FunctionCallArgsPackage functionCallArgsPackage) { String functionPropertyName = propertyNameBuilder.apply(functionCallArgsPackage); diff --git a/presto-base-jdbc/src/test/java/io/prestosql/sql/builder/functioncall/MockMetadata.java b/presto-base-jdbc/src/test/java/io/prestosql/sql/builder/functioncall/MockMetadata.java index c5f4ec4bb..843360eca 100644 --- a/presto-base-jdbc/src/test/java/io/prestosql/sql/builder/functioncall/MockMetadata.java +++ b/presto-base-jdbc/src/test/java/io/prestosql/sql/builder/functioncall/MockMetadata.java @@ -47,6 +47,7 @@ public class MockMetadata return ((BuiltInFunctionHandle) delegate.getFunctionAndTypeManager().resolveFunction(Optional.empty(), QualifiedObjectName.valueOf(name.toString()), parameterTypes)).getSignature(); } + @Override public FunctionAndTypeManager getFunctionAndTypeManager() { return delegate.getFunctionAndTypeManager(); diff --git a/presto-base-jdbc/src/test/java/io/prestosql/sql/builder/functioncall/TestingJdbcExternalFunctionHub.java b/presto-base-jdbc/src/test/java/io/prestosql/sql/builder/functioncall/TestingJdbcExternalFunctionHub.java index a574175dd..173f543ee 100644 --- a/presto-base-jdbc/src/test/java/io/prestosql/sql/builder/functioncall/TestingJdbcExternalFunctionHub.java +++ b/presto-base-jdbc/src/test/java/io/prestosql/sql/builder/functioncall/TestingJdbcExternalFunctionHub.java @@ -27,6 +27,7 @@ public class TestingJdbcExternalFunctionHub { private CatalogSchemaName catalogSchemaName = new CatalogSchemaName("jdbc", "foo"); + @Override public Set getExternalFunctions() { return ImmutableSet.builder().add(EXTERNAL_FUNCTION_INFO).build(); diff --git a/presto-benchmark-driver/pom.xml b/presto-benchmark-driver/pom.xml index e6d6757ce..0874460d4 100644 --- a/presto-benchmark-driver/pom.xml +++ b/presto-benchmark-driver/pom.xml @@ -47,6 +47,11 @@ units + + io.airlift + log + + io.airlift log-manager diff --git a/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkDriver.java b/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkDriver.java index 5229b1cbe..336a7faef 100644 --- a/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkDriver.java +++ b/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkDriver.java @@ -52,8 +52,8 @@ public class BenchmarkDriver public void run(Suite suite) { // select queries to run - List queries = suite.selectQueries(this.queries); - if (queries.isEmpty()) { + List benchmarkQueries = suite.selectQueries(this.queries); + if (benchmarkQueries.isEmpty()) { return; } @@ -78,7 +78,7 @@ public class BenchmarkDriver } for (BenchmarkSchema benchmarkSchema : benchmarkSchemas) { - for (BenchmarkQuery benchmarkQuery : queries) { + for (BenchmarkQuery benchmarkQuery : benchmarkQueries) { session = ClientSession.builder(session) .withCatalog(session.getCatalog()) .withSchema(benchmarkSchema.getName()) diff --git a/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkDriverOptions.java b/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkDriverOptions.java index d32a60257..d843c9538 100644 --- a/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkDriverOptions.java +++ b/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkDriverOptions.java @@ -110,12 +110,12 @@ public class BenchmarkDriverOptions private static URI parseServer(String server) { - server = server.toLowerCase(ENGLISH); - if (server.startsWith("http://") || server.startsWith("https://")) { - return URI.create(server); + String localServer = server.toLowerCase(ENGLISH); + if (localServer.startsWith("http://") || localServer.startsWith("https://")) { + return URI.create(localServer); } - HostAndPort host = HostAndPort.fromString(server); + HostAndPort host = HostAndPort.fromString(localServer); try { return new URI("http", null, host.getHost(), host.getPortOrDefault(80), null, null, null); } diff --git a/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkQueryRunner.java b/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkQueryRunner.java index cd5609539..93ae9d17b 100644 --- a/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkQueryRunner.java +++ b/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/BenchmarkQueryRunner.java @@ -22,6 +22,7 @@ import io.airlift.http.client.HttpClientConfig; import io.airlift.http.client.JsonResponseHandler; import io.airlift.http.client.Request; import io.airlift.http.client.jetty.JettyHttpClient; +import io.airlift.log.Logger; import io.airlift.units.Duration; import io.prestosql.client.ClientSession; import io.prestosql.client.QueryData; @@ -58,6 +59,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS; public class BenchmarkQueryRunner implements Closeable { + private static final Logger LOG = Logger.get(BenchmarkQueryRunner.class); private final int warm; private final int runs; private final boolean debug; @@ -236,13 +238,14 @@ public class BenchmarkQueryRunner } @SuppressWarnings("CallToPrintStackTrace") - public void handleFailure(Exception e) + public void handleFailure(Exception exception) { + Exception e = exception; if (debug) { if (e == null) { e = new RuntimeException("Unknown error"); } - e.printStackTrace(); + LOG.debug("Error message: " + e.getStackTrace()); } failures++; diff --git a/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/Suite.java b/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/Suite.java index 020603a5c..977db7584 100644 --- a/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/Suite.java +++ b/presto-benchmark-driver/src/main/java/io/prestosql/benchmark/driver/Suite.java @@ -147,11 +147,11 @@ public class Suite for (String q : query) { queryNameTemplates.add(Pattern.compile(sanitizeString(q))); } - ImmutableList.Builder schemaNameTemplates = ImmutableList.builder(); + ImmutableList.Builder schemaNameTemplatesBuilder = ImmutableList.builder(); for (String s : schema) { - schemaNameTemplates.add(new RegexTemplate(sanitizeString(s))); + schemaNameTemplatesBuilder.add(new RegexTemplate(sanitizeString(s))); } - return new Suite(name, session, schemaNameTemplates.build(), queryNameTemplates.build()); + return new Suite(name, session, schemaNameTemplatesBuilder.build(), queryNameTemplates.build()); } private String sanitizeString(String name) diff --git a/presto-benchmark/src/test/java/io/prestosql/benchmark/MemoryLocalQueryRunner.java b/presto-benchmark/src/test/java/io/prestosql/benchmark/MemoryLocalQueryRunner.java index 3a7b23cf2..fba8e1179 100644 --- a/presto-benchmark/src/test/java/io/prestosql/benchmark/MemoryLocalQueryRunner.java +++ b/presto-benchmark/src/test/java/io/prestosql/benchmark/MemoryLocalQueryRunner.java @@ -123,16 +123,16 @@ public class MemoryLocalQueryRunner private static LocalQueryRunner createMemoryLocalQueryRunner(Session session) { - LocalQueryRunner localQueryRunner = LocalQueryRunner.queryRunnerWithInitialTransaction(session); + LocalQueryRunner queryRunnerWithInitialTransaction = LocalQueryRunner.queryRunnerWithInitialTransaction(session); // add tpch - localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of()); - localQueryRunner.createCatalog( + queryRunnerWithInitialTransaction.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of()); + queryRunnerWithInitialTransaction.createCatalog( "memory", new MemoryConnectorFactory(), ImmutableMap.of("memory.max-data-per-node", "4GB")); - return localQueryRunner; + return queryRunnerWithInitialTransaction; } public void dropTable(String tableName) diff --git a/presto-cli/src/test/java/io/prestosql/cli/TestCsvPrinter.java b/presto-cli/src/test/java/io/prestosql/cli/TestCsvPrinter.java index 8ff306b83..6c0b412e6 100644 --- a/presto-cli/src/test/java/io/prestosql/cli/TestCsvPrinter.java +++ b/presto-cli/src/test/java/io/prestosql/cli/TestCsvPrinter.java @@ -18,6 +18,7 @@ import org.testng.annotations.Test; import java.io.IOException; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import java.util.List; import static io.prestosql.cli.CsvPrinter.CsvOutputFormat.NO_HEADER; @@ -172,7 +173,7 @@ public class TestCsvPrinter List fieldNames = ImmutableList.of("first", "last", "quantity"); OutputPrinter printer = new CsvPrinter(fieldNames, writer, NO_HEADER); - printRows(printer, TestAlignedTablePrinter.row("hello".getBytes(), null, 123)); + printRows(printer, TestAlignedTablePrinter.row("hello".getBytes(StandardCharsets.UTF_8), null, 123)); printer.finish(); String expected = "\"68 65 6c 6c 6f\",\"\",\"123\"\n"; diff --git a/presto-cli/src/test/java/io/prestosql/cli/TestJsonPrinter.java b/presto-cli/src/test/java/io/prestosql/cli/TestJsonPrinter.java index debc31336..341c287b6 100644 --- a/presto-cli/src/test/java/io/prestosql/cli/TestJsonPrinter.java +++ b/presto-cli/src/test/java/io/prestosql/cli/TestJsonPrinter.java @@ -18,6 +18,7 @@ import org.testng.annotations.Test; import java.io.IOException; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import java.util.List; import static io.prestosql.cli.TestAlignedTablePrinter.row; @@ -72,7 +73,7 @@ public class TestJsonPrinter List fieldNames = ImmutableList.of("first", "last", "quantity"); OutputPrinter printer = new JsonPrinter(fieldNames, writer); - printer.printRows(rows(row("hello".getBytes(), null, 123)), true); + printer.printRows(rows(row("hello".getBytes(StandardCharsets.UTF_8), null, 123)), true); printer.finish(); String expected = "{\"first\":\"68 65 6c 6c 6f\",\"last\":null,\"quantity\":123}\n"; diff --git a/presto-cli/src/test/java/io/prestosql/cli/TestQueryRunner.java b/presto-cli/src/test/java/io/prestosql/cli/TestQueryRunner.java index e272dd1e7..d9dd59edc 100644 --- a/presto-cli/src/test/java/io/prestosql/cli/TestQueryRunner.java +++ b/presto-cli/src/test/java/io/prestosql/cli/TestQueryRunner.java @@ -134,7 +134,6 @@ public class TestQueryRunner ImmutableList.of(new Column("_col0", BIGINT, new ClientTypeSignature(BIGINT))), ImmutableList.of(ImmutableList.of(123)), StatementStats.builder().setState("FINISHED").build(), - //new StatementStats("FINISHED", false, true, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, null), null, ImmutableList.of(), null, diff --git a/presto-cli/src/test/java/io/prestosql/cli/TestTsvPrinter.java b/presto-cli/src/test/java/io/prestosql/cli/TestTsvPrinter.java index ed06d5eea..dfcb3d3a7 100644 --- a/presto-cli/src/test/java/io/prestosql/cli/TestTsvPrinter.java +++ b/presto-cli/src/test/java/io/prestosql/cli/TestTsvPrinter.java @@ -18,6 +18,7 @@ import org.testng.annotations.Test; import java.io.IOException; import java.io.StringWriter; +import java.nio.charset.StandardCharsets; import java.util.List; import static io.prestosql.cli.TestAlignedTablePrinter.row; @@ -96,7 +97,7 @@ public class TestTsvPrinter List fieldNames = ImmutableList.of("first", "last", "quantity"); OutputPrinter printer = new TsvPrinter(fieldNames, writer, false); - printer.printRows(rows(row("hello".getBytes(), null, 123)), true); + printer.printRows(rows(row("hello".getBytes(StandardCharsets.UTF_8), null, 123)), true); printer.finish(); String expected = "68 65 6c 6c 6f\t\t123\n"; diff --git a/presto-client/src/main/java/io/prestosql/client/block/ExternalBlockEncodingSerde.java b/presto-client/src/main/java/io/prestosql/client/block/ExternalBlockEncodingSerde.java index 15bf13297..756cabd65 100644 --- a/presto-client/src/main/java/io/prestosql/client/block/ExternalBlockEncodingSerde.java +++ b/presto-client/src/main/java/io/prestosql/client/block/ExternalBlockEncodingSerde.java @@ -80,8 +80,9 @@ public final class ExternalBlockEncodingSerde } @Override - public void writeBlock(SliceOutput output, Block block) + public void writeBlock(SliceOutput output, Block inputBlock) { + Block block = inputBlock; while (true) { // get the encoding name String encodingName = block.getEncodingName(); diff --git a/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchClient.java b/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchClient.java index cf694a421..0a7100d8b 100644 --- a/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchClient.java +++ b/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchClient.java @@ -156,15 +156,15 @@ public class ElasticsearchClient { // discover other nodes in the cluster and add them to the client try { - Set nodes = fetchNodes(); + Set nodeSet = fetchNodes(); - HttpHost[] hosts = nodes.stream() + HttpHost[] hosts = nodeSet.stream() .map(Node::getAddress) .map(address -> HttpHost.create(format("%s://%s", tlsEnabled ? "https" : "http", address))) .toArray(HttpHost[]::new); client.getLowLevelClient().setHosts(hosts); - this.nodes.set(nodes); + this.nodes.set(nodeSet); } catch (Throwable e) { // Catch all exceptions here since throwing an exception from executor#scheduleWithFixedDelay method @@ -297,6 +297,7 @@ public class ElasticsearchClient } } catch (IOException | GeneralSecurityException ignored) { + // could be ignored } try (InputStream in = new FileInputStream(trustStorePath)) { @@ -359,7 +360,7 @@ public class ElasticsearchClient SearchShardsResponse shardsResponse = doRequest(format("%s/_search_shards", index), SEARCH_SHARDS_RESPONSE_CODEC::fromJson); ImmutableList.Builder shards = ImmutableList.builder(); - List nodes = ImmutableList.copyOf(nodeById.values()); + List nodeList = ImmutableList.copyOf(nodeById.values()); for (List shardGroup : shardsResponse.getShardGroups()) { Stream preferred = shardGroup.stream() @@ -374,7 +375,7 @@ public class ElasticsearchClient if (!candidate.isPresent()) { // pick an arbitrary shard with and assign to an arbitrary node chosen = preferred.findFirst().get(); - node = nodes.get(chosen.getShard() % nodes.size()); + node = nodeList.get(chosen.getShard() % nodeList.size()); } else { chosen = candidate.get(); diff --git a/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchMetadata.java b/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchMetadata.java index 0252066e8..d7eee3e8b 100644 --- a/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchMetadata.java +++ b/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchMetadata.java @@ -182,6 +182,8 @@ public class ElasticsearchMetadata return BOOLEAN; case "binary": return VARBINARY; + default: + break; } } else if (type instanceof DateTimeType) { diff --git a/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchPageSource.java b/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchPageSource.java index ebe351c9b..7222682c8 100644 --- a/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchPageSource.java +++ b/presto-elasticsearch/src/main/java/io/prestosql/elasticsearch/ElasticsearchPageSource.java @@ -309,7 +309,7 @@ public class ElasticsearchPageSource else if (type instanceof RowType) { RowType rowType = (RowType) type; - List decoders = rowType.getFields().stream() + List decoderList = rowType.getFields().stream() .map(field -> createDecoder(appendPath(path, field.getName().get()), field.getType())) .collect(toImmutableList()); @@ -318,7 +318,7 @@ public class ElasticsearchPageSource .map(Optional::get) .collect(toImmutableList()); - return new RowDecoder(path, fieldNames, decoders); + return new RowDecoder(path, fieldNames, decoderList); } if (type instanceof ArrayType) { Type elementType = ((ArrayType) type).getElementType(); diff --git a/presto-example-http/src/main/java/io/prestosql/plugin/example/ExampleColumnHandle.java b/presto-example-http/src/main/java/io/prestosql/plugin/example/ExampleColumnHandle.java index 2ef9866da..ae7ca03c7 100644 --- a/presto-example-http/src/main/java/io/prestosql/plugin/example/ExampleColumnHandle.java +++ b/presto-example-http/src/main/java/io/prestosql/plugin/example/ExampleColumnHandle.java @@ -41,6 +41,7 @@ public final class ExampleColumnHandle } @JsonProperty + @Override public String getColumnName() { return columnName; diff --git a/presto-example-http/src/main/java/io/prestosql/plugin/example/ExampleTable.java b/presto-example-http/src/main/java/io/prestosql/plugin/example/ExampleTable.java index 0e7a5a57b..cd78b6e9d 100644 --- a/presto-example-http/src/main/java/io/prestosql/plugin/example/ExampleTable.java +++ b/presto-example-http/src/main/java/io/prestosql/plugin/example/ExampleTable.java @@ -43,11 +43,11 @@ public class ExampleTable this.columns = ImmutableList.copyOf(requireNonNull(columns, "columns is null")); this.sources = ImmutableList.copyOf(requireNonNull(sources, "sources is null")); - ImmutableList.Builder columnsMetadata = ImmutableList.builder(); + ImmutableList.Builder columnMetadataBuilder = ImmutableList.builder(); for (ExampleColumn column : this.columns) { - columnsMetadata.add(new ColumnMetadata(column.getName(), column.getType())); + columnMetadataBuilder.add(new ColumnMetadata(column.getName(), column.getType())); } - this.columnsMetadata = columnsMetadata.build(); + this.columnsMetadata = columnMetadataBuilder.build(); } @JsonProperty diff --git a/presto-example-http/src/test/java/io/prestosql/plugin/example/TestExampleMetadata.java b/presto-example-http/src/test/java/io/prestosql/plugin/example/TestExampleMetadata.java index 881e1b801..5244849ad 100644 --- a/presto-example-http/src/test/java/io/prestosql/plugin/example/TestExampleMetadata.java +++ b/presto-example-http/src/test/java/io/prestosql/plugin/example/TestExampleMetadata.java @@ -17,6 +17,7 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.io.Resources; +import io.airlift.log.Logger; import io.prestosql.spi.PrestoException; import io.prestosql.spi.connector.ColumnMetadata; import io.prestosql.spi.connector.ConnectorTableMetadata; @@ -40,6 +41,7 @@ import static org.testng.Assert.fail; @Test(singleThreaded = true) public class TestExampleMetadata { + private static final Logger LOG = Logger.get(TestExampleMetadata.class); private static final ExampleTableHandle NUMBERS_TABLE_HANDLE = new ExampleTableHandle("example", "numbers"); private ExampleMetadata metadata; @@ -82,12 +84,14 @@ public class TestExampleMetadata fail("Expected getColumnHandle of unknown table to throw a TableNotFoundException"); } catch (TableNotFoundException expected) { + LOG.info("Error message: " + expected.getMessage()); } try { metadata.getColumnHandles(SESSION, new ExampleTableHandle("example", "unknown")); fail("Expected getColumnHandle of unknown table to throw a TableNotFoundException"); } catch (TableNotFoundException expected) { + LOG.info("Error message: " + expected.getMessage()); } } diff --git a/presto-geospatial/src/test/java/io/prestosql/plugin/geospatial/aggregation/TestGeometryUnionGeoAggregation.java b/presto-geospatial/src/test/java/io/prestosql/plugin/geospatial/aggregation/TestGeometryUnionGeoAggregation.java index 27b53f7f1..2b13a2506 100644 --- a/presto-geospatial/src/test/java/io/prestosql/plugin/geospatial/aggregation/TestGeometryUnionGeoAggregation.java +++ b/presto-geospatial/src/test/java/io/prestosql/plugin/geospatial/aggregation/TestGeometryUnionGeoAggregation.java @@ -360,7 +360,6 @@ public class TestGeometryUnionGeoAggregation { List wktList = Arrays.stream(wkts).map(wkt -> format("ST_GeometryFromText('%s')", wkt)).collect(toList()); String wktArray = format("ARRAY[%s]", COMMA_JOINER.join(wktList)); - // ST_Union(ARRAY[ST_GeometryFromText('...'), ...]) assertFunction(format("geometry_union(%s)", wktArray), GEOMETRY, expectedWkt); reverse(wktList); diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/coercions/HiveCoercer.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/coercions/HiveCoercer.java index 2321b4551..18af8ec2e 100644 --- a/presto-hive/src/main/java/io/prestosql/plugin/hive/coercions/HiveCoercer.java +++ b/presto-hive/src/main/java/io/prestosql/plugin/hive/coercions/HiveCoercer.java @@ -201,21 +201,21 @@ public interface HiveCoercer requireNonNull(toHiveType, "toHiveType is null"); List fromFieldTypes = extractStructFieldTypes(fromHiveType); List toFieldTypes = extractStructFieldTypes(toHiveType); - ImmutableList.Builder>> coercers = ImmutableList.builder(); + ImmutableList.Builder>> coercersBuilder = ImmutableList.builder(); this.nullBlocks = new Block[toFieldTypes.size()]; for (int i = 0; i < toFieldTypes.size(); i++) { if (i >= fromFieldTypes.size()) { nullBlocks[i] = toFieldTypes.get(i).getType(typeManager).createBlockBuilder(null, 1).appendNull().build(); - coercers.add(Optional.empty()); + coercersBuilder.add(Optional.empty()); } else if (!fromFieldTypes.get(i).equals(toFieldTypes.get(i))) { - coercers.add(Optional.of(createCoercer(typeManager, fromFieldTypes.get(i), toFieldTypes.get(i)))); + coercersBuilder.add(Optional.of(createCoercer(typeManager, fromFieldTypes.get(i), toFieldTypes.get(i)))); } else { - coercers.add(Optional.empty()); + coercersBuilder.add(Optional.empty()); } } - this.coercers = coercers.build(); + this.coercers = coercersBuilder.build(); } @Override diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/file/FileHiveMetastore.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/file/FileHiveMetastore.java index 736ccd9a0..174d0e046 100644 --- a/presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/file/FileHiveMetastore.java +++ b/presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/file/FileHiveMetastore.java @@ -139,8 +139,8 @@ public class FileHiveMetastore { HiveConfig hiveConfig = new HiveConfig(); HdfsConfiguration hdfsConfiguration = new HiveHdfsConfiguration(new HdfsConfigurationInitializer(hiveConfig), ImmutableSet.of()); - HdfsEnvironment hdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hiveConfig, new NoHdfsAuthentication()); - return new FileHiveMetastore(hdfsEnvironment, catalogDirectory.toURI().toString(), "test"); + HdfsEnvironment localHdfsEnvironment = new HdfsEnvironment(hdfsConfiguration, hiveConfig, new NoHdfsAuthentication()); + return new FileHiveMetastore(localHdfsEnvironment, catalogDirectory.toURI().toString(), "test"); } @Inject @@ -647,6 +647,7 @@ public class FileHiveMetastore metadataFileSystem.delete(createdFile, false); } catch (IOException ignored) { + // could be ignored } } throw e; diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/glue/GlueHiveMetastore.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/glue/GlueHiveMetastore.java index 08d446970..c6b1b864a 100644 --- a/presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/glue/GlueHiveMetastore.java +++ b/presto-hive/src/main/java/io/prestosql/plugin/hive/metastore/glue/GlueHiveMetastore.java @@ -399,8 +399,9 @@ public class GlueHiveMetastore } @Override - public void createDatabase(HiveIdentity identity, Database database) + public void createDatabase(HiveIdentity identity, Database inputDatabase) { + Database database = inputDatabase; if (!database.getLocation().isPresent() && defaultDir.isPresent()) { String databaseLocation = new Path(defaultDir.get(), database.getDatabaseName()).toString(); database = Database.builder(database) diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/parquet/ParquetRecordWriter.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/parquet/ParquetRecordWriter.java index 2ce996dc5..daef8f7e4 100644 --- a/presto-hive/src/main/java/io/prestosql/plugin/hive/parquet/ParquetRecordWriter.java +++ b/presto-hive/src/main/java/io/prestosql/plugin/hive/parquet/ParquetRecordWriter.java @@ -62,14 +62,14 @@ public final class ParquetRecordWriter conf.setLong(ParquetOutputFormat.BLOCK_SIZE, getParquetWriterBlockSize(session).toBytes()); conf.setLong(ParquetOutputFormat.PAGE_SIZE, getParquetWriterPageSize(session).toBytes()); - RecordWriter recordWriter = new MapredParquetOutputFormat() + RecordWriter hiveRecordWriter = new MapredParquetOutputFormat() .getHiveRecordWriter(conf, target, Text.class, false, properties, Reporter.NULL); - Object realWriter = REAL_WRITER_FIELD.get(recordWriter); + Object realWriter = REAL_WRITER_FIELD.get(hiveRecordWriter); Object internalWriter = INTERNAL_WRITER_FIELD.get(realWriter); - ParquetFileWriter fileWriter = (ParquetFileWriter) FILE_WRITER_FIELD.get(internalWriter); + ParquetFileWriter parquetFileWriter = (ParquetFileWriter) FILE_WRITER_FIELD.get(internalWriter); - return new ParquetRecordWriter(recordWriter, fileWriter); + return new ParquetRecordWriter(hiveRecordWriter, parquetFileWriter); } private final RecordWriter recordWriter; diff --git a/presto-hive/src/main/java/io/prestosql/plugin/hive/s3/PrestoS3FileSystem.java b/presto-hive/src/main/java/io/prestosql/plugin/hive/s3/PrestoS3FileSystem.java index 861e76426..d07a391f1 100644 --- a/presto-hive/src/main/java/io/prestosql/plugin/hive/s3/PrestoS3FileSystem.java +++ b/presto-hive/src/main/java/io/prestosql/plugin/hive/s3/PrestoS3FileSystem.java @@ -401,6 +401,7 @@ public class PrestoS3FileSystem throws IOException { boolean srcDirectory; + Path dstPath = null; try { srcDirectory = directory(src); } @@ -414,24 +415,25 @@ public class PrestoS3FileSystem return false; } // move source under destination directory - dst = new Path(dst, src.getName()); + dstPath = new Path(dst, src.getName()); } catch (FileNotFoundException e) { // destination does not exist + LOG.debug("destination does not exist"); } - if (keysEqual(src, dst)) { + if (keysEqual(src, dstPath)) { return false; } if (srcDirectory) { for (FileStatus file : listStatus(src)) { - rename(file.getPath(), new Path(dst, file.getPath().getName())); + rename(file.getPath(), new Path(dstPath, file.getPath().getName())); } deleteObject(keyFromPath(src) + DIRECTORY_SUFFIX); } else { - s3.copyObject(getBucketName(uri), keyFromPath(src), getBucketName(uri), keyFromPath(dst)); + s3.copyObject(getBucketName(uri), keyFromPath(src), getBucketName(uri), keyFromPath(dstPath)); delete(src, true); } diff --git a/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/TestRecordingHiveMetastore.java b/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/TestRecordingHiveMetastore.java index 56217962e..619897729 100644 --- a/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/TestRecordingHiveMetastore.java +++ b/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/TestRecordingHiveMetastore.java @@ -108,7 +108,7 @@ public class TestRecordingHiveMetastore throws IOException { HiveConfig recordingHiveConfig = new HiveConfig() - .setRecordingPath(File.createTempFile("recording_test", "json").getAbsolutePath()) + .setRecordingPath(File.createTempFile("recording_test", "json").getCanonicalPath()) .setRecordingDuration(new Duration(10, TimeUnit.MINUTES)); RecordingHiveMetastore recordingHiveMetastore = new RecordingHiveMetastore(new TestingHiveMetastore(), recordingHiveConfig); diff --git a/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/TestSemiTransactionalHiveMetastore.java b/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/TestSemiTransactionalHiveMetastore.java index 4a10fe978..0ad8a4a1d 100644 --- a/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/TestSemiTransactionalHiveMetastore.java +++ b/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/TestSemiTransactionalHiveMetastore.java @@ -108,8 +108,8 @@ public class TestSemiTransactionalHiveMetastore Map> partNamesUpdateMap = new HashMap<>(); List statistics = ImmutableList.of(STATISTICS_1, STATISTICS_1); for (int index = 0; index < partitions.size(); index++) { - PartitionStatistics stats = statistics.get(index); - partNamesUpdateMap.put(partitions.get(index), actualStatistics -> stats); + PartitionStatistics partitionStatistics = statistics.get(index); + partNamesUpdateMap.put(partitions.get(index), actualStatistics -> partitionStatistics); } thriftHiveMetastore.updatePartitionsStatistics(IDENTITY, MockThriftMetastoreClient.TEST_DATABASE, MockThriftMetastoreClient.TEST_TABLE_UP_NAME, partNamesUpdateMap); } diff --git a/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java b/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java index ddf1eb6ff..7e30ed02e 100644 --- a/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java +++ b/presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/thrift/InMemoryThriftMetastore.java @@ -100,8 +100,9 @@ public class InMemoryThriftMetastore } @Override - public synchronized void createDatabase(HiveIdentity identity, Database database) + public synchronized void createDatabase(HiveIdentity identity, Database inputDatabase) { + Database database = inputDatabase; requireNonNull(database, "database is null"); File directory; diff --git a/presto-hive/src/test/java/io/prestosql/plugin/hive/parquet/ParquetTester.java b/presto-hive/src/test/java/io/prestosql/plugin/hive/parquet/ParquetTester.java index c475d824b..4875a234a 100644 --- a/presto-hive/src/test/java/io/prestosql/plugin/hive/parquet/ParquetTester.java +++ b/presto-hive/src/test/java/io/prestosql/plugin/hive/parquet/ParquetTester.java @@ -70,6 +70,7 @@ import java.io.File; import java.io.IOException; import java.io.UncheckedIOException; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -462,7 +463,7 @@ public class ParquetTester return new SqlDecimal((BigInteger) fieldFromCursor, decimalType.getPrecision(), decimalType.getScale()); } if (isVarcharType(type)) { - return new String(((Slice) fieldFromCursor).getBytes()); + return new String(((Slice) fieldFromCursor).getBytes(), StandardCharsets.UTF_8); } if (VARBINARY.equals(type)) { return new SqlVarbinary(((Slice) fieldFromCursor).getBytes()); diff --git a/presto-hive/src/test/java/io/prestosql/plugin/hive/s3/TestPrestoS3FileSystem.java b/presto-hive/src/test/java/io/prestosql/plugin/hive/s3/TestPrestoS3FileSystem.java index 2dbd95112..09760f055 100644 --- a/presto-hive/src/test/java/io/prestosql/plugin/hive/s3/TestPrestoS3FileSystem.java +++ b/presto-hive/src/test/java/io/prestosql/plugin/hive/s3/TestPrestoS3FileSystem.java @@ -288,8 +288,6 @@ public class TestPrestoS3FileSystem { java.nio.file.Path stagingParent = createTempDirectory("test"); java.nio.file.Path staging = Paths.get(stagingParent.toString(), "staging"); - // stagingParent = /tmp/testXXX - // staging = /tmp/testXXX/staging try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) { MockAmazonS3 s3 = new MockAmazonS3(); @@ -311,7 +309,6 @@ public class TestPrestoS3FileSystem throws Exception { java.nio.file.Path staging = createTempFile("staging", null); - // staging = /tmp/stagingXXX.tmp try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) { MockAmazonS3 s3 = new MockAmazonS3(); @@ -332,8 +329,6 @@ public class TestPrestoS3FileSystem { java.nio.file.Path staging = createTempDirectory("staging"); java.nio.file.Path link = Paths.get(staging + ".symlink"); - // staging = /tmp/stagingXXX - // link = /tmp/stagingXXX.symlink -> /tmp/stagingXXX try { try { diff --git a/presto-hive/src/test/java/io/prestosql/plugin/hive/statistics/BenchmarkGetPartitionsSample.java b/presto-hive/src/test/java/io/prestosql/plugin/hive/statistics/BenchmarkGetPartitionsSample.java index 15e4f2ce8..5fa28b2c1 100644 --- a/presto-hive/src/test/java/io/prestosql/plugin/hive/statistics/BenchmarkGetPartitionsSample.java +++ b/presto-hive/src/test/java/io/prestosql/plugin/hive/statistics/BenchmarkGetPartitionsSample.java @@ -62,12 +62,12 @@ public class BenchmarkGetPartitionsSample @Setup public void setup() { - ImmutableList.Builder partitions = ImmutableList.builder(); + ImmutableList.Builder partitionBuilder = ImmutableList.builder(); SchemaTableName table = new SchemaTableName("schema", "table"); for (int i = 0; i < TOTAL_SIZE; i++) { - partitions.add(new HivePartition(table, "partition_" + i, ImmutableMap.of())); + partitionBuilder.add(new HivePartition(table, "partition_" + i, ImmutableMap.of())); } - this.partitions = partitions.build(); + this.partitions = partitionBuilder.build(); } } diff --git a/presto-jmx/src/main/java/io/prestosql/plugin/jmx/JmxColumnHandle.java b/presto-jmx/src/main/java/io/prestosql/plugin/jmx/JmxColumnHandle.java index 00a905920..2939e108e 100644 --- a/presto-jmx/src/main/java/io/prestosql/plugin/jmx/JmxColumnHandle.java +++ b/presto-jmx/src/main/java/io/prestosql/plugin/jmx/JmxColumnHandle.java @@ -40,6 +40,7 @@ public class JmxColumnHandle } @JsonProperty + @Override public String getColumnName() { return columnName; diff --git a/presto-jmx/src/main/java/io/prestosql/plugin/jmx/JmxConnectorConfig.java b/presto-jmx/src/main/java/io/prestosql/plugin/jmx/JmxConnectorConfig.java index c38b895d9..7d9a36b55 100644 --- a/presto-jmx/src/main/java/io/prestosql/plugin/jmx/JmxConnectorConfig.java +++ b/presto-jmx/src/main/java/io/prestosql/plugin/jmx/JmxConnectorConfig.java @@ -31,6 +31,7 @@ import static java.util.concurrent.TimeUnit.SECONDS; public class JmxConnectorConfig { + private static final Pattern PATTERN = Pattern.compile("(? dumpTables = ImmutableSet.of(); private Duration dumpPeriod = new Duration(10, SECONDS); private int maxEntries = 24 * 60 * 60; @@ -44,7 +45,7 @@ public class JmxConnectorConfig @Config("jmx.dump-tables") public JmxConnectorConfig setDumpTables(String tableNames) { - this.dumpTables = Splitter.on(Pattern.compile("(? columns = ImmutableList.of(0); assertEquals(jmxHistoricalData.getRows(TABLE_NAME, columns), ImmutableList.of()); - assertEquals(jmxHistoricalData.getRows(TABLE_NAME.toUpperCase(), columns), ImmutableList.of()); + assertEquals(jmxHistoricalData.getRows(TABLE_NAME.toUpperCase(Locale.ROOT), columns), ImmutableList.of()); jmxHistoricalData.addRow(TABLE_NAME, ImmutableList.of(42)); - jmxHistoricalData.addRow(TABLE_NAME.toUpperCase(), ImmutableList.of(44)); + jmxHistoricalData.addRow(TABLE_NAME.toUpperCase(Locale.ROOT), ImmutableList.of(44)); assertEquals(jmxHistoricalData.getRows(TABLE_NAME, columns), ImmutableList.of( ImmutableList.of(42), ImmutableList.of(44))); - assertEquals(jmxHistoricalData.getRows(TABLE_NAME.toUpperCase(), columns), ImmutableList.of( + assertEquals(jmxHistoricalData.getRows(TABLE_NAME.toUpperCase(Locale.ROOT), columns), ImmutableList.of( ImmutableList.of(42), ImmutableList.of(44))); } } diff --git a/presto-kafka/src/main/java/io/prestosql/plugin/kafka/KafkaMetadata.java b/presto-kafka/src/main/java/io/prestosql/plugin/kafka/KafkaMetadata.java index cd747b0b3..6d21fbccc 100644 --- a/presto-kafka/src/main/java/io/prestosql/plugin/kafka/KafkaMetadata.java +++ b/presto-kafka/src/main/java/io/prestosql/plugin/kafka/KafkaMetadata.java @@ -16,6 +16,7 @@ package io.prestosql.plugin.kafka; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import io.airlift.log.Logger; import io.prestosql.decoder.dummy.DummyRowDecoder; import io.prestosql.spi.connector.ColumnHandle; import io.prestosql.spi.connector.ColumnMetadata; @@ -48,6 +49,7 @@ import static java.util.Objects.requireNonNull; public class KafkaMetadata implements ConnectorMetadata { + private static final Logger LOG = Logger.get(KafkaMetadata.class); private final boolean hideInternalColumns; private final Map tableDescriptions; @@ -178,6 +180,7 @@ public class KafkaMetadata } catch (TableNotFoundException e) { // information_schema table or a system table + LOG.debug("Error message: " + e.getMessage()); } } return columns.build(); diff --git a/presto-kafka/src/test/java/io/prestosql/plugin/kafka/KafkaQueryRunner.java b/presto-kafka/src/test/java/io/prestosql/plugin/kafka/KafkaQueryRunner.java index 6c5d3438b..6a3ef7db9 100644 --- a/presto-kafka/src/test/java/io/prestosql/plugin/kafka/KafkaQueryRunner.java +++ b/presto-kafka/src/test/java/io/prestosql/plugin/kafka/KafkaQueryRunner.java @@ -135,8 +135,8 @@ public final class KafkaQueryRunner Logging.initialize(); DistributedQueryRunner queryRunner = createKafkaQueryRunner(EmbeddedKafka.createEmbeddedKafka(), TpchTable.getTables()); Thread.sleep(10); - Logger log = Logger.get(KafkaQueryRunner.class); - log.info("======== SERVER STARTED ========"); - log.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl()); + Logger logger = Logger.get(KafkaQueryRunner.class); + logger.info("======== SERVER STARTED ========"); + logger.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl()); } } diff --git a/presto-kafka/src/test/java/io/prestosql/plugin/kafka/util/EmbeddedKafka.java b/presto-kafka/src/test/java/io/prestosql/plugin/kafka/util/EmbeddedKafka.java index c8ecca179..bd9f067d4 100644 --- a/presto-kafka/src/test/java/io/prestosql/plugin/kafka/util/EmbeddedKafka.java +++ b/presto-kafka/src/test/java/io/prestosql/plugin/kafka/util/EmbeddedKafka.java @@ -86,7 +86,7 @@ public class EmbeddedKafka .put("auto.create.topics.enable", "false") .put("zookeeper.connection.timeout.ms", "1000000") .put("port", "0") - .put("log.dirs", kafkaDataDir.getAbsolutePath()) + .put("log.dirs", kafkaDataDir.getCanonicalPath()) .put("zookeeper.connect", zookeeper.getConnectString()) .putAll(Maps.fromProperties(overrideProperties)) .build(); diff --git a/presto-local-file/src/main/java/io/prestosql/plugin/localfile/LocalFileColumnHandle.java b/presto-local-file/src/main/java/io/prestosql/plugin/localfile/LocalFileColumnHandle.java index f96a0348e..4493021e8 100644 --- a/presto-local-file/src/main/java/io/prestosql/plugin/localfile/LocalFileColumnHandle.java +++ b/presto-local-file/src/main/java/io/prestosql/plugin/localfile/LocalFileColumnHandle.java @@ -45,6 +45,7 @@ public class LocalFileColumnHandle this.ordinalPosition = ordinalPosition; } + @Override @JsonProperty public String getColumnName() { diff --git a/presto-local-file/src/main/java/io/prestosql/plugin/localfile/LocalFileRecordCursor.java b/presto-local-file/src/main/java/io/prestosql/plugin/localfile/LocalFileRecordCursor.java index 4afe2f5e7..f3e7b515c 100644 --- a/presto-local-file/src/main/java/io/prestosql/plugin/localfile/LocalFileRecordCursor.java +++ b/presto-local-file/src/main/java/io/prestosql/plugin/localfile/LocalFileRecordCursor.java @@ -35,6 +35,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.RandomAccessFile; import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; import java.time.Instant; import java.time.ZoneId; import java.time.format.DateTimeFormatter; @@ -274,7 +275,7 @@ public class LocalFileRecordCursor private static Optional getDomain(OptionalInt timestampOrdinalPosition, TupleDomain predicate) { Optional> domains = predicate.getDomains(); - Domain domain = null; + Domain localDomain = null; if (domains.isPresent() && timestampOrdinalPosition.isPresent()) { Map domainMap = domains.get(); Set timestampDomain = domainMap.entrySet().stream() @@ -283,10 +284,10 @@ public class LocalFileRecordCursor .collect(toSet()); if (!timestampDomain.isEmpty()) { - domain = Iterables.getOnlyElement(timestampDomain); + localDomain = Iterables.getOnlyElement(timestampDomain); } } - return Optional.ofNullable(domain); + return Optional.ofNullable(localDomain); } private BufferedReader createNextReader() @@ -299,7 +300,7 @@ public class LocalFileRecordCursor FileInputStream fileInputStream = new FileInputStream(file); InputStream in = isGZipped(file) ? new GZIPInputStream(fileInputStream) : fileInputStream; - return new BufferedReader(new InputStreamReader(in)); + return new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8)); } public static boolean isGZipped(File file) @@ -316,21 +317,21 @@ public class LocalFileRecordCursor public List readFields() throws IOException { - List fields = null; + List fieldsList = null; boolean newReader = false; if (maxRowFromFile <= 0) { throw new PrestoException(LOCAL_FILE_READ_ERROR, "Local file too large for presto."); } - while (fields == null) { + while (fieldsList == null) { if (reader == null) { return null; } String line = reader.readLine(); if (line != null) { - fields = LINE_SPLITTER.splitToList(line); - if (!newReader || meetsPredicate(fields)) { + fieldsList = LINE_SPLITTER.splitToList(line); + if (!newReader || meetsPredicate(fieldsList)) { maxRowFromFile--; - return fields; + return fieldsList; } } reader.close(); @@ -338,7 +339,7 @@ public class LocalFileRecordCursor newReader = true; } maxRowFromFile--; - return fields; + return fieldsList; } private boolean meetsPredicate(List fields) diff --git a/presto-main/src/main/java/io/prestosql/MockSplit.java b/presto-main/src/main/java/io/prestosql/MockSplit.java index 564610fab..652467283 100644 --- a/presto-main/src/main/java/io/prestosql/MockSplit.java +++ b/presto-main/src/main/java/io/prestosql/MockSplit.java @@ -51,10 +51,7 @@ public class MockSplit @JsonProperty("endIndex") long endIndex, @JsonProperty("lastModifiedTime") long lastModifiedTime) { - this.filepath = filepath; - this.startIndex = startIndex; - this.endIndex = endIndex; - this.lastModifiedTime = lastModifiedTime; + this(filepath, startIndex, endIndex, lastModifiedTime, false); this.schema = TEST_SCHEMA; this.table = TEST_TABLE; } diff --git a/presto-main/src/main/java/io/prestosql/catalog/AbstractCatalogStore.java b/presto-main/src/main/java/io/prestosql/catalog/AbstractCatalogStore.java index 472f6bb34..6a3772d1a 100644 --- a/presto-main/src/main/java/io/prestosql/catalog/AbstractCatalogStore.java +++ b/presto-main/src/main/java/io/prestosql/catalog/AbstractCatalogStore.java @@ -95,6 +95,7 @@ public abstract class AbstractCatalogStore List catalogFileNames, List globalFileNames); + @Override public void createCatalog(CatalogInfo catalogInfo, CatalogFileInputStream configFiles) throws IOException { @@ -159,6 +160,7 @@ public abstract class AbstractCatalogStore } } + @Override public void deleteCatalog(String catalogName, boolean totalDelete) { CatalogFilePath catalogPath = new CatalogFilePath(baseDirectory, catalogName); @@ -205,6 +207,7 @@ public abstract class AbstractCatalogStore } } + @Override public CatalogInfo getCatalogInformation(String catalogName) throws IOException { @@ -235,6 +238,7 @@ public abstract class AbstractCatalogStore return new CatalogInfo(catalogName, connectorName, null, createdTime, version, catalogProperties); } + @Override public CatalogFileInputStream getCatalogFiles(String catalogName) throws IOException { @@ -273,6 +277,7 @@ public abstract class AbstractCatalogStore } } + @Override public Set listCatalogNames() throws IOException { diff --git a/presto-main/src/main/java/io/prestosql/connector/informationschema/InformationSchemaColumnHandle.java b/presto-main/src/main/java/io/prestosql/connector/informationschema/InformationSchemaColumnHandle.java index 99a13d229..7ed34b1a6 100644 --- a/presto-main/src/main/java/io/prestosql/connector/informationschema/InformationSchemaColumnHandle.java +++ b/presto-main/src/main/java/io/prestosql/connector/informationschema/InformationSchemaColumnHandle.java @@ -33,6 +33,7 @@ public class InformationSchemaColumnHandle } @JsonProperty + @Override public String getColumnName() { return columnName; diff --git a/presto-main/src/main/java/io/prestosql/connector/system/SystemColumnHandle.java b/presto-main/src/main/java/io/prestosql/connector/system/SystemColumnHandle.java index 68e4a3dd9..3e906fd33 100644 --- a/presto-main/src/main/java/io/prestosql/connector/system/SystemColumnHandle.java +++ b/presto-main/src/main/java/io/prestosql/connector/system/SystemColumnHandle.java @@ -37,6 +37,7 @@ public class SystemColumnHandle } @JsonProperty + @Override public String getColumnName() { return columnName; diff --git a/presto-main/src/main/java/io/prestosql/cube/CubeStatementGenerator.java b/presto-main/src/main/java/io/prestosql/cube/CubeStatementGenerator.java index 444f829e3..b8ec02571 100644 --- a/presto-main/src/main/java/io/prestosql/cube/CubeStatementGenerator.java +++ b/presto-main/src/main/java/io/prestosql/cube/CubeStatementGenerator.java @@ -97,7 +97,7 @@ public class CubeStatementGenerator for (Symbol symbol : aggregationNode.getGroupingKeys()) { Object column = symbolMappings.get(symbol.getName()); if (column instanceof ColumnHandle) { - builder.groupBy(((ColumnHandle) column).getColumnName()); + builder.groupByAddString(((ColumnHandle) column).getColumnName()); } else { // Don't know how to handle it diff --git a/presto-main/src/main/java/io/prestosql/discovery/server/HetuInMemoryStore.java b/presto-main/src/main/java/io/prestosql/discovery/server/HetuInMemoryStore.java index 776051505..de3184564 100644 --- a/presto-main/src/main/java/io/prestosql/discovery/server/HetuInMemoryStore.java +++ b/presto-main/src/main/java/io/prestosql/discovery/server/HetuInMemoryStore.java @@ -36,16 +36,16 @@ public class HetuInMemoryStore @Override public void put(Entry entry) { - Long maxAgeInMs = entry.getMaxAgeInMs(); + Long entryMaxAgeInMs = entry.getMaxAgeInMs(); if (entry.getMaxAgeInMs() == null) { // when put entity, set the default max time. // the entity from remote, the max age time is null, so the entity can't be expired when the node of entity is disconnected. // then the max age time is reached, the entity will be expired. // default max age time is 30s. - maxAgeInMs = this.maxAgeInMs; + entryMaxAgeInMs = this.maxAgeInMs; } - Entry newEntry = new Entry(entry.getKey(), entry.getValue(), entry.getVersion(), entry.getTimestamp(), maxAgeInMs); + Entry newEntry = new Entry(entry.getKey(), entry.getValue(), entry.getVersion(), entry.getTimestamp(), entryMaxAgeInMs); super.put(newEntry); } } diff --git a/presto-main/src/main/java/io/prestosql/dispatcher/DispatchManager.java b/presto-main/src/main/java/io/prestosql/dispatcher/DispatchManager.java index 45b08ccd0..282fd4e2d 100644 --- a/presto-main/src/main/java/io/prestosql/dispatcher/DispatchManager.java +++ b/presto-main/src/main/java/io/prestosql/dispatcher/DispatchManager.java @@ -189,8 +189,9 @@ public class DispatchManager * Creates and registers a dispatch query with the query tracker. This method will never fail to register a query with the query * tracker. If an error occurs while creating a dispatch query, a failed dispatch will be created and registered. */ - private void createQueryInternal(QueryId queryId, String slug, SessionContext sessionContext, String query, ResourceGroupManager resourceGroupManager) + private void createQueryInternal(QueryId queryId, String slug, SessionContext sessionContext, String inputQuery, ResourceGroupManager resourceGroupManager) { + String query = inputQuery; Session session = null; DispatchQuery dispatchQuery = null; try { diff --git a/presto-main/src/main/java/io/prestosql/dispatcher/QueuedStatementResource.java b/presto-main/src/main/java/io/prestosql/dispatcher/QueuedStatementResource.java index fb0ec99c4..48d773ea1 100644 --- a/presto-main/src/main/java/io/prestosql/dispatcher/QueuedStatementResource.java +++ b/presto-main/src/main/java/io/prestosql/dispatcher/QueuedStatementResource.java @@ -354,13 +354,13 @@ public class QueuedStatementResource public QueryResults getQueryResults(long token, UriInfo uriInfo, String xForwardedProto) { - long lastToken = this.lastToken.get(); + long tmpLastToken = this.lastToken.get(); // token should be the last token or the next token - if (token != lastToken && token != lastToken + 1) { + if (token != tmpLastToken && token != tmpLastToken + 1) { throw new WebApplicationException(Response.Status.GONE); } // advance (or stay at) the token - this.lastToken.compareAndSet(lastToken, token); + this.lastToken.compareAndSet(tmpLastToken, token); synchronized (this) { // if query submission has not finished, return simple empty result diff --git a/presto-main/src/main/java/io/prestosql/dynamicfilter/DynamicFilterService.java b/presto-main/src/main/java/io/prestosql/dynamicfilter/DynamicFilterService.java index ac5d73b3c..6feede54c 100644 --- a/presto-main/src/main/java/io/prestosql/dynamicfilter/DynamicFilterService.java +++ b/presto-main/src/main/java/io/prestosql/dynamicfilter/DynamicFilterService.java @@ -429,9 +429,9 @@ public class DynamicFilterService builder.add(df); } } - Set dynamicFilters = builder.build(); - if (!dynamicFilters.isEmpty()) { - supplier.add(dynamicFilters); + Set dynamicFiltersSet = builder.build(); + if (!dynamicFiltersSet.isEmpty()) { + supplier.add(dynamicFiltersSet); } } return supplier; diff --git a/presto-main/src/main/java/io/prestosql/event/QueryMonitor.java b/presto-main/src/main/java/io/prestosql/event/QueryMonitor.java index bc023640e..239f83dc1 100644 --- a/presto-main/src/main/java/io/prestosql/event/QueryMonitor.java +++ b/presto-main/src/main/java/io/prestosql/event/QueryMonitor.java @@ -413,7 +413,6 @@ public class QueryMonitor long waiting = queryStats.getResourceWaitingTime().toMillis(); List stages = StageInfo.getAllStages(queryInfo.getOutputStage()); - // long lastSchedulingCompletion = 0; long firstTaskStartTime = queryEndTime.getMillis(); long firstStageFirstTaskStartTime = queryEndTime.getMillis(); long lastTaskStartTime = queryStartTime.getMillis() + planning; diff --git a/presto-main/src/main/java/io/prestosql/failuredetector/HeartbeatFailureDetector.java b/presto-main/src/main/java/io/prestosql/failuredetector/HeartbeatFailureDetector.java index b69a19bda..1287c7d4e 100644 --- a/presto-main/src/main/java/io/prestosql/failuredetector/HeartbeatFailureDetector.java +++ b/presto-main/src/main/java/io/prestosql/failuredetector/HeartbeatFailureDetector.java @@ -276,6 +276,7 @@ public class HeartbeatFailureDetector return new URI(url); } catch (URISyntaxException ignored) { + // could be ignored } } return null; @@ -510,11 +511,11 @@ public class HeartbeatFailureDetector @JsonProperty public FailureInfo getLastFailureInfo() { - Exception lastFailureException = getLastFailureException(); - if (lastFailureException == null) { + Exception exception = getLastFailureException(); + if (exception == null) { return null; } - return Failures.toFailure(lastFailureException).toFailureInfo(); + return Failures.toFailure(exception).toFailureInfo(); } @JsonProperty diff --git a/presto-main/src/main/java/io/prestosql/heuristicindex/SplitFiltering.java b/presto-main/src/main/java/io/prestosql/heuristicindex/SplitFiltering.java index 8727c58a5..6ac07039f 100644 --- a/presto-main/src/main/java/io/prestosql/heuristicindex/SplitFiltering.java +++ b/presto-main/src/main/java/io/prestosql/heuristicindex/SplitFiltering.java @@ -442,11 +442,6 @@ public class SplitFiltering return false; } - /* (!(table.getConnectorHandle().isFilterSupported() - * && (isSupportedExpression(filterNode.getPredicate()) - * || (((TableScanNode) sourceNode).getPredicate().isPresent() - * && isSupportedExpression(((TableScanNode) sourceNode).getPredicate().get()))))) - */ if (!table.getConnectorHandle().isFilterSupported()) { return false; } diff --git a/presto-main/src/main/java/io/prestosql/memory/ClusterMemoryManager.java b/presto-main/src/main/java/io/prestosql/memory/ClusterMemoryManager.java index bf01f88cd..8fddeea43 100644 --- a/presto-main/src/main/java/io/prestosql/memory/ClusterMemoryManager.java +++ b/presto-main/src/main/java/io/prestosql/memory/ClusterMemoryManager.java @@ -536,7 +536,6 @@ public class ClusterMemoryManager // Add new nodes for (InternalNode node : aliveNodes) { if (!nodes.containsKey(node.getNodeIdentifier()) && shouldIncludeNode(node)) { -// nodes.put(node.getNodeIdentifier(), new RemoteNodeMemory(node, httpClient, memoryInfoCodec, assignmentsRequestCodec, locationFactory.createMemoryInfoLocation(node), isBinaryEncoding)); nodes.put(node.getInternalUri().toString(), new RemoteNodeMemory(node, httpClient, memoryInfoCodec, assignmentsRequestCodec, locationFactory.createMemoryInfoLocation(node), isBinaryEncoding)); allNodes.put(node.getInternalUri().toString(), new RemoteNodeMemory(node, httpClient, memoryInfoCodec, assignmentsRequestCodec, locationFactory.createMemoryInfoLocation(node), isBinaryEncoding)); } diff --git a/presto-main/src/main/java/io/prestosql/memory/MemoryPool.java b/presto-main/src/main/java/io/prestosql/memory/MemoryPool.java index 7e470328b..85a0d0f12 100644 --- a/presto-main/src/main/java/io/prestosql/memory/MemoryPool.java +++ b/presto-main/src/main/java/io/prestosql/memory/MemoryPool.java @@ -255,12 +255,12 @@ public class MemoryPool // query is not registered (likely a race with query completion) return Futures.immediateFuture(null); } - ListenableFuture future = targetMemoryPool.reserve(queryId, MOVE_QUERY_TAG, originalReserved); + ListenableFuture listenableFuture = targetMemoryPool.reserve(queryId, MOVE_QUERY_TAG, originalReserved); free(queryId, MOVE_QUERY_TAG, originalReserved); targetMemoryPool.reserveRevocable(queryId, originalRevocableReserved); freeRevocable(queryId, originalRevocableReserved); targetMemoryPool.taggedMemoryAllocations.put(queryId, taggedAllocations); - return future; + return listenableFuture; } /** diff --git a/presto-main/src/main/java/io/prestosql/operator/aggregation/builder/InMemoryAggregationBuilder.java b/presto-main/src/main/java/io/prestosql/operator/aggregation/builder/InMemoryAggregationBuilder.java index dfc38a25b..b2066de91 100644 --- a/presto-main/src/main/java/io/prestosql/operator/aggregation/builder/InMemoryAggregationBuilder.java +++ b/presto-main/src/main/java/io/prestosql/operator/aggregation/builder/InMemoryAggregationBuilder.java @@ -364,11 +364,11 @@ public abstract class InMemoryAggregationBuilder { InMemoryAggregationBuilderState myState = new InMemoryAggregationBuilderState(); myState.groupBy = groupBy.capture(serdeProvider); - List aggregators = new ArrayList<>(); + List aggregatorsList = new ArrayList<>(); for (Aggregator aggregator : this.aggregators) { - aggregators.add(aggregator.capture(serdeProvider)); + aggregatorsList.add(aggregator.capture(serdeProvider)); } - myState.aggregators = aggregators; + myState.aggregators = aggregatorsList; myState.full = full; return myState; } diff --git a/presto-main/src/main/java/io/prestosql/operator/aggregation/builder/MergingHashAggregationBuilder.java b/presto-main/src/main/java/io/prestosql/operator/aggregation/builder/MergingHashAggregationBuilder.java index e1b7a5473..414ca7dc9 100644 --- a/presto-main/src/main/java/io/prestosql/operator/aggregation/builder/MergingHashAggregationBuilder.java +++ b/presto-main/src/main/java/io/prestosql/operator/aggregation/builder/MergingHashAggregationBuilder.java @@ -64,15 +64,15 @@ public class MergingHashAggregationBuilder int overwriteIntermediateChannelOffset, JoinCompiler joinCompiler) { - ImmutableList.Builder groupByPartialChannels = ImmutableList.builder(); + ImmutableList.Builder groupByPartialChannelsBuilder = ImmutableList.builder(); for (int i = 0; i < groupByTypes.size(); i++) { - groupByPartialChannels.add(i); + groupByPartialChannelsBuilder.add(i); } this.accumulatorFactories = accumulatorFactories; this.step = AggregationNode.Step.partialInput(step); this.expectedGroups = expectedGroups; - this.groupByPartialChannels = groupByPartialChannels.build(); + this.groupByPartialChannels = groupByPartialChannelsBuilder.build(); this.hashChannel = hashChannel.isPresent() ? Optional.of(groupByTypes.size()) : hashChannel; this.operatorContext = operatorContext; this.sortedPages = sortedPages; diff --git a/presto-main/src/main/java/io/prestosql/operator/aggregation/multimapagg/MultimapAggregationState.java b/presto-main/src/main/java/io/prestosql/operator/aggregation/multimapagg/MultimapAggregationState.java index f5b28a3aa..607ca5035 100644 --- a/presto-main/src/main/java/io/prestosql/operator/aggregation/multimapagg/MultimapAggregationState.java +++ b/presto-main/src/main/java/io/prestosql/operator/aggregation/multimapagg/MultimapAggregationState.java @@ -37,6 +37,7 @@ public interface MultimapAggregationState throw new UnsupportedOperationException(); } + @Override long getEstimatedSize(); int getEntryCount(); diff --git a/presto-main/src/main/java/io/prestosql/operator/dynamicfilter/CrossRegionDynamicFilterOperator.java b/presto-main/src/main/java/io/prestosql/operator/dynamicfilter/CrossRegionDynamicFilterOperator.java index a8937f4b5..4ece1407e 100644 --- a/presto-main/src/main/java/io/prestosql/operator/dynamicfilter/CrossRegionDynamicFilterOperator.java +++ b/presto-main/src/main/java/io/prestosql/operator/dynamicfilter/CrossRegionDynamicFilterOperator.java @@ -255,8 +255,8 @@ public class CrossRegionDynamicFilterOperator @Override public Operator createOperator(DriverContext driverContext) { - OperatorContext operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, CrossRegionDynamicFilterOperator.class.getSimpleName()); - return new CrossRegionDynamicFilterOperator(operatorContext, queryId, symbols, typeProvider, dynamicFilterCacheManager, columns, outputNodeSybmols); + OperatorContext context = driverContext.addOperatorContext(operatorId, planNodeId, CrossRegionDynamicFilterOperator.class.getSimpleName()); + return new CrossRegionDynamicFilterOperator(context, queryId, symbols, typeProvider, dynamicFilterCacheManager, columns, outputNodeSybmols); } @Override diff --git a/presto-main/src/main/java/io/prestosql/operator/project/DictionaryAwarePageProjection.java b/presto-main/src/main/java/io/prestosql/operator/project/DictionaryAwarePageProjection.java index eefacaa48..e2038e149 100644 --- a/presto-main/src/main/java/io/prestosql/operator/project/DictionaryAwarePageProjection.java +++ b/presto-main/src/main/java/io/prestosql/operator/project/DictionaryAwarePageProjection.java @@ -94,16 +94,16 @@ public class DictionaryAwarePageProjection this.session = session; this.yieldSignal = requireNonNull(yieldSignal, "yieldSignal is null"); - Block block = requireNonNull(page, "page is null").getBlock(0).getLoadedBlock(); - this.block = block; + Block loadedBlock = requireNonNull(page, "page is null").getBlock(0).getLoadedBlock(); + this.block = loadedBlock; this.selectedPositions = requireNonNull(selectedPositions, "selectedPositions is null"); Optional dictionary = Optional.empty(); - if (block instanceof RunLengthEncodedBlock) { - dictionary = Optional.of(((RunLengthEncodedBlock) block).getValue()); + if (loadedBlock instanceof RunLengthEncodedBlock) { + dictionary = Optional.of(((RunLengthEncodedBlock) loadedBlock).getValue()); } - else if (block instanceof DictionaryBlock) { - dictionary = Optional.of(((DictionaryBlock) block).getDictionary()); + else if (loadedBlock instanceof DictionaryBlock) { + dictionary = Optional.of(((DictionaryBlock) loadedBlock).getDictionary()); } // Try use dictionary processing first; if it fails, fall back to the generic case diff --git a/presto-main/src/main/java/io/prestosql/operator/scalar/annotations/ParametricScalarImplementation.java b/presto-main/src/main/java/io/prestosql/operator/scalar/annotations/ParametricScalarImplementation.java index 3b5c889b3..c6937200a 100644 --- a/presto-main/src/main/java/io/prestosql/operator/scalar/annotations/ParametricScalarImplementation.java +++ b/presto-main/src/main/java/io/prestosql/operator/scalar/annotations/ParametricScalarImplementation.java @@ -333,13 +333,13 @@ public class ParametricScalarImplementation this.dependencies = ImmutableList.copyOf(requireNonNull(dependencies, "dependencies is null")); this.constructorDependencies = ImmutableList.copyOf(requireNonNull(constructorDependencies, "constructorDependencies is null")); - int numberOfBlockPositionArguments = 0; + int cnt = 0; for (ArgumentProperty argumentProperty : argumentProperties) { if (argumentProperty.getArgumentType() == VALUE_TYPE && argumentProperty.getNullConvention().equals(BLOCK_AND_POSITION)) { - numberOfBlockPositionArguments++; + cnt++; } } - this.numberOfBlockPositionArguments = numberOfBlockPositionArguments; + this.numberOfBlockPositionArguments = cnt; } public boolean isNullable() @@ -481,9 +481,9 @@ public class ParametricScalarImplementation .map(TypeParameter::value) .collect(toImmutableSet()); - SqlType returnType = method.getAnnotation(SqlType.class); - checkArgument(returnType != null, "Method [%s] is missing @SqlType annotation", method); - this.returnType = parseTypeSignature(returnType.value(), literalParameters); + SqlType returnType1 = method.getAnnotation(SqlType.class); + checkArgument(returnType1 != null, "Method [%s] is missing @SqlType annotation", method); + this.returnType = parseTypeSignature(returnType1.value(), literalParameters); Class actualReturnType = method.getReturnType(); this.returnNativeContainerType = Primitives.unwrap(actualReturnType); @@ -505,7 +505,7 @@ public class ParametricScalarImplementation "Expected type parameter to only contain A-Z and 0-9 (starting with A-Z), but got %s on method [%s]", typeParameter.value(), method); } - inferSpecialization(method, actualReturnType, returnType.value()); + inferSpecialization(method, actualReturnType, returnType1.value()); parseArguments(method); this.constructorMethodHandle = getConstructor(method, constructor); @@ -672,29 +672,29 @@ public class ParametricScalarImplementation private MethodHandle getMethodHandle(Method method) { - MethodHandle methodHandle = methodHandle(FUNCTION_IMPLEMENTATION_ERROR, method); + MethodHandle handle = methodHandle(FUNCTION_IMPLEMENTATION_ERROR, method); if (!isStatic(method.getModifiers())) { // Change type of "this" argument to Object to make sure callers won't have classloader issues - methodHandle = methodHandle.asType(methodHandle.type().changeParameterType(0, Object.class)); + handle = handle.asType(handle.type().changeParameterType(0, Object.class)); // Re-arrange the parameters, so that the "this" parameter is after the meta parameters - int[] permutedIndices = new int[methodHandle.type().parameterCount()]; + int[] permutedIndices = new int[handle.type().parameterCount()]; permutedIndices[0] = dependencies.size(); - MethodType newType = methodHandle.type().changeParameterType(dependencies.size(), methodHandle.type().parameterType(0)); + MethodType newType = handle.type().changeParameterType(dependencies.size(), handle.type().parameterType(0)); for (int i = 0; i < dependencies.size(); i++) { permutedIndices[i + 1] = i; - newType = newType.changeParameterType(i, methodHandle.type().parameterType(i + 1)); + newType = newType.changeParameterType(i, handle.type().parameterType(i + 1)); } for (int i = dependencies.size() + 1; i < permutedIndices.length; i++) { permutedIndices[i] = i; } - methodHandle = permuteArguments(methodHandle, newType, permutedIndices); + handle = permuteArguments(handle, newType, permutedIndices); } - return methodHandle; + return handle; } public ParametricScalarImplementation get() { - Signature signature = new Signature( + Signature newSignature = new Signature( header.getName(), SCALAR, createTypeVariableConstraints(typeParameters, dependencies), @@ -704,7 +704,7 @@ public class ParametricScalarImplementation false); return new ParametricScalarImplementation( - signature, + newSignature, argumentNativeContainerTypes, specializedTypeParameters, choices, diff --git a/presto-main/src/main/java/io/prestosql/operator/unnest/UnnestOperator.java b/presto-main/src/main/java/io/prestosql/operator/unnest/UnnestOperator.java index ff0cad2a1..ac8bc08c0 100644 --- a/presto-main/src/main/java/io/prestosql/operator/unnest/UnnestOperator.java +++ b/presto-main/src/main/java/io/prestosql/operator/unnest/UnnestOperator.java @@ -74,8 +74,8 @@ public class UnnestOperator public Operator createOperator(DriverContext driverContext) { checkState(!closed, "Factory is already closed"); - OperatorContext operatorContext = driverContext.addOperatorContext(operatorId, planNodeId, UnnestOperator.class.getSimpleName()); - return new UnnestOperator(operatorContext, replicateChannels, replicateTypes, unnestChannels, unnestTypes, withOrdinality); + OperatorContext localOperatorContext = driverContext.addOperatorContext(operatorId, planNodeId, UnnestOperator.class.getSimpleName()); + return new UnnestOperator(localOperatorContext, replicateChannels, replicateTypes, unnestChannels, unnestTypes, withOrdinality); } @Override diff --git a/presto-main/src/main/java/io/prestosql/protocol/FullSmileResponseHandler.java b/presto-main/src/main/java/io/prestosql/protocol/FullSmileResponseHandler.java index a1eb2402e..914626e8f 100644 --- a/presto-main/src/main/java/io/prestosql/protocol/FullSmileResponseHandler.java +++ b/presto-main/src/main/java/io/prestosql/protocol/FullSmileResponseHandler.java @@ -108,18 +108,18 @@ public class FullSmileResponseHandler this.smileBytes = requireNonNull(smileBytes, "smileBytes is null"); this.responseBytes = smileBytes; - T value = null; - IllegalArgumentException exception = null; + T val = null; + IllegalArgumentException illegalArgumentException = null; try { - value = smileCodec.fromSmile(smileBytes); + val = smileCodec.fromSmile(smileBytes); } catch (IllegalArgumentException e) { - exception = new IllegalArgumentException("Unable to create " + smileCodec.getType() + " from SMILE response", e); + illegalArgumentException = new IllegalArgumentException("Unable to create " + smileCodec.getType() + " from SMILE response", e); } - this.hasValue = (exception == null); - this.value = value; - this.exception = exception; + this.hasValue = (illegalArgumentException == null); + this.value = val; + this.exception = illegalArgumentException; } @Override diff --git a/presto-main/src/main/java/io/prestosql/protocol/ObjectMapperProvider.java b/presto-main/src/main/java/io/prestosql/protocol/ObjectMapperProvider.java index 8ff50fb9c..127cab473 100644 --- a/presto-main/src/main/java/io/prestosql/protocol/ObjectMapperProvider.java +++ b/presto-main/src/main/java/io/prestosql/protocol/ObjectMapperProvider.java @@ -76,6 +76,7 @@ public class ObjectMapperProvider modules.add(new JodaModule()); } catch (ClassNotFoundException ignored) { + // could be ignored } } diff --git a/presto-main/src/main/java/io/prestosql/query/CachedSqlQueryExecution.java b/presto-main/src/main/java/io/prestosql/query/CachedSqlQueryExecution.java index a55dc60f7..818375767 100644 --- a/presto-main/src/main/java/io/prestosql/query/CachedSqlQueryExecution.java +++ b/presto-main/src/main/java/io/prestosql/query/CachedSqlQueryExecution.java @@ -408,14 +408,14 @@ public class CachedSqlQueryExecution connectorTransactionHandleMap = new HashMap<>(); // A map of String fully qualified names to TableHandles for ease of access - Map tables = new HashMap<>(); + Map tableHandleHashMap = new HashMap<>(); for (TableHandle handle : analysis.getTables()) { - tables.put(handle.getFullyQualifiedName(), handle); + tableHandleHashMap.put(handle.getFullyQualifiedName(), handle); analysis.getCubes(handle).forEach(cubeHandle -> { - tables.putIfAbsent(cubeHandle.getFullyQualifiedName(), cubeHandle); + tableHandleHashMap.putIfAbsent(cubeHandle.getFullyQualifiedName(), cubeHandle); }); } - this.tables = tables; + this.tables = tableHandleHashMap; this.reuseTableScanNewMappingIdMap = new HashMap(); } diff --git a/presto-main/src/main/java/io/prestosql/queryeditorui/execution/QueryInfoClient.java b/presto-main/src/main/java/io/prestosql/queryeditorui/execution/QueryInfoClient.java index ddde65ac6..e4d47df92 100644 --- a/presto-main/src/main/java/io/prestosql/queryeditorui/execution/QueryInfoClient.java +++ b/presto-main/src/main/java/io/prestosql/queryeditorui/execution/QueryInfoClient.java @@ -53,8 +53,9 @@ public class QueryInfoClient this.okHttpClient = okHttpClient; } - public BasicQueryInfo from(URI infoUri, String id) + public BasicQueryInfo from(URI inputInfoUri, String id) { + URI infoUri = inputInfoUri; infoUri = requireNonNull(infoUri, "infoUri is null"); HttpUrl url = HttpUrl.get(infoUri); url = url.newBuilder().encodedPath("/v1/query/" + id).query(null).build(); diff --git a/presto-main/src/main/java/io/prestosql/queryeditorui/output/builders/CsvOutputBuilder.java b/presto-main/src/main/java/io/prestosql/queryeditorui/output/builders/CsvOutputBuilder.java index f5863936e..ae05f4211 100644 --- a/presto-main/src/main/java/io/prestosql/queryeditorui/output/builders/CsvOutputBuilder.java +++ b/presto-main/src/main/java/io/prestosql/queryeditorui/output/builders/CsvOutputBuilder.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.UUID; import java.util.zip.GZIPOutputStream; @@ -60,10 +61,10 @@ public class CsvOutputBuilder this.countingOutputStream = new CountingOutputStream(new FileOutputStream(this.outputFile)); OutputStreamWriter writer; if (compressedOutput) { - writer = new OutputStreamWriter(new GZIPOutputStream(this.countingOutputStream)); + writer = new OutputStreamWriter(new GZIPOutputStream(this.countingOutputStream), StandardCharsets.UTF_8); } else { - writer = new OutputStreamWriter(this.countingOutputStream); + writer = new OutputStreamWriter(this.countingOutputStream, StandardCharsets.UTF_8); } this.csvWriter = new CSVWriter(writer); } @@ -137,7 +138,7 @@ public class CsvOutputBuilder csvWriter.close(); } catch (IOException e) { - e.printStackTrace(); + LOG.debug("Error message: " + e.getStackTrace()); } return outputFile; diff --git a/presto-main/src/main/java/io/prestosql/queryeditorui/protocol/Table.java b/presto-main/src/main/java/io/prestosql/queryeditorui/protocol/Table.java index 0e0c270e5..289a9daf9 100644 --- a/presto-main/src/main/java/io/prestosql/queryeditorui/protocol/Table.java +++ b/presto-main/src/main/java/io/prestosql/queryeditorui/protocol/Table.java @@ -91,13 +91,13 @@ public class Table public static Table fromInput(Input input) { - List columns = new ArrayList<>(input.getColumns().size()); + List columnsList = new ArrayList<>(input.getColumns().size()); for (Column c : input.getColumns()) { - columns.add(c.getName()); + columnsList.add(c.getName()); } - return new Table(input.getCatalogName().getCatalogName(), input.getSchema(), input.getTable(), columns); + return new Table(input.getCatalogName().getCatalogName(), input.getSchema(), input.getTable(), columnsList); } @JsonProperty diff --git a/presto-main/src/main/java/io/prestosql/queryeditorui/resources/LoginResource.java b/presto-main/src/main/java/io/prestosql/queryeditorui/resources/LoginResource.java index 7fffc6717..5b722f085 100644 --- a/presto-main/src/main/java/io/prestosql/queryeditorui/resources/LoginResource.java +++ b/presto-main/src/main/java/io/prestosql/queryeditorui/resources/LoginResource.java @@ -49,12 +49,12 @@ public class LoginResource @FormParam("redirectPath") String redirectPath, @Context SecurityContext securityContext) { - username = emptyToNull(username); + String inputUsername = emptyToNull(username); password = emptyToNull(password); - redirectPath = emptyToNull(redirectPath); - Optional newCookie = uiAuthenticator.checkLoginCredentials(username, password, securityContext.isSecure()); + String inputRedirectPath = emptyToNull(redirectPath); + Optional newCookie = uiAuthenticator.checkLoginCredentials(inputUsername, password, securityContext.isSecure()); if (newCookie.isPresent()) { - return UiAuthenticator.redirectFromSuccessfulLoginResponse(redirectPath) + return UiAuthenticator.redirectFromSuccessfulLoginResponse(inputRedirectPath) .cookie(newCookie.get()).build(); } // authentication failed, redirect back to the login page diff --git a/presto-main/src/main/java/io/prestosql/queryeditorui/security/UiAuthenticator.java b/presto-main/src/main/java/io/prestosql/queryeditorui/security/UiAuthenticator.java index b4b6d3a07..279290c44 100644 --- a/presto-main/src/main/java/io/prestosql/queryeditorui/security/UiAuthenticator.java +++ b/presto-main/src/main/java/io/prestosql/queryeditorui/security/UiAuthenticator.java @@ -110,13 +110,15 @@ public class UiAuthenticator builder.uri(new URI(null, null, null, path, null)); } catch (URISyntaxException ignored) { + // could be ignored } return builder.build(); } - public static Response.ResponseBuilder redirectFromSuccessfulLoginResponse(String redirectPath) + public static Response.ResponseBuilder redirectFromSuccessfulLoginResponse(String inputRedirectPath) { + String redirectPath = inputRedirectPath; URI redirectLocation = UI_LOCATION_URI; redirectPath = emptyToNull(redirectPath); @@ -125,6 +127,7 @@ public class UiAuthenticator redirectLocation = new URI(redirectPath); } catch (URISyntaxException ignored) { + // could be ignored } } diff --git a/presto-main/src/main/java/io/prestosql/queryeditorui/store/queries/InMemoryQueryStore.java b/presto-main/src/main/java/io/prestosql/queryeditorui/store/queries/InMemoryQueryStore.java index 251ef6476..6fa2c480d 100644 --- a/presto-main/src/main/java/io/prestosql/queryeditorui/store/queries/InMemoryQueryStore.java +++ b/presto-main/src/main/java/io/prestosql/queryeditorui/store/queries/InMemoryQueryStore.java @@ -25,6 +25,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -61,7 +62,7 @@ public class InMemoryQueryStore byte[] buffer = new byte[4096]; int n; while ((n = fin.read(buffer)) > 0) { - jsonString.append(new String(buffer, 0, n)); + jsonString.append(new String(buffer, 0, n, StandardCharsets.UTF_8)); } featuredQueries.addAll(SAVED_QUERIES_CODEC.fromJson(jsonString.toString())); featuredQueries.stream().forEach(q -> q.setFeatured(true)); @@ -99,7 +100,7 @@ public class InMemoryQueryStore queryList.add(query); try (FileOutputStream fout = new FileOutputStream(targetPath)) { String json = SAVED_QUERIES_CODEC.toJson(queryList); - fout.write(json.getBytes()); + fout.write(json.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { LOG.error("Error while saving queries", e); diff --git a/presto-main/src/main/java/io/prestosql/seedstore/SeedStoreManager.java b/presto-main/src/main/java/io/prestosql/seedstore/SeedStoreManager.java index 2f4011036..9a8a11103 100644 --- a/presto-main/src/main/java/io/prestosql/seedstore/SeedStoreManager.java +++ b/presto-main/src/main/java/io/prestosql/seedstore/SeedStoreManager.java @@ -40,6 +40,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; @@ -437,7 +438,7 @@ public class SeedStoreManager while (retryTimes <= SEED_RETRY_TIMES && (seeds == null || seeds.size() == 0)); if (seeds == null || seeds.size() == 0) { - throw new PrestoException(SEED_STORE_FAILURE, String.format("add seed=%s to seed store failed after retry:%d", + throw new PrestoException(SEED_STORE_FAILURE, String.format(Locale.ROOT, "add seed=%s to seed store failed after retry:%d", seed.getLocation(), SEED_RETRY_TIMES)); } diff --git a/presto-main/src/main/java/io/prestosql/server/testing/TestingPrestoServer.java b/presto-main/src/main/java/io/prestosql/server/testing/TestingPrestoServer.java index 5ceffb86d..029117718 100755 --- a/presto-main/src/main/java/io/prestosql/server/testing/TestingPrestoServer.java +++ b/presto-main/src/main/java/io/prestosql/server/testing/TestingPrestoServer.java @@ -224,14 +224,14 @@ public class TestingPrestoServer this.baseDataDir = baseDataDir.orElseGet(TestingPrestoServer::tempDirectory); this.preserveData = baseDataDir.isPresent(); - properties = new HashMap<>(properties); - String coordinatorPort = properties.remove("http-server.http.port"); + Map propertiesMap = new HashMap<>(properties); + String coordinatorPort = propertiesMap.remove("http-server.http.port"); if (coordinatorPort == null) { coordinatorPort = "0"; } ImmutableMap.Builder serverProperties = ImmutableMap.builder() - .putAll(properties) + .putAll(propertiesMap) .put("coordinator", String.valueOf(coordinator)) .put("presto.version", "testversion") .put("task.concurrency", "4") diff --git a/presto-main/src/main/java/io/prestosql/snapshot/SnapshotStateId.java b/presto-main/src/main/java/io/prestosql/snapshot/SnapshotStateId.java index 28c0696f4..88d494f88 100644 --- a/presto-main/src/main/java/io/prestosql/snapshot/SnapshotStateId.java +++ b/presto-main/src/main/java/io/prestosql/snapshot/SnapshotStateId.java @@ -49,16 +49,16 @@ public class SnapshotStateId { String[] components = str.split(SLASH); // the 4 first components are queryId, snapshotId, stageId, and taskId, according to generateHierarchy - TaskId taskId = new TaskId(components[0], Integer.parseInt(components[2]), Integer.parseInt(components[3])); - long snapshotId = Long.parseLong(components[1]); + TaskId newTaskId = new TaskId(components[0], Integer.parseInt(components[2]), Integer.parseInt(components[3])); + long snapshotId1 = Long.parseLong(components[1]); List parts = Arrays.asList(components); - return new SnapshotStateId(snapshotId, taskId, parts); + return new SnapshotStateId(snapshotId1, newTaskId, parts); } public static SnapshotStateId forTaskComponent(long snapshotId, TaskContext taskContext, String component) { - TaskId taskId = taskContext.getTaskId(); - return new SnapshotStateId(snapshotId, taskId, component); + TaskId localTaskId = taskContext.getTaskId(); + return new SnapshotStateId(snapshotId, localTaskId, component); } public static SnapshotStateId forTaskComponent(long snapshotId, TaskId taskId, String component) @@ -69,10 +69,10 @@ public class SnapshotStateId public static SnapshotStateId forOperator(long snapshotId, OperatorContext operatorContext) { DriverContext driverContext = operatorContext.getDriverContext(); - TaskId taskId = driverContext.getTaskId(); + TaskId localTaskId = driverContext.getTaskId(); int pipelineId = driverContext.getPipelineContext().getPipelineId(); int driverId = driverContext.getDriverId(); - return new SnapshotStateId(snapshotId, taskId, pipelineId, driverId, operatorContext.getOperatorId()); + return new SnapshotStateId(snapshotId, localTaskId, pipelineId, driverId, operatorContext.getOperatorId()); } public static SnapshotStateId forOperator(long snapshotId, TaskId taskId, int pipelineId, int driverId, int operatorId) @@ -83,10 +83,10 @@ public class SnapshotStateId public static SnapshotStateId forDriverComponent(long snapshotId, OperatorContext operatorContext, String component) { DriverContext driverContext = operatorContext.getDriverContext(); - TaskId taskId = driverContext.getTaskId(); + TaskId localTaskId = driverContext.getTaskId(); int pipelineId = driverContext.getPipelineContext().getPipelineId(); int driverId = driverContext.getDriverId(); - return new SnapshotStateId(snapshotId, taskId, pipelineId, driverId, component); + return new SnapshotStateId(snapshotId, localTaskId, pipelineId, driverId, component); } public SnapshotStateId(long snapshotId, TaskId taskId, Object... parts) diff --git a/presto-main/src/main/java/io/prestosql/sql/planner/optimizations/joins/JoinGraph.java b/presto-main/src/main/java/io/prestosql/sql/planner/optimizations/joins/JoinGraph.java index 9c17f1f26..cecb10ce7 100644 --- a/presto-main/src/main/java/io/prestosql/sql/planner/optimizations/joins/JoinGraph.java +++ b/presto-main/src/main/java/io/prestosql/sql/planner/optimizations/joins/JoinGraph.java @@ -111,11 +111,11 @@ public class JoinGraph public JoinGraph withFilter(RowExpression expression) { - ImmutableList.Builder filters = ImmutableList.builder(); - filters.addAll(this.filters); - filters.add(expression); + ImmutableList.Builder rowExpressionBuilder = ImmutableList.builder(); + rowExpressionBuilder.addAll(this.filters); + rowExpressionBuilder.add(expression); - return new JoinGraph(nodes, edges, rootId, filters.build(), assignments); + return new JoinGraph(nodes, edges, rootId, rowExpressionBuilder.build(), assignments); } public List getFilters() @@ -187,12 +187,12 @@ public class JoinGraph checkState(!edges.containsKey(node.getId()), "Node [%s] appeared in two JoinGraphs", node); } - List nodes = ImmutableList.builder() + List planNodes = ImmutableList.builder() .addAll(this.nodes) .addAll(other.nodes) .build(); - ImmutableMultimap.Builder edges = ImmutableMultimap.builder() + ImmutableMultimap.Builder edgeBuilder = ImmutableMultimap.builder() .putAll(this.edges) .putAll(other.edges); @@ -209,11 +209,11 @@ public class JoinGraph PlanNode left = context.getSymbolSource(leftSymbol); PlanNode right = context.getSymbolSource(rightSymbol); - edges.put(left.getId(), new Edge(right, leftSymbol, rightSymbol)); - edges.put(right.getId(), new Edge(left, rightSymbol, leftSymbol)); + edgeBuilder.put(left.getId(), new Edge(right, leftSymbol, rightSymbol)); + edgeBuilder.put(right.getId(), new Edge(left, rightSymbol, leftSymbol)); } - return new JoinGraph(nodes, edges.build(), newRoot, joinedFilters, Optional.empty()); + return new JoinGraph(planNodes, edgeBuilder.build(), newRoot, joinedFilters, Optional.empty()); } private static class Builder diff --git a/presto-main/src/main/java/io/prestosql/sql/planner/sanity/PlanSanityChecker.java b/presto-main/src/main/java/io/prestosql/sql/planner/sanity/PlanSanityChecker.java index 2bd977671..72ecc2202 100644 --- a/presto-main/src/main/java/io/prestosql/sql/planner/sanity/PlanSanityChecker.java +++ b/presto-main/src/main/java/io/prestosql/sql/planner/sanity/PlanSanityChecker.java @@ -46,7 +46,6 @@ public final class PlanSanityChecker Stage.FINAL, new ValidateDependenciesChecker(), new NoDuplicatePlanNodeIdsChecker(), -// new SugarFreeChecker(), new TypeValidator(), new NoSubqueryExpressionLeftChecker(), new NoIdentifierLeftChecker(), diff --git a/presto-main/src/main/java/io/prestosql/sql/relational/optimizer/ExpressionOptimizer.java b/presto-main/src/main/java/io/prestosql/sql/relational/optimizer/ExpressionOptimizer.java index 6409e83eb..99b273876 100644 --- a/presto-main/src/main/java/io/prestosql/sql/relational/optimizer/ExpressionOptimizer.java +++ b/presto-main/src/main/java/io/prestosql/sql/relational/optimizer/ExpressionOptimizer.java @@ -89,8 +89,9 @@ public class ExpressionOptimizer } @Override - public RowExpression visitCall(CallExpression call, Void context) + public RowExpression visitCall(CallExpression inputCall, Void context) { + CallExpression call = inputCall; if (functionResolution.isCastFunction(call.getFunctionHandle())) { call = rewriteCast(call); } diff --git a/presto-main/src/main/java/io/prestosql/sql/rewrite/DescribeInputRewrite.java b/presto-main/src/main/java/io/prestosql/sql/rewrite/DescribeInputRewrite.java index f7a8ce553..bc1d07520 100644 --- a/presto-main/src/main/java/io/prestosql/sql/rewrite/DescribeInputRewrite.java +++ b/presto-main/src/main/java/io/prestosql/sql/rewrite/DescribeInputRewrite.java @@ -114,10 +114,10 @@ final class DescribeInputRewrite Analysis analysis = analyzer.analyze(statement, true); // get all parameters in query - List parameters = getParameters(statement); + List parameterList = getParameters(statement); // return the positions and types of all parameters - Row[] rows = parameters.stream().map(parameter -> createDescribeInputRow(parameter, analysis)).toArray(Row[]::new); + Row[] rows = parameterList.stream().map(parameter -> createDescribeInputRow(parameter, analysis)).toArray(Row[]::new); Optional limit = Optional.empty(); if (rows.length == 0) { rows = new Row[] {row(new NullLiteral(), new NullLiteral())}; diff --git a/presto-main/src/main/java/io/prestosql/sql/rewrite/StatementRewrite.java b/presto-main/src/main/java/io/prestosql/sql/rewrite/StatementRewrite.java index 8a064087b..c06079d3a 100644 --- a/presto-main/src/main/java/io/prestosql/sql/rewrite/StatementRewrite.java +++ b/presto-main/src/main/java/io/prestosql/sql/rewrite/StatementRewrite.java @@ -51,12 +51,13 @@ public final class StatementRewrite CubeManager cubeManager, SqlParser parser, Optional queryExplainer, - Statement node, + Statement inputNode, List parameters, AccessControl accessControl, WarningCollector warningCollector, HeuristicIndexerManager heuristicIndexerManager) { + Statement node = inputNode; for (Rewrite rewrite : REWRITES) { node = requireNonNull(rewrite.rewrite(session, metadata, cubeManager, parser, queryExplainer, node, parameters, accessControl, warningCollector, heuristicIndexerManager), "Statement rewrite returned null"); diff --git a/presto-main/src/main/java/io/prestosql/statestore/EmbeddedStateStoreLauncher.java b/presto-main/src/main/java/io/prestosql/statestore/EmbeddedStateStoreLauncher.java index 3c1420b41..61a1ec50f 100644 --- a/presto-main/src/main/java/io/prestosql/statestore/EmbeddedStateStoreLauncher.java +++ b/presto-main/src/main/java/io/prestosql/statestore/EmbeddedStateStoreLauncher.java @@ -251,6 +251,7 @@ public class EmbeddedStateStoreLauncher Thread.sleep((long) (new SecureRandom().nextDouble() * 1000)); } catch (InterruptedException e) { + LOG.debug("Error message: " + e.getMessage()); } boolean registered = false; diff --git a/presto-main/src/main/java/io/prestosql/transaction/InMemoryTransactionManager.java b/presto-main/src/main/java/io/prestosql/transaction/InMemoryTransactionManager.java index d9c904a54..276b59f66 100644 --- a/presto-main/src/main/java/io/prestosql/transaction/InMemoryTransactionManager.java +++ b/presto-main/src/main/java/io/prestosql/transaction/InMemoryTransactionManager.java @@ -443,8 +443,8 @@ public class InMemoryTransactionManager public boolean isExpired(Duration idleTimeout) { - Long idleStartTime = this.idleStartTime.get(); - return idleStartTime != null && Duration.nanosSince(idleStartTime).compareTo(idleTimeout) > 0; + Long localIdleStartTime = this.idleStartTime.get(); + return localIdleStartTime != null && Duration.nanosSince(localIdleStartTime).compareTo(idleTimeout) > 0; } public void checkOpenTransaction() @@ -513,8 +513,8 @@ public class InMemoryTransactionManager { checkOpenTransaction(); - CatalogMetadata catalogMetadata = this.catalogMetadata.get(catalogName); - if (catalogMetadata == null) { + CatalogMetadata localCatalogMetadata = this.catalogMetadata.get(catalogName); + if (localCatalogMetadata == null) { Catalog catalog = catalogsByName.get(catalogName); verify(catalog != null, "Unknown catalog: %s", catalogName); Connector connector = catalog.getConnector(catalogName); @@ -523,7 +523,7 @@ public class InMemoryTransactionManager ConnectorTransactionMetadata informationSchema = createConnectorTransactionMetadata(catalog.getInformationSchemaId(), catalog); ConnectorTransactionMetadata systemTables = createConnectorTransactionMetadata(catalog.getSystemTablesId(), catalog); - catalogMetadata = new CatalogMetadata( + localCatalogMetadata = new CatalogMetadata( metadata.getCatalogName(), metadata.getConnectorMetadata(), metadata.getTransactionHandle(), @@ -535,11 +535,11 @@ public class InMemoryTransactionManager systemTables.getTransactionHandle(), connector.getCapabilities()); - this.catalogMetadata.put(catalog.getConnectorCatalogName(), catalogMetadata); - this.catalogMetadata.put(catalog.getInformationSchemaId(), catalogMetadata); - this.catalogMetadata.put(catalog.getSystemTablesId(), catalogMetadata); + this.catalogMetadata.put(catalog.getConnectorCatalogName(), localCatalogMetadata); + this.catalogMetadata.put(catalog.getInformationSchemaId(), localCatalogMetadata); + this.catalogMetadata.put(catalog.getSystemTablesId(), localCatalogMetadata); } - return catalogMetadata; + return localCatalogMetadata; } public synchronized ConnectorTransactionMetadata createConnectorTransactionMetadata(CatalogName catalogName, Catalog catalog) @@ -676,12 +676,12 @@ public class InMemoryTransactionManager .orElse(new Duration(0, MILLISECONDS)); // dereferencing this field is safe because the field is atomic - @SuppressWarnings("FieldAccessNotGuarded") Optional writtenConnectorId = Optional.ofNullable(this.writtenConnectorId.get()); + @SuppressWarnings("FieldAccessNotGuarded") Optional localWrittenConnectorId = Optional.ofNullable(this.writtenConnectorId.get()); // copying the key set is safe here because the map is concurrent @SuppressWarnings("FieldAccessNotGuarded") List catalogNames = ImmutableList.copyOf(connectorIdToMetadata.keySet()); - return new TransactionInfo(transactionId, isolationLevel, readOnly, autoCommitContext, createTime, idleTime, catalogNames, writtenConnectorId); + return new TransactionInfo(transactionId, isolationLevel, readOnly, autoCommitContext, createTime, idleTime, catalogNames, localWrittenConnectorId); } private static class ConnectorTransactionMetadata diff --git a/presto-main/src/main/java/io/prestosql/type/setdigest/SetDigest.java b/presto-main/src/main/java/io/prestosql/type/setdigest/SetDigest.java index b3bca35c4..db8203848 100644 --- a/presto-main/src/main/java/io/prestosql/type/setdigest/SetDigest.java +++ b/presto-main/src/main/java/io/prestosql/type/setdigest/SetDigest.java @@ -86,20 +86,20 @@ public class SetDigest int hllLength = input.readInt(); Slice serializedHll = Slices.allocate(hllLength); input.readBytes(serializedHll, hllLength); - HyperLogLog hll = HyperLogLog.newInstance(serializedHll); + HyperLogLog hyperLogLog = HyperLogLog.newInstance(serializedHll); - Long2ShortRBTreeMap minhash = new Long2ShortRBTreeMap(); - int maxHashes = input.readInt(); + Long2ShortRBTreeMap long2ShortRBTreeMap = new Long2ShortRBTreeMap(); + int readInt = input.readInt(); int minhashLength = input.readInt(); // The values are stored after the keys SliceInput valuesInput = serialized.getInput(); valuesInput.setPosition(input.position() + minhashLength * SIZE_OF_LONG); for (int i = 0; i < minhashLength; i++) { - minhash.put(input.readLong(), valuesInput.readShort()); + long2ShortRBTreeMap.put(input.readLong(), valuesInput.readShort()); } - return new SetDigest(maxHashes, hll, minhash); + return new SetDigest(readInt, hyperLogLog, long2ShortRBTreeMap); } public Slice serialize() diff --git a/presto-main/src/main/java/io/prestosql/utils/HeuristicIndexUtils.java b/presto-main/src/main/java/io/prestosql/utils/HeuristicIndexUtils.java index 63cadd65d..8b1d19a60 100644 --- a/presto-main/src/main/java/io/prestosql/utils/HeuristicIndexUtils.java +++ b/presto-main/src/main/java/io/prestosql/utils/HeuristicIndexUtils.java @@ -82,8 +82,7 @@ public class HeuristicIndexUtils private static String parsePartitionValue(String rightVal) { - // quoted value - // e.g. 'value' + // quoted value, e.g. 'value' if (rightVal.matches("^'.*'$")) { return rightVal.substring(1, rightVal.length() - 1); } @@ -98,8 +97,7 @@ public class HeuristicIndexUtils private static String parsePartitionName(String leftVal) { - // quoted - // e.g. "a" + // quoted, e.g. "a" if (leftVal.startsWith("\"")) { return leftVal.substring(1, leftVal.length() - 1).trim(); } diff --git a/presto-main/src/main/java/io/prestosql/utils/RangeUtil.java b/presto-main/src/main/java/io/prestosql/utils/RangeUtil.java index a31d6f84e..89002e8fa 100644 --- a/presto-main/src/main/java/io/prestosql/utils/RangeUtil.java +++ b/presto-main/src/main/java/io/prestosql/utils/RangeUtil.java @@ -62,12 +62,10 @@ public class RangeUtil return -1; } - /* get the index of middle element - of arr[low..high]*/ - mid = (low + high) / 2; /* low + (high - low)/2 */ + // get the index of middle element of arr[low..high] + mid = (low + high) / 2; - /* If x is same as middle element, - then return mid */ + // If x is same as middle element, then return mid if (getOrder(arr.get(mid)) == x) { return mid; } @@ -97,8 +95,7 @@ public class RangeUtil } } - /* Function to get index of floor of x in - arr[low..high] */ + // Function to get index of floor of x in arr[low..high] public static int floorSearch(List arr, int low, int high, long x) throws Exception { diff --git a/presto-main/src/test/java/io/prestosql/block/AbstractTestBlock.java b/presto-main/src/test/java/io/prestosql/block/AbstractTestBlock.java index 14b1d5fd6..a9bc27001 100644 --- a/presto-main/src/test/java/io/prestosql/block/AbstractTestBlock.java +++ b/presto-main/src/test/java/io/prestosql/block/AbstractTestBlock.java @@ -14,6 +14,7 @@ package io.prestosql.block; import com.google.common.collect.ImmutableList; +import io.airlift.log.Logger; import io.airlift.slice.DynamicSliceOutput; import io.airlift.slice.Slice; import io.airlift.slice.SliceOutput; @@ -57,6 +58,7 @@ import static org.testng.Assert.fail; @Test public abstract class AbstractTestBlock { + private static final Logger LOG = Logger.get(AbstractTestBlock.class); private static final Metadata METADATA = createTestMetadataManager(); protected void assertBlock(Block block, Supplier newBlockBuilder, T[] expectedValues) @@ -78,12 +80,14 @@ public abstract class AbstractTestBlock fail("expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { + LOG.info("Error message: " + expected.getStackTrace()); } try { block.isNull(block.getPositionCount()); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { + LOG.info("Error message: " + expected.getStackTrace()); } } diff --git a/presto-main/src/test/java/io/prestosql/discovery/server/TestHetuInMemoryStore.java b/presto-main/src/test/java/io/prestosql/discovery/server/TestHetuInMemoryStore.java index 60f3f8336..cb8fec868 100644 --- a/presto-main/src/test/java/io/prestosql/discovery/server/TestHetuInMemoryStore.java +++ b/presto-main/src/test/java/io/prestosql/discovery/server/TestHetuInMemoryStore.java @@ -21,6 +21,8 @@ import io.airlift.discovery.store.Version; import io.airlift.units.Duration; import org.testng.annotations.Test; +import java.nio.charset.StandardCharsets; + import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; @@ -35,9 +37,9 @@ public class TestHetuInMemoryStore .setStoreCacheTtl(Duration.valueOf("5s")); HetuInMemoryStore inMemoryStore = new HetuInMemoryStore(new ConflictResolver(), discoveryConfig); - Entry entry = new Entry("key".getBytes(), "value".getBytes(), new Version(1L), 0L, null); + Entry entry = new Entry("key".getBytes(StandardCharsets.UTF_8), "value".getBytes(), new Version(1L), 0L, null); inMemoryStore.put(entry); - Entry check = inMemoryStore.get("key".getBytes()); + Entry check = inMemoryStore.get("key".getBytes(StandardCharsets.UTF_8)); assertFalse(check.equals(entry)); assertEquals((long) check.getMaxAgeInMs(), 10000L); } @@ -50,9 +52,9 @@ public class TestHetuInMemoryStore .setStoreCacheTtl(Duration.valueOf("5s")); HetuInMemoryStore inMemoryStore = new HetuInMemoryStore(new ConflictResolver(), discoveryConfig); - Entry entry = new Entry("key".getBytes(), "value".getBytes(), new Version(1L), 0L, 5000L); + Entry entry = new Entry("key".getBytes(StandardCharsets.UTF_8), "value".getBytes(), new Version(1L), 0L, 5000L); inMemoryStore.put(entry); - Entry check = inMemoryStore.get("key".getBytes()); + Entry check = inMemoryStore.get("key".getBytes(StandardCharsets.UTF_8)); assertTrue(check.equals(entry)); assertEquals((long) check.getMaxAgeInMs(), 5000L); } diff --git a/presto-main/src/test/java/io/prestosql/execution/executor/TaskExecutorSimulator.java b/presto-main/src/test/java/io/prestosql/execution/executor/TaskExecutorSimulator.java index 0ee9f9cc7..dfee880c7 100644 --- a/presto-main/src/test/java/io/prestosql/execution/executor/TaskExecutorSimulator.java +++ b/presto-main/src/test/java/io/prestosql/execution/executor/TaskExecutorSimulator.java @@ -298,6 +298,7 @@ public class TaskExecutorSimulator (int) splitQueue.getSelectedCountLevel4().getOneMinute().getRate()); } catch (Exception ignored) { + //could be ignored } }, 1, 1, SECONDS); } diff --git a/presto-main/src/test/java/io/prestosql/execution/executor/TestTaskExecutor.java b/presto-main/src/test/java/io/prestosql/execution/executor/TestTaskExecutor.java index d6eefe908..e330eaf7c 100644 --- a/presto-main/src/test/java/io/prestosql/execution/executor/TestTaskExecutor.java +++ b/presto-main/src/test/java/io/prestosql/execution/executor/TestTaskExecutor.java @@ -286,6 +286,7 @@ public class TestTaskExecutor catch (IllegalStateException e) { // under high concurrency sometimes the deregister call can occur after completion // this is not a real problem + // could be ignored } taskExecutor.removeTask(taskHandles[0]); taskExecutor.removeTask(taskHandles[1]); diff --git a/presto-main/src/test/java/io/prestosql/heuristicindex/TestSplitFiltering.java b/presto-main/src/test/java/io/prestosql/heuristicindex/TestSplitFiltering.java index 6294d0b82..4b636d2e8 100644 --- a/presto-main/src/test/java/io/prestosql/heuristicindex/TestSplitFiltering.java +++ b/presto-main/src/test/java/io/prestosql/heuristicindex/TestSplitFiltering.java @@ -82,7 +82,6 @@ public class TestSplitFiltering PropertyService.setProperty(HetuConstant.FILTER_CACHE_LOADING_DELAY, new Duration(5000, TimeUnit.MILLISECONDS)); PropertyService.setProperty(HetuConstant.FILTER_CACHE_LOADING_THREADS, 2L); - //ComparisonExpression expr = new ComparisonExpression(ComparisonExpression.Operator.EQUAL, new SymbolReference("a"), new StringLiteral("test_value")); RowExpression expression = PlanBuilder.comparison(OperatorType.EQUAL, new VariableReferenceExpression("a", VarcharType.VARCHAR), new ConstantExpression(utf8Slice("test_value"), VarcharType.VARCHAR)); SqlStageExecution stage = TestUtil.getTestStage(expression); diff --git a/presto-main/src/test/java/io/prestosql/operator/aggregation/groupby/AggregationTestInput.java b/presto-main/src/test/java/io/prestosql/operator/aggregation/groupby/AggregationTestInput.java index 3d76added..1aff3150c 100644 --- a/presto-main/src/test/java/io/prestosql/operator/aggregation/groupby/AggregationTestInput.java +++ b/presto-main/src/test/java/io/prestosql/operator/aggregation/groupby/AggregationTestInput.java @@ -78,17 +78,17 @@ public class AggregationTestInput private Page[] getPages() { - Page[] pages = this.pages; + Page[] localPages = this.pages; if (isReversed) { - pages = AggregationTestUtils.reverseColumns(pages); + localPages = AggregationTestUtils.reverseColumns(localPages); } if (offset > 0) { - pages = AggregationTestUtils.offsetColumns(pages, offset); + localPages = AggregationTestUtils.offsetColumns(localPages, offset); } - return pages; + return localPages; } public GroupedAccumulator createGroupedAccumulator() diff --git a/presto-main/src/test/java/io/prestosql/operator/project/TestDictionaryAwarePageFilter.java b/presto-main/src/test/java/io/prestosql/operator/project/TestDictionaryAwarePageFilter.java index 84a70d190..9b3c86de1 100644 --- a/presto-main/src/test/java/io/prestosql/operator/project/TestDictionaryAwarePageFilter.java +++ b/presto-main/src/test/java/io/prestosql/operator/project/TestDictionaryAwarePageFilter.java @@ -179,8 +179,9 @@ public class TestDictionaryAwarePageFilter return new DictionaryAwarePageFilter(new TestDictionaryFilter(filterRange, expectedType)); } - private static void testFilter(DictionaryAwarePageFilter filter, Block block, boolean filterRange) + private static void testFilter(DictionaryAwarePageFilter filter, Block inputBlock, boolean filterRange) { + Block block = inputBlock; IntSet actualSelectedPositions = toSet(filter.filter(null, new Page(block))); block = block.getLoadedBlock(); @@ -236,7 +237,7 @@ public class TestDictionaryAwarePageFilter public TestDictionaryFilter(boolean filterRange) { - this.filterRange = filterRange; + this(filterRange, null); } public TestDictionaryFilter(boolean filterRange, Class expectedType) diff --git a/presto-main/src/test/java/io/prestosql/operator/spiller/BenchmarkBinaryFileSpiller.java b/presto-main/src/test/java/io/prestosql/operator/spiller/BenchmarkBinaryFileSpiller.java index 9c8e7d560..d23724abd 100644 --- a/presto-main/src/test/java/io/prestosql/operator/spiller/BenchmarkBinaryFileSpiller.java +++ b/presto-main/src/test/java/io/prestosql/operator/spiller/BenchmarkBinaryFileSpiller.java @@ -143,7 +143,7 @@ public class BenchmarkBinaryFileSpiller private List createInputPages() { - ImmutableList.Builder pages = ImmutableList.builder(); + ImmutableList.Builder builder = ImmutableList.builder(); PageBuilder pageBuilder = new PageBuilder(TYPES); LineItemGenerator lineItemGenerator = new LineItemGenerator(1, 1, 1); @@ -159,11 +159,11 @@ public class BenchmarkBinaryFileSpiller VARCHAR.writeString(pageBuilder.getBlockBuilder(3), lineItem.getReturnFlag()); DOUBLE.writeDouble(pageBuilder.getBlockBuilder(4), lineItem.getExtendedPrice()); } - pages.add(pageBuilder.build()); + builder.add(pageBuilder.build()); pageBuilder.reset(); } - return pages.build(); + return builder.build(); } public List getPages() diff --git a/presto-main/src/test/java/io/prestosql/server/MockHttpServletRequest.java b/presto-main/src/test/java/io/prestosql/server/MockHttpServletRequest.java index 42f797953..0d7ad03f5 100644 --- a/presto-main/src/test/java/io/prestosql/server/MockHttpServletRequest.java +++ b/presto-main/src/test/java/io/prestosql/server/MockHttpServletRequest.java @@ -86,8 +86,8 @@ public class MockHttpServletRequest @Override public String getHeader(String name) { - Enumeration headers = getHeaders(name); - return headers.hasMoreElements() ? headers.nextElement() : null; + Enumeration localHeaders = getHeaders(name); + return localHeaders.hasMoreElements() ? localHeaders.nextElement() : null; } @Override diff --git a/presto-main/src/test/java/io/prestosql/spiller/TestBinaryFileSpiller.java b/presto-main/src/test/java/io/prestosql/spiller/TestBinaryFileSpiller.java index 74fab5c02..a5212b929 100644 --- a/presto-main/src/test/java/io/prestosql/spiller/TestBinaryFileSpiller.java +++ b/presto-main/src/test/java/io/prestosql/spiller/TestBinaryFileSpiller.java @@ -68,7 +68,12 @@ public class TestBinaryFileSpiller Metadata metadata = createTestMetadataManager(); spillerStats = new SpillerStats(); FeaturesConfig featuresConfig = new FeaturesConfig(); - featuresConfig.setSpillerSpillPaths(spillPath.getAbsolutePath()); + try { + featuresConfig.setSpillerSpillPaths(spillPath.getCanonicalPath()); + } + catch (IOException e) { + System.out.println(e.getStackTrace()); + } featuresConfig.setSpillMaxUsedSpaceThreshold(1.0); NodeSpillConfig nodeSpillConfig = new NodeSpillConfig(); singleStreamSpillerFactory = new FileSingleStreamSpillerFactory(metadata, spillerStats, featuresConfig, nodeSpillConfig); diff --git a/presto-main/src/test/java/io/prestosql/spiller/TestGenericPartitioningSpiller.java b/presto-main/src/test/java/io/prestosql/spiller/TestGenericPartitioningSpiller.java index 396d15abf..f531f51e3 100644 --- a/presto-main/src/test/java/io/prestosql/spiller/TestGenericPartitioningSpiller.java +++ b/presto-main/src/test/java/io/prestosql/spiller/TestGenericPartitioningSpiller.java @@ -173,6 +173,7 @@ public class TestGenericPartitioningSpiller } catch (UncheckedIOException ignored) { // expected + // could be ignored } } diff --git a/presto-main/src/test/java/io/prestosql/sql/TestExpressionInterpreter.java b/presto-main/src/test/java/io/prestosql/sql/TestExpressionInterpreter.java index 64656ccbf..fc098dc36 100644 --- a/presto-main/src/test/java/io/prestosql/sql/TestExpressionInterpreter.java +++ b/presto-main/src/test/java/io/prestosql/sql/TestExpressionInterpreter.java @@ -1484,6 +1484,8 @@ public class TestExpressionInterpreter return 12345L; case "bound_decimal_long": return Decimals.encodeUnscaledValue(new BigInteger("12345678901234567890123")); + default: + break; } return toSymbolReference(symbol); diff --git a/presto-main/src/test/java/io/prestosql/sql/planner/TestLogicalPlanner.java b/presto-main/src/test/java/io/prestosql/sql/planner/TestLogicalPlanner.java index 3fd2907ec..72810753e 100644 --- a/presto-main/src/test/java/io/prestosql/sql/planner/TestLogicalPlanner.java +++ b/presto-main/src/test/java/io/prestosql/sql/planner/TestLogicalPlanner.java @@ -466,7 +466,7 @@ public class TestLogicalPlanner @Test public void testSubqueryPruning() { - List subqueries = QueryTemplate.parameter("subquery").of( + List subqueries = QueryTemplate.parameter("subquery").ofStringList( "orderkey IN (SELECT orderkey FROM lineitem WHERE orderkey % 2 = 0)", "EXISTS(SELECT orderkey FROM lineitem WHERE orderkey % 2 = 0)", "0 = (SELECT orderkey FROM lineitem WHERE orderkey % 2 = 0)"); diff --git a/presto-main/src/test/java/io/prestosql/sql/planner/iterative/rule/test/RuleAssert.java b/presto-main/src/test/java/io/prestosql/sql/planner/iterative/rule/test/RuleAssert.java index d973a3f03..6fb2cdd10 100644 --- a/presto-main/src/test/java/io/prestosql/sql/planner/iterative/rule/test/RuleAssert.java +++ b/presto-main/src/test/java/io/prestosql/sql/planner/iterative/rule/test/RuleAssert.java @@ -131,13 +131,13 @@ public class RuleAssert public void matches(PlanMatchPattern pattern) { RuleApplication ruleApplication = applyRule(); - TypeProvider types = ruleApplication.types; + TypeProvider typeProvider = ruleApplication.types; if (!ruleApplication.wasRuleApplied()) { fail(format( "%s did not fire for:\n%s", rule.getClass().getName(), - formatPlan(plan, types))); + formatPlan(plan, typeProvider))); } PlanNode actual = ruleApplication.getTransformedPlan(); @@ -146,7 +146,7 @@ public class RuleAssert fail(format( "%s: rule fired but return the original plan:\n%s", rule.getClass().getName(), - formatPlan(plan, types))); + formatPlan(plan, typeProvider))); } if (!ImmutableSet.copyOf(plan.getOutputSymbols()).equals(ImmutableSet.copyOf(actual.getOutputSymbols()))) { @@ -160,7 +160,7 @@ public class RuleAssert } inTransaction(session -> { - assertPlan(session, metadata, ruleApplication.statsProvider, new Plan(actual, types, StatsAndCosts.empty()), ruleApplication.lookup, pattern); + assertPlan(session, metadata, ruleApplication.statsProvider, new Plan(actual, typeProvider, StatsAndCosts.empty()), ruleApplication.lookup, pattern); return null; }); } diff --git a/presto-main/src/test/java/io/prestosql/sql/planner/sanity/TestValidateAggregationsWithDefaultValues.java b/presto-main/src/test/java/io/prestosql/sql/planner/sanity/TestValidateAggregationsWithDefaultValues.java index 34d52c185..0aa588c10 100644 --- a/presto-main/src/test/java/io/prestosql/sql/planner/sanity/TestValidateAggregationsWithDefaultValues.java +++ b/presto-main/src/test/java/io/prestosql/sql/planner/sanity/TestValidateAggregationsWithDefaultValues.java @@ -112,18 +112,18 @@ public class TestValidateAggregationsWithDefaultValues @Test public void testGloballyDistributedFinalAggregationSeparatedFromPartialAggregationByRemoteHashExchange() { - Symbol symbol = new Symbol("symbol"); + Symbol symbolObj = new Symbol("symbol"); PlanNode root = builder.aggregation( af -> af.step(FINAL) - .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) + .groupingSets(groupingSets(ImmutableList.of(symbolObj), 2, ImmutableSet.of(0))) .source(builder.exchange(e -> e .type(REPARTITION) .scope(REMOTE) - .fixedHashDistributionParitioningScheme(ImmutableList.of(symbol), ImmutableList.of(symbol)) - .addInputsSet(symbol) + .fixedHashDistributionParitioningScheme(ImmutableList.of(symbolObj), ImmutableList.of(symbolObj)) + .addInputsSet(symbolObj) .addSource(builder.aggregation(ap -> ap .step(PARTIAL) - .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) + .groupingSets(groupingSets(ImmutableList.of(symbolObj), 2, ImmutableSet.of(0))) .source(tableScanNode)))))); validatePlan(root, false); } @@ -131,18 +131,18 @@ public class TestValidateAggregationsWithDefaultValues @Test public void testSingleNodeFinalAggregationSeparatedFromPartialAggregationByLocalHashExchange() { - Symbol symbol = new Symbol("symbol"); + Symbol symbolObj = new Symbol("symbol"); PlanNode root = builder.aggregation( af -> af.step(FINAL) - .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) + .groupingSets(groupingSets(ImmutableList.of(symbolObj), 2, ImmutableSet.of(0))) .source(builder.exchange(e -> e .type(REPARTITION) .scope(LOCAL) - .fixedHashDistributionParitioningScheme(ImmutableList.of(symbol), ImmutableList.of(symbol)) - .addInputsSet(symbol) + .fixedHashDistributionParitioningScheme(ImmutableList.of(symbolObj), ImmutableList.of(symbolObj)) + .addInputsSet(symbolObj) .addSource(builder.aggregation(ap -> ap .step(PARTIAL) - .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) + .groupingSets(groupingSets(ImmutableList.of(symbolObj), 2, ImmutableSet.of(0))) .source(tableScanNode)))))); validatePlan(root, true); } @@ -150,20 +150,20 @@ public class TestValidateAggregationsWithDefaultValues @Test public void testWithPartialAggregationBelowJoin() { - Symbol symbol = new Symbol("symbol"); + Symbol symbolObj = new Symbol("symbol"); PlanNode root = builder.aggregation( af -> af.step(FINAL) - .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) + .groupingSets(groupingSets(ImmutableList.of(symbolObj), 2, ImmutableSet.of(0))) .source(builder.join( INNER, builder.exchange(e -> e .type(REPARTITION) .scope(LOCAL) - .fixedHashDistributionParitioningScheme(ImmutableList.of(symbol), ImmutableList.of(symbol)) - .addInputsSet(symbol) + .fixedHashDistributionParitioningScheme(ImmutableList.of(symbolObj), ImmutableList.of(symbolObj)) + .addInputsSet(symbolObj) .addSource(builder.aggregation(ap -> ap .step(PARTIAL) - .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) + .groupingSets(groupingSets(ImmutableList.of(symbolObj), 2, ImmutableSet.of(0))) .source(tableScanNode)))), builder.values()))); validatePlan(root, true); @@ -172,15 +172,15 @@ public class TestValidateAggregationsWithDefaultValues @Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Final aggregation with default value not separated from partial aggregation by local hash exchange") public void testWithPartialAggregationBelowJoinWithoutSeparatingExchange() { - Symbol symbol = new Symbol("symbol"); + Symbol symbolObj = new Symbol("symbol"); PlanNode root = builder.aggregation( af -> af.step(FINAL) - .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) + .groupingSets(groupingSets(ImmutableList.of(symbolObj), 2, ImmutableSet.of(0))) .source(builder.join( INNER, builder.aggregation(ap -> ap .step(PARTIAL) - .groupingSets(groupingSets(ImmutableList.of(symbol), 2, ImmutableSet.of(0))) + .groupingSets(groupingSets(ImmutableList.of(symbolObj), 2, ImmutableSet.of(0))) .source(tableScanNode)), builder.values()))); validatePlan(root, true); diff --git a/presto-main/src/test/java/io/prestosql/statestore/TestStateFetcher.java b/presto-main/src/test/java/io/prestosql/statestore/TestStateFetcher.java index 4952e131a..1f3da9d65 100644 --- a/presto-main/src/test/java/io/prestosql/statestore/TestStateFetcher.java +++ b/presto-main/src/test/java/io/prestosql/statestore/TestStateFetcher.java @@ -35,6 +35,7 @@ import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -142,7 +143,7 @@ public class TestStateFetcher { String mockData; try (InputStream in = new FileInputStream(file)) { - InputStreamReader isReader = new InputStreamReader(in); + InputStreamReader isReader = new InputStreamReader(in, StandardCharsets.UTF_8); BufferedReader reader = new BufferedReader(isReader); StringBuilder stringBuilder = new StringBuilder(); String tempString; diff --git a/presto-main/src/test/java/io/prestosql/tests/QueryTemplate.java b/presto-main/src/test/java/io/prestosql/tests/QueryTemplate.java index 5f73013ce..29afc5a18 100644 --- a/presto-main/src/test/java/io/prestosql/tests/QueryTemplate.java +++ b/presto-main/src/test/java/io/prestosql/tests/QueryTemplate.java @@ -158,7 +158,7 @@ public class QueryTemplate return new Parameter(key, value); } - public List of(String... values) + public List ofStringList(String... values) { return Arrays.stream(values) .map(this::of) diff --git a/presto-main/src/test/java/io/prestosql/util/TestAutoCloseableCloser.java b/presto-main/src/test/java/io/prestosql/util/TestAutoCloseableCloser.java index 318014065..0feb7825b 100644 --- a/presto-main/src/test/java/io/prestosql/util/TestAutoCloseableCloser.java +++ b/presto-main/src/test/java/io/prestosql/util/TestAutoCloseableCloser.java @@ -80,6 +80,7 @@ public class TestAutoCloseableCloser closer.close(); } catch (Throwable ignored) { + // could be ignored } for (TestAutoCloseable closeable : closeables) { assertTrue(closeable.isClosed()); diff --git a/presto-matching/src/main/java/io/prestosql/matching/pattern/FilterPattern.java b/presto-matching/src/main/java/io/prestosql/matching/pattern/FilterPattern.java index 18a31bbf0..f045a4858 100644 --- a/presto-matching/src/main/java/io/prestosql/matching/pattern/FilterPattern.java +++ b/presto-matching/src/main/java/io/prestosql/matching/pattern/FilterPattern.java @@ -44,9 +44,9 @@ public class FilterPattern public Stream accept(Object object, Captures captures, C context) { //TODO remove cast - BiPredicate predicate = (BiPredicate) this.predicate; + BiPredicate biPredicate = (BiPredicate) this.predicate; return Stream.of(Match.of(captures)) - .filter(match -> predicate.test((T) object, context)); + .filter(match -> biPredicate.test((T) object, context)); } @Override diff --git a/presto-matching/src/test/java/io/prestosql/matching/example/rel/ProjectNode.java b/presto-matching/src/test/java/io/prestosql/matching/example/rel/ProjectNode.java index 879492bd8..15fb98e24 100644 --- a/presto-matching/src/test/java/io/prestosql/matching/example/rel/ProjectNode.java +++ b/presto-matching/src/test/java/io/prestosql/matching/example/rel/ProjectNode.java @@ -23,6 +23,7 @@ public class ProjectNode this.source = source; } + @Override public RelNode getSource() { return source; diff --git a/presto-memory/src/main/java/io/prestosql/plugin/memory/statistics/StatisticsUtils.java b/presto-memory/src/main/java/io/prestosql/plugin/memory/statistics/StatisticsUtils.java index 735fd6512..11009d83f 100644 --- a/presto-memory/src/main/java/io/prestosql/plugin/memory/statistics/StatisticsUtils.java +++ b/presto-memory/src/main/java/io/prestosql/plugin/memory/statistics/StatisticsUtils.java @@ -170,7 +170,7 @@ public class StatisticsUtils { ColumnStatisticsData.Builder columnStatBuilder = ColumnStatisticsData.builder(); - // MIN_VALUE, MAX_VALUE + // MIN VALUE, MAX VALUE // We ask the engine to compute either both or neither verify(stats.containsKey(MIN_VALUE) == stats.containsKey(MAX_VALUE)); if (stats.containsKey(MIN_VALUE)) { diff --git a/presto-mysql/src/main/java/io/prestosql/plugin/mysql/MySqlClient.java b/presto-mysql/src/main/java/io/prestosql/plugin/mysql/MySqlClient.java index 12016ff64..68db3fe19 100644 --- a/presto-mysql/src/main/java/io/prestosql/plugin/mysql/MySqlClient.java +++ b/presto-mysql/src/main/java/io/prestosql/plugin/mysql/MySqlClient.java @@ -258,8 +258,9 @@ public class MySqlClient } @Override - public void renameColumn(JdbcIdentity identity, JdbcTableHandle handle, JdbcColumnHandle jdbcColumn, String newColumnName) + public void renameColumn(JdbcIdentity identity, JdbcTableHandle handle, JdbcColumnHandle jdbcColumn, String inputNewColumnName) { + String newColumnName = inputNewColumnName; try (Connection connection = connectionFactory.openConnection(identity)) { DatabaseMetaData metadata = connection.getMetaData(); if (metadata.storesUpperCaseIdentifiers()) { @@ -392,7 +393,7 @@ public class MySqlClient byte[] in = slice.getBytes(); SliceOutput dynamicSliceOutput = new DynamicSliceOutput(in.length); SORTED_MAPPER.writeValue((OutputStream) dynamicSliceOutput, SORTED_MAPPER.readValue(parser, Object.class)); - // nextToken() returns null if the input is parsed correctly, + // the function nextToken() returns null if the input is parsed correctly, // but will throw an exception if there are trailing characters. parser.nextToken(); return dynamicSliceOutput.slice(); diff --git a/presto-mysql/src/main/java/io/prestosql/plugin/mysql/optimization/function/MysqlExternalFunctionHub.java b/presto-mysql/src/main/java/io/prestosql/plugin/mysql/optimization/function/MysqlExternalFunctionHub.java index cf37f1ef6..22d76f1c8 100644 --- a/presto-mysql/src/main/java/io/prestosql/plugin/mysql/optimization/function/MysqlExternalFunctionHub.java +++ b/presto-mysql/src/main/java/io/prestosql/plugin/mysql/optimization/function/MysqlExternalFunctionHub.java @@ -44,6 +44,7 @@ public class MysqlExternalFunctionHub return jdbcConfig.getConnectorRegistryFunctionNamespace(); } + @Override public Set getExternalFunctions() { return ImmutableSet.builder() diff --git a/presto-mysql/src/test/java/io/prestosql/plugin/mysql/DockerizedMySqlServer.java b/presto-mysql/src/test/java/io/prestosql/plugin/mysql/DockerizedMySqlServer.java index f01f1e163..133bb50b8 100644 --- a/presto-mysql/src/test/java/io/prestosql/plugin/mysql/DockerizedMySqlServer.java +++ b/presto-mysql/src/test/java/io/prestosql/plugin/mysql/DockerizedMySqlServer.java @@ -54,8 +54,7 @@ public class DockerizedMySqlServer } catch (Exception e) { System.out.println("## Docker environment not properly set up. Skip test. ##"); - System.out.println("Error message:"); - e.printStackTrace(); + System.out.println("Error message: " + e.getStackTrace()); throw new SkipException("Docker environment not initialized for tests"); } } diff --git a/presto-mysql/src/test/java/io/prestosql/plugin/mysql/MySqlQueryRunner.java b/presto-mysql/src/test/java/io/prestosql/plugin/mysql/MySqlQueryRunner.java index 614c54b4c..b3283cd8b 100644 --- a/presto-mysql/src/test/java/io/prestosql/plugin/mysql/MySqlQueryRunner.java +++ b/presto-mysql/src/test/java/io/prestosql/plugin/mysql/MySqlQueryRunner.java @@ -89,9 +89,10 @@ public final class MySqlQueryRunner } } - public static QueryRunner createMySqlQueryRunner(String jdbcUrl, Map connectorProperties, Iterable> tables) + public static QueryRunner createMySqlQueryRunner(String jdbcUrl, Map connectorPropertiesMap, Iterable> tables) throws Exception { + Map connectorProperties = connectorPropertiesMap; DistributedQueryRunner queryRunner = null; try { queryRunner = new DistributedQueryRunner(createSession(), 3); diff --git a/presto-mysql/src/test/java/io/prestosql/plugin/mysql/TestMySqlTypeMapping.java b/presto-mysql/src/test/java/io/prestosql/plugin/mysql/TestMySqlTypeMapping.java index 6601b2625..7e2d6f26c 100644 --- a/presto-mysql/src/test/java/io/prestosql/plugin/mysql/TestMySqlTypeMapping.java +++ b/presto-mysql/src/test/java/io/prestosql/plugin/mysql/TestMySqlTypeMapping.java @@ -297,7 +297,8 @@ public class TestMySqlTypeMapping try { assertQuery( "SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'tpch' AND TABLE_NAME = 'test_unsupported_data_type'", - "VALUES 'supported_column'"); // no 'unsupported_column' + "VALUES 'supported_column'"); + // no unsupported_column } finally { jdbcSqlExecutor.execute("DROP TABLE tpch.test_unsupported_data_type"); diff --git a/presto-orc/src/main/java/io/prestosql/orc/metadata/statistics/DecimalStatistics.java b/presto-orc/src/main/java/io/prestosql/orc/metadata/statistics/DecimalStatistics.java index db72aea7a..d87bdefbd 100644 --- a/presto-orc/src/main/java/io/prestosql/orc/metadata/statistics/DecimalStatistics.java +++ b/presto-orc/src/main/java/io/prestosql/orc/metadata/statistics/DecimalStatistics.java @@ -47,14 +47,14 @@ public class DecimalStatistics this.minimum = minimum; this.maximum = maximum; - long retainedSizeInBytes = 0; + long tmpRetainedSizeInBytes = 0; if (minimum != null) { - retainedSizeInBytes += BIG_DECIMAL_INSTANCE_SIZE + decimalSizeInBytes; + tmpRetainedSizeInBytes += BIG_DECIMAL_INSTANCE_SIZE + decimalSizeInBytes; } if (maximum != null && minimum != maximum) { - retainedSizeInBytes += BIG_DECIMAL_INSTANCE_SIZE + decimalSizeInBytes; + tmpRetainedSizeInBytes += BIG_DECIMAL_INSTANCE_SIZE + decimalSizeInBytes; } - this.retainedSizeInBytes = retainedSizeInBytes + INSTANCE_SIZE; + this.retainedSizeInBytes = tmpRetainedSizeInBytes + INSTANCE_SIZE; } @Override diff --git a/presto-orc/src/main/java/io/prestosql/orc/writer/DictionaryBuilder.java b/presto-orc/src/main/java/io/prestosql/orc/writer/DictionaryBuilder.java index ee4e1f93b..de0ea3914 100644 --- a/presto-orc/src/main/java/io/prestosql/orc/writer/DictionaryBuilder.java +++ b/presto-orc/src/main/java/io/prestosql/orc/writer/DictionaryBuilder.java @@ -21,6 +21,8 @@ import io.prestosql.spi.block.BlockBuilder; import io.prestosql.spi.block.VariableWidthBlockBuilder; import org.openjdk.jol.info.ClassLayout; +import java.nio.charset.StandardCharsets; + import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Verify.verify; import static io.prestosql.spi.block.PageBuilderStatus.DEFAULT_MAX_PAGE_SIZE_IN_BYTES; @@ -192,7 +194,7 @@ public class DictionaryBuilder { byte[] escapedBytes; try { - escapedBytes = unescapeJava(new String(text)).getBytes(); + escapedBytes = unescapeJava(new String(text, StandardCharsets.UTF_8)).getBytes(StandardCharsets.UTF_8); } catch (IllegalArgumentException e) { return text.length; @@ -217,11 +219,11 @@ public class DictionaryBuilder private static int calculateMaxFill(int hashSize) { - int maxFill = (int) Math.ceil(hashSize * FILL_RATIO); - if (maxFill == hashSize) { - maxFill--; + int ceil = (int) Math.ceil(hashSize * FILL_RATIO); + if (ceil == hashSize) { + ceil--; } - return maxFill; + return ceil; } private long getMaskedHash(long rawHash) diff --git a/presto-orc/src/main/java/io/prestosql/orc/writer/SliceDictionaryColumnWriter.java b/presto-orc/src/main/java/io/prestosql/orc/writer/SliceDictionaryColumnWriter.java index 687511fff..43b5033bd 100644 --- a/presto-orc/src/main/java/io/prestosql/orc/writer/SliceDictionaryColumnWriter.java +++ b/presto-orc/src/main/java/io/prestosql/orc/writer/SliceDictionaryColumnWriter.java @@ -207,8 +207,9 @@ public class SliceDictionaryColumnWriter return OptionalInt.of(toIntExact(directColumnWriter.getBufferedBytes())); } - private boolean writeDictionaryRowGroup(Block dictionary, int valueCount, IntBigArray dictionaryIndexes, int maxDirectBytes) + private boolean writeDictionaryRowGroup(Block dictionary, int count, IntBigArray dictionaryIndexes, int maxDirectBytes) { + int valueCount = count; int[][] segments = dictionaryIndexes.getSegments(); for (int i = 0; valueCount > 0 && i < segments.length; i++) { int[] segment = segments[i]; diff --git a/presto-orc/src/test/java/io/prestosql/orc/metadata/statistics/AbstractStatisticsBuilderTest.java b/presto-orc/src/test/java/io/prestosql/orc/metadata/statistics/AbstractStatisticsBuilderTest.java index 7f45f51c2..5cd77707b 100644 --- a/presto-orc/src/test/java/io/prestosql/orc/metadata/statistics/AbstractStatisticsBuilderTest.java +++ b/presto-orc/src/test/java/io/prestosql/orc/metadata/statistics/AbstractStatisticsBuilderTest.java @@ -266,8 +266,9 @@ public abstract class AbstractStatisticsBuilderTest statistics) + private static ColumnStatistics getMergedColumnStatisticsPairwise(List statisticsList) { + List statistics = statisticsList; while (statistics.size() > 1) { ImmutableList.Builder mergedStatistics = ImmutableList.builder(); for (int i = 0; i < statistics.size(); i += 2) { diff --git a/presto-orc/src/test/java/io/prestosql/orc/metadata/statistics/TestDateStatisticsBuilder.java b/presto-orc/src/test/java/io/prestosql/orc/metadata/statistics/TestDateStatisticsBuilder.java index 0c5c3f373..440088c39 100644 --- a/presto-orc/src/test/java/io/prestosql/orc/metadata/statistics/TestDateStatisticsBuilder.java +++ b/presto-orc/src/test/java/io/prestosql/orc/metadata/statistics/TestDateStatisticsBuilder.java @@ -17,6 +17,7 @@ import com.google.common.collect.ContiguousSet; import com.google.common.collect.DiscreteDomain; import com.google.common.collect.ImmutableList; import com.google.common.collect.Range; +import io.airlift.log.Logger; import org.testng.annotations.Test; import static io.prestosql.orc.metadata.statistics.AbstractStatisticsBuilderTest.StatisticsType.DATE; @@ -28,6 +29,8 @@ import static org.testng.Assert.fail; public class TestDateStatisticsBuilder extends AbstractStatisticsBuilderTest { + private static final Logger LOG = Logger.get(TestDateStatisticsBuilder.class); + public TestDateStatisticsBuilder() { super(DATE, DateStatisticsBuilder::new, DateStatisticsBuilder::addValue); @@ -62,6 +65,7 @@ public class TestDateStatisticsBuilder fail("Expected ArithmeticException"); } catch (ArithmeticException expected) { + LOG.info("Error message: " + expected.getMessage()); } try { @@ -69,6 +73,7 @@ public class TestDateStatisticsBuilder fail("Expected ArithmeticException"); } catch (ArithmeticException expected) { + LOG.info("Error message: " + expected.getMessage()); } } diff --git a/presto-parquet/src/main/java/io/prestosql/parquet/ParquetTypeUtils.java b/presto-parquet/src/main/java/io/prestosql/parquet/ParquetTypeUtils.java index 59a4ba55a..c503a3811 100644 --- a/presto-parquet/src/main/java/io/prestosql/parquet/ParquetTypeUtils.java +++ b/presto-parquet/src/main/java/io/prestosql/parquet/ParquetTypeUtils.java @@ -53,8 +53,9 @@ public final class ParquetTypeUtils return (new ColumnIOFactory()).getColumnIO(requestedSchema, fileSchema, true); } - public static GroupColumnIO getMapKeyValueColumn(GroupColumnIO groupColumnIO) + public static GroupColumnIO getMapKeyValueColumn(GroupColumnIO inputGroupColumnIO) { + GroupColumnIO groupColumnIO = inputGroupColumnIO; while (groupColumnIO.getChildrenCount() == 1) { groupColumnIO = (GroupColumnIO) groupColumnIO.getChild(0); } @@ -68,8 +69,9 @@ public final class ParquetTypeUtils * 4. Otherwise, the repeated field's type is the element type with the repeated field's repetition. * https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#lists */ - public static ColumnIO getArrayElementColumn(ColumnIO columnIO) + public static ColumnIO getArrayElementColumn(ColumnIO inputColumnIO) { + ColumnIO columnIO = inputColumnIO; while (columnIO instanceof GroupColumnIO && !columnIO.getType().isRepetition(REPEATED)) { columnIO = ((GroupColumnIO) columnIO).getChild(0); } diff --git a/presto-parquet/src/main/java/io/prestosql/parquet/reader/ListColumnReader.java b/presto-parquet/src/main/java/io/prestosql/parquet/reader/ListColumnReader.java index 4e599b546..5fc17e25f 100644 --- a/presto-parquet/src/main/java/io/prestosql/parquet/reader/ListColumnReader.java +++ b/presto-parquet/src/main/java/io/prestosql/parquet/reader/ListColumnReader.java @@ -58,8 +58,9 @@ public class ListColumnReader } } - private static int getNextCollectionStartIndex(int[] repetitionLevels, int maxRepetitionLevel, int elementIndex) + private static int getNextCollectionStartIndex(int[] repetitionLevels, int maxRepetitionLevel, int inputElementIndex) { + int elementIndex = inputElementIndex; do { elementIndex++; } @@ -70,9 +71,10 @@ public class ListColumnReader /** * This method is only called for non-empty collections */ - private static int getCollectionSize(int[] repetitionLevels, int maxRepetitionLevel, int nextIndex) + private static int getCollectionSize(int[] repetitionLevels, int maxRepetitionLevel, int inputNextIndex) { int size = 1; + int nextIndex = inputNextIndex; while (hasMoreElements(repetitionLevels, nextIndex) && !isCollectionBeginningMarker(repetitionLevels, maxRepetitionLevel, nextIndex)) { // Collection elements can not only be primitive, but also can have nested structure // Counting only elements which belong to current collection, skipping inner elements of nested collections/structs diff --git a/presto-parquet/src/main/java/io/prestosql/parquet/reader/ParquetReader.java b/presto-parquet/src/main/java/io/prestosql/parquet/reader/ParquetReader.java index 1cc77eaf8..b37d75999 100644 --- a/presto-parquet/src/main/java/io/prestosql/parquet/reader/ParquetReader.java +++ b/presto-parquet/src/main/java/io/prestosql/parquet/reader/ParquetReader.java @@ -174,15 +174,15 @@ public class ParquetReader { List parameters = field.getType().getTypeParameters(); checkArgument(parameters.size() == 2, "Maps must have two type parameters, found %s", parameters.size()); - Block[] blocks = new Block[parameters.size()]; + Block[] localBlocks = new Block[parameters.size()]; ColumnChunk columnChunk = readColumnChunk(field.getChildren().get(0).get()); - blocks[0] = columnChunk.getBlock(); - blocks[1] = readColumnChunk(field.getChildren().get(1).get()).getBlock(); + localBlocks[0] = columnChunk.getBlock(); + localBlocks[1] = readColumnChunk(field.getChildren().get(1).get()).getBlock(); IntList offsets = new IntArrayList(); BooleanList valueIsNull = new BooleanArrayList(); calculateCollectionOffsets(field, offsets, valueIsNull, columnChunk.getDefinitionLevels(), columnChunk.getRepetitionLevels()); - Block mapBlock = ((MapType) field.getType()).createBlockFromKeyValue(Optional.of(valueIsNull.toBooleanArray()), offsets.toIntArray(), blocks[0], blocks[1]); + Block mapBlock = ((MapType) field.getType()).createBlockFromKeyValue(Optional.of(valueIsNull.toBooleanArray()), offsets.toIntArray(), localBlocks[0], localBlocks[1]); return new ColumnChunk(mapBlock, columnChunk.getDefinitionLevels(), columnChunk.getRepetitionLevels()); } @@ -190,24 +190,24 @@ public class ParquetReader throws IOException { List fields = field.getType().getTypeSignature().getParameters(); - Block[] blocks = new Block[fields.size()]; + Block[] localBlocks = new Block[fields.size()]; ColumnChunk columnChunk = null; List> parameters = field.getChildren(); for (int i = 0; i < fields.size(); i++) { Optional parameter = parameters.get(i); if (parameter.isPresent()) { columnChunk = readColumnChunk(parameter.get()); - blocks[i] = columnChunk.getBlock(); + localBlocks[i] = columnChunk.getBlock(); } } for (int i = 0; i < fields.size(); i++) { - if (blocks[i] == null) { - blocks[i] = RunLengthEncodedBlock.create(field.getType(), null, columnChunk.getBlock().getPositionCount()); + if (localBlocks[i] == null) { + localBlocks[i] = RunLengthEncodedBlock.create(field.getType(), null, columnChunk.getBlock().getPositionCount()); } } BooleanList structIsNull = StructColumnReader.calculateStructOffsets(field, columnChunk.getDefinitionLevels(), columnChunk.getRepetitionLevels()); boolean[] structIsNullVector = structIsNull.toBooleanArray(); - Block rowBlock = RowBlock.fromFieldBlocks(structIsNullVector.length, Optional.of(structIsNullVector), blocks); + Block rowBlock = RowBlock.fromFieldBlocks(structIsNullVector.length, Optional.of(structIsNullVector), localBlocks); return new ColumnChunk(rowBlock, columnChunk.getDefinitionLevels(), columnChunk.getRepetitionLevels()); } diff --git a/presto-parquet/src/main/java/io/prestosql/parquet/reader/PrimitiveColumnReader.java b/presto-parquet/src/main/java/io/prestosql/parquet/reader/PrimitiveColumnReader.java index 03888091f..90b69238e 100644 --- a/presto-parquet/src/main/java/io/prestosql/parquet/reader/PrimitiveColumnReader.java +++ b/presto-parquet/src/main/java/io/prestosql/parquet/reader/PrimitiveColumnReader.java @@ -300,20 +300,20 @@ public abstract class PrimitiveColumnReader private ValuesReader initDataReader(ParquetEncoding dataEncoding, int valueCount, ByteBufferInputStream in) { - ValuesReader valuesReader; + ValuesReader localValuesReader; if (dataEncoding.usesDictionary()) { if (dictionary == null) { throw new ParquetDecodingException("Dictionary is missing for Page"); } - valuesReader = dataEncoding.getDictionaryBasedValuesReader(columnDescriptor, VALUES, dictionary); + localValuesReader = dataEncoding.getDictionaryBasedValuesReader(columnDescriptor, VALUES, dictionary); } else { - valuesReader = dataEncoding.getValuesReader(columnDescriptor, VALUES); + localValuesReader = dataEncoding.getValuesReader(columnDescriptor, VALUES); } try { - valuesReader.initFromPage(valueCount, in); - return valuesReader; + localValuesReader.initFromPage(valueCount, in); + return localValuesReader; } catch (IOException e) { throw new ParquetDecodingException("Error reading parquet page in column " + columnDescriptor, e); diff --git a/presto-parquet/src/test/java/io/prestosql/parquet/TestTupleDomainParquetPredicate.java b/presto-parquet/src/test/java/io/prestosql/parquet/TestTupleDomainParquetPredicate.java index 0b4a5ce51..017966e46 100644 --- a/presto-parquet/src/test/java/io/prestosql/parquet/TestTupleDomainParquetPredicate.java +++ b/presto-parquet/src/test/java/io/prestosql/parquet/TestTupleDomainParquetPredicate.java @@ -36,6 +36,7 @@ import org.apache.parquet.schema.PrimitiveType; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.Optional; @@ -281,7 +282,7 @@ public class TestTupleDomainParquetPredicate TupleDomainParquetPredicate parquetPredicate = new TupleDomainParquetPredicate(effectivePredicate, singletonList(column)); Statistics stats = getStatsBasedOnType(column.getType()); stats.setNumNulls(1L); - stats.setMinMaxFromBytes(value.getBytes(), value.getBytes()); + stats.setMinMaxFromBytes(value.getBytes(StandardCharsets.UTF_8), value.getBytes(StandardCharsets.UTF_8)); assertTrue(parquetPredicate.matches(2, ImmutableMap.of(column, stats), ID, true)); } diff --git a/presto-parser/src/main/java/io/prestosql/sql/parser/AstBuilder.java b/presto-parser/src/main/java/io/prestosql/sql/parser/AstBuilder.java index a96fbed0b..089f8cd79 100644 --- a/presto-parser/src/main/java/io/prestosql/sql/parser/AstBuilder.java +++ b/presto-parser/src/main/java/io/prestosql/sql/parser/AstBuilder.java @@ -1748,7 +1748,7 @@ class AstBuilder String fieldString = context.identifier().getText(); Extract.Field field; try { - field = Extract.Field.valueOf(fieldString.toUpperCase()); + field = Extract.Field.valueOf(fieldString.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException e) { throw parseError("Invalid EXTRACT field: " + fieldString, context); diff --git a/presto-parser/src/main/java/io/prestosql/sql/parser/ErrorHandler.java b/presto-parser/src/main/java/io/prestosql/sql/parser/ErrorHandler.java index 853669200..22424025d 100644 --- a/presto-parser/src/main/java/io/prestosql/sql/parser/ErrorHandler.java +++ b/presto-parser/src/main/java/io/prestosql/sql/parser/ErrorHandler.java @@ -64,8 +64,9 @@ public class ErrorHandler } @Override - public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String message, RecognitionException e) + public void syntaxError(Recognizer recognizer, Object offendingSymbol, int line, int charPositionInLine, String inputMessage, RecognitionException e) { + String message = inputMessage; try { Parser parser = (Parser) recognizer; diff --git a/presto-parser/src/main/java/io/prestosql/sql/tree/Intersect.java b/presto-parser/src/main/java/io/prestosql/sql/tree/Intersect.java index b29d933de..1e2025db2 100644 --- a/presto-parser/src/main/java/io/prestosql/sql/tree/Intersect.java +++ b/presto-parser/src/main/java/io/prestosql/sql/tree/Intersect.java @@ -45,6 +45,7 @@ public class Intersect this.relations = ImmutableList.copyOf(relations); } + @Override public List getRelations() { return relations; diff --git a/presto-parser/src/main/java/io/prestosql/sql/tree/RoutineCharacteristics.java b/presto-parser/src/main/java/io/prestosql/sql/tree/RoutineCharacteristics.java index ef08265c9..7d83a8566 100644 --- a/presto-parser/src/main/java/io/prestosql/sql/tree/RoutineCharacteristics.java +++ b/presto-parser/src/main/java/io/prestosql/sql/tree/RoutineCharacteristics.java @@ -13,6 +13,7 @@ */ package io.prestosql.sql.tree; +import java.util.Locale; import java.util.Objects; import java.util.Optional; @@ -33,7 +34,7 @@ public class RoutineCharacteristics public Language(String language) { - this.language = requireNonNull(language.toUpperCase()); + this.language = requireNonNull(language.toUpperCase(Locale.ROOT)); } public String getLanguage() diff --git a/presto-parser/src/main/java/io/prestosql/sql/tree/Union.java b/presto-parser/src/main/java/io/prestosql/sql/tree/Union.java index ace5b873e..90664c55b 100644 --- a/presto-parser/src/main/java/io/prestosql/sql/tree/Union.java +++ b/presto-parser/src/main/java/io/prestosql/sql/tree/Union.java @@ -45,6 +45,7 @@ public class Union this.relations = ImmutableList.copyOf(relations); } + @Override public List getRelations() { return relations; diff --git a/presto-parser/src/main/java/io/prestosql/sql/util/SpecialCommentFormatter.java b/presto-parser/src/main/java/io/prestosql/sql/util/SpecialCommentFormatter.java index 14f3c76f6..de1d346b5 100644 --- a/presto-parser/src/main/java/io/prestosql/sql/util/SpecialCommentFormatter.java +++ b/presto-parser/src/main/java/io/prestosql/sql/util/SpecialCommentFormatter.java @@ -43,11 +43,12 @@ public class SpecialCommentFormatter return sql.substring(sql.indexOf("@") + 1, sql.lastIndexOf("#")); } - private static void insertIntoTableColumnMap(String comment) + private static void insertIntoTableColumnMap(String inputComment) { if (!queryMap.isEmpty()) { queryMap.clear(); } + String comment = inputComment; comment = comment.replaceAll("\\s", ""); String[] tableAndColumns = comment.split("="); String[] columns = tableAndColumns[1].split(","); diff --git a/presto-password-authenticators/src/main/java/io/prestosql/plugin/password/LdapAuthenticator.java b/presto-password-authenticators/src/main/java/io/prestosql/plugin/password/LdapAuthenticator.java index eb670bbb8..8df9edcd4 100644 --- a/presto-password-authenticators/src/main/java/io/prestosql/plugin/password/LdapAuthenticator.java +++ b/presto-password-authenticators/src/main/java/io/prestosql/plugin/password/LdapAuthenticator.java @@ -180,6 +180,7 @@ public class LdapAuthenticator context.close(); } catch (NamingException ignored) { + // could be ignored } } diff --git a/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/JsonUtils.java b/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/JsonUtils.java index 2a2a5eb47..009be632d 100644 --- a/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/JsonUtils.java +++ b/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/JsonUtils.java @@ -30,8 +30,9 @@ public final class JsonUtils { private JsonUtils() {} - public static T parseJson(Path path, Class javaType) + public static T parseJson(Path inputPath, Class javaType) { + Path path = inputPath; if (!path.isAbsolute()) { path = path.toAbsolutePath(); } diff --git a/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/jmx/RebindSafeMBeanServer.java b/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/jmx/RebindSafeMBeanServer.java index e52a947a2..430c5625a 100644 --- a/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/jmx/RebindSafeMBeanServer.java +++ b/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/jmx/RebindSafeMBeanServer.java @@ -75,6 +75,7 @@ public class RebindSafeMBeanServer return mbeanServer.registerMBean(object, name); } catch (InstanceAlreadyExistsException ignored) { + // could be ignored } try { diff --git a/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/security/FileBasedAccessControl.java b/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/security/FileBasedAccessControl.java index 2ee941d7a..43e362b7c 100644 --- a/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/security/FileBasedAccessControl.java +++ b/presto-plugin-toolkit/src/main/java/io/prestosql/plugin/base/security/FileBasedAccessControl.java @@ -212,6 +212,7 @@ public class FileBasedAccessControl } } + @Override public void checkCanUpdateTable(ConnectorTransactionHandle transactionHandle, ConnectorIdentity identity, SchemaTableName tableName) { if (!checkTablePermission(identity, tableName, UPDATE)) { diff --git a/presto-postgresql/src/main/java/io/prestosql/plugin/postgresql/BasePostgreSqlClient.java b/presto-postgresql/src/main/java/io/prestosql/plugin/postgresql/BasePostgreSqlClient.java index 19da0bc88..a62a9b554 100644 --- a/presto-postgresql/src/main/java/io/prestosql/plugin/postgresql/BasePostgreSqlClient.java +++ b/presto-postgresql/src/main/java/io/prestosql/plugin/postgresql/BasePostgreSqlClient.java @@ -256,6 +256,8 @@ public abstract class BasePostgreSqlClient case "timestamptz": // PostgreSQL's "timestamp with time zone" is reported as Types.TIMESTAMP rather than Types.TIMESTAMP_WITH_TIMEZONE return Optional.of(timestampWithTimeZoneColumnMapping()); + default: + break; } if (typeHandle.getJdbcType() == Types.VARCHAR && !jdbcTypeName.equals("varchar")) { // This can be e.g. an ENUM @@ -401,7 +403,7 @@ public abstract class BasePostgreSqlClient byte[] in = slice.getBytes(); SliceOutput dynamicSliceOutput = new DynamicSliceOutput(in.length); SORTED_MAPPER.writeValue((OutputStream) dynamicSliceOutput, SORTED_MAPPER.readValue(parser, Object.class)); - // nextToken() returns null if the input is parsed correctly, + // the function nextToken() returns null if the input is parsed correctly, // but will throw an exception if there are trailing characters. parser.nextToken(); return dynamicSliceOutput.slice(); diff --git a/presto-postgresql/src/test/java/io/prestosql/plugin/postgresql/PostgreSqlQueryRunner.java b/presto-postgresql/src/test/java/io/prestosql/plugin/postgresql/PostgreSqlQueryRunner.java index 0a26c5ec7..4e3842372 100644 --- a/presto-postgresql/src/test/java/io/prestosql/plugin/postgresql/PostgreSqlQueryRunner.java +++ b/presto-postgresql/src/test/java/io/prestosql/plugin/postgresql/PostgreSqlQueryRunner.java @@ -48,9 +48,10 @@ public final class PostgreSqlQueryRunner return createPostgreSqlQueryRunner(server, ImmutableMap.of(), ImmutableList.copyOf(tables)); } - public static QueryRunner createPostgreSqlQueryRunner(TestingPostgreSqlServer server, Map connectorProperties, Iterable> tables) + public static QueryRunner createPostgreSqlQueryRunner(TestingPostgreSqlServer server, Map inputConnectorProperties, Iterable> tables) throws Exception { + Map connectorProperties = inputConnectorProperties; DistributedQueryRunner queryRunner = null; try { queryRunner = new DistributedQueryRunner(createSession(), 3); diff --git a/presto-postgresql/src/test/java/io/prestosql/plugin/postgresql/TestPostgreSqlTypeMapping.java b/presto-postgresql/src/test/java/io/prestosql/plugin/postgresql/TestPostgreSqlTypeMapping.java index fa6fd728d..d7f819f44 100644 --- a/presto-postgresql/src/test/java/io/prestosql/plugin/postgresql/TestPostgreSqlTypeMapping.java +++ b/presto-postgresql/src/test/java/io/prestosql/plugin/postgresql/TestPostgreSqlTypeMapping.java @@ -413,10 +413,10 @@ public class TestPostgreSqlTypeMapping protected DataTypeTest arrayDateTest(Function, DataType>> arrayTypeFactory) { - ZoneId jvmZone = ZoneId.systemDefault(); - checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone"); + ZoneId localJvmZone = ZoneId.systemDefault(); + checkState(localJvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone"); LocalDate dateOfLocalTimeChangeForwardAtMidnightInJvmZone = LocalDate.of(1970, 1, 1); - checkIsGap(jvmZone, dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()); + checkIsGap(localJvmZone, dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()); ZoneId someZone = ZoneId.of("Europe/Vilnius"); LocalDate dateOfLocalTimeChangeForwardAtMidnightInSomeZone = LocalDate.of(1983, 4, 1); @@ -486,10 +486,10 @@ public class TestPostgreSqlTypeMapping { // Note: there is identical test for MySQL - ZoneId jvmZone = ZoneId.systemDefault(); - checkState(jvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone"); + ZoneId localJvmZone = ZoneId.systemDefault(); + checkState(localJvmZone.getId().equals("America/Bahia_Banderas"), "This test assumes certain JVM time zone"); LocalDate dateOfLocalTimeChangeForwardAtMidnightInJvmZone = LocalDate.of(1970, 1, 1); - checkIsGap(jvmZone, dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()); + checkIsGap(localJvmZone, dateOfLocalTimeChangeForwardAtMidnightInJvmZone.atStartOfDay()); ZoneId someZone = ZoneId.of("Europe/Vilnius"); LocalDate dateOfLocalTimeChangeForwardAtMidnightInSomeZone = LocalDate.of(1983, 4, 1); @@ -507,7 +507,7 @@ public class TestPostgreSqlTypeMapping .addRoundTrip(dateDataType(), dateOfLocalTimeChangeForwardAtMidnightInSomeZone) .addRoundTrip(dateDataType(), dateOfLocalTimeChangeBackwardAtMidnightInSomeZone); - for (String timeZoneId : ImmutableList.of(UTC_KEY.getId(), jvmZone.getId(), someZone.getId())) { + for (String timeZoneId : ImmutableList.of(UTC_KEY.getId(), localJvmZone.getId(), someZone.getId())) { Session session = Session.builder(getQueryRunner().getDefaultSession()) .setTimeZoneKey(TimeZoneKey.getTimeZoneKey(timeZoneId)) .build(); @@ -683,7 +683,8 @@ public class TestPostgreSqlTypeMapping try { assertQuery( "SELECT column_name FROM information_schema.columns WHERE table_schema = 'tpch' AND table_name = 'test_unsupported_data_type'", - "VALUES 'key'"); // no 'unsupported_column' + "VALUES 'key'"); + // no unsupported_column } finally { jdbcSqlExecutor.execute("DROP TABLE tpch.test_unsupported_data_type"); diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/CreateTableTests.java b/presto-product-tests/src/main/java/io/prestosql/tests/CreateTableTests.java index 77fe274e3..2a841c9bd 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/CreateTableTests.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/CreateTableTests.java @@ -15,6 +15,7 @@ package io.prestosql.tests; import com.google.inject.Inject; +import io.airlift.log.Logger; import io.prestosql.tempto.ProductTest; import io.prestosql.tempto.Requires; import io.prestosql.tempto.fulfillment.table.hive.tpch.ImmutableTpchTablesRequirements.ImmutableNationTable; @@ -41,6 +42,8 @@ public class CreateTableTests @Inject private HdfsClient hdfsClient; + private static final Logger LOG = Logger.get(CreateTableTests.class); + @Test(groups = CREATE_TABLE) public void shouldCreateTableAsSelect() { @@ -77,7 +80,7 @@ public class CreateTableTests threads[i].join(); } catch (InterruptedException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } } //after simultaneous create Table, it should allow to insert, update @@ -100,7 +103,7 @@ public class CreateTableTests threads[i].join(); } catch (InterruptedException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } } // after simultaneous drop there should not be table folder diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/TestCarbondataConcurrent.java b/presto-product-tests/src/main/java/io/prestosql/tests/TestCarbondataConcurrent.java index 3386696a3..2a342e88e 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/TestCarbondataConcurrent.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/TestCarbondataConcurrent.java @@ -25,6 +25,7 @@ public class TestCarbondataConcurrent public TestCarbondataConcurrent(String tableName, CreateTableTests.CarbonTaskOperation taskOperation) { + super.setName("TestCarbondataConcurrent"); this.tableName = tableName; this.taskOperation = taskOperation; } diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/cassandra/TestSelect.java b/presto-product-tests/src/main/java/io/prestosql/tests/cassandra/TestSelect.java index 3f5e9e716..0114f6d2e 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/cassandra/TestSelect.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/cassandra/TestSelect.java @@ -23,6 +23,7 @@ import io.prestosql.tempto.internal.query.CassandraQueryExecutor; import io.prestosql.tempto.query.QueryResult; import org.testng.annotations.Test; +import java.nio.charset.StandardCharsets; import java.sql.Date; import java.sql.Timestamp; import java.time.LocalDateTime; @@ -187,7 +188,7 @@ public class TestSelect "[0]", Short.MIN_VALUE, "\0", Byte.MIN_VALUE, Timestamp.valueOf(LocalDateTime.of(1970, 1, 1, 0, 0)), "d2177dd0-eaa2-11de-a572-001b779c76e3", "01234567-0123-0123-0123-0123456789ab", "\0", String.valueOf(Long.MIN_VALUE)), - row("the quick brown fox jumped over the lazy dog", 9223372036854775807L, "01234".getBytes(), + row("the quick brown fox jumped over the lazy dog", 9223372036854775807L, "01234".getBytes(StandardCharsets.UTF_8), true, new Double("99999999999999999999999999999999999999"), Double.MAX_VALUE, Date.valueOf("9999-12-31"), Float.MAX_VALUE, "[4,5,6,7]", "255.255.255.255", Integer.MAX_VALUE, "[4,5,6]", "{\"a\":1,\"b\":2}", "[4,5,6]", Short.MAX_VALUE, "this is a text value", Byte.MAX_VALUE, Timestamp.valueOf(LocalDateTime.of(9999, 12, 31, 23, 59, 59)), diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoCliTests.java b/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoCliTests.java index 2cb274f8d..6665cf247 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoCliTests.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoCliTests.java @@ -86,6 +86,7 @@ public class PrestoCliTests {} @AfterTestWithContext + @Override public void stopPresto() throws InterruptedException { diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoLdapCliTests.java b/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoLdapCliTests.java index f33cfd81f..d8f417a99 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoLdapCliTests.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/cli/PrestoLdapCliTests.java @@ -80,6 +80,7 @@ public class PrestoLdapCliTests {} @AfterTestWithContext + @Override public void stopPresto() throws InterruptedException { diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/jdbc/JdbcTests.java b/presto-product-tests/src/main/java/io/prestosql/tests/jdbc/JdbcTests.java index 940d7d348..9594f2252 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/jdbc/JdbcTests.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/jdbc/JdbcTests.java @@ -29,6 +29,7 @@ import javax.inject.Inject; import javax.inject.Named; import java.math.BigDecimal; +import java.nio.charset.StandardCharsets; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.Date; @@ -246,7 +247,7 @@ public class JdbcTests assertThat(query("select {fn convert('1234.567', SQL_DECIMAL)}")).containsExactly(row(new BigDecimal(1235))); assertThat(query("select {fn convert('123456', SQL_INTEGER)}")).containsExactly(row(123456)); - assertThat(query("select {fn convert('123abcd', SQL_VARBINARY)}")).containsExactly(row("123abcd".getBytes())); + assertThat(query("select {fn convert('123abcd', SQL_VARBINARY)}")).containsExactly(row("123abcd".getBytes(StandardCharsets.UTF_8))); assertThat(query("select {fn dayofmonth(date '2016-10-20')}")).containsExactly(row(20)); assertThat(query("select {fn dayofweek(date '2016-10-20')}")).containsExactly(row(5)); assertThat(query("select {fn dayofyear(date '2016-10-20')}")).containsExactly(row(294)); diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/jdbc/PreparedStatements.java b/presto-product-tests/src/main/java/io/prestosql/tests/jdbc/PreparedStatements.java index 7a5c23f5f..9e9e7bce2 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/jdbc/PreparedStatements.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/jdbc/PreparedStatements.java @@ -24,6 +24,7 @@ import org.testng.annotations.Test; import java.math.BigDecimal; import java.math.BigInteger; +import java.nio.charset.StandardCharsets; import java.sql.Connection; import java.sql.Date; import java.sql.SQLException; @@ -373,7 +374,7 @@ public class PreparedStatements "def", "ghi ", Boolean.FALSE, - "jkl".getBytes()), + "jkl".getBytes(StandardCharsets.UTF_8)), row(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null)); } else { diff --git a/presto-product-tests/src/main/java/io/prestosql/tests/utils/JdbcDriverUtils.java b/presto-product-tests/src/main/java/io/prestosql/tests/utils/JdbcDriverUtils.java index dee0c99dc..c51932455 100644 --- a/presto-product-tests/src/main/java/io/prestosql/tests/utils/JdbcDriverUtils.java +++ b/presto-product-tests/src/main/java/io/prestosql/tests/utils/JdbcDriverUtils.java @@ -63,9 +63,10 @@ public class JdbcDriverUtils return null; } - public static void setSessionProperty(Connection connection, String key, String value) + public static void setSessionProperty(Connection connection, String key, String inputValue) throws SQLException { + String value = inputValue; if (usingPrestoJdbcDriver(connection)) { PrestoConnection prestoConnection = connection.unwrap(PrestoConnection.class); prestoConnection.setSessionProperty(key, value); diff --git a/presto-product-tests/src/test/java/io/prestosql/tests/querystats/TestHttpQueryStatsClient.java b/presto-product-tests/src/test/java/io/prestosql/tests/querystats/TestHttpQueryStatsClient.java index a41779a85..41d98faa0 100644 --- a/presto-product-tests/src/test/java/io/prestosql/tests/querystats/TestHttpQueryStatsClient.java +++ b/presto-product-tests/src/test/java/io/prestosql/tests/querystats/TestHttpQueryStatsClient.java @@ -80,7 +80,7 @@ public class TestHttpQueryStatsClient private void mockHttpResponse(String answerJson) { - httpResponse = new TestingResponse(HttpStatus.OK, ImmutableListMultimap.of(), answerJson.getBytes()); + httpResponse = new TestingResponse(HttpStatus.OK, ImmutableListMultimap.of(), answerJson.getBytes(UTF_8)); } private void mockErrorHttpResponse(HttpStatus statusCode) diff --git a/presto-proxy/src/main/java/io/prestosql/proxy/JsonWebTokenHandler.java b/presto-proxy/src/main/java/io/prestosql/proxy/JsonWebTokenHandler.java index 0f21c18b3..95f326d7c 100644 --- a/presto-proxy/src/main/java/io/prestosql/proxy/JsonWebTokenHandler.java +++ b/presto-proxy/src/main/java/io/prestosql/proxy/JsonWebTokenHandler.java @@ -89,6 +89,7 @@ public class JsonWebTokenHandler throw new RuntimeException("Failed to load key file: " + file, e); } catch (GeneralSecurityException ignored) { + // could be ignored } try { diff --git a/presto-record-decoder/src/main/java/io/prestosql/decoder/avro/AvroColumnDecoder.java b/presto-record-decoder/src/main/java/io/prestosql/decoder/avro/AvroColumnDecoder.java index 44b1b87fd..b0ebb6667 100644 --- a/presto-record-decoder/src/main/java/io/prestosql/decoder/avro/AvroColumnDecoder.java +++ b/presto-record-decoder/src/main/java/io/prestosql/decoder/avro/AvroColumnDecoder.java @@ -272,8 +272,9 @@ public class AvroColumnDecoder } } - private static Block serializeMap(BlockBuilder blockBuilder, Object value, Type type, String columnName) + private static Block serializeMap(BlockBuilder inputBlockBuilder, Object value, Type type, String columnName) { + BlockBuilder blockBuilder = inputBlockBuilder; if (value == null) { requireNonNull(blockBuilder, "parent blockBuilder is null").appendNull(); return blockBuilder.build(); diff --git a/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/AbstractResourceConfigurationManager.java b/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/AbstractResourceConfigurationManager.java index 2713d95e0..ff80d24a4 100644 --- a/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/AbstractResourceConfigurationManager.java +++ b/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/AbstractResourceConfigurationManager.java @@ -32,6 +32,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Optional; import java.util.Queue; @@ -107,8 +108,9 @@ public abstract class AbstractResourceConfigurationManager return selectors.build(); } - private void validateSelectors(List groups, SelectorSpec spec) + private void validateSelectors(List inputGroups, SelectorSpec spec) { + List groups = inputGroups; spec.getQueryType().ifPresent(this::validateQueryType); StringBuilder fullyQualifiedGroupName = new StringBuilder(); for (ResourceGroupNameTemplate groupName : spec.getGroup().getSegments()) { @@ -128,7 +130,7 @@ public abstract class AbstractResourceConfigurationManager private void validateQueryType(String queryType) { try { - QueryType.valueOf(queryType.toUpperCase()); + QueryType.valueOf(queryType.toUpperCase(Locale.ROOT)); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(format("Selector specifies an invalid query type: %s", queryType)); diff --git a/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/ResourceGroupIdTemplate.java b/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/ResourceGroupIdTemplate.java index 8c0d2f08e..5fc875a25 100644 --- a/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/ResourceGroupIdTemplate.java +++ b/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/ResourceGroupIdTemplate.java @@ -37,9 +37,9 @@ public class ResourceGroupIdTemplate @JsonCreator public ResourceGroupIdTemplate(String fullId) { - List segments = Splitter.on(".").splitToList(requireNonNull(fullId, "fullId is null")); - checkArgument(!segments.isEmpty(), "Resource group id is empty"); - this.segments = segments.stream() + List segmentsList = Splitter.on(".").splitToList(requireNonNull(fullId, "fullId is null")); + checkArgument(!segmentsList.isEmpty(), "Resource group id is empty"); + this.segments = segmentsList.stream() .map(ResourceGroupNameTemplate::new) .collect(Collectors.toList()); } diff --git a/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/StaticSelector.java b/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/StaticSelector.java index d4c32be59..494428538 100644 --- a/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/StaticSelector.java +++ b/presto-resource-group-managers/src/main/java/io/prestosql/plugin/resourcegroups/StaticSelector.java @@ -64,10 +64,10 @@ public class StaticSelector this.queryType = requireNonNull(queryType, "queryType is null"); this.group = requireNonNull(group, "group is null"); - HashSet variableNames = new HashSet<>(ImmutableList.of(USER_VARIABLE, SOURCE_VARIABLE)); - userRegex.ifPresent(u -> addNamedGroups(u, variableNames)); - sourceRegex.ifPresent(s -> addNamedGroups(s, variableNames)); - this.variableNames = ImmutableSet.copyOf(variableNames); + HashSet variableNamesSet = new HashSet<>(ImmutableList.of(USER_VARIABLE, SOURCE_VARIABLE)); + userRegex.ifPresent(u -> addNamedGroups(u, variableNamesSet)); + sourceRegex.ifPresent(s -> addNamedGroups(s, variableNamesSet)); + this.variableNames = ImmutableSet.copyOf(variableNamesSet); Set unresolvedVariables = Sets.difference(group.getVariableNames(), variableNames); checkArgument(unresolvedVariables.isEmpty(), "unresolved variables %s in resource group ID '%s', available: %s\"", unresolvedVariables, group, variableNames); diff --git a/presto-session-property-managers/src/test/java/io/prestosql/plugin/session/TestFileSessionPropertyManager.java b/presto-session-property-managers/src/test/java/io/prestosql/plugin/session/TestFileSessionPropertyManager.java index 6d22effed..df82c8fd8 100644 --- a/presto-session-property-managers/src/test/java/io/prestosql/plugin/session/TestFileSessionPropertyManager.java +++ b/presto-session-property-managers/src/test/java/io/prestosql/plugin/session/TestFileSessionPropertyManager.java @@ -37,6 +37,8 @@ import static org.testng.Assert.assertEquals; public class TestFileSessionPropertyManager { + private static final Pattern PIPELINE = Pattern.compile("global.pipeline.user_.*"); + private static final Pattern INTERACTIVE = Pattern.compile("global.interactive.user_.*"); private static final SessionConfigurationContext CONTEXT = new SessionConfigurationContext( "user", Optional.of("source"), @@ -54,7 +56,7 @@ public class TestFileSessionPropertyManager Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(Pattern.compile("global.pipeline.user_.*")), + Optional.of(PIPELINE), properties); assertProperties(properties, spec); @@ -107,7 +109,7 @@ public class TestFileSessionPropertyManager Optional.empty(), Optional.empty(), Optional.empty(), - Optional.of(Pattern.compile("global.interactive.user_.*")), + Optional.of(INTERACTIVE), ImmutableMap.of("PROPERTY", "VALUE")); assertProperties(ImmutableMap.of(), spec); diff --git a/presto-spi/src/main/java/io/prestosql/spi/connector/classloader/ClassLoaderSafeConnectorMetadata.java b/presto-spi/src/main/java/io/prestosql/spi/connector/classloader/ClassLoaderSafeConnectorMetadata.java index 005fc8477..bf9ed1d19 100644 --- a/presto-spi/src/main/java/io/prestosql/spi/connector/classloader/ClassLoaderSafeConnectorMetadata.java +++ b/presto-spi/src/main/java/io/prestosql/spi/connector/classloader/ClassLoaderSafeConnectorMetadata.java @@ -739,6 +739,7 @@ public class ClassLoaderSafeConnectorMetadata } } + @Override public Optional> applyProjection(ConnectorSession session, ConnectorTableHandle handle, List projections, Map assignments) { try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { @@ -746,6 +747,7 @@ public class ClassLoaderSafeConnectorMetadata } } + @Override public Optional applySample(ConnectorSession session, ConnectorTableHandle handle, SampleType sampleType, double sampleRatio) { try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { @@ -779,6 +781,7 @@ public class ClassLoaderSafeConnectorMetadata /** * Hetu can only create index for supported connectors. */ + @Override public boolean isHeuristicIndexSupported() { return delegate.isHeuristicIndexSupported(); diff --git a/presto-spi/src/main/java/io/prestosql/spi/dynamicfilter/BloomFilterDynamicFilter.java b/presto-spi/src/main/java/io/prestosql/spi/dynamicfilter/BloomFilterDynamicFilter.java index fc114e740..a3b48b710 100644 --- a/presto-spi/src/main/java/io/prestosql/spi/dynamicfilter/BloomFilterDynamicFilter.java +++ b/presto-spi/src/main/java/io/prestosql/spi/dynamicfilter/BloomFilterDynamicFilter.java @@ -22,6 +22,7 @@ import io.prestosql.spi.util.BloomFilter; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Set; import java.util.stream.Collectors; @@ -46,10 +47,7 @@ public class BloomFilterDynamicFilter public BloomFilterDynamicFilter(String filterId, ColumnHandle columnHandle, BloomFilter bloomFilterDeserialized, Type type) { - this.filterId = filterId; - this.type = type; - this.columnHandle = columnHandle; - this.bloomFilterDeserialized = bloomFilterDeserialized; + this(filterId, columnHandle, bloomFilterDeserialized, null, type); } private BloomFilterDynamicFilter(String filterId, ColumnHandle columnHandle, BloomFilter bloomFilterDeserialized, byte[] bloomFilterSerialized, Type type) @@ -83,7 +81,7 @@ public class BloomFilterDynamicFilter bloomFilter.add((Slice) value); } else { - bloomFilter.add(String.valueOf(value).getBytes()); + bloomFilter.add(String.valueOf(value).getBytes(StandardCharsets.UTF_8)); } } return bloomFilter; diff --git a/presto-spi/src/main/java/io/prestosql/spi/function/BuiltInScalarFunctionImplementation.java b/presto-spi/src/main/java/io/prestosql/spi/function/BuiltInScalarFunctionImplementation.java index a0f1c0327..76d9cde5e 100644 --- a/presto-spi/src/main/java/io/prestosql/spi/function/BuiltInScalarFunctionImplementation.java +++ b/presto-spi/src/main/java/io/prestosql/spi/function/BuiltInScalarFunctionImplementation.java @@ -129,7 +129,7 @@ public final class BuiltInScalarFunctionImplementation } List> parameterList = methodHandle.type().parameterList(); - boolean hasProperties = false; + boolean tmpHasProperties = false; if (parameterList.contains(ConnectorSession.class)) { checkArgument(parameterList.stream().filter(ConnectorSession.class::equals).count() == 1, "function implementation should have exactly one ConnectorSession parameter"); if (!instanceFactory.isPresent()) { @@ -138,9 +138,9 @@ public final class BuiltInScalarFunctionImplementation else { checkArgument(parameterList.get(1) == ConnectorSession.class, "ConnectorSession must be the second argument when instanceFactory is present"); } - hasProperties = true; + tmpHasProperties = true; } - this.hasProperties = hasProperties; + this.hasProperties = tmpHasProperties; } public boolean isNullable() diff --git a/presto-spi/src/main/java/io/prestosql/spi/function/RoutineCharacteristics.java b/presto-spi/src/main/java/io/prestosql/spi/function/RoutineCharacteristics.java index 1f9d833d4..42fd7caab 100644 --- a/presto-spi/src/main/java/io/prestosql/spi/function/RoutineCharacteristics.java +++ b/presto-spi/src/main/java/io/prestosql/spi/function/RoutineCharacteristics.java @@ -17,6 +17,7 @@ import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Locale; import java.util.Objects; import java.util.Optional; @@ -38,7 +39,7 @@ public class RoutineCharacteristics @JsonCreator public Language(String language) { - this.language = requireNonNull(language.toUpperCase()); + this.language = requireNonNull(language.toUpperCase(Locale.ROOT)); } @JsonValue diff --git a/presto-spi/src/main/java/io/prestosql/spi/function/Signature.java b/presto-spi/src/main/java/io/prestosql/spi/function/Signature.java index c410564fe..b26635aff 100644 --- a/presto-spi/src/main/java/io/prestosql/spi/function/Signature.java +++ b/presto-spi/src/main/java/io/prestosql/spi/function/Signature.java @@ -128,7 +128,7 @@ public final class Signature public static OperatorType unmangleOperator(String mangledName) { checkArgument(mangledName.startsWith(OPERATOR_PREFIX), "not a mangled operator name: %s", mangledName); - return OperatorType.valueOf(mangledName.substring(OPERATOR_PREFIX.length()).toUpperCase()); + return OperatorType.valueOf(mangledName.substring(OPERATOR_PREFIX.length()).toUpperCase(Locale.ROOT)); } public static boolean isMangleOperator(String mangledName) diff --git a/presto-spi/src/main/java/io/prestosql/spi/function/SqlInvokedFunction.java b/presto-spi/src/main/java/io/prestosql/spi/function/SqlInvokedFunction.java index 7dad3d866..6034fc656 100644 --- a/presto-spi/src/main/java/io/prestosql/spi/function/SqlInvokedFunction.java +++ b/presto-spi/src/main/java/io/prestosql/spi/function/SqlInvokedFunction.java @@ -155,11 +155,11 @@ public class SqlInvokedFunction public SqlFunctionHandle getRequiredFunctionHandle() { - Optional functionHandle = getFunctionHandle(); - if (!functionHandle.isPresent()) { + Optional sqlFunctionHandle = getFunctionHandle(); + if (!sqlFunctionHandle.isPresent()) { throw new IllegalStateException("missing functionHandle"); } - return functionHandle.get(); + return sqlFunctionHandle.get(); } public String getRequiredVersion() diff --git a/presto-spi/src/main/java/io/prestosql/spi/security/SelectedRole.java b/presto-spi/src/main/java/io/prestosql/spi/security/SelectedRole.java index ee468d82a..79e8ce8f6 100644 --- a/presto-spi/src/main/java/io/prestosql/spi/security/SelectedRole.java +++ b/presto-spi/src/main/java/io/prestosql/spi/security/SelectedRole.java @@ -90,9 +90,9 @@ public class SelectedRole { Matcher m = PATTERN.matcher(value); if (m.matches()) { - Type type = Type.valueOf(m.group(1)); - Optional role = Optional.ofNullable(m.group(3)); - return new SelectedRole(type, role); + Type tmpType = Type.valueOf(m.group(1)); + Optional role1 = Optional.ofNullable(m.group(3)); + return new SelectedRole(tmpType, role1); } throw new IllegalArgumentException("Could not parse selected role: " + value); } diff --git a/presto-spi/src/main/java/io/prestosql/spi/statistics/ComputedStatistics.java b/presto-spi/src/main/java/io/prestosql/spi/statistics/ComputedStatistics.java index 3fcc8f56e..36b668265 100644 --- a/presto-spi/src/main/java/io/prestosql/spi/statistics/ComputedStatistics.java +++ b/presto-spi/src/main/java/io/prestosql/spi/statistics/ComputedStatistics.java @@ -143,16 +143,16 @@ public class ComputedStatistics public static ComputedStatistics restoreComputedStatistics(Object state, BlockEncodingSerdeProvider serdeProvider) { ComputedStatisticsState myState = (ComputedStatisticsState) state; - List groupingValues = Arrays.stream(myState.groupingValues).map(array -> restoreBlock(array, serdeProvider)).collect(Collectors.toList()); - Map tableStatistics = new HashMap<>(); + List groupingValuesList = Arrays.stream(myState.groupingValues).map(array -> restoreBlock(array, serdeProvider)).collect(Collectors.toList()); + Map tableStatisticTypeMap = new HashMap<>(); for (Map.Entry entry : myState.tableStatistics.entrySet()) { - tableStatistics.put(entry.getKey(), restoreBlock(entry.getValue(), serdeProvider)); + tableStatisticTypeMap.put(entry.getKey(), restoreBlock(entry.getValue(), serdeProvider)); } - Map columnStatistics = new HashMap<>(); + Map columnStatisticMetadataMap = new HashMap<>(); for (Map.Entry entry : myState.columnStatistics.entrySet()) { - columnStatistics.put(entry.getKey(), restoreBlock(entry.getValue(), serdeProvider)); + columnStatisticMetadataMap.put(entry.getKey(), restoreBlock(entry.getValue(), serdeProvider)); } - return new ComputedStatistics(myState.groupingColumns, groupingValues, tableStatistics, columnStatistics); + return new ComputedStatistics(myState.groupingColumns, groupingValuesList, tableStatisticTypeMap, columnStatisticMetadataMap); } private static byte[] serializeBlock(Block block, BlockEncodingSerdeProvider serdeProvider) diff --git a/presto-spi/src/test/java/io/prestosql/spi/dynamicfilter/TestBloomFilterDynamicFilter.java b/presto-spi/src/test/java/io/prestosql/spi/dynamicfilter/TestBloomFilterDynamicFilter.java index 904052b2f..4ee9534b5 100644 --- a/presto-spi/src/test/java/io/prestosql/spi/dynamicfilter/TestBloomFilterDynamicFilter.java +++ b/presto-spi/src/test/java/io/prestosql/spi/dynamicfilter/TestBloomFilterDynamicFilter.java @@ -17,6 +17,7 @@ package io.prestosql.spi.dynamicfilter; import io.airlift.slice.Slice; import org.testng.annotations.Test; +import java.nio.charset.StandardCharsets; import java.util.HashSet; import static io.airlift.slice.Slices.utf8Slice; @@ -50,7 +51,7 @@ public class TestBloomFilterDynamicFilter assertTrue(bfdf.contains(v3)); assertTrue(bfdf.contains(String.valueOf(v4))); assertTrue(bfdf.contains(v5)); - assertTrue(bfdf.contains(new String(v5.getBytes()))); + assertTrue(bfdf.contains(new String(v5.getBytes(), StandardCharsets.UTF_8))); assertFalse(bfdf.contains(String.valueOf(5))); assertTrue(bfdf.contains(v6)); } diff --git a/presto-spi/src/test/java/io/prestosql/spi/snapshot/SnapshotTestUtil.java b/presto-spi/src/test/java/io/prestosql/spi/snapshot/SnapshotTestUtil.java index caa4621c1..2b6bc62fa 100644 --- a/presto-spi/src/test/java/io/prestosql/spi/snapshot/SnapshotTestUtil.java +++ b/presto-spi/src/test/java/io/prestosql/spi/snapshot/SnapshotTestUtil.java @@ -14,6 +14,8 @@ */ package io.prestosql.spi.snapshot; +import io.airlift.log.Logger; + import java.lang.reflect.Array; import java.lang.reflect.Field; import java.util.ArrayList; @@ -25,6 +27,8 @@ import java.util.Set; public final class SnapshotTestUtil { + private static final Logger LOG = Logger.get(SnapshotTestUtil.class); + private SnapshotTestUtil() {} public static Map toSimpleSnapshotMapping(Object snapshot) @@ -37,7 +41,7 @@ public final class SnapshotTestUtil fieldValue = field.get(snapshot); } catch (IllegalAccessException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } if (fieldValue == null) { continue; @@ -113,7 +117,7 @@ public final class SnapshotTestUtil } } catch (IllegalAccessException e) { - e.printStackTrace(); + LOG.info("Error message: " + e.getStackTrace()); } } return result; diff --git a/presto-spi/src/test/java/io/prestosql/spi/util/TestBloomFilter.java b/presto-spi/src/test/java/io/prestosql/spi/util/TestBloomFilter.java index 4cd5d70da..15923f88e 100644 --- a/presto-spi/src/test/java/io/prestosql/spi/util/TestBloomFilter.java +++ b/presto-spi/src/test/java/io/prestosql/spi/util/TestBloomFilter.java @@ -19,6 +19,7 @@ import org.testng.annotations.Test; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.util.Random; import static org.testng.Assert.assertFalse; @@ -91,7 +92,7 @@ public class TestBloomFilter { BloomFilter bloomFilter = new BloomFilter(COUNT, 0.1); for (String value : values) { - bloomFilter.add(value.getBytes()); + bloomFilter.add(value.getBytes(StandardCharsets.UTF_8)); } ByteArrayOutputStream out = new ByteArrayOutputStream(); @@ -104,7 +105,7 @@ public class TestBloomFilter System.out.println("Deserialization 1M values took: " + (System.nanoTime() - deserializationStart) / 1000000 + " ms"); for (String value : values) { - assertTrue(deserializedBloomFilter.test(value.getBytes()), "Value should exist in deserialized BloomFilter"); + assertTrue(deserializedBloomFilter.test(value.getBytes(StandardCharsets.UTF_8)), "Value should exist in deserialized BloomFilter"); } BloomFilter bloomFilter1 = new BloomFilter(COUNT, 0.01); diff --git a/presto-sqlserver/src/main/java/io/prestosql/plugin/sqlserver/SqlServerClient.java b/presto-sqlserver/src/main/java/io/prestosql/plugin/sqlserver/SqlServerClient.java index b8c624aef..06328d7a5 100644 --- a/presto-sqlserver/src/main/java/io/prestosql/plugin/sqlserver/SqlServerClient.java +++ b/presto-sqlserver/src/main/java/io/prestosql/plugin/sqlserver/SqlServerClient.java @@ -76,7 +76,7 @@ public class SqlServerClient { String sql = format( "sp_rename %s, %s", - singleQuote(catalogName, schemaName, tableName), + singleQuoteByList(catalogName, schemaName, tableName), singleQuote(newTable.getTableName())); try (Connection connection = connectionFactory.openConnection(identity)) { execute(connection, sql); @@ -92,7 +92,7 @@ public class SqlServerClient try (Connection connection = connectionFactory.openConnection(identity)) { String sql = format( "sp_rename %s, %s, 'COLUMN'", - singleQuote(handle.getCatalogName(), handle.getSchemaName(), handle.getTableName(), jdbcColumn.getColumnName()), + singleQuoteByList(handle.getCatalogName(), handle.getSchemaName(), handle.getTableName(), jdbcColumn.getColumnName()), singleQuote(newColumnName)); execute(connection, sql); } @@ -164,7 +164,7 @@ public class SqlServerClient return true; } - private static String singleQuote(String... objects) + private static String singleQuoteByList(String... objects) { return singleQuote(DOT_JOINER.join(objects)); } diff --git a/presto-sqlserver/src/test/java/io/prestosql/plugin/sqlserver/SqlServerQueryRunner.java b/presto-sqlserver/src/test/java/io/prestosql/plugin/sqlserver/SqlServerQueryRunner.java index 16905c4ea..24677f67a 100644 --- a/presto-sqlserver/src/test/java/io/prestosql/plugin/sqlserver/SqlServerQueryRunner.java +++ b/presto-sqlserver/src/test/java/io/prestosql/plugin/sqlserver/SqlServerQueryRunner.java @@ -50,9 +50,10 @@ public final class SqlServerQueryRunner return createSqlServerQueryRunner(testingSqlServer, ImmutableMap.of(), ImmutableList.copyOf(tables)); } - public static QueryRunner createSqlServerQueryRunner(TestingSqlServer testingSqlServer, Map connectorProperties, Iterable> tables) + public static QueryRunner createSqlServerQueryRunner(TestingSqlServer testingSqlServer, Map inputConnectorProperties, Iterable> tables) throws Exception { + Map connectorProperties = inputConnectorProperties; DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(createSession()) .build(); try { diff --git a/presto-testing-docker/src/main/java/io/prestosql/testing/docker/DockerContainer.java b/presto-testing-docker/src/main/java/io/prestosql/testing/docker/DockerContainer.java index 7623002e9..40c321c0d 100644 --- a/presto-testing-docker/src/main/java/io/prestosql/testing/docker/DockerContainer.java +++ b/presto-testing-docker/src/main/java/io/prestosql/testing/docker/DockerContainer.java @@ -226,7 +226,7 @@ public final class DockerContainer private void waitForContainerPorts(List ports) { - List hostPorts = ports.stream() + List hostPortsList = ports.stream() .map(this::getHostPort) .collect(toImmutableList()); @@ -235,7 +235,7 @@ public final class DockerContainer .withMaxAttempts(Integer.MAX_VALUE) // limited by MaxDuration .abortOn(error -> !isContainerUp()) .withDelay(Duration.of(5, SECONDS)) - .onRetry(event -> LOG.info("Waiting for ports %s that are exposed on %s on %s ...", ports, HOST_IP, hostPorts)); + .onRetry(event -> LOG.info("Waiting for ports %s that are exposed on %s on %s ...", ports, HOST_IP, hostPortsList)); Failsafe.with(retryPolicy).run(() -> { for (int port : ports) { diff --git a/presto-tests/src/main/java/io/prestosql/tests/AbstractTestJoinQueries.java b/presto-tests/src/main/java/io/prestosql/tests/AbstractTestJoinQueries.java index 129511cde..e0c4b1324 100644 --- a/presto-tests/src/main/java/io/prestosql/tests/AbstractTestJoinQueries.java +++ b/presto-tests/src/main/java/io/prestosql/tests/AbstractTestJoinQueries.java @@ -873,7 +873,7 @@ public class AbstractTestJoinQueries queryTemplate.replace(condition.of("(x+y in (VALUES 4,5)) AND (x in (VALUES 4,5)) != (y in (VALUES 4,5))")), "VALUES (4,1)"); - for (QueryTemplate.Parameter joinType : type.of("left", "right", "full")) { + for (QueryTemplate.Parameter joinType : type.ofStringList("left", "right", "full")) { assertQueryFails( queryTemplate.replace( joinType, diff --git a/presto-tests/src/main/java/io/prestosql/tests/AbstractTestOrderByQueries.java b/presto-tests/src/main/java/io/prestosql/tests/AbstractTestOrderByQueries.java index e0687d13f..e17d53f12 100644 --- a/presto-tests/src/main/java/io/prestosql/tests/AbstractTestOrderByQueries.java +++ b/presto-tests/src/main/java/io/prestosql/tests/AbstractTestOrderByQueries.java @@ -121,9 +121,9 @@ public class AbstractTestOrderByQueries queryTemplate("SELECT count(*) %output% FROM (SELECT substr(name,1,1) letter FROM nation) x GROUP BY %groupBy% ORDER BY %orderBy%") .replaceAll( - parameter("output").of("", ", letter", ", letter AS y"), - parameter("groupBy").of("x.letter", "letter"), - parameter("orderBy").of("x.letter", "letter")) + parameter("output").ofStringList("", ", letter", ", letter AS y"), + parameter("groupBy").ofStringList("x.letter", "letter"), + parameter("orderBy").ofStringList("x.letter", "letter")) .forEach(this::assertQueryOrdered); } diff --git a/presto-tests/src/main/java/io/prestosql/tests/AbstractTestQueries.java b/presto-tests/src/main/java/io/prestosql/tests/AbstractTestQueries.java index 6583e7e85..66b0d707e 100644 --- a/presto-tests/src/main/java/io/prestosql/tests/AbstractTestQueries.java +++ b/presto-tests/src/main/java/io/prestosql/tests/AbstractTestQueries.java @@ -3302,11 +3302,11 @@ public abstract class AbstractTestQueries "GROUP BY o1.orderkey ORDER BY o1.orderkey LIMIT 5", joinType, condition); - List conditions = condition.of( + List conditions = condition.ofStringList( "EXISTS(SELECT avg(orderkey) FROM orders)", "(SELECT avg(orderkey) FROM orders) > 3"); for (QueryTemplate.Parameter actualCondition : conditions) { - for (QueryTemplate.Parameter actualJoinType : joinType.of("", "LEFT", "RIGHT")) { + for (QueryTemplate.Parameter actualJoinType : joinType.ofStringList("", "LEFT", "RIGHT")) { assertQuery(queryTemplate.replace(actualJoinType, actualCondition)); } assertQuery( @@ -4913,20 +4913,20 @@ public abstract class AbstractTestQueries //the %subquery% is wrapped in a SELECT so that H2 does not blow up on the VALUES subquery return queryTemplate("SELECT %value% %operator% %quantifier% (SELECT * FROM (%subquery%))") .replaceAll( - parameter("subquery").of( + parameter("subquery").ofStringList( "SELECT 1 WHERE false", "SELECT CAST(NULL AS INTEGER)", "VALUES (1), (NULL)"), - parameter("quantifier").of("ALL", "ANY"), - parameter("value").of("1", "NULL"), - parameter("operator").of("=", "!=", "<", ">", "<=", ">=")) + parameter("quantifier").ofStringList("ALL", "ANY"), + parameter("value").ofStringList("1", "NULL"), + parameter("operator").ofStringList("=", "!=", "<", ">", "<=", ">=")) .collect(toDataProvider()); } @Test public void testPreparedStatementWithSubqueries() { - List leftValues = parameter("left").of( + List leftValues = parameter("left").ofStringList( "", "1 = ", "EXISTS", "1 IN", @@ -5068,8 +5068,8 @@ public abstract class AbstractTestQueries @Test public void testSubqueriesWithDisjunction() { - List projections = parameter("projection").of("count(*)", "*", "%condition%"); - List conditions = parameter("condition").of( + List projections = parameter("projection").ofStringList("count(*)", "*", "%condition%"); + List conditions = parameter("condition").ofStringList( "nationkey IN (SELECT 1) OR TRUE", "EXISTS(SELECT 1) OR TRUE"); diff --git a/presto-tests/src/test/java/io/prestosql/execution/TestDataCenterHTTPClientV1.java b/presto-tests/src/test/java/io/prestosql/execution/TestDataCenterHTTPClientV1.java index 5b3191ba8..5846a6191 100644 --- a/presto-tests/src/test/java/io/prestosql/execution/TestDataCenterHTTPClientV1.java +++ b/presto-tests/src/test/java/io/prestosql/execution/TestDataCenterHTTPClientV1.java @@ -248,16 +248,16 @@ public class TestDataCenterHTTPClientV1 public static DistributedQueryRunner createQueryRunner(Session session) throws Exception { - DistributedQueryRunner queryRunner = DistributedQueryRunner.builder(session) + DistributedQueryRunner distributedQueryRunner = DistributedQueryRunner.builder(session) .setNodeCount(2) .build(); try { - queryRunner.installPlugin(new TpchPlugin()); - queryRunner.createCatalog("tpch", "tpch"); - return queryRunner; + distributedQueryRunner.installPlugin(new TpchPlugin()); + distributedQueryRunner.createCatalog("tpch", "tpch"); + return distributedQueryRunner; } catch (Exception e) { - queryRunner.close(); + distributedQueryRunner.close(); throw e; } } diff --git a/presto-tests/src/test/java/io/prestosql/memory/TestMemoryManager.java b/presto-tests/src/test/java/io/prestosql/memory/TestMemoryManager.java index 7b0e13077..53d433e77 100644 --- a/presto-tests/src/test/java/io/prestosql/memory/TestMemoryManager.java +++ b/presto-tests/src/test/java/io/prestosql/memory/TestMemoryManager.java @@ -14,6 +14,7 @@ package io.prestosql.memory; import com.google.common.collect.ImmutableMap; +import io.airlift.log.Logger; import io.prestosql.Session; import io.prestosql.plugin.tpch.TpchPlugin; import io.prestosql.server.BasicQueryInfo; @@ -55,6 +56,7 @@ import static org.testng.Assert.fail; @Test(singleThreaded = true) public class TestMemoryManager { + private static final Logger LOG = Logger.get(TestMemoryManager.class); private static final Session SESSION = testSessionBuilder() .setCatalog("tpch") // Use sf1000 to make sure this takes at least one second, so that the memory manager will fail the query @@ -98,6 +100,7 @@ public class TestMemoryManager } catch (RuntimeException e) { // expected + LOG.info("Error message: " + e.getMessage()); } Session session = testSessionBuilder() .setCatalog("tpch") @@ -214,8 +217,10 @@ public class TestMemoryManager public void testNoLeak() throws Exception { - testNoLeak("SELECT clerk FROM orders"); // TableScan operator - testNoLeak("SELECT COUNT(*), clerk FROM orders WHERE orderstatus='O' GROUP BY clerk"); // ScanFilterProjectOperator, AggregationOperator + // TableScan operator + testNoLeak("SELECT clerk FROM orders"); + // ScanFilterProjectOperator and AggregationOperator + testNoLeak("SELECT COUNT(*), clerk FROM orders WHERE orderstatus='O' GROUP BY clerk"); } private void testNoLeak(@Language("SQL") String query) diff --git a/presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/valuesets/PrestoThriftEquatableValueSet.java b/presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/valuesets/PrestoThriftEquatableValueSet.java index 98173dae6..e059d2218 100644 --- a/presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/valuesets/PrestoThriftEquatableValueSet.java +++ b/presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/valuesets/PrestoThriftEquatableValueSet.java @@ -94,9 +94,9 @@ public final class PrestoThriftEquatableValueSet public static PrestoThriftEquatableValueSet fromEquatableValueSet(EquatableValueSet valueSet) { Type type = valueSet.getType(); - Set values = valueSet.getEntries(); - List thriftValues = new ArrayList<>(values.size()); - for (ValueEntry value : values) { + Set valueEntrySet = valueSet.getEntries(); + List thriftValues = new ArrayList<>(valueEntrySet.size()); + for (ValueEntry value : valueEntrySet) { checkState(type.equals(value.getType()), "ValueEntrySet has elements of different types: %s vs %s", type, value.getType()); thriftValues.add(fromBlock(value.getBlock(), type)); } diff --git a/presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/valuesets/PrestoThriftRangeValueSet.java b/presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/valuesets/PrestoThriftRangeValueSet.java index d2f397b87..9468e75db 100644 --- a/presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/valuesets/PrestoThriftRangeValueSet.java +++ b/presto-thrift-api/src/main/java/io/prestosql/plugin/thrift/api/valuesets/PrestoThriftRangeValueSet.java @@ -89,10 +89,10 @@ public final class PrestoThriftRangeValueSet public static PrestoThriftRangeValueSet fromSortedRangeSet(SortedRangeSet valueSet) { - List ranges = valueSet.getOrderedRanges().stream() + List prestoThriftRanges = valueSet.getOrderedRanges().stream() .map(PrestoThriftRange::fromRange) .collect(toImmutableList()); - return new PrestoThriftRangeValueSet(ranges); + return new PrestoThriftRangeValueSet(prestoThriftRanges); } @ThriftEnum @@ -192,8 +192,8 @@ public final class PrestoThriftRangeValueSet public static PrestoThriftMarker fromMarker(Marker marker) { - PrestoThriftBlock value = marker.getValueBlock().isPresent() ? fromBlock(marker.getValueBlock().get(), marker.getType()) : null; - return new PrestoThriftMarker(value, fromBound(marker.getBound())); + PrestoThriftBlock prestoThriftBlock = marker.getValueBlock().isPresent() ? fromBlock(marker.getValueBlock().get(), marker.getType()) : null; + return new PrestoThriftMarker(prestoThriftBlock, fromBound(marker.getBound())); } } diff --git a/presto-thrift-testing-server/src/main/java/io/prestosql/plugin/thrift/server/ThriftIndexedTpchService.java b/presto-thrift-testing-server/src/main/java/io/prestosql/plugin/thrift/server/ThriftIndexedTpchService.java index 605829f89..d9231d656 100644 --- a/presto-thrift-testing-server/src/main/java/io/prestosql/plugin/thrift/server/ThriftIndexedTpchService.java +++ b/presto-thrift-testing-server/src/main/java/io/prestosql/plugin/thrift/server/ThriftIndexedTpchService.java @@ -32,6 +32,7 @@ import io.prestosql.tests.tpch.TpchIndexedData; import io.prestosql.tests.tpch.TpchIndexedData.IndexedTable; import io.prestosql.tests.tpch.TpchScaledTable; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -181,7 +182,7 @@ public class ThriftIndexedTpchService } else { checkArgument(bytes != null); - result.add(new String(bytes, startOffset, sizes[index])); + result.add(new String(bytes, startOffset, sizes[index], StandardCharsets.UTF_8)); startOffset += sizes[index]; } } diff --git a/presto-thrift-testing-server/src/main/java/io/prestosql/plugin/thrift/server/ThriftTpchService.java b/presto-thrift-testing-server/src/main/java/io/prestosql/plugin/thrift/server/ThriftTpchService.java index a4dad26f9..ee1fc2ee7 100644 --- a/presto-thrift-testing-server/src/main/java/io/prestosql/plugin/thrift/server/ThriftTpchService.java +++ b/presto-thrift-testing-server/src/main/java/io/prestosql/plugin/thrift/server/ThriftTpchService.java @@ -228,6 +228,8 @@ public class ThriftTpchService return 0.01; case "sf1": return 1.0; + default: + break; } throw new IllegalArgumentException("Schema is not setup: " + schemaName); } diff --git a/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsColumnHandle.java b/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsColumnHandle.java index c0e413f2d..8fba9e654 100644 --- a/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsColumnHandle.java +++ b/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsColumnHandle.java @@ -38,6 +38,7 @@ public class TpcdsColumnHandle } @JsonProperty + @Override public String getColumnName() { return columnName; diff --git a/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsMetadata.java b/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsMetadata.java index 10956c862..f9c389478 100644 --- a/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsMetadata.java +++ b/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsMetadata.java @@ -66,11 +66,11 @@ public class TpcdsMetadata public TpcdsMetadata() { - ImmutableSet.Builder tableNames = ImmutableSet.builder(); + ImmutableSet.Builder tableNamesBuilder = ImmutableSet.builder(); for (Table tpcdsTable : Table.getBaseTables()) { - tableNames.add(tpcdsTable.getName().toLowerCase(ENGLISH)); + tableNamesBuilder.add(tpcdsTable.getName().toLowerCase(ENGLISH)); } - this.tableNames = tableNames.build(); + this.tableNames = tableNamesBuilder.build(); } @Override diff --git a/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsRecordSet.java b/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsRecordSet.java index 347ffefac..a33c0f9fe 100644 --- a/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsRecordSet.java +++ b/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/TpcdsRecordSet.java @@ -55,11 +55,11 @@ public class TpcdsRecordSet this.results = results; this.columns = ImmutableList.copyOf(columns); - ImmutableList.Builder columnTypes = ImmutableList.builder(); + ImmutableList.Builder columnTypesBuilder = ImmutableList.builder(); for (Column column : columns) { - columnTypes.add(getPrestoType(column.getType())); + columnTypesBuilder.add(getPrestoType(column.getType())); } - this.columnTypes = columnTypes.build(); + this.columnTypes = columnTypesBuilder.build(); } @Override diff --git a/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/statistics/TableStatisticsDataRepository.java b/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/statistics/TableStatisticsDataRepository.java index 2cc8e2788..a71f2926f 100644 --- a/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/statistics/TableStatisticsDataRepository.java +++ b/presto-tpcds/src/main/java/io/prestosql/plugin/tpcds/statistics/TableStatisticsDataRepository.java @@ -34,10 +34,11 @@ public class TableStatisticsDataRepository .registerModule(new Jdk8Module()); public void save( - String schemaName, + String inputSchemaName, Table table, TableStatisticsData statisticsData) { + String schemaName = inputSchemaName; schemaName = normalizeSchemaName(schemaName); String filename = table.getName(); Path path = Paths.get("presto-tpcds", "src", "main", "resources", "tpcds", "statistics", schemaName, filename + ".json"); @@ -67,8 +68,9 @@ public class TableStatisticsDataRepository } } - public Optional load(String schemaName, Table table) + public Optional load(String schemaNameInput, Table table) { + String schemaName = schemaNameInput; schemaName = normalizeSchemaName(schemaName); String filename = table.getName(); String resourcePath = "/tpcds/statistics/" + schemaName + "/" + filename + ".json"; diff --git a/presto-tpch/src/main/java/io/prestosql/plugin/tpch/TpchColumnHandle.java b/presto-tpch/src/main/java/io/prestosql/plugin/tpch/TpchColumnHandle.java index d98998b26..321d08daf 100644 --- a/presto-tpch/src/main/java/io/prestosql/plugin/tpch/TpchColumnHandle.java +++ b/presto-tpch/src/main/java/io/prestosql/plugin/tpch/TpchColumnHandle.java @@ -38,6 +38,7 @@ public class TpchColumnHandle } @JsonProperty + @Override public String getColumnName() { return columnName; diff --git a/presto-tpch/src/main/java/io/prestosql/plugin/tpch/TpchMetadata.java b/presto-tpch/src/main/java/io/prestosql/plugin/tpch/TpchMetadata.java index bdc738eda..d5e5ed197 100644 --- a/presto-tpch/src/main/java/io/prestosql/plugin/tpch/TpchMetadata.java +++ b/presto-tpch/src/main/java/io/prestosql/plugin/tpch/TpchMetadata.java @@ -135,11 +135,11 @@ public class TpchMetadata public TpchMetadata(ColumnNaming columnNaming, boolean predicatePushdownEnabled, boolean partitioningEnabled) { - ImmutableSet.Builder tableNames = ImmutableSet.builder(); + ImmutableSet.Builder tableNamesBuilder = ImmutableSet.builder(); for (TpchTable tpchTable : TpchTable.getTables()) { - tableNames.add(tpchTable.getTableName()); + tableNamesBuilder.add(tpchTable.getTableName()); } - this.tableNames = tableNames.build(); + this.tableNames = tableNamesBuilder.build(); this.columnNaming = columnNaming; this.predicatePushdownEnabled = predicatePushdownEnabled; this.partitioningEnabled = partitioningEnabled; @@ -463,6 +463,7 @@ public class TpchMetadata localProperties); } + @Override public Optional> applyFilter(ConnectorSession session, ConnectorTableHandle table, Constraint constraint) { TpchTableHandle handle = (TpchTableHandle) table;