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

Dongjoon Hyun commented on SPARK-22717:
---------------------------------------

In the PR, we are discussing the side effects of PostgreSQL TRUNCATE like the 
following.
{code}
postgres=# CREATE TABLE parent(a INT);
CREATE TABLE
postgres=# CREATE TABLE child(b INT) INHERITS (parent);
CREATE TABLE
postgres=# INSERT INTO parent VALUES(1);
INSERT 0 1
postgres=# SELECT * FROM parent;
 a
---
 1
(1 row)

postgres=# INSERT INTO child VALUES(2);
INSERT 0 1
postgres=# SELECT * FROM parent;
 a
---
 1
 2
(2 rows)

postgres=# SELECT * FROM child;
 a | b
---+---
 2 |
(1 row)

postgres=# TRUNCATE TABLE parent;
TRUNCATE TABLE
postgres=# SELECT * FROM parent;
 a
---
(0 rows)

postgres=# SELECT * FROM child;
 a | b
---+---
(0 rows)
{code}

> Postgres is assumed to cascade truncate table by default which is not true
> --------------------------------------------------------------------------
>
>                 Key: SPARK-22717
>                 URL: https://issues.apache.org/jira/browse/SPARK-22717
>             Project: Spark
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 2.2.1
>         Environment: Postgres 8,9,10
>            Reporter: Bolke de Bruin
>
> The postgres dialect returns True for isCascadingTruncateTable, which is 
> mentioned to be returned 
> ([https://github.com/apache/spark/blob/d4107196d59638845bd19da6aab074424d90ddaf/sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala#L152])
>  to indicate that it cascades by default. This is not true accoriding to the 
> documentation[https://www.postgresql.org/docs/9.1/static/sql-truncate.html]
> {code}
> domino=> truncate domino.info;
> ERROR:  cannot truncate a table referenced in a foreign key constraint
> DETAIL:  Table "fix" references "info".
> HINT:  Truncate table "fix" at the same time, or use TRUNCATE ... CASCADE.
> {code}



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to