You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@phoenix.apache.org by Nico Pappagianis <ni...@salesforce.com> on 2016/10/06 23:27:22 UTC

Phoenix-Spark Integration quotes in table name

Hello all,

I have a scala script that references a phoenix table called
ENTITY."tableName" including the quotation marks.

When I try to read from the table and load into an RDD via:

val table = """ENTITY."z02""""
val nameCol = "colName"
val rdd: RDD[Map[String, AnyRef]] = sc.phoenixTableAsRDD(
        table, Seq(nameCol), zkUrl = Some(zkHost)
)

when I run this I get:

Table undefined. tableName=_ENTITY.tableName

Notice there are no quotes around tableName. When I print the variable in
scala its as expected: ENTITY."z02", so scala understands where the quotes
are in the string.


The read succeeds when running this with dataframes from sqlContext:

val df = sqlContext.read.format("jdbc").options(

      Map(

        "driver" -> "org.apache.phoenix.jdbc.PhoenixDriver",

        "url" -> zkHost,

        "dbtable" -> table)).load()

    df.show

The above works.

Any insight on why the rdd implementation fails to pass the string along
correctly?

Thanks!

Re: Phoenix-Spark Integration quotes in table name

Posted by Nico Pappagianis <ni...@salesforce.com>.
Solved:

Looks like I just needed a quote preceding the quotes I wanted in the
string, i.e.  """ENTITY.""z02"""""

Strange, because when using the sqlContext the string only needed to be of
the form  """ENTITY."z02""""



On Thu, Oct 6, 2016 at 4:27 PM, Nico Pappagianis <
nico.pappagianis@salesforce.com> wrote:

> Hello all,
>
> I have a scala script that references a phoenix table called
> ENTITY."tableName" including the quotation marks.
>
> When I try to read from the table and load into an RDD via:
>
> val table = """ENTITY."z02""""
> val nameCol = "colName"
> val rdd: RDD[Map[String, AnyRef]] = sc.phoenixTableAsRDD(
>         table, Seq(nameCol), zkUrl = Some(zkHost)
> )
>
> when I run this I get:
>
> Table undefined. tableName=_ENTITY.tableName
>
> Notice there are no quotes around tableName. When I print the variable in
> scala its as expected: ENTITY."z02", so scala understands where the quotes
> are in the string.
>
>
> The read succeeds when running this with dataframes from sqlContext:
>
> val df = sqlContext.read.format("jdbc").options(
>
>       Map(
>
>         "driver" -> "org.apache.phoenix.jdbc.PhoenixDriver",
>
>         "url" -> zkHost,
>
>         "dbtable" -> table)).load()
>
>     df.show
>
> The above works.
>
> Any insight on why the rdd implementation fails to pass the string along
> correctly?
>
> Thanks!
>
>