Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
IrakliJani opened this issue Oct 19, 2022 · 11 comments
Open
Labels

Comments

@IrakliJani
Copy link

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

version: @databricks/sql@0.1.8-beta.2

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
Copy link
Author

btw, this seems to be fixed as of 73874d4 but latest npm package points to @databricks/sql@0.1.8-beta.2
could you publish 73874d4 as beta.3?
thanks!

@kravets-levko
Copy link
Collaborator

kravets-levko commented Oct 20, 2022

Hi @IrakliJani! Thank you for reporting this issue. I didn't manage to reproduce it, however, it looks really suspicious, and I doubt that 73874d4 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!

@IrakliJani
Copy link
Author

IrakliJani commented Oct 26, 2022

@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
Copy link
Author

btw at @lightdash we already use this lib forked from here and it works 73874d4

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

@kravets-levko
Copy link
Collaborator

kravets-levko commented Oct 27, 2022

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

@IrakliJani
Copy link
Author

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

@raghavrammohan
Copy link

raghavrammohan commented Nov 1, 2022

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

@kravets-levko
Copy link
Collaborator

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 #78 (comment) ? It would really help me to understand this issue. Thank you, and sorry for inconvenience

@raghavrammohan
Copy link

raghavrammohan commented Nov 3, 2022

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": "leslie@luv2code.com"
            }
          }
        ]
      },
      {
        "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": "emma@luv2code.com"
            }
          }
        ]
      },
      {
        "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": "avani@luv2code.com"
            }
          }
        ]
      },
      {
        "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": "yuri@luv2code.com"
            }
          }
        ]
      },
      {
        "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": "juan@luv2code.com"
            }
          }
        ]
      }
    ],
    "columns": null,
    "binaryColumns": null,
    "columnCount": null,
    "arrowBatches": null,
    "resultLinks": null
  }
]

@kravets-levko
Copy link
Collaborator

kravets-levko commented Nov 8, 2022

@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
Copy link
Collaborator

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants