Skip to content

Commit

Permalink
More hints and comments around the bug #149.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ondrej Zizka committed Nov 29, 2024
1 parent 12b2090 commit 5b2fe80
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/cz/dynawest/csvcruncher/HsqlDbHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) """
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 5b2fe80

Please sign in to comment.