Skip to content

Conversation

@vgmartinez
Copy link
Contributor

What is this PR for?

Fix bug
https://issues.apache.org/jira/browse/ZEPPELIN-628

Todos

How should this be tested?

run a query that contains (something)...eg

%jdbc
select max(ss_promo_sk), ss_customer_sk from qhive.tpcds_orc_500.store_sales where ss_sold_date_sk >= 2452640 and ss_customer_sk > 3 and ss_customer_sk < 20 group by ss_customer_sk

It is ok if the propertyKey is default:

PropertyKey: default, SQL command: 'select max(ss_promo_sk), ss_customer_sk from qhive.tpcds_orc_500.store_sales where ss_sold_date_sk >= 2452640 and ss_customer_sk > 3 and ss_customer_sk < 20 group by ss_customer_sk'

Questions:

Does the licenses files need update? no
Is there breaking changes for older versions? no
Does this needs documentation? no

@vgmartinez vgmartinez changed the title Zeppelin-628 ] Fix parse propertyKey in interpreter name [Zeppelin-628 ] Fix parse propertyKey in interpreter name for JDBC Jan 22, 2016
@felixcheung
Copy link
Member

thanks for addressing this. could we add some tests for this?

@vgmartinez
Copy link
Contributor Author

Hi @felixcheung, thanks for review...
add the test, is enough? or you think is necessary something more?

Copy link
Member

Choose a reason for hiding this comment

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

maybe add trim() because the string could be %jdbc (redshift) select * from...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it is not necessary because when I write this query the interpreter what comes is not the name of the interpreter...eg

%jdbc (redshift) select * from...

to string is applied trim in paragraph class...and the interpreter receives this way without spaces

(redshift) select * from...

and finally on line 353 is applied trim to the query....what do you think?

Copy link

Choose a reason for hiding this comment

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

This presupposes that the end-user will be using the first line as a declaration of the interpreter:

%jdbc (redshift)\n

What about in cases where the user has selected a default interpreter for each paragraph and doesn't need to specify the %<interpreter> prefix? When a user does that then any query with a function will error.

Copy link

Choose a reason for hiding this comment

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

Oops, I see you're checking for startsWith, nevermind.

@felixcheung
Copy link
Member

in additional to getPropertyKey() is there a place where it parses the rest of the query? that might need to be changed too?

@vgmartinez
Copy link
Contributor Author

I think there is no to change any more...I'm sorry for my english...;)

@felixcheung
Copy link
Member

ok, I'll try to test this out a bit in 1-2 days

@vgmartinez
Copy link
Contributor Author

Hi @felixcheung, could you check the bug...?

@felixcheung
Copy link
Member

I've tested it a bit, it seems to work - to reproduce the bug, do I need to have multiple, or valid propertyKey?

For example, I type a random one and it does not complain:

%jdbc (blah)
select max(code) as ok, min(title) as t from films2 group by code, did,  kind;

@vgmartinez
Copy link
Contributor Author

the problem was when they used the in this way %jdbc and had the query something like this select max(code) as ok, min(title) as t from films2 group by code, did, kind
Because trying to parse what was within bracket.
I think is ready...

Copy link
Member

Choose a reason for hiding this comment

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

Is it a problem if

%jdbc)default(

Or

%jdbc()

Or

%jdbc(
select ....

Or

%jdbc(
default)
select ...
?

Copy link
Member

Choose a reason for hiding this comment

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

Would you be able to address these cases? @vgmartinez

@felixcheung
Copy link
Member

Tested the current broken behavior, thanks for fixing this.
Added a comment on parsing.
Also, I think it's an issue when the return value from getPropertyKey is invalid, like %jdbc (blah) but that could be fixed separately.

@jongyoul
Copy link
Member

jongyoul commented Feb 2, 2016

@felixcheung I don't think current implementation is good. but I think it's better handle it with different issue. Does it make sense?

@felixcheung
Copy link
Member

property key not matching a valid profile is probably a fix would be great to make separately - would you be interested in that, @vgmartinez ?
let's fix the parsing and merge this, since I think it is affecting a bunch of users.

@vgmartinez
Copy link
Contributor Author

Hi @felixcheung @jongyoul
I propose message of error when user set a not valid prefix, similar to when interpreter not found...I think is responsibility of user set a valid prefix...

something like this:

image

the problem here is that you always have to put the prefix in default or not...
what do you think guys...?

@jongyoul
Copy link
Member

jongyoul commented Feb 9, 2016

@vgmartinez I think we need to support default interpreter without setting any default word. In other words, users should be able to use default jdbc by typing just %jdbc.

@jongyoul jongyoul mentioned this pull request Feb 9, 2016
@felixcheung
Copy link
Member

agreed, I think %jdbc should work.
can't we check only when a prefix is there? say %jdbc() or %jdbc (something_invalid) should both fail, but %jdbc is ok?

@vgmartinez
Copy link
Contributor Author

Hi @felixcheung @jongyoul
I tested it and looks like this:

image

I rebase and push...review please...;)

@jongyoul
Copy link
Member

@vgmartinez it looks like that you merge master into your branch. Please check it and rebase your PR from master again.

@vgmartinez
Copy link
Contributor Author

@jongyoul...Done

assertEquals(t.getPropertyKey("(redshift)\n select max(cant) from test_table where id >= 2452640"),
"redshift");
}

