Handling column names directly?
See original GitHub issueTypically, a csv file will have a header row (e.g. carat,cut,color,clarity,depth,table,price,x,y,z
for the diamonds data set from ggplot2
).
Is there a chance of adding an option to perform RBQL queries directly with the columns (e.g. carat
) instead of having to reference them by their index (e.g. a1
)?
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:17 (10 by maintainers)
Top Results From Across the Web
How to write SQL queries with spaces in column names
In SQL Server, we can specify the column name with space in square bracket or parenthesis. Let us understand the concept with some...
Read more >data.table: why is it not always possible to pass column names ...
Being able to pass column names directly is an attractive feature of data.table. But dispensing with quotes around a column name, ...
Read more >Strategies for Handling Long Column Names
If you have source tables with long column names, alternative strategies are available for handling the long column names so that the corresponding...
Read more >Managing changing column names in Power Query #10
In today's video, I will show how to manage column headers that changes names so your power bi file does not break when...
Read more >How to search for column names in SQL Server - Solution center
There are many solutions on the internet for this and most of the suggestions are different scripts joining sys.table with sys.columns that ...
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
So, I wrote the code to support
a.good_alphanumeric_column_name
anda["arbitrary column name!"]
notation, it’s available in the master branch. Took me almost 150 commits [sigh] Soon I will start deploying it to the apps. And I would really appreciated any feedback, guys! Please, let me know what you think.PS I rewrote JS implementation: replaced all callbacks with async/await so it should be much easier to read now.
Yep, I think that a.name, a.age, b.name, etc notations are the way to go. But there is no need to do
replaceAll
, because it is unreliable even with “a.” and “b.” prefixes. Original user query should be altered as little as possible. One case where it will definetely fail are string literals: should we replacea.name
inside string literals? In case of SQL keywords (“SELECT”, “WHERE”, etc) the answer is no, and RBQL isolates string literals before it starts searching for the keywords. But in case of a.name the answer is not so obvious. Here is an absolutely artificial and contrived example, but it will fail withreplaceAll
:The output would be
a1 = Andy
instead ofa.name = Andy
. I agree that such situation would probably never happen in practice, but my general position still holds: original query should be altered as little as possible. This is also important for exceptions/errors that contain failed query expression, if the query was significantly altered it wouldn’t be recognizable by the user, and it would be harder to correct that error.So to implement this “a.name” etc notations I suggest to initialize special “a” and “b” objects (if either “a.” or “b.” were detected somewhere in the query). This should be relatively easy to do - almost the same code that currently initializes a1, a2, b1 etc variables. “a” and “b” can also support square bracket access like a[“person name”]. Those who think that this is super ugly and non-SQLish can pretend that this feature doesn’t exist and only columns without whitespaces/special characters are supported. I don’t have 100% guarantee that this approach would work, but I currently don’t see why it wouldn’t, and the only way to be sure is to try and implement this.