databricks-sql-nodejs icon indicating copy to clipboard operation
databricks-sql-nodejs copied to clipboard

TypeError: Cannot read properties of undefined (reading 'binaryVal')

Open IrakliJani opened this issue 3 years ago • 11 comments

getting an error when I try to get columns of the table.

version: @databricks/[email protected]

TypeError: Cannot read properties of undefined (reading 'binaryVal')
    at JsonResult.getColumnValue (/Users/jani/code/lightdash/node_modules/@databricks/sql/dist/result/JsonResult.js:108:23)
    at JsonResult.getSchemaValues (/Users/jani/code/lightdash/node_modules/@databricks/sql/dist/result/JsonResult.js:40:34)
    at /Users/jani/code/lightdash/node_modules/@databricks/sql/dist/result/JsonResult.js:28:62
    at Array.reduce (<anonymous>)
    at JsonResult.getRows (/Users/jani/code/lightdash/node_modules/@databricks/sql/dist/result/JsonResult.js:28:28)
    at /Users/jani/code/lightdash/node_modules/@databricks/sql/dist/result/JsonResult.js:17:31
    at Array.reduce (<anonymous>)
    at JsonResult.getValue (/Users/jani/code/lightdash/node_modules/@databricks/sql/dist/result/JsonResult.js:15:26)
    at getResult (/Users/jani/code/lightdash/node_modules/@databricks/sql/dist/DBSQLOperation/getResult.js:16:20)
    at /Users/jani/code/lightdash/node_modules/@databricks/sql/dist/DBSQLOperation/index.js:48:56

code that I am running:

query = await session.getColumns({
    catalogName: request.database,
    schemaName: request.schema,
    tableName: request.table,
});

const result = await query.fetchAll()

IrakliJani avatar Oct 19 '22 09:10 IrakliJani

btw, this seems to be fixed as of https://github.com/databricks/databricks-sql-nodejs/commit/73874d4b14a0ffb5abeb9c46d338696a2b408671 but latest npm package points to @databricks/[email protected] could you publish https://github.com/databricks/databricks-sql-nodejs/commit/73874d4b14a0ffb5abeb9c46d338696a2b408671 as beta.3? thanks!

IrakliJani avatar Oct 19 '22 09:10 IrakliJani

