Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 70DCC200D2B for ; Thu, 2 Nov 2017 11:06:08 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 6F6E21609EE; Thu, 2 Nov 2017 10:06:08 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 8E997160BFB for ; Thu, 2 Nov 2017 11:06:07 +0100 (CET) Received: (qmail 60678 invoked by uid 500); 2 Nov 2017 10:06:06 -0000 Mailing-List: contact dev-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list dev@phoenix.apache.org Received: (qmail 60465 invoked by uid 99); 2 Nov 2017 10:06:06 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Nov 2017 10:06:06 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id C745A1808EF for ; Thu, 2 Nov 2017 10:06:05 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id J6ggjQoZFEn9 for ; Thu, 2 Nov 2017 10:06:04 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 8FD4560F6A for ; Thu, 2 Nov 2017 10:06:02 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id EF136E0BCA for ; Thu, 2 Nov 2017 10:06:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id AEB0F24157 for ; Thu, 2 Nov 2017 10:06:00 +0000 (UTC) Date: Thu, 2 Nov 2017 10:06:00 +0000 (UTC) From: "Lokesh Kumar (JIRA)" To: dev@phoenix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (PHOENIX-4347) Spark Dataset loaded using Phoenix Spark Datasource - Timestamp filter issue MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 02 Nov 2017 10:06:08 -0000 [ https://issues.apache.org/jira/browse/PHOENIX-4347?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Lokesh Kumar updated PHOENIX-4347: ---------------------------------- Description: Created a Phoenix table with below schema: {code:java} CREATE TABLE IF NOT EXISTS sample_table ( id VARCHAR NOT NULL, metricid VARCHAR NOT NULL, timestamp TIMESTAMP NOT NULL, metricvalue DOUBLE, CONSTRAINT st_pk PRIMARY KEY(id,metricid,timestamp)) SALT_BUCKETS = 20; {code} Inserted some data into this and loaded as Spark Dataset using the Phoenix spark datasource ('org.apache.phoenix.spark') options. The Spark Dataset's schema is as given below: root |-- ID: string (nullable = true) |-- METRICID: string (nullable = true) |-- TIMESTAMP: timestamp (nullable = true) |-- METRICVALUE: double (nullable = true) I apply the Dataset's filter operation on Timestamp column as given below: {code:java} Dataset ds = ds = ds.filter("TIMESTAMP >= CAST('2017-10-31 00:00:00.0' AS TIMESTAMP)") {code} This operation throws me an exception as: testPhoenixTimestamp(DatasetTest): org.apache.phoenix.exception.PhoenixParserException: ERROR 604 (42P00): Syntax error. Mismatched input. Expecting "RPAREN", got "00" at line 1, column 145. The generated query looks like this: {code:java} 2017-11-02 15:29:31,722 INFO [main] org.apache.phoenix.mapreduce.PhoenixInputFormat Select Statement: SELECT "ID","METRICID","TIMESTAMP","0"."METRICVALUE" FROM METRIC_TBR_DATA WHERE ( "TIMESTAMP" IS NOT NULL AND "TIMESTAMP" >= 2017-10-31 00:00:00.0) {code} The issue is with Timestamp filter condition, where the timestamp value is not wrapped in to_timestamp() function. I have fixed this locally in org.apache.phoenix.spark.PhoenixRelation class compileValue() function, by checking the value's class. If it is java.sql.Timestamp then I am wrapping the value with to_timestamp() function. Please let me know if there is another way of correctly querying Timestamp values in Phoenix through Spark's Dataset API. was: Created a Phoenix table with below schema: {code:java} CREATE TABLE IF NOT EXISTS sample_table ( id VARCHAR NOT NULL, metricid VARCHAR NOT NULL, timestamp TIMESTAMP NOT NULL, metricvalue DOUBLE, CONSTRAINT st_pk PRIMARY KEY(id,metricid,timestamp)) SALT_BUCKETS = 20; {code} Inserted some data into this and loaded as Spark Dataset using the Phoenix spark datasource ('org.apache.phoenix.spark') options. The Spark Dataset's schema is as given below: root |-- ID: string (nullable = true) |-- METRICID: string (nullable = true) |-- TIMESTAMP: timestamp (nullable = true) |-- METRICVALUE: double (nullable = true) I apply the Dataset's filter operation on Timestamp column as given below: {code:java} Dataset ds = ds = ds.filter("TIMESTAMP >= CAST('2017-10-31 00:00:00.0' AS TIMESTAMP)") {code} This operation throws me an exception as: testPhoenixTimestamp(DatasetTest): org.apache.phoenix.exception.PhoenixParserException: ERROR 604 (42P00): Syntax error. Mismatched input. Expecting "RPAREN", got "00" at line 1, column 145. The generated query looks like this: {code:java} 2017-11-02 15:29:31,722 INFO [main] org.apache.phoenix.mapreduce.PhoenixInputFormat Select Statement: SELECT "ID","METRICID","TIMESTAMP","0"."METRICVALUE" FROM METRIC_TBR_DATA WHERE ( "TIMESTAMP" IS NOT NULL AND "TIMESTAMP" >= *2017-10-31 00:00:00.0*) {code} The issue is highlighted in bold above, where the timestamp value is not wrapped in to_timestamp() function. I have fixed this locally in org.apache.phoenix.spark.PhoenixRelation class compileValue() function, by checking the value's class. If it is java.sql.Timestamp then I am wrapping the value with to_timestamp() function. Please let me know if there is another way of correctly querying Timestamp values in Phoenix through Spark's Dataset API. > Spark Dataset loaded using Phoenix Spark Datasource - Timestamp filter issue > ---------------------------------------------------------------------------- > > Key: PHOENIX-4347 > URL: https://issues.apache.org/jira/browse/PHOENIX-4347 > Project: Phoenix > Issue Type: Bug > Affects Versions: 4.11.0 > Environment: CentOS 6.5, Fedora 25 > Reporter: Lokesh Kumar > Priority: Major > Labels: phoenix, spark-sql > > Created a Phoenix table with below schema: > {code:java} > CREATE TABLE IF NOT EXISTS sample_table ( > id VARCHAR NOT NULL, > metricid VARCHAR NOT NULL, > timestamp TIMESTAMP NOT NULL, > metricvalue DOUBLE, > CONSTRAINT st_pk PRIMARY KEY(id,metricid,timestamp)) SALT_BUCKETS = 20; > {code} > Inserted some data into this and loaded as Spark Dataset using the Phoenix spark datasource ('org.apache.phoenix.spark') options. > The Spark Dataset's schema is as given below: > root > |-- ID: string (nullable = true) > |-- METRICID: string (nullable = true) > |-- TIMESTAMP: timestamp (nullable = true) > |-- METRICVALUE: double (nullable = true) > I apply the Dataset's filter operation on Timestamp column as given below: > {code:java} > Dataset ds = > ds = ds.filter("TIMESTAMP >= CAST('2017-10-31 00:00:00.0' AS TIMESTAMP)") > {code} > This operation throws me an exception as: > testPhoenixTimestamp(DatasetTest): org.apache.phoenix.exception.PhoenixParserException: ERROR 604 (42P00): Syntax error. Mismatched input. Expecting "RPAREN", got "00" at line 1, column 145. > The generated query looks like this: > {code:java} > 2017-11-02 15:29:31,722 INFO [main] org.apache.phoenix.mapreduce.PhoenixInputFormat > Select Statement: SELECT "ID","METRICID","TIMESTAMP","0"."METRICVALUE" FROM METRIC_TBR_DATA WHERE ( "TIMESTAMP" IS NOT NULL AND "TIMESTAMP" >= 2017-10-31 00:00:00.0) > {code} > The issue is with Timestamp filter condition, where the timestamp value is not wrapped in to_timestamp() function. > I have fixed this locally in org.apache.phoenix.spark.PhoenixRelation class compileValue() function, by checking the value's class. If it is java.sql.Timestamp then I am wrapping the value with to_timestamp() function. > Please let me know if there is another way of correctly querying Timestamp values in Phoenix through Spark's Dataset API. -- This message was sent by Atlassian JIRA (v6.4.14#64029)