[ 
https://issues.apache.org/jira/browse/AIRFLOW-3804?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16759965#comment-16759965
 ] 

jack commented on AIRFLOW-3804:
-------------------------------

[~ashb]

All codes I tested with the library generates the error so I don't see how this 
could be a problem with the library:

*+Basic _mysql:+*

 
{code:java}
import _mysql
 db=_mysql.connect(host="...",user="...",passwd="...",db="...")
 db.query("""SELECT * FROM my_table where modifiedTS>2019-02-04 15:06:23 and 
modifiedTS<= 2019-02-04 15:28:26""")
 r=db.use_result()
 r.fetch_row(){code}
 

*+Extended MySQLdb:+*
 
{code:java}
import MySQLdb
db=MySQLdb.connect(host="...",user="...",passwd="...",db="...")
db.query("""SELECT * FROM my_table where modifiedTS>2019-02-04 15:06:23 and 
modifiedTS<= 2019-02-04 15:28:26""")
r=db.use_result()
r.fetch_row(){code}
 
{code:java}
File "test.py", line 18, in <module> where modifiedTS>2019-02-04 15:06:23 and 
modifiedTS<= 2019-02-04 15:28:26""") _mysql_exceptions.ProgrammingError: (1064, 
"You have an error in your SQL syntax; check the manual that corresponds to 
your MySQL server version for the right syntax to use near '15:06:23 and 
modifiedTS<= 2019-02-04 15:28:26' at line 11"){code}
 

 *OR*:
{code:java}
import MySQLdb
conn=MySQLdb.connect(host="...",user="...",passwd="...",db="...")
curs = conn.cursor()
try:
 try:
     curs.execute("""SELECT * FROM my_table where modifiedTS>2019-02-04 
15:06:23 and modifiedTS<= 2019-02-04 15:28:26""")
 except (MySQLdb.Error, MySQLdb.Warning) as e:
     print(e)
     exit(0)
 row = curs.fetchone()
 if row:
    print row[0]
 exit(0)
finally:
 conn.close()
{code}
 
{code:java}
(1064, "You have an error in your SQL syntax; check the manual that corresponds 
to your MySQL server version for the right syntax to use near '15:06:23 and 
modifiedTS<= 2019-02-04 15:28:26' at line 1"){code}
 

 

This is a problem with how Airflow hook/operators are using the library, It's 
not a problem in the library itself.

> MySqlToGoogleCloudStorageOperator success when it should fail
> -------------------------------------------------------------
>
>                 Key: AIRFLOW-3804
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-3804
>             Project: Apache Airflow
>          Issue Type: Bug
>            Reporter: jack
>            Priority: Major
>
> Testing the following query on MySqlToGoogleCloudStorageOperator.
>  
> {code:java}
> SELECT * FROM table where modifiedTS>2000-01-01 00:00:00 and modifiedTS<= 
> 2019-02-04 13:55:21{code}
>  
> The operator runs smoothly and report success so airflow continue to execute 
> the down stream of the operator.
> However this query is invalid.
> Running it on MySQL will give:
>  
> {code:java}
> Error Code: 1064. You have an error in your SQL syntax; check the manual that 
> corresponds to your MySQL server version for the right syntax to use near 
> '00:00:00  and modifiedTS<= 2019-02-04 13:55:21' at line 11{code}
>  
> The operator should have *FAILD* when running this query it has syntax error.
> There is probably a problem with how this operator treats the result of this 
> query and confuses it with valid result of no rows returned. 
>  
> Not sure if it's related but I'm running the query with SQL file using : 
> filename option of the operator.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to