Syntax Error on nested queries from google spreadsheet with blank column names
See original GitHub issueRedash 4.0.1+b4038 Pulling data from google spreadsheet the spreadsheet has some columns with blank headers If I run a query against the query results from pulling in the spreadsheet (e.g. query_45) I get an error
File "/opt/redash/redash.4.0.1.b4038/redash/query_runner/query_results.py", line 92, in create_table
connection.execute(create_table)
OperationalError: near ")": syntax error
This is caused by create_table with a create table string that contains a blank column header at the end. e.g.
CREATE TABLE table_46 (Name, Phone, )
I hacked a fix into my query_results.py to create named columns for blank columns.
------------------query_results.py:79--------------------
def fix_column_name(name,columncounter):
if name.strip() == '':
name = u"BLANK{colno}".format(colno=columncounter)
return name.replace(':', '_').replace('.', '_').replace(' ', '_')
def create_table(connection, table_name, query_results):
columns = [column['name']
for column in query_results['columns']]
safe_columns = []
colno = 0
for column in columns:
safe_columns.append(fix_column_name(column,colno))
colno = colno + 1
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Formula Parse Errors In Google Sheets And How To Fix Them
In this post, I'll explain what a Google Sheets formula parse error is, how to identify what's causing the problem, and how to...
Read more >Query Function in Google Sheets - Complete Tutorial
Learn how lazy Google Sheets users take advantage of the QUERY function, which lets you write SQL queries in a Sheet. Sit back...
Read more >syntax error SELECT list cannot be empty at [1:9]. Halp? - Reddit
The first SELECT is missing a select list, so you'll have to add a column to select there or * to select all...
Read more >How to use Google Sheets QUERY function - Ablebits
headers is optional for when you need to indicate the number of header rows in your data. Omit the argument (as I do...
Read more >5+ Easy Fixes for the Formula Parse Error in Google Sheets
This type of error is unique to Google Sheets. It usually occurs when Google Sheets cannot make sense of your formula, so it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I would suggest Excel style with letters since that’s what excel and google docs both use for the column id. It would make it easier for someone to refer back to their spreadsheet if it’s a complex one.
Let’s go with option #2 - rename the columns. But instead of
blank_
, maybecolumn_
+ column number?