diff --git a/dbeam-core/src/test/java/com/spotify/dbeam/args/QueryBuilderArgsTest.java b/dbeam-core/src/test/java/com/spotify/dbeam/args/QueryBuilderArgsTest.java index 0012770a..280a6b55 100644 --- a/dbeam-core/src/test/java/com/spotify/dbeam/args/QueryBuilderArgsTest.java +++ b/dbeam-core/src/test/java/com/spotify/dbeam/args/QueryBuilderArgsTest.java @@ -291,6 +291,19 @@ public void shouldCreateParallelQueriesWithPartitionColumn() throws IOException, actual.buildQueries(connection)); } + @Test + public void testSqlQueryWithLimitOne() throws IOException, SQLException { + final QueryBuilderArgs actual = + parseOptions( + String.format( + "--connectionUrl=jdbc:postgresql://some_db --sqlFile=%s", + coffeesSqlQueryPath.toString())); + Assert.assertEquals( + "SELECT * FROM (SELECT * FROM COFFEES WHERE SIZE > 10)" + + " as user_sql_query WHERE 1=1 LIMIT 1", + actual.sqlQueryWithLimitOne()); + } + private QueryBuilderArgs parseOptions(String cmdLineArgs) throws IOException { JdbcExportPipelineOptions opts = commandLineToOptions(cmdLineArgs); return JdbcExportArgsFactory.createQueryArgs(opts);