[ 
https://issues.apache.org/jira/browse/PHOENIX-3944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16056995#comment-16056995
 ] 

ASF GitHub Bot commented on PHOENIX-3944:
-----------------------------------------

Github user ankitsinghal commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/261#discussion_r123153895
  
    --- Diff: phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java 
---
    @@ -710,6 +714,27 @@ public void testCreateViewWithUpdateCacheFrquency() 
throws Exception {
           assertTrue(rs.next());
         }
     
    +    @Test
    +    public void 
testCreateViewMappedToExistingHbaseTableWithNamespaceMappingEnabled() throws 
Exception {
    +        Properties props = new Properties();
    +        props.setProperty(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, 
"true");
    +        Connection conn = DriverManager.getConnection(getUrl(),props);
    +
    +        String ns = "NS_" + generateUniqueName();
    +        String table = "TABLE_" + generateUniqueName();
    +        String fam = "CF";
    +
    +        HBaseAdmin admin = 
conn.unwrap(PhoenixConnection.class).getQueryServices().getAdmin();
    +        admin.createNamespace(NamespaceDescriptor.create(ns).build());
    +        HTableDescriptor desc = new HTableDescriptor(TableName.valueOf(ns, 
table));
    +        desc.addFamily(new HColumnDescriptor(fam));
    +        admin.createTable(desc);
    +
    +        conn.createStatement().execute("CREATE SCHEMA " + ns);
    +        conn.createStatement().execute("CREATE VIEW " + ns + "." + table + 
" "
    +            + "(PK VARCHAR PRIMARY KEY, " + fam + ".COL VARCHAR)");
    --- End diff --
    
    can you update a test to include a case where user has "NS.TBL" in default 
namespace and he wants to map a view.(\"NS.TBL\")(for backward compatibility).
    ```
    desc = new HTableDescriptor(TableName.valueOf(ns+"."+table));
            desc.addFamily(new HColumnDescriptor(fam));
            admin.createTable(desc);
    
    conn.createStatement().execute("CREATE VIEW \"" + ns + "." + table + "\""
                    + "(PK VARCHAR PRIMARY KEY, " + fam + ".COL VARCHAR)");
    ```


> ReadOnlyTableException occurs when we map Phoenix view to an existing HBase 
> table with Namespace Mapping enabled
> ----------------------------------------------------------------------------------------------------------------
>
>                 Key: PHOENIX-3944
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-3944
>             Project: Phoenix
>          Issue Type: Bug
>            Reporter: Toshihiro Suzuki
>
> Firstly, I created a namespace and a table in hbase shell:
> {code}
> hbase> create_namespace "NS"
> hbase> create "NS:TBL", "CF"
> {code}
> After that, I tried to create a phoenix view for this existing hbase table in 
> phoenix-sqlline:
> {code}
> phoenix> CREATE VIEW ns.tbl (pk VARCHAR PRIMARY KEY, cf.col VARCHAR);
> {code}
> However, I encountered the following error and I was not able to create the 
> view:
> {code}
> org.apache.phoenix.schema.ReadOnlyTableException: ERROR 505 (42000): Table is 
> read only.
>       at 
> org.apache.phoenix.query.ConnectionQueryServicesImpl.ensureTableCreated(ConnectionQueryServicesImpl.java:1072)
>       at 
> org.apache.phoenix.query.ConnectionQueryServicesImpl.createTable(ConnectionQueryServicesImpl.java:1434)
>       at 
> org.apache.phoenix.schema.MetaDataClient.createTableInternal(MetaDataClient.java:2624)
>       at 
> org.apache.phoenix.schema.MetaDataClient.createTable(MetaDataClient.java:1040)
>       at 
> org.apache.phoenix.compile.CreateTableCompiler$2.execute(CreateTableCompiler.java:212)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:393)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:376)
>       at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:375)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:363)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1707)
>       at org.apache.PhoenixTest.main(PhoenixTest.java:55)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:498)
>       at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to