Hi @IrakliJani! Thank you for reporting this issue. I didn't manage to reproduce it, however, it looks really suspicious, and I doubt that https://github.com/databricks/databricks-sql-nodejs/commit/73874d4b14a0ffb5abeb9c46d338696a2b408671 actully fixes it. So I think I need to ask you for help:

  1. find a folder with this library installed (it should be node_modules/@databricks/sql)
  2. inside that folder, find a dist/DBSQLOperation/getResult.js file
  3. Find a line with function getResult(schema, data) { and right after it add these two lines:
    console.log(JSON.stringify(schema, null, 2));
    console.log(JSON.stringify(data, null, 2));
    
  4. run your code again and share the output
  5. after that, you could remove those lines.

Please feel free to reach me if you have any questions, and thank you!

kravets-levko avatar Oct 20 '22 14:10 kravets-levko

@kravets-levko here is the output on the iteration that failed. lmk if you need full output

Schema
{
  "columns": [
    {
      "columnName": "TABLE_CAT",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 1,
      "comment": "Catalog name. NULL if not applicable"
    },
    {
      "columnName": "TABLE_SCHEM",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 2,
      "comment": "Schema name"
    },
    {
      "columnName": "TABLE_NAME",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 3,
      "comment": "Table name"
    },
    {
      "columnName": "COLUMN_NAME",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 4,
      "comment": "Column name"
    },
    {
      "columnName": "DATA_TYPE",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 3,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 5,
      "comment": "SQL type from java.sql.Types"
    },
    {
      "columnName": "TYPE_NAME",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 6,
      "comment": "Data source dependent type name, for a UDT the type name is fully qualified"
    },
    {
      "columnName": "COLUMN_SIZE",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 3,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 7,
      "comment": "Column size. For char or date types this is the maximum number of characters, for numeric or decimal types this is precision."
    },
    {
      "columnName": "BUFFER_LENGTH",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 1,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 8,
      "comment": "Unused"
    },
    {
      "columnName": "DECIMAL_DIGITS",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 3,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 9,
      "comment": "The number of fractional digits"
    },
    {
      "columnName": "NUM_PREC_RADIX",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 3,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 10,
      "comment": "Radix (typically either 10 or 2)"
    },
    {
      "columnName": "NULLABLE",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 3,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 11,
      "comment": "Is NULL allowed"
    },
    {
      "columnName": "REMARKS",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 12,
      "comment": "Comment describing column (may be null)"
    },
    {
      "columnName": "COLUMN_DEF",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 13,
      "comment": "Default value (may be null)"
    },
    {
      "columnName": "SQL_DATA_TYPE",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 3,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 14,
      "comment": "Unused"
    },
    {
      "columnName": "SQL_DATETIME_SUB",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 3,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 15,
      "comment": "Unused"
    },
    {
      "columnName": "CHAR_OCTET_LENGTH",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 3,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 16,
      "comment": "For char types the maximum number of bytes in the column"
    },
    {
      "columnName": "ORDINAL_POSITION",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 3,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 17,
      "comment": "Index of column in table (starting at 1)"
    },
    {
      "columnName": "IS_NULLABLE",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 18,
      "comment": "\"NO\" means column definitely does not allow NULL values; \"YES\" means the column might allow NULL values. An empty string means nobody knows."
    },
    {
      "columnName": "SCOPE_CATALOG",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 19,
      "comment": "Catalog of table that is the scope of a reference attribute (null if DATA_TYPE isn't REF)"
    },
    {
      "columnName": "SCOPE_SCHEMA",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 20,
      "comment": "Schema of table that is the scope of a reference attribute (null if the DATA_TYPE isn't REF)"
    },
    {
      "columnName": "SCOPE_TABLE",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 21,
      "comment": "Table name that this the scope of a reference attribute (null if the DATA_TYPE isn't REF)"
    },
    {
      "columnName": "SOURCE_DATA_TYPE",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 2,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 22,
      "comment": "Source type of a distinct type or user-generated Ref type, SQL type from java.sql.Types (null if DATA_TYPE isn't DISTINCT or user-generated REF)"
    },
    {
      "columnName": "IS_AUTO_INCREMENT",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 23,
      "comment": "Indicates whether this column is auto incremented."
    }
  ]
}
Data
[
  {
    "startRowOffset": {
      "buffer": {
        "type": "Buffer",
        "data": [
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0
        ]
      },
      "offset": 0
    },
    "rows": [
      {
        "colVals": [
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "hive_metastore"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "jaffle"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "stg_orders"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "order_id"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": -5
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "BIGINT"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 8
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": {
              "value": null
            },
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 10
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 1
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": ""
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 0
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "YES"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": {
              "value": null
            },
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "NO"
            }
          }
        ]
      },
      {
        "colVals": [
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "hive_metastore"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "jaffle"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "stg_orders"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "customer_id"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": -5
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "BIGINT"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 8
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": {
              "value": null
            },
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 10
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 1
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": ""
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 1
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "YES"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": {
              "value": null
            },
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "NO"
            }
          }
        ]
      },
      {
        "colVals": [
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "hive_metastore"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "jaffle"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "stg_orders"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "order_date"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 91
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "DATE"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 4
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": {
              "value": null
            },
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 1
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": ""
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 2
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "YES"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": {
              "value": null
            },
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "NO"
            }
          }
        ]
      },
      {
        "colVals": [
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "hive_metastore"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "jaffle"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "stg_orders"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "status"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 12
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "STRING"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": {
              "value": null
            },
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 1
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": ""
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": null
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 3
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "YES"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": null
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": {
              "value": null
            },
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "NO"
            }
          }
        ]
      }
    ],
    "columns": null,
    "binaryColumns": null,
    "columnCount": null,
    "arrowBatches": null,
    "resultLinks": null
  }
]

IrakliJani avatar Oct 26 '22 22:10 IrakliJani

btw at @lightdash we already use this lib forked from here and it works https://github.com/databricks/databricks-sql-nodejs/commit/73874d4b14a0ffb5abeb9c46d338696a2b408671

here's the code https://github.com/lightdash/lightdash/blob/main/packages/warehouses/src/warehouseClients/DatabricksWarehouseClient.ts#L9

IrakliJani avatar Oct 26 '22 22:10 IrakliJani

Hi @IrakliJani! Sorry for a late reply. First of all, thank you for logs - it will help me to uderstand if there's some other bug or not. Also, I want to let you know that we released v1.0.0 - so you could try it and see if your issue is fixed there

kravets-levko avatar Oct 27 '22 07:10 kravets-levko

@kravets-levko already upgraded and it works, thanks!

IrakliJani avatar Oct 27 '22 07:10 IrakliJani

Hi, I am currently v1.0.0 but still running into this issue

