sodadata / soda-sql

Soda SQL and Soda Spark have been deprecated and replaced by Soda Core. docs.soda.io/soda-core/overview.html
https://docs.soda.io/
Apache License 2.0
60 stars 15 forks source link

Getting error after soda analyze command for mysql soda. #208

Open danilyef opened 2 years ago

danilyef commented 2 years ago

When I start soda analyze command I got the following error message:

SELECT
  COUNT(CASE WHEN case regexp '^\\\-?[0-9]+$' THEN 1 END) AS number_whole,
   ....
 FROM (SELECT * FROM table_name LIMIT 1000) T

Exception: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'regexp '^\\\-?[0-9]+$' THEN 1 END) AS number_whole,
  COUNT(CASE WHEN case regex' at line 2
Traceback (most recent call last):
  File "/opt/anaconda3/lib/python3.8/site-packages/sodasql/cli/cli.py", line 287, in analyze
    dataset_analyze_results = dataset_analyzer.analyze(warehouse, table_name)
  File "/opt/anaconda3/lib/python3.8/site-packages/sodasql/dataset_analyzer.py", line 76, in analyze
    row = warehouse.sql_fetchone(
  File "/opt/anaconda3/lib/python3.8/site-packages/sodasql/scan/warehouse.py", line 32, in sql_fetchone
    return sql_fetchone(self.connection, sql)
  File "/opt/anaconda3/lib/python3.8/site-packages/sodasql/scan/db.py", line 22, in sql_fetchone
    return sql_fetchone_description(connection, sql)[0]
  File "/opt/anaconda3/lib/python3.8/site-packages/sodasql/scan/db.py", line 35, in sql_fetchone_description
    cursor.execute(sql)
  File "/opt/anaconda3/lib/python3.8/site-packages/mysql/connector/cursor.py", line 569, in execute
    self._handle_result(self._connection.cmd_query(stmt))
  File "/opt/anaconda3/lib/python3.8/site-packages/mysql/connector/connection.py", line 855, in cmd_query
    result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
  File "/opt/anaconda3/lib/python3.8/site-packages/mysql/connector/connection.py", line 665, in _handle_result
    raise errors.get_exception(packet)
mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'regexp '^\\\-?[0-9]+$' THEN 1 END) AS number_whole,
  COUNT(CASE WHEN case regex' at line 2

warehouse.yml

name: soda_sql
connection:
  type: mysql
  host: my_host
  port: '3306'
  username: env_var(MYSQL_USERNAME)
  password: env_var(MYSQL_PASSWORD)
  database: my_database

OS: macOs Python Version: Python 3.8.12 pip Version: 22.0.3 Soda CLI version:2.1.3 Warehouse Type: mysql Mysql version: 8.0.26