diff --git a/src/main/kotlin/cz/dynawest/csvcruncher/HsqlDbHelper.kt b/src/main/kotlin/cz/dynawest/csvcruncher/HsqlDbHelper.kt index c5613ba..9176fd5 100644 --- a/src/main/kotlin/cz/dynawest/csvcruncher/HsqlDbHelper.kt +++ b/src/main/kotlin/cz/dynawest/csvcruncher/HsqlDbHelper.kt @@ -98,7 +98,7 @@ class HsqlDbHelper(val jdbcConn: Connection) { } catch (ex: SQLSyntaxErrorException) { if (ex.message!!.contains("object not found:")) { - throw throwHintForObjectNotFound(ex, this) + throw throwHintForObjectNotFound(ex, this, sql) } throw CsvCruncherException(""" | Seems your SQL contains errors: diff --git a/src/main/kotlin/cz/dynawest/csvcruncher/util/HsqldbErrorHandling.kt b/src/main/kotlin/cz/dynawest/csvcruncher/util/HsqldbErrorHandling.kt index b0c71dd..a645076 100644 --- a/src/main/kotlin/cz/dynawest/csvcruncher/util/HsqldbErrorHandling.kt +++ b/src/main/kotlin/cz/dynawest/csvcruncher/util/HsqldbErrorHandling.kt @@ -10,7 +10,7 @@ object HsqldbErrorHandling { /** * Analyzes the exception against the given DB connection and rethrows an exception with a message containing the available objects as a hint. */ - fun throwHintForObjectNotFound(ex: SQLSyntaxErrorException, helper: HsqlDbHelper): CsvCruncherException { + fun throwHintForObjectNotFound(ex: SQLSyntaxErrorException, helper: HsqlDbHelper, sql: String): CsvCruncherException { val notFoundIsColumn = analyzeWhatWasNotFound(ex.message!!) val tableNames = helper.formatListOfAvailableTables(notFoundIsColumn) val hintMsg = if (notFoundIsColumn) """ @@ -23,6 +23,8 @@ object HsqldbErrorHandling { | Looks like you are referring to a table that was not created. | This could mean that you have a typo in the input file name, | or maybe you use --combineInputs but try to use the original inputs. + | Or it is this known bug: https://github.com/OndraZizka/csv-cruncher/issues/149 + | SQL: $sql | These tables are actually available: | """.trimMargin() diff --git a/src/test/kotlin/cz/dynawest/csvcruncher/it/OptionsCombinationsTest.kt b/src/test/kotlin/cz/dynawest/csvcruncher/it/OptionsCombinationsTest.kt index 8deb257..9c92b11 100644 --- a/src/test/kotlin/cz/dynawest/csvcruncher/it/OptionsCombinationsTest.kt +++ b/src/test/kotlin/cz/dynawest/csvcruncher/it/OptionsCombinationsTest.kt @@ -116,6 +116,18 @@ class OptionsCombinationsTest { assertIterableEquals("Op,recording_group_id,status,storage_base_url,owner_id,room_id,session_id,requested_ts,created_ts,deleted_ts,updated_ts,is_deleted,acc_consumer_id".split(","), columnNames) } + /** + * Fails because of: + * $table placeholder not replaced when dir input with non-canonical JSONs is used. #149 + * https://github.com/OndraZizka/csv-cruncher/issues/149 + * + * Fails in extractColumnsInfoFrom1LineSelect() + * when querying + * SQL: SELECT $table.* FROM $table LIMIT 1 + * + * The solution is not trivial, it needs to determine the output columns, using some merging of common columns, + * probably utilizing SQL's NATURAL JOIN to reuse the same-named columns. + */ @Test fun combineInputDir_JsonAndCsv_defaultSql_issue149(testInfo: TestInfo) { val command =