{"level":"info","message":"Created DBSQLClient"}
TypeError: Cannot read property 'binaryVal' of undefined
    at JsonResult.getColumnValue (/Users/raghav/MyWorkspace/Test-JS/node_modules/@databricks/sql/dist/result/JsonResult.js:108:23)
    at JsonResult.getSchemaValues (/Users/raghav/MyWorkspace/Test-JS/node_modules/@databricks/sql/dist/result/JsonResult.js:40:34)
    at /Users/raghav/MyWorkspace/Test-JS/node_modules/@databricks/sql/dist/result/JsonResult.js:28:62
    at Array.reduce (<anonymous>)
    at JsonResult.getRows (/Users/raghav/MyWorkspace/Test-JS/node_modules/@databricks/sql/dist/result/JsonResult.js:28:28)
    at /Users/raghav/MyWorkspace/Test-JS/node_modules/@databricks/sql/dist/result/JsonResult.js:17:31
    at Array.reduce (<anonymous>)
    at JsonResult.getValue (/Users/raghav/MyWorkspace/Test-JS/node_modules/@databricks/sql/dist/result/JsonResult.js:15:26)
    at getResult (/Users/raghav/MyWorkspace/Test-JS/node_modules/@databricks/sql/dist/DBSQLOperation/getResult.js:16:20)
    at /Users/raghav/MyWorkspace/Test-JS/node_modules/@databricks/sql/dist/DBSQLOperation/index.js:77:56
Below is the code I am running
const client = new DBSQLClient();
const utils  = DBSQLClient.utils;
var options = {
  "token": token,
  "host":  serverHostname,
  "path":  httpPath
}

client.connect(
  options = options).then(
    async client => {
      const session = await client.openSession();
      const queryOperation = await session.executeStatement(
        statement = 'SELECT * FROM employee_directory.employee',
        options   = {
          runAsync: true,
          // maxRows:  10000 // This option enables the direct results feature.
        }
      );
      const result = await queryOperation.fetchAll({
        progress: false,
        callback: () => {},
      });
      await queryOperation.close();
      console.table(result);
      await session.close();
      await client.close();
}).catch((error) => {
  console.log(error);
});

Can someone help me out on this ? TIA

raghavrammohan avatar Nov 01 '22 18:11 raghavrammohan

Hi @raghavrammohan! I'm still investigating this issue, and, sadly, no workarounds for now. If possible, could you please help me with debugging and repeat steps described in https://github.com/databricks/databricks-sql-nodejs/issues/78#issuecomment-1285650917 ? It would really help me to understand this issue. Thank you, and sorry for inconvenience

kravets-levko avatar Nov 01 '22 19:11 kravets-levko

Here is the output @kravets-levko that you needed

Schema
{
  "columns": [
    {
      "columnName": "id",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 3,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 1,
      "comment": ""
    },
    {
      "columnName": "first_name",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 2,
      "comment": ""
    },
    {
      "columnName": "last_name",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 3,
      "comment": ""
    },
    {
      "columnName": "email",
      "typeDesc": {
        "types": [
          {
            "primitiveEntry": {
              "type": 7,
              "typeQualifiers": null
            },
            "arrayEntry": null,
            "mapEntry": null,
            "structEntry": null,
            "unionEntry": null,
            "userDefinedTypeEntry": null
          }
        ]
      },
      "position": 4,
      "comment": ""
    }
  ]
}
Data
[
  {
    "startRowOffset": {
      "buffer": {
        "type": "Buffer",
        "data": [
          0,
          0,
          0,
          0,
          0,
          0,
          0,
          0
        ]
      },
      "offset": 0
    },
    "rows": [
      {
        "colVals": [
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 1
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "Leslie"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "Andrews"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "[email protected]"
            }
          }
        ]
      },
      {
        "colVals": [
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 2
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "Emma"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "Baumgarten"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "[email protected]"
            }
          }
        ]
      },
      {
        "colVals": [
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 3
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "Avani"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "Gupta"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "[email protected]"
            }
          }
        ]
      },
      {
        "colVals": [
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 4
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "Yuri"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "Petrov"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "[email protected]"
            }
          }
        ]
      },
      {
        "colVals": [
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": {
              "value": 5
            },
            "i64Val": null,
            "doubleVal": null,
            "stringVal": null
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "Juan"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "Vega"
            }
          },
          {
            "boolVal": null,
            "byteVal": null,
            "i16Val": null,
            "i32Val": null,
            "i64Val": null,
            "doubleVal": null,
            "stringVal": {
              "value": "[email protected]"
            }
          }
        ]
      }
    ],
    "columns": null,
    "binaryColumns": null,
    "columnCount": null,
    "arrowBatches": null,
    "resultLinks": null
  }
]

raghavrammohan avatar Nov 03 '22 15:11 raghavrammohan

@raghavrammohan and @IrakliJani it turns out that probably you're using an old endpoint - you are getting results in row-based format which is deprecated and not used in new runtimes. ~~Could you please check the version of runtime used for your endpoints? Thank you!~~

I'd suggest you to contact Databricks support to help figure this out.

kravets-levko avatar Nov 08 '22 16:11 kravets-levko

Sorry for not getting back for a while. So, I want to ask you to upgrade to latest version of the library, and check if the issue is still present there. Please let me know in either case. Thank you!

kravets-levko avatar Sep 08 '23 10:09 kravets-levko