Cascading / lingual

Stand-alone ANSI SQL for Cascading on Apache Hadoop
http://www.cascading.org/lingual/
48 stars 17 forks source link

Lingual shell gives untruthful exit codes #14

Closed alexanderdean closed 10 years ago

alexanderdean commented 10 years ago
vagrant@master:~$ echo "select count(*) from \"api_in\".\"api_full_stats\";" | lingual shell
Concurrent, Inc - Lingual 1.0.2
only 10,000 rows will be displayed
sqlline version 1.1.6
0: jdbc:lingual:hadoop> select count(*) from "api_in"."api_full_stats";
{utcTimestamp=1392573579207, currentTimestamp=1392573579207, localTimestamp=1392573579207, timeZone=sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]}
Warning: exception while executing query: flow failed: unhandled exception: unable to create connection: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.: xxx.rds.amazonaws.com (state=,code=0)
Error: exception while executing query (state=,code=0)
0: jdbc:lingual:hadoop> Closing: SC

vagrant@master:~$ echo $?
0
alexanderdean commented 10 years ago

This basically makes lingual shell unusable for non-interactive use (e.g. scripting).

fs111 commented 10 years ago

can you try this: echo "select count(*) from \"api_in\".\"api_full_stats\";" | lingual shell -

Note the "-" at the end. It tells lingual, that this is not an interactive session, but it should just read from stdin, run and exit.

alexanderdean commented 10 years ago

Hmm same problem:

vagrant@master:~$ echo "select count(*) from \"api_in\".\"api_full_stats\";" | lingual shell -
Concurrent, Inc - Lingual 1.0.2
only 10,000 rows will be displayed
sqlline version 1.1.6
0: jdbc:lingual:local> select count(*) from "api_in"."api_full_stats";
Error: From line 1, column 22 to line 1, column 46: "Table 'api_in.api_full_stats' not found" (state=,code=0)
0: jdbc:lingual:local> Closing: SC

vagrant@master:~$ echo $?
0
joeposner commented 10 years ago

Thanks. We'll look into this.

On Sun, Feb 16, 2014 at 1:27 PM, Alexander Dean notifications@github.comwrote:

Hmm same problem:

vagrant@master:~$ echo "select count(_) from \"api_in\".\"api_fullstats\";" | lingual shell - Concurrent, Inc - Lingual 1.0.2 only 10,000 rows will be displayed sqlline version 1.1.6 0: jdbc:lingual:local> select count() from "api_in"."api_full_stats"; Error: From line 1, column 22 to line 1, column 46: "Table 'api_in.api_full_stats' not found" (state=,code=0) 0: jdbc:lingual:local> Closing: SC

vagrant@master:~$ echo $? 0

Reply to this email directly or view it on GitHubhttps://github.com/Cascading/lingual/issues/14#issuecomment-35213259 .

alexanderdean commented 10 years ago

Thanks guys

alexanderdean commented 10 years ago

Ouch, it's actually worse than I thought. Not only 0 for failed queries, but 1 for successful queries!

vagrant@master:~$ lingual shell <<- EOQ
> INSERT INTO "api_out"."api_full_stats"
>
.bash_history              .bashrc                    .cascading/                .lingual/                  postinstall.sh             .ssh/                      test.sh                    .veewee_version
.bash_logout               .cache/                    .ivy2/                     load-hbase-txns.sh         .profile                   .sudo_as_admin_successful  .vbox_version
> SELECT * FROM "api_in"."api_full_stats";
> EOQ
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/CascadingSDK/tools/lingual-client/bin/cascading-hbase-2.2.0-provider.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-1.2.1/lib/slf4j-log4j12-1.4.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Concurrent, Inc - Lingual 1.0.2
only 10,000 rows will be displayed
sqlline version 1.1.6
0: jdbc:lingual:hadoop> INSERT INTO "api_out"."api_full_stats"
. . . . . . . . . . . > SELECT * FROM "api_in"."api_full_stats";
{utcTimestamp=1392737556637, currentTimestamp=1392737556637, localTimestamp=1392737556637, timeZone=sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]}
+-----------+
| ROWCOUNT  |
+-----------+
| 100000    |
+-----------+
1 row selected (57.778 seconds)
0: jdbc:lingual:hadoop> Closing: SC

vagrant@master:~$ echo $?
1
fs111 commented 10 years ago

even if there is a bug, you will have to add the "-" to the invocation, to make it all work. We should get to the problem soon.

alexanderdean commented 10 years ago

Sorry yes, that was an attempt to see if the issue still happened without the '-', I was using '-' by default...

joeposner commented 10 years ago

The bug is with the sqlline library we use which defaults to calling System.exit() when we don't really want it to (and to returning the opposite of what it should in non-interactive mode). I'm fixing the code to properly pass the error.

On Tue, Feb 18, 2014 at 7:48 AM, Alexander Dean notifications@github.comwrote:

Sorry yes, that was an attempt to see if the issue still happened without the '-', I was using '-' by default...

Reply to this email directly or view it on GitHubhttps://github.com/Cascading/lingual/issues/14#issuecomment-35397310 .

alexanderdean commented 10 years ago

Nice one, thanks @joeposner

fs111 commented 10 years ago

This is also fixed in the latest wip build. Closing this one as well.

joeposner commented 10 years ago

We did have a bug that needed fixing and as noted, that's now resolved.

But that said you want to use "-sql -" not "-" as the arg when piping data to lingual shell. The "-sql -" means "process stdin with the expectation that it's SQL" whereas any other arg gets processed as if you typed it in the interactive prompt.

alexanderdean commented 10 years ago

Thanks @joeposner - good to know about --sql -...