代码:36. DB::Exception: 位置选项不受支持。(BAD_ARGUMENTS)

huangapple go评论98阅读模式
英文:

Code: 36. DB::Exception: Positional options are not supported. (BAD_ARGUMENTS)

问题

我正在使用sys.process._来创建和运行进程,例如:

  val clickhouseClient = Process("clickhouse-client --version").!!
  println(s"************************************************** ${clickhouseClient}")

这个打印语句给出了clickhouse-client的版本

但是如果我执行以下操作:

  val clickhouseClient = Process("clickhouse-client -q 'show databases'").!!
  println(s"************************************************** ${clickhouseClient}")

这会导致错误 - Code: 36. DB::Exception: Positional options are not supported. (BAD_ARGUMENTS)

我的目标是使用当前的方法查询clickhouse-server。不知道为什么会失败。

此外,在Go语言中,你可以这样做:

submitCommand := `
                   #!/bin/bash
                   set -euf -o pipefail
                   cat %s | clickhouse-client --host=9000 \
                                              --query="INSERT INTO some_table Format some_format" \
		                                      --stacktrace
`
cmd := exec.CommandContext(ctx, "bash", "-c", submitCommand)
stdout := &strings.Builder{}
stderr := &strings.Builder{}
cmd.Stdout = stdout
cmd.Stderr = stderr
cmd.Run()

不确定如何在Scala中实现这个。有没有更好的方法来做这些事情?

任何帮助都将不胜感激!

英文:

I'm using sys.process._ to create and run process like

  val clickhouseClient = Process("clickhouse-client --version").!!
  println(s"************************************************** ${clickhouseClient}")

This print statement gives me the clickhouse-client version.

But if it do the following:

  val clickhouseClient = Process("clickhouse-client -q 'show databases'").!!
  println(s"************************************************** ${clickhouseClient}")

This give ERROR - Code: 36. DB::Exception: Positional options are not supported. (BAD_ARGUMENTS)

My aim is to query the clickhouse-server using current approach. Don't know why its failing

Futhermore, In golang you would do something like:

submitCommand := `
                   #!/bin/bash
                   set -euf -o pipefail
                   cat %s | clickhouse-client --host=9000 \
                                              --query="INSERT INTO some_table Format some_format" \
		                                      --stacktrace
`
cmd := exec.CommandContext(ctx, "bash", "-c", submitCommand)
stdout := &strings.Builder{}
stderr := &strings.Builder{}
cmd.Stdout = stdout
cmd.Stderr = stderr
cmd.Run()

Not sure how to do this in scala. Are the any better approach to do these things?

Any help is appreciated!!!

答案1

得分: 1

以下是解决问题的步骤:

val commandTemplate = "show databases"
val result = Process("clickhouse-client", Seq(s"--query=$commandTemplate")).!!
println(s"The result: $result")

通过执行上述代码,问题得到了解决。

英文:

So doing the following solved the issue:

val commandTemplate = "show databases"
val result = Process("clickhouse-client", Seq(s"--query=$commandTemplate")).!!
println(s"The result: $result")

答案2

得分: 0

抱歉,我不是Scala专家,但看起来这只是一个命令行参数的问题。这个错误是来自clickhouse-client本身:

代码:36. DB::Exception: 不支持位置选项。

如果命令行参数不正确,我可以重现这个特定的错误。也可能是传递给命令行的引号的问题。

英文:

Not a scala expert I'm sorry, but it looks like it's just a problem with the command-line arguments. This error is coming from clickhouse-client itself:

Code: 36. DB::Exception: Positional options are not supported.

I can reproduce this particular error if the command-line parameters are not correct. Could also be an issue with the quoting as passed through to the command line.

答案3

得分: 0

clickhouse-client -q show databases
代码:36. DB::Exception: 不支持位置选项。 (BAD_ARGUMENTS)

尝试

"clickhouse-client -q 'show databases'"
英文:
clickhouse-client -q show databases
Code: 36. DB::Exception: Positional options are not supported. (BAD_ARGUMENTS)

try

"clickhouse-client -q \'show databases\'"

huangapple
  • 本文由 发表于 2023年6月8日 21:13:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/76432227.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定