Use of AND operator in Jython - jython

I am trying to use AND operator in Jython
If a!=b AND a!=C :
Can we not do that ,because i am getting syntax error?
SyntaxError: mismatched input 'AND' expecting COLON
Help?

If only i had little patience!!
It was just uppercase AND creating issue #grin
if a!=b and a!=c:
Works great!

Related

"Error: unterminated parenthesized expression" when using function of object after parenthesis

i'm running into the problem:
Error: unterminated parenthesized expression
when trying to compile:
expiry_epoch = (expiry_date_bytes.pointer(expiry_date_bytes.size) as Int64*).value
I'm not that comfortable with crystal so i'm better off asking.
The only fix in my mind is:
expiry_epoch = expiry_date_bytes.pointer(expiry_date_bytes.size) as Int64*
expiry_epoch = expiry_epoch.value
Thanks in advance!
That as syntax is very old and effectively obsolete by now.
You can write expiry_date_bytes.pointer(expiry_date_bytes.size).as(Int64*).value

ParseException when trying to concatenate a string containing HTML in Hive query

I'm trying to concatenate two strings in Hive like below, but it keeps complaining about a ParseException
select concat('', cast(77 as varchar), '') as page_url
;
The message says:
FAILED: ParseException line 1:13 cannot recognize input near 'concat' '(' ''<a href="'' in expression specification
I tried using backticks around the strings and also escaping any potential special characters, but no luck. How can I get the concatenation to work?
I'm using Hive version 2.0.4
In this particular case, the problem was arising because I was using cast as varchar when I should have been using string

Redshift Regex count. Repetition operator error

I am trying to do a simple regex pattern match in Redshift
I have this code and I get the following error:
REGEXP_COUNT ( "code", '^(?=.{8}$)[A-z]{2,5}[0-9]{3,6}$' )
ERROR: Invalid preceding regular expression prior to repetition operator. The error occured while parsing the regular expression fragment: '^(?>>>HERE>>>=.{8}$)[A-'.
The pattern works fine in testing in python and online checkers I'm guessing its a REGEX language problem. I have checked in PostgreSQL documentation on REGEX to try get help as I can't find much details on actual Redshift.
Thanks,

BigQuery - Illegal Escape Sequence

I'm having an issue matching regular expression in BigQuery. I have the following line of code that tries to identify user agents:
when regexp_contains((cs_user_agent), '^AppleCoreMedia\/1\.(.*)iPod') then "iOS App - iPod"
However, BigQuery doesn't seem to like escape sequences for some reason and I get this error that I can't figure out:
Syntax error: Illegal escape sequence: \/ at [4:63]
This code works fine in a regex validator I use, but BigQuery is unhappy with it and I can't figure out why. Thanks in advance for the help
Use regexp_contains((cs_user_agent), r'^AppleCoreMedia\/1\.(.*)iPod')

Antlr4 No viable alternative at input symbols

I'm implementing a simple program walker grammar and I get this common error in multiple lines. I think it is caused by same reason, but I'm new to antlr so I couldn't figure it out.
For example, in this following code snippet:
program
: (declaration)*
(statement)*
EOF!
;
I got error:
No viable alternative at input '!'
after EOF, and I got a similar error with:
declaration
: INT VARNUM '=' expression ';'
-> ^(DECL VARNUM expression)
;
I got the error:
No viable alternative at input '->'
After reading other questions, I know that matching one token with multiple definitions can cause this problem. But I haven't test it with any input yet, I got this error in intelliJ. How can I fix my problem?
This is ANTLR v3 syntax, you're trying to compile it with ANTLR v4, which won't work.
Either downgrade to ANTLR v3, or use v4 syntax. The difference comes from the fact that v4 doesn't support automatic AST generation, and you're trying to use AST construction operators, which were removed.
The first snippet only requires you to remove the !. Parentheses aren't necessary.
program
: declaration*
statement*
EOF
;
As for the second one, remove everything after the ->:
declaration
: INT VARNUM '=' expression ';'
;
If you need to build an AST with v4, see my answer here.