Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set command does not validate given value #224

Closed
arina-ielchiieva opened this issue Nov 28, 2018 · 1 comment
Closed

Set command does not validate given value #224

arina-ielchiieva opened this issue Nov 28, 2018 · 1 comment

Comments

@arina-ielchiieva
Copy link
Collaborator

arina-ielchiieva commented Nov 28, 2018

Set command allows to set non integer value for ALL properties that require numeric values, after that queries fail to execute:

0: jdbc:drill:zk=local> !set headerInterval xxx
0: jdbc:drill:zk=local> !set headerinterval 
headerinterval      xxx
0: jdbc:drill:zk=local> select * from sys.version;
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
	at sqlline.SqlLineOpts.getInt(SqlLineOpts.java:304)
	at sqlline.SqlLineOpts.getHeaderInterval(SqlLineOpts.java:580)
	at sqlline.TableOutputFormat.print(TableOutputFormat.java:60)
	at sqlline.SqlLine.print(SqlLine.java:1719)
	at sqlline.Commands.execute(Commands.java:949)
	at sqlline.Commands.sql(Commands.java:882)
	at sqlline.SqlLine.dispatch(SqlLine.java:725)
	at sqlline.SqlLine.begin(SqlLine.java:540)
	at sqlline.SqlLine.start(SqlLine.java:264)
	at sqlline.SqlLine.main(SqlLine.java:195)
0: jdbc:drill:zk=local> !reset headerinterval 
[headerinterval] was reset to [100]
0: jdbc:drill:zk=local> select * from sys.version;
+------------------+-------------------------------------------+---------------------------------------+----------------------------+-----------------------------+----------------------------+
|     version      |                 commit_id                 |            commit_message             |        commit_time         |         build_email         |         build_time         |
+------------------+-------------------------------------------+---------------------------------------+----------------------------+-----------------------------+----------------------------+
| 1.15.0-SNAPSHOT  | 2bcdf2c1c6b38be7c5f40112e7ff9c62889cc50a  | DRILL-6866: Upgrade to SqlLine 1.6.0  | 28.11.2018 @ 13:27:45 EET  | arina.yelchiyeva@gmail.com  | 28.11.2018 @ 16:26:44 EET  |
+------------------+-------------------------------------------+---------------------------------------+----------------------------+-----------------------------+----------------------------+
1 row selected (0.089 seconds)

set isolation command does not check if value is valid.
The same is for timestampFormat, dateFormat and timeFormat.

0: jdbc:drill:zk=local> !set isolation xxx
0: jdbc:drill:zk=local> !set isolation 
isolation           xxx

set outputFormat does not validate given value and then outputs warning during query execution:

0: jdbc:drill:zk=local> !set outputformat xxx
0: jdbc:drill:zk=local> select * from sys.version;
Unknown output format "xxx". Possible values: [xmlattr, tsv, xmlattrs, xmlelements, csv, json, vertical, table]
+------------------+-------------------------------------------+---------------------------------------+----------------------------+-----------------------------+----------------------------+
|     version      |                 commit_id                 |            commit_message             |        commit_time         |         build_email         |         build_time         |
+------------------+-------------------------------------------+---------------------------------------+----------------------------+-----------------------------+----------------------------+
| 1.15.0-SNAPSHOT  | 2bcdf2c1c6b38be7c5f40112e7ff9c62889cc50a  | DRILL-6866: Upgrade to SqlLine 1.6.0  | 28.11.2018 @ 13:27:45 EET  | arina.yelchiyeva@gmail.com  | 28.11.2018 @ 16:26:44 EET  |
+------------------+-------------------------------------------+---------------------------------------+----------------------------+-----------------------------+----------------------------+
1 row selected (1.369 seconds)

set colorScheme and mode validates given value but outputs full stacktrace:

0: jdbc:drill:zk=local> !set colorscheme xxx
java.lang.IllegalArgumentException: Unknown color scheme "xxx". Possible values: [chester, dark, dracula, light, obsidian, solarized, vs2010]
	at sqlline.SqlLineOpts.setColorScheme(SqlLineOpts.java:491)
	at sqlline.SqlLineOpts.set(SqlLineOpts.java:269)
	at sqlline.Commands.setProperty(Commands.java:660)
	at sqlline.Commands.set(Commands.java:621)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:38)
	at sqlline.SqlLine.dispatch(SqlLine.java:722)
	at sqlline.SqlLine.begin(SqlLine.java:540)
	at sqlline.SqlLine.start(SqlLine.java:264)
	at sqlline.SqlLine.main(SqlLine.java:195)
0: jdbc:drill:zk=local> !set mode xxx
java.lang.IllegalArgumentException: Unknown mode "xxx". Possible values: [emacs, vi]
	at sqlline.SqlLineOpts.setMode(SqlLineOpts.java:663)
	at sqlline.SqlLineOpts.set(SqlLineOpts.java:269)
	at sqlline.Commands.setProperty(Commands.java:660)
	at sqlline.Commands.set(Commands.java:621)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sqlline.ReflectiveCommandHandler.execute(ReflectiveCommandHandler.java:38)
	at sqlline.SqlLine.dispatch(SqlLine.java:722)
	at sqlline.SqlLine.begin(SqlLine.java:540)
	at sqlline.SqlLine.start(SqlLine.java:264)
	at sqlline.SqlLine.main(SqlLine.java:195)

Better to output usage warning like for reset command:

0: jdbc:drill:zk=local> !reset
Usage: reset (all | <property name>)
@arina-ielchiieva arina-ielchiieva changed the title Set command allows to set non numeric value for props that require numeric Set command does not validate given value Nov 28, 2018
@julianhyde
Copy link
Owner

Fixed in e853fe4 and e04bb9c, PR #230.

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 a pull request may close this issue.

2 participants