Return-Path: X-Original-To: apmail-hbase-issues-archive@www.apache.org Delivered-To: apmail-hbase-issues-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 89CDE1735C for ; Tue, 28 Oct 2014 12:15:35 +0000 (UTC) Received: (qmail 57052 invoked by uid 500); 28 Oct 2014 12:15:34 -0000 Delivered-To: apmail-hbase-issues-archive@hbase.apache.org Received: (qmail 57005 invoked by uid 500); 28 Oct 2014 12:15:34 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 56937 invoked by uid 99); 28 Oct 2014 12:15:34 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Oct 2014 12:15:34 +0000 Date: Tue, 28 Oct 2014 12:15:34 +0000 (UTC) From: "Sean Busbey (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-12329) Table create with duplicate column family names quietly succeeds MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HBASE-12329?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14186745#comment-14186745 ] Sean Busbey commented on HBASE-12329: ------------------------------------- - org.apache.hadoop.hbase.client.UnmodifyableHTableDescriptor needs to be updated to add the new method. - needs unit tests that verify expected behavior for the update method and handling of duplicate addFamily calls - either update the API example in the ref guide (currently Example 10.2) to show "update an existing CF" or file a follow on ticket that such docs are needed {code} /** * Adds a column family. + * If multiple families with the same name are added, only the last one will be saved. + * For the updating purpose please use {@link #updateFamily(HColumnDescriptor)} instead. * @param family HColumnDescriptor of family to add. */ public HTableDescriptor addFamily(final HColumnDescriptor family) { {code} Since the initial patch targets master, instead of having the "last one wins" warning have the method throw on duplicates. We'll leave a note here on the jira for the committer to replace that behavior on backport with a warning about last one wins and the throwing in a future version. {code} + * Updates the existing column family. + * @param family HColumnDescriptor of family to update + * @return this (for chained invocation) + */ + public HTableDescriptor updateFamily(final HColumnDescriptor family) { {code} Consider naming the method {{modifyFamily}} to match o.a.h.h.client.Admin.modifyColumn {code} + if (family.getName() == null || family.getName().length <= 0) { + throw new NullPointerException("Family name cannot be null or empty"); + } + {code} when the string is empty, throw an IllegalArgumentException. {code} + # Warn if duplicate columns are added + if htd.hasFamily(descriptor.getName) + puts "Family '" + descriptor.getNameAsString() + "' already exists, the old one will be replaced" + end + htd.addFamily(descriptor) {code} Use htd the way we are updating the API to suggest people use it: use updateFamily after warning, only use addFamily when it won't be an update. > Table create with duplicate column family names quietly succeeds > ---------------------------------------------------------------- > > Key: HBASE-12329 > URL: https://issues.apache.org/jira/browse/HBASE-12329 > Project: HBase > Issue Type: Bug > Components: Client, shell > Reporter: Sean Busbey > Assignee: Jingcheng Du > Priority: Minor > Attachments: HBASE-12329.diff > > > From the mailing list > {quote} > I was expecting that it is forbidden, **but** this call does not throw any > exception > {code} > String[] families = {"cf", "cf"}; > HTableDescriptor desc = new HTableDescriptor(name); > for (String cf : families) { > HColumnDescriptor coldef = new HColumnDescriptor(cf); > desc.addFamily(coldef); > } > try { > admin.createTable(desc); > } catch (TableExistsException e) { > throw new IOException("table \'" + name + "\' already exists"); > } > {code} > {quote} > And Ted's follow up replicates in the shell > {code} > hbase(main):001:0> create 't2', {NAME => 'f1'}, {NAME => 'f1'} > The table got created - with 1 column family: > hbase(main):002:0> describe 't2' > DESCRIPTION > ENABLED > 't2', {NAME => 'f1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', > REPLICATION_SCOPE => '0 true > ', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => > '2147483647', KEEP_DELETED > _CELLS => 'false', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE > => 'true'} > 1 row(s) in 0.1000 seconds > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)