From dev-return-3432-archive-asf-public=cust-asf.ponee.io@madlib.apache.org Fri Jun 29 01:48:45 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id DB31918066B for ; Fri, 29 Jun 2018 01:48:44 +0200 (CEST) Received: (qmail 17739 invoked by uid 500); 28 Jun 2018 23:48:43 -0000 Mailing-List: contact dev-help@madlib.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@madlib.apache.org Delivered-To: mailing list dev@madlib.apache.org Received: (qmail 17700 invoked by uid 99); 28 Jun 2018 23:48:43 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jun 2018 23:48:43 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E7EDAE1113; Thu, 28 Jun 2018 23:48:42 +0000 (UTC) From: kaknikhil To: dev@madlib.apache.org Reply-To: dev@madlib.apache.org References: In-Reply-To: Subject: [GitHub] madlib pull request #282: Utilites: Add CTAS while dropping some columns Content-Type: text/plain Message-Id: <20180628234842.E7EDAE1113@git1-us-west.apache.org> Date: Thu, 28 Jun 2018 23:48:42 +0000 (UTC) Github user kaknikhil commented on a diff in the pull request: https://github.com/apache/madlib/pull/282#discussion_r199002937 --- 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 -- maybe we should also test that the dropped columns were indeed dropped from the output table ? ---