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

MLDB-2105 sql square bracket enh + test update #836

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

FinchPowers
Copy link
Member

@FinchPowers FinchPowers commented Jan 30, 2017

No description provided.

"""
It doesn't matter that it maches, it's a string.
"""
res = mldb.query("SELECT a[foo] FROM (SELECT {foo: 123} AS a)")
self.assertEqual(res, [
['_rowName', "a[foo]"],
['_rowName', "a.foo"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever the operator used in the query, the result uses the dot notation.

def test_inner_whitespaces_double_quotes(self):
res = mldb.query("""
SELECT a["f b"] FROM (
SELECT parse_json('{"f b" : 123}') AS a
)
""")
self.assertEqual(res, [
['_rowName', "a[f b]"],
['_rowName', "a.f b"],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dot notation returns non "round trippable" result though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok never mind, MLDB returns that already when we do something like

SELECT a."f b"

@mathieumb
Copy link
Contributor

+1 with some hesitation... now the bracket operator will mean slightly different things when whats on the left is an identifier and when its not. When its an identifier, it'll only select a column from it. When its any row expression on the left, it'll allow evaluation of an expression in the context of that row expression.

@FinchPowers
Copy link
Member Author

@jeremybarnes What do you think?

@jeremybarnes
Copy link
Contributor

I think that this needs to be thought through more. We're now making the . an operator that can be used anywhere; I think it's unclear what the precedence is and how it interacts with other lexical constructs that include dots. To me, [] and . are different constructs syntactically, it just so happens that . is implemented in terms of []. Let's keep the code cleanup, and do a whiteboard session on the semantics.

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

Successfully merging this pull request may close these issues.

3 participants