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 5F11D200C1F for ; Sat, 18 Feb 2017 08:00:59 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 5D9E5160B71; Sat, 18 Feb 2017 07:00:59 +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 A23F0160B63 for ; Sat, 18 Feb 2017 08:00:58 +0100 (CET) Received: (qmail 61076 invoked by uid 500); 18 Feb 2017 07:00:57 -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 61064 invoked by uid 99); 18 Feb 2017 07:00:57 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 18 Feb 2017 07:00:57 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 55D80C3268 for ; Sat, 18 Feb 2017 07:00:57 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.199 X-Spam-Level: X-Spam-Status: No, score=-1.199 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id FoPRPTgWogvD for ; Sat, 18 Feb 2017 07:00:56 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 681FB5FD3B for ; Sat, 18 Feb 2017 07:00:56 +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 A9505E0026 for ; Sat, 18 Feb 2017 07:00:49 +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 6656B21D62 for ; Sat, 18 Feb 2017 07:00:49 +0000 (UTC) Date: Sat, 18 Feb 2017 07:00:49 +0000 (UTC) From: "Kevin Liew (JIRA)" To: dev@phoenix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (PHOENIX-476) Support declaration of DEFAULT in CREATE statement MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sat, 18 Feb 2017 07:00:59 -0000 [ https://issues.apache.org/jira/browse/PHOENIX-476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15873022#comment-15873022 ] Kevin Liew edited comment on PHOENIX-476 at 2/18/17 6:59 AM: ------------------------------------------------------------- Hi [~tdsilva], support for sequence expressions is planned for PHOENIX-3425, which will likely be picked up again after the Calcite integration. We do expect this error when parsing sequence values as default expression: {code:java} CANNOT_CREATE_DEFAULT(1031, "42Y90", "Cannot create column with a stateful default value.") {code} was (Author: kliew): Hi [~tdsilva], support for sequence expressions is planned for PHOENIX-3425. We do expect this error when parsing sequence values as default expression: {code:java} CANNOT_CREATE_DEFAULT(1031, "42Y90", "Cannot create column with a stateful default value.") {code} > Support declaration of DEFAULT in CREATE statement > -------------------------------------------------- > > Key: PHOENIX-476 > URL: https://issues.apache.org/jira/browse/PHOENIX-476 > Project: Phoenix > Issue Type: New Feature > Affects Versions: 3.0-Release > Reporter: James Taylor > Assignee: Kevin Liew > Fix For: 4.9.0 > > Attachments: PHOENIX-476.10.patch, PHOENIX-476.11.patch, PHOENIX-476.12.patch, PHOENIX-476.2.patch, PHOENIX-476.3.patch, PHOENIX-476.4.patch, PHOENIX-476.5.patch, PHOENIX-476.6.patch, PHOENIX-476.7.patch, PHOENIX-476.8.patch, PHOENIX-476.9.patch, PHOENIX-476.patch > > > Support the declaration of a default value in the CREATE TABLE/VIEW statement like this: > CREATE TABLE Persons ( > Pid int NOT NULL PRIMARY KEY, > LastName varchar(255) NOT NULL, > FirstName varchar(255), > Address varchar(255), > City varchar(255) DEFAULT 'Sandnes' > ) > To implement this, we'd need to: > 1. add a new DEFAULT_VALUE key value column in SYSTEM.TABLE and pass through the value when the table is created (in MetaDataClient). > 2. always set NULLABLE to ResultSetMetaData.columnNoNulls if a default value is present, since the column will never be null. > 3. add a getDefaultValue() accessor in PColumn > 4. for a row key column, during UPSERT use the default value if no value was specified for that column. This could be done in the PTableImpl.newKey method. > 5. for a key value column with a default value, we can get away without incurring any storage cost. Although a little bit of extra effort than if we persisted the default value on an UPSERT for key value columns, this approach has the benefit of not incurring any storage cost for a default value. > * serialize any default value into KeyValueColumnExpression > * in the evaluate method of KeyValueColumnExpression, conditionally use the default value if the column value is not present. If doing partial evaluation, you should not yet return the default value, as we may not have encountered the the KeyValue for the column yet (since a filter evaluates each time it sees each KeyValue, and there may be more than one KeyValue referenced in the expression). Partial evaluation is determined by calling Tuple.isImmutable(), where false means it is NOT doing partial evaluation, while true means it is. > * modify EvaluateOnCompletionVisitor by adding a visitor method for RowKeyColumnExpression and KeyValueColumnExpression to set evaluateOnCompletion to true if they have a default value specified. This will cause filter evaluation to execute one final time after all KeyValues for a row have been seen, since it's at this time we know we should use the default value. -- This message was sent by Atlassian JIRA (v6.3.15#6346)