From 6e7fb516a3a70db57e49f74c46886a2bceb9d7d5 Mon Sep 17 00:00:00 2001 From: Joan Augsburger Date: Mon, 22 Jun 2020 18:52:11 +0100 Subject: [PATCH] fix(griffin) - missing 'throws' (#423) --- .../src/main/java/io/questdb/griffin/SqlCompiler.java | 2 +- .../AlterTableAlterSymbolColumnCacheFlagTest.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/io/questdb/griffin/SqlCompiler.java b/core/src/main/java/io/questdb/griffin/SqlCompiler.java index 0e45256ed..2e85f9c32 100644 --- a/core/src/main/java/io/questdb/griffin/SqlCompiler.java +++ b/core/src/main/java/io/questdb/griffin/SqlCompiler.java @@ -883,7 +883,7 @@ public class SqlCompiler implements Closeable { } if (metadata.getColumnType(columnIndex) != ColumnType.SYMBOL) { - SqlException.$(lexer.lastTokenPosition(), "Invalid column type - Column should be of type symbol"); + throw SqlException.$(lexer.lastTokenPosition(), "Invalid column type - Column should be of type symbol"); } writer.changeCacheFlag(columnIndex, cache); diff --git a/core/src/test/java/io/questdb/griffin/AlterTableAlterSymbolColumnCacheFlagTest.java b/core/src/test/java/io/questdb/griffin/AlterTableAlterSymbolColumnCacheFlagTest.java index f0e3e7554..14b439b78 100644 --- a/core/src/test/java/io/questdb/griffin/AlterTableAlterSymbolColumnCacheFlagTest.java +++ b/core/src/test/java/io/questdb/griffin/AlterTableAlterSymbolColumnCacheFlagTest.java @@ -24,7 +24,9 @@ package io.questdb.griffin; -import io.questdb.cairo.*; +import io.questdb.cairo.RecordCursorPrinter; +import io.questdb.cairo.TableReader; +import io.questdb.cairo.TableWriter; import io.questdb.cairo.sql.Record; import io.questdb.cairo.sql.RecordMetadata; import io.questdb.griffin.engine.functions.rnd.SharedRandom; @@ -35,8 +37,6 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Test; -import static io.questdb.griffin.CompiledQuery.ALTER; - public class AlterTableAlterSymbolColumnCacheFlagTest extends AbstractGriffinTest { @Before @@ -49,6 +49,11 @@ public class AlterTableAlterSymbolColumnCacheFlagTest extends AbstractGriffinTes assertFailure("alter table x alter column z", 28, "'add index' or 'cache' or 'nocache' expected"); } + @Test + public void testAlterFlagInNonSymbolColumn() throws Exception { + assertFailure("alter table x alter column b cache", 29, "Invalid column type - Column should be of type symbol"); + } + @Test public void testWhenCacheOrNocacheAreNotInAlterStatement() throws Exception { assertFailure("alter table x alter column z ca", 29, "'cache' or 'nocache' expected"); -- GitLab