Closed parmitam closed 7 years ago
Any comments? Can we push this through?
This implementation conflates NULL with a zero-length byte array. I'm not in favor of introducing nullability into Myria as a special case for one attribute type.
I am not sure I understand the issue with allowing a blob-type variable (not even column) being null. Could you help me understand why this is a problem? It never gets stored in a column, it is the initial state of a variable used in MyriaL UDA. I am not using the null keyword anymore
I now think we should just use the empty blob literal b''
(assuming we've settled on the Python-style byte literal syntax described in PEP-3112), and add a check to compile_expr()
that op.value
is the empty literal (until we add general blob literal support). That seems to me to be the cleanest and most forward-compatible solution (i.e., assuming that we will eventually support blob literals as the value of a blob type anywhere in MyriaL).
How would you distinguish between b'' and empty string in python?
Slowly starting to catch up on my backlog :)
Agree with @senderista that b''
is the best literal syntax here, and that it's fine to not (yet) support arbitrary byte string literals. I'd also be comfortable with an implicit conversion from ''
to b''
, but am not sure how much work that would involve. (Assuming that this is still an open discussion, isn't it possible to write a UDA that emits its initial null state? If a null value ever leaks into a relation, we are then forced to make operators null-aware.)
Assuming we want to live in a Python 2 universe, we will probably want to use the unicode
type for strings and bytes
for byte strings. basestring
and bytearray
is another option, but I prefer that the byte strings be immutable.
there seem to be two issues here: a) value null of the variable ending up in the relation b) using a keyword to specify and empty bytearray/bytes/b'' which is indistinguishable from an empty string when expressed in MyriaL. For a) I'll change it so that we never send null to the relation -- @BrandonHaynes is right, it could end up in a relation and we might need to change more to ensure everything can handle null values. For b) I am not sure that we can do this without a keyword. if we are agreed that we can leave the arbitrary byte string literals for later, I'll make the change specified in a) and get this change in for now.
I don't understand why we cannot distinguish b''
from ''
in MyriaL.
b'' parses as empty string _LexToken(STRINGLITERAL,'',3,38) a regular expression specified to look for a prepended b causes errors in lexer as well. If you have better ideas, lmk.
I implemented byte string parsing using the b''
syntax. Do you want me to push it to a separate branch?
Let me know what you think about the b'\xFF'
format I implemented. It's obviously more verbose than just using the unescaped hex codes like b'FF'
(but is Python-compatible).
Yeah, this is essentially identical to my implementation. Might want to support double-quotes as well since ordinary strings do.
This works end-to-end.
@parmitam @BrandonHaynes any reason not to merge this (and the MyriaX blob_literal
branch) into master? (I still have to fix the new integration test for BITSET
expressions in MyriaX, but I guess I can leave that test out for now.)
Looks fine to me, modulo the stray debugging print statements.
I have a long string of changes here, please let me know if you need me to sqash for review. Overview: