[
https://issues.apache.org/jira/browse/HBASE-26269?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17422931#comment-17422931
]
Sean Busbey commented on HBASE-26269:
-------------------------------------
This is a consequence of HBASE-11686 and is behaving as expected, since the
load call is a ruby primitive that runs in the top level ruby binding and not
in the workspace made for the shell session.
if you run the shell with the `--top-level-defs` option given in the release
note on the change you should get the old behavior.
{code}
(base) sbusbey@Seans-MacBook-Pro hbase-3.0.0-alpha-2-SNAPSHOT % cat
/tmp/hbase-list.txt
list
(base) sbusbey@Seans-MacBook-Pro hbase-3.0.0-alpha-2-SNAPSHOT % ./bin/hbase
shell --top-level-defs
2021-09-30T12:15:17,492 WARN [main] util.NativeCodeLoader: Unable to load
native-hadoop library for your platform... using builtin-java classes where
applicable
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/book.html#shell
Version 3.0.0-alpha-2-SNAPSHOT, rdc8196faf4873516d8d7325516f01ad4cdf13166, Thu
Sep 30 00:01:37 CDT 2021
Took 0.0014 seconds
hbase:001:0> load '/tmp/hbase-list.txt'
TABLE
0 row(s)
Took 0.6126 seconds
=> true
hbase:002:0> exit
{code}
Alternatively, if your loaded ruby file expressly calls things in the shell
instance that's at the top level that will work without the flag:
{code}
(base) sbusbey@Seans-MacBook-Pro hbase-3.0.0-alpha-2-SNAPSHOT % cat
/tmp/hbase-shell-list.txt
@shell.command 'list'
(base) sbusbey@Seans-MacBook-Pro hbase-3.0.0-alpha-2-SNAPSHOT % ./bin/hbase
shell
2021-09-30T12:19:27,044 WARN [main] util.NativeCodeLoader: Unable to load
native-hadoop library for your platform... using builtin-java classes where
applicable
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/book.html#shell
Version 3.0.0-alpha-2-SNAPSHOT, rdc8196faf4873516d8d7325516f01ad4cdf13166, Thu
Sep 30 00:01:37 CDT 2021
Took 0.0012 seconds
hbase:001:0> load '/tmp/hbase-shell-list.txt'
TABLE
0 row(s)
Took 0.6044 seconds
=> true
hbase:002:0> exit
{code}
The existing release note would be better if we expressly added the example of
using ruby load calls.
What do you think of this update text?
{quote}
<!-- markdown -->
In shell, all HBase constants and commands have been moved out of the top-level
and into an IRB Workspace. Piped stdin and scripts passed by name to the shell
will be evaluated within this workspace. If you need the top-level definitions,
such as to use the Ruby `load` command on files that contain hbase shell
commands, you should run the shell with the compatibility flag
`--top-level-defs`.
{quote}
Alternatively, maybe we should add a command to the shell that evaluates a file
in the context of the current IRB workspace.
> Shell 'load' command behavior has changed
> -----------------------------------------
>
> Key: HBASE-26269
> URL: https://issues.apache.org/jira/browse/HBASE-26269
> Project: HBase
> Issue Type: Bug
> Components: shell
> Affects Versions: 3.0.0-alpha-2, 2.4.5
> Reporter: Nick Dimiduk
> Priority: Major
>
> After upgrade fro 2.3.x to 2.4.x, we noticed that the behavior of the shell's
> {{load}} command has changed.
> Given a file of commands, i.e.
> {noformat}
> $ echo 'list' > /tmp/file
> {noformat}
> 2.3.x:
> {noformat}
> $ hbase shell
> hbase(main):001:0> load '/tmp/file'
> TABLE
>
>
> TestTable
>
>
> 1 row(s)
> Took 0.3076 seconds
>
>
> => true
> hbase(main):002:0>
> {noformat}
> branch-2.4:
> {noformat}
> $ hbase shell
> hbase:001:0> load '/tmp/file'
> Traceback (most recent call last):
> NameError (undefined local variable or method `list' for main:Object)
> {noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)