madlib-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iyerr3 <...@git.apache.org>
Subject [GitHub] madlib pull request #282: Utilites: Add CTAS while dropping some columns
Date Tue, 03 Jul 2018 15:58:55 GMT
Github user iyerr3 commented on a diff in the pull request:

    https://github.com/apache/madlib/pull/282#discussion_r199861894
  
    --- Diff: src/ports/postgres/modules/utilities/test/utilities.sql_in ---
    @@ -0,0 +1,77 @@
    +/* ----------------------------------------------------------------------- */
    +/**
    + *
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + *
    + */
    +/* ----------------------------------------------------------------------- */
    +
    +CREATE TABLE "__madlib_temp_Quoted"(b varchar);
    +CREATE TABLE __madlib_temp_non_quoted(a text);
    +-- assert that madlib_temp tables are created
    +SELECT assert(count(*) >= 2, 'Error setting up madlib_temp in schema ' || quote_ident(current_schema()))
    +FROM pg_tables
    +WHERE tablename LIKE '%madlib\_temp%'
    +  AND quote_ident(schemaname) = quote_ident(current_schema());
    +
    +-- cleanup
    +SELECT cleanup_madlib_temp_tables(quote_ident(current_schema()));
    +
    +-- assert that madlib_temp tables are dropped
    +SELECT assert(count(*) = 0, 'Error cleaning up madlib_temp in schema ' || quote_ident(current_schema()))
    +FROM pg_tables
    +WHERE tablename LIKE '%madlib\_temp%'
    +  AND quote_ident(schemaname) = quote_ident(current_schema());
    +
    +-- test dropcols
    +DROP TABLE IF EXISTS dt_golf CASCADE;
    +CREATE TABLE dt_golf (
    +    id integer NOT NULL,
    +    id_2 integer,
    +    "OUTLOOK" text,
    +    temperature double precision,
    +    humidity double precision,
    +    "Cont,features" double precision[],
    +    cat_features text[],
    +    windy boolean,
    +    class text
    +) ;
    +
    +INSERT INTO dt_golf (id,"OUTLOOK",temperature,humidity,"Cont,features",cat_features,
windy,class) VALUES
    +(1, 'sunny', 85, 85,ARRAY[85, 85], ARRAY['a', 'b'], false, 'Don''t Play'),
    +(2, 'sunny', 80, 90, ARRAY[80, 90], ARRAY['a', 'b'], true, 'Don''t Play'),
    +(3, 'overcast', 83, 78, ARRAY[83, 78], ARRAY['a', 'b'], false, 'Play'),
    +(4, 'rain', 70, NULL, ARRAY[70, 96], ARRAY['a', 'b'], false, 'Play'),
    +(5, 'rain', 68, 80, ARRAY[68, 80], ARRAY['a', 'b'], false, 'Play'),
    +(6, 'rain', NULL, 70, ARRAY[65, 70], ARRAY['a', 'b'], true, 'Don''t Play'),
    +(7, 'overcast', 64, 65, ARRAY[64, 65], ARRAY['c', 'b'], NULL , 'Play'),
    +(8, 'sunny', 72, 95, ARRAY[72, 95], ARRAY['a', 'b'], false, 'Don''t Play'),
    +(9, 'sunny', 69, 70, ARRAY[69, 70], ARRAY['a', 'b'], false, 'Play'),
    +(10, 'rain', 75, 80, ARRAY[75, 80], ARRAY['a', 'b'], false, 'Play'),
    +(11, 'sunny', 75, 70, ARRAY[75, 70], ARRAY['a', 'd'], true, 'Play'),
    +(12, 'overcast', 72, 90, ARRAY[72, 90], ARRAY['c', 'b'], NULL, 'Play'),
    +(13, 'overcast', 81, 75, ARRAY[81, 75], ARRAY['a', 'b'], false, 'Play'),
    +(15, NULL, 81, 75, ARRAY[81, 75], ARRAY['a', 'b'], false, 'Play'),
    +(16, 'overcast', NULL, 75, ARRAY[81, 75], ARRAY['a', 'd'], false, 'Play'),
    +(14, 'rain', 71, 80, ARRAY[71, 80], ARRAY['c', 'b'], true, 'Don''t Play');
    +
    +SELECT dropcols('dt_golf', 'dt_golf2', '"OUTLOOK", "Cont,features", cat_features');
    +-- test if the retained columns are present in output table
    +SELECT
    +    id, id_2, temperature, humidity, windy, class
    --- End diff --
    
    Added a test for dropped cols. 


---

Mime
View raw message