MCPcopy Create free account
hub / github.com/apache/impala / precmd

Method precmd

shell/impala_shell/impala_shell.py:780–803  ·  view source on GitHub ↗
(self, args)

Source from the content-addressed store, hash-verified

778 host=self.impalad[0], port=self.impalad[1], db=db)
779
780 def precmd(self, args):
781 # In Python2, 'args' could in str type if it's the original input line, or in unicode
782 # type if it's a split query appended by us. See how we deal with 'parsed_cmds' below.
783 if sys.version_info.major == 2 and isinstance(args, str):
784 args = self.sanitise_input(args.decode('utf-8')) # python2
785 else:
786 args = self.sanitise_input(args) # python3
787 if not args: return args
788 # Split args using sqlparse. If there are multiple queries present in user input,
789 # the length of the returned query list will be greater than one.
790 parsed_cmds = sqlparse.split(args)
791 if len(parsed_cmds) > 1:
792 # The last command needs a delimiter to be successfully executed.
793 parsed_cmds[-1] += ImpalaShell.CMD_DELIM
794 self.cmdqueue.extend(parsed_cmds)
795 # If cmdqueue is populated, then commands are executed from the cmdqueue, and user
796 # input is ignored. Send an empty string as the user input just to be safe.
797 return str()
798 # There is no need to reconnect if we are quitting.
799 if not self.imp_client.is_connected() and not self._is_quit_command(args):
800 print(ImpalaShell.CONNECTION_LOST_MESSAGE, file=sys.stderr)
801 self._connect()
802 self._validate_database(immediately=True)
803 return args
804
805 def onecmd(self, line):
806 """Overridden to ensure the variable replacement is processed in interactive

Callers

nothing calls this directly

Calls 6

sanitise_inputMethod · 0.95
_is_quit_commandMethod · 0.95
_connectMethod · 0.95
_validate_databaseMethod · 0.95
decodeMethod · 0.80
is_connectedMethod · 0.80

Tested by

no test coverage detected