Copy link
Member

Choose a reason for hiding this comment

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

How about adding what felix mentioned into test cases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok...add more tests cases....

@vgmartinez
Copy link
Contributor Author

@jongyoul
I have added more tests....

@felixcheung
Copy link
Member

@vgmartinez could you rebase to latest on master to get Travis tests to run again?


// if return null is that prefix not found
assertEquals(t.getPropertyKey("(fake) select max(cant) from test_table where id >= 2452640"),
null);
Copy link
Member

Choose a reason for hiding this comment

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

@vgmartinez I saw the failure and found out the below:

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.apache.zeppelin.jdbc.JDBCInterpreterTest
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/travis/build/apache/incubator-zeppelin/zeppelin-interpreter/target/zeppelin-interpreter-0.6.0-incubating-SNAPSHOT.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/travis/build/apache/incubator-zeppelin/zeppelin-interpreter/target/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/travis/.m2/repository/org/slf4j/slf4j-log4j12/1.7.10/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
log4j:WARN No appenders could be found for logger (org.apache.zeppelin.jdbc.JDBCInterpreter).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Tests run: 4, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.474 sec <<< FAILURE! - in org.apache.zeppelin.jdbc.JDBCInterpreterTest
testForParsePropertyKey(org.apache.zeppelin.jdbc.JDBCInterpreterTest)  Time elapsed: 0.339 sec  <<< FAILURE!
java.lang.AssertionError: expected:<fake> but was:<null>
    at org.junit.Assert.fail(Assert.java:88)
    at org.junit.Assert.failNotEquals(Assert.java:743)
    at org.junit.Assert.assertEquals(Assert.java:118)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at org.apache.zeppelin.jdbc.JDBCInterpreterTest.testForParsePropertyKey(JDBCInterpreterTest.java:78)

It needs to fix the test case. It should return fake actually.

@vgmartinez
Copy link
Contributor Author

hi @felixcheung @jongyoul...I have added more test and fix the other

@jongyoul
Copy link
Member

LGTM

@felixcheung
Copy link
Member

looks good, merging if no more comments.

@asfgit asfgit closed this in a283dfa Feb 17, 2016
prabhjyotsingh pushed a commit to prabhjyotsingh/zeppelin that referenced this pull request Feb 19, 2016
### What is this PR for?
Fix bug
https://issues.apache.org/jira/browse/ZEPPELIN-628

### Todos

### How should this be tested?
run a query that contains (something)...eg
```
%jdbc
select max(ss_promo_sk), ss_customer_sk from qhive.tpcds_orc_500.store_sales where ss_sold_date_sk >= 2452640 and ss_customer_sk > 3 and ss_customer_sk < 20 group by ss_customer_sk
```
It is ok if the **propertyKey** is default:
```
PropertyKey: default, SQL command: 'select max(ss_promo_sk), ss_customer_sk from qhive.tpcds_orc_500.store_sales where ss_sold_date_sk >= 2452640 and ss_customer_sk > 3 and ss_customer_sk < 20 group by ss_customer_sk'
```
### Questions:

Does the licenses files need update? no
Is there breaking changes for older versions? no
Does this needs documentation? no

Author: vgmartinez <viktor.manuel.garcia@gmail.com>

Closes apache#667 from vgmartinez/bug_628 and squashes the following commits:

4859cac [vgmartinez] fix test for parse propertyKey
810c14e [vgmartinez] add more tests for parse prefix
9d59c60 [vgmartinez] fixed parse properties
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.

4 participants