Re: Review Request 58840: AMBARI-20886. Create idempotent Ambari DB Schema SQL script for AzureDB

2017-05-02 Thread Jonathan Hurley

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58840/#review173647
---


Ship it!




Ship It!

- Jonathan Hurley


On May 2, 2017, 3:24 p.m., Attila Doroszlai wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/58840/
> ---
> 
> (Updated May 2, 2017, 3:24 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, Laszlo Puskas, Sandor Magyari, 
> Sumit Mohanty, Sebastian Toader, and Sid Wagle.
> 
> 
> Bugs: AMBARI-20886
> https://issues.apache.org/jira/browse/AMBARI-20886
> 
> 
> Repository: ambari
> 
> 
> Description
> ---
> 
> Based on existing SQL Server script generate at compile-time for AzureDB a 
> SQL script that:
>  * runs CREATE TABLE, CREATE INDEX and ADD CONSTRAINT statements only if the 
> objects do not exist yet,
>  * DELETEs rows before running INSERT statements.
> 
> 
> Diffs
> -
> 
>   ambari-server/pom.xml da1f09eceb999650c33729120b6959462445a115 
>   ambari-server/src/main/assemblies/server.xml 
> 51ee14e0bc215ba2fdad24112c7c0ab3ff2d1189 
>   ambari-server/src/main/python/azuredb_create_generator.py PRE-CREATION 
>   ambari-server/src/main/resources/.gitignore PRE-CREATION 
>   ambari-server/src/main/sh/azuredb_create_generator.sh PRE-CREATION 
> 
> 
> Diff: https://reviews.apache.org/r/58840/diff/5/
> 
> 
> Testing
> ---
> 
> Tested with Microsoft SQL Server on Linux using Docker:
> 
> ```
> $ mvn -q -pl ambari-server clean generate-resources
> $ export MSSQL_PASSWORD='hVn?1AY6b\l&'
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> ba7ad59f747eac75e696cbab8ed7f30af0c98dc81250ee393ebf0e01e71f2965
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 107
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (0 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (1 rows affected)
> 
> (1 rows affected)
> 
> (184 rows affected)
> 
> (53 rows affected)
> 
> (7 rows affected)
> 
> (1 rows affected)
> 
> (8 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (54 rows affected)
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (14 rows affected)
> 
> (19 rows affected)
> 
> (24 rows affected)
> 
> (31 rows affected)
> 
> (42 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> 
> $ docker rm -f mssql
> mssql
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> 5dfdd09a70b76f5cd9716fff94680b758c92f3850b227c0c274eea800bdf3402
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (14 rows affected)
> 
> (19 rows affected)
> 
> (24 rows affected)
> 
> (31 rows affected)
> 
> (42 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> ```
> 
> 
> Thanks,
> 
> Attila 

Re: Review Request 58840: AMBARI-20886. Create idempotent Ambari DB Schema SQL script for AzureDB

2017-05-02 Thread Attila Doroszlai

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58840/
---

(Updated May 2, 2017, 9:24 p.m.)


Review request for Ambari, Jonathan Hurley, Laszlo Puskas, Sandor Magyari, 
Sumit Mohanty, Sebastian Toader, and Sid Wagle.


Changes
---

* add overview comment in Python script
* make re.sub calls more readable by using multi-line strings


Bugs: AMBARI-20886
https://issues.apache.org/jira/browse/AMBARI-20886


Repository: ambari


Description
---

Based on existing SQL Server script generate at compile-time for AzureDB a SQL 
script that:
 * runs CREATE TABLE, CREATE INDEX and ADD CONSTRAINT statements only if the 
objects do not exist yet,
 * DELETEs rows before running INSERT statements.


Diffs (updated)
-

  ambari-server/pom.xml da1f09eceb999650c33729120b6959462445a115 
  ambari-server/src/main/assemblies/server.xml 
51ee14e0bc215ba2fdad24112c7c0ab3ff2d1189 
  ambari-server/src/main/python/azuredb_create_generator.py PRE-CREATION 
  ambari-server/src/main/resources/.gitignore PRE-CREATION 
  ambari-server/src/main/sh/azuredb_create_generator.sh PRE-CREATION 


Diff: https://reviews.apache.org/r/58840/diff/5/

Changes: https://reviews.apache.org/r/58840/diff/4-5/


Testing
---

Tested with Microsoft SQL Server on Linux using Docker:

```
$ mvn -q -pl ambari-server clean generate-resources
$ export MSSQL_PASSWORD='hVn?1AY6b\l&'
$ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
-p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
ba7ad59f747eac75e696cbab8ed7f30af0c98dc81250ee393ebf0e01e71f2965
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
107

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql

(0 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql

(1 rows affected)

(1 rows affected)

(184 rows affected)

(53 rows affected)

(7 rows affected)

(1 rows affected)

(8 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(54 rows affected)

(54 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(8 rows affected)

(1 rows affected)

(7 rows affected)

(53 rows affected)

(1 rows affected)

(14 rows affected)

(19 rows affected)

(24 rows affected)

(31 rows affected)

(42 rows affected)

(53 rows affected)

(1 rows affected)

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)

$ docker rm -f mssql
mssql
$ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
-p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
5dfdd09a70b76f5cd9716fff94680b758c92f3850b227c0c274eea800bdf3402
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql

(54 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(8 rows affected)

(1 rows affected)

(7 rows affected)

(53 rows affected)

(1 rows affected)

(14 rows affected)

(19 rows affected)

(24 rows affected)

(31 rows affected)

(42 rows affected)

(53 rows affected)

(1 rows affected)

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)
```


Thanks,

Attila Doroszlai



Re: Review Request 58840: AMBARI-20886. Create idempotent Ambari DB Schema SQL script for AzureDB

2017-05-02 Thread Alejandro Fernandez

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58840/#review173618
---


Fix it, then Ship it!





ambari-server/src/main/python/azuredb_create_generator.py
Lines 24 (patched)


Add some documentation for what this file is supposed to do


- Alejandro Fernandez


On May 2, 2017, 10:09 a.m., Attila Doroszlai wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/58840/
> ---
> 
> (Updated May 2, 2017, 10:09 a.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, Laszlo Puskas, Sandor Magyari, 
> Sumit Mohanty, Sebastian Toader, and Sid Wagle.
> 
> 
> Bugs: AMBARI-20886
> https://issues.apache.org/jira/browse/AMBARI-20886
> 
> 
> Repository: ambari
> 
> 
> Description
> ---
> 
> Based on existing SQL Server script generate at compile-time for AzureDB a 
> SQL script that:
>  * runs CREATE TABLE, CREATE INDEX and ADD CONSTRAINT statements only if the 
> objects do not exist yet,
>  * DELETEs rows before running INSERT statements.
> 
> 
> Diffs
> -
> 
>   ambari-server/pom.xml da1f09eceb999650c33729120b6959462445a115 
>   ambari-server/src/main/assemblies/server.xml 
> 51ee14e0bc215ba2fdad24112c7c0ab3ff2d1189 
>   ambari-server/src/main/python/azuredb_create_generator.py PRE-CREATION 
>   ambari-server/src/main/resources/.gitignore PRE-CREATION 
>   ambari-server/src/main/sh/azuredb_create_generator.sh PRE-CREATION 
> 
> 
> Diff: https://reviews.apache.org/r/58840/diff/4/
> 
> 
> Testing
> ---
> 
> Tested with Microsoft SQL Server on Linux using Docker:
> 
> ```
> $ mvn -q -pl ambari-server clean generate-resources
> $ export MSSQL_PASSWORD='hVn?1AY6b\l&'
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> ba7ad59f747eac75e696cbab8ed7f30af0c98dc81250ee393ebf0e01e71f2965
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 107
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (0 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (1 rows affected)
> 
> (1 rows affected)
> 
> (184 rows affected)
> 
> (53 rows affected)
> 
> (7 rows affected)
> 
> (1 rows affected)
> 
> (8 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (54 rows affected)
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (14 rows affected)
> 
> (19 rows affected)
> 
> (24 rows affected)
> 
> (31 rows affected)
> 
> (42 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> 
> $ docker rm -f mssql
> mssql
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> 5dfdd09a70b76f5cd9716fff94680b758c92f3850b227c0c274eea800bdf3402
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (14 rows affected)
> 
> (19 rows affected)
> 
> (24 rows affected)
> 
> (31 rows affected)
> 
> (42 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from 

Re: Review Request 58840: AMBARI-20886. Create idempotent Ambari DB Schema SQL script for AzureDB

2017-05-02 Thread Attila Doroszlai

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58840/
---

(Updated May 2, 2017, 12:09 p.m.)


Review request for Ambari, Jonathan Hurley, Laszlo Puskas, Sandor Magyari, 
Sumit Mohanty, Sebastian Toader, and Sid Wagle.


Changes
---

re-implemented in Python


Bugs: AMBARI-20886
https://issues.apache.org/jira/browse/AMBARI-20886


Repository: ambari


Description
---

Based on existing SQL Server script generate at compile-time for AzureDB a SQL 
script that:
 * runs CREATE TABLE, CREATE INDEX and ADD CONSTRAINT statements only if the 
objects do not exist yet,
 * DELETEs rows before running INSERT statements.


Diffs (updated)
-

  ambari-server/pom.xml da1f09eceb999650c33729120b6959462445a115 
  ambari-server/src/main/assemblies/server.xml 
51ee14e0bc215ba2fdad24112c7c0ab3ff2d1189 
  ambari-server/src/main/python/azuredb_create_generator.py PRE-CREATION 
  ambari-server/src/main/resources/.gitignore PRE-CREATION 
  ambari-server/src/main/sh/azuredb_create_generator.sh PRE-CREATION 


Diff: https://reviews.apache.org/r/58840/diff/4/

Changes: https://reviews.apache.org/r/58840/diff/3-4/


Testing
---

Tested with Microsoft SQL Server on Linux using Docker:

```
$ mvn -q -pl ambari-server clean generate-resources
$ export MSSQL_PASSWORD='hVn?1AY6b\l&'
$ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
-p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
ba7ad59f747eac75e696cbab8ed7f30af0c98dc81250ee393ebf0e01e71f2965
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
107

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql

(0 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql

(1 rows affected)

(1 rows affected)

(184 rows affected)

(53 rows affected)

(7 rows affected)

(1 rows affected)

(8 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(54 rows affected)

(54 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(8 rows affected)

(1 rows affected)

(7 rows affected)

(53 rows affected)

(1 rows affected)

(14 rows affected)

(19 rows affected)

(24 rows affected)

(31 rows affected)

(42 rows affected)

(53 rows affected)

(1 rows affected)

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)

$ docker rm -f mssql
mssql
$ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
-p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
5dfdd09a70b76f5cd9716fff94680b758c92f3850b227c0c274eea800bdf3402
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql

(54 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(8 rows affected)

(1 rows affected)

(7 rows affected)

(53 rows affected)

(1 rows affected)

(14 rows affected)

(19 rows affected)

(24 rows affected)

(31 rows affected)

(42 rows affected)

(53 rows affected)

(1 rows affected)

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)
```


Thanks,

Attila Doroszlai



Re: Review Request 58840: AMBARI-20886. Create idempotent Ambari DB Schema SQL script for AzureDB

2017-04-29 Thread Sid Wagle

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58840/#review173430
---


Ship it!




Ship It!

- Sid Wagle


On April 28, 2017, 4:21 p.m., Attila Doroszlai wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/58840/
> ---
> 
> (Updated April 28, 2017, 4:21 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, Laszlo Puskas, Sandor Magyari, 
> Sumit Mohanty, Sebastian Toader, and Sid Wagle.
> 
> 
> Bugs: AMBARI-20886
> https://issues.apache.org/jira/browse/AMBARI-20886
> 
> 
> Repository: ambari
> 
> 
> Description
> ---
> 
> Based on existing SQL Server script generate at compile-time for AzureDB a 
> SQL script that:
>  * runs CREATE TABLE, CREATE INDEX and ADD CONSTRAINT statements only if the 
> objects do not exist yet,
>  * DELETEs rows before running INSERT statements.
> 
> 
> Diffs
> -
> 
>   ambari-server/pom.xml da1f09eceb999650c33729120b6959462445a115 
>   ambari-server/src/main/assemblies/server.xml 
> 27835265f78a3a7aed37eaa544e25679eee8b400 
>   ambari-server/src/main/perl/azuredb_create_generator.pl PRE-CREATION 
>   ambari-server/src/main/perl/azuredb_delete_generator.pl PRE-CREATION 
>   ambari-server/src/main/resources/.gitignore PRE-CREATION 
>   ambari-server/src/main/sh/azuredb_create_generator.sh PRE-CREATION 
> 
> 
> Diff: https://reviews.apache.org/r/58840/diff/3/
> 
> 
> Testing
> ---
> 
> Tested with Microsoft SQL Server on Linux using Docker:
> 
> ```
> $ mvn -q -pl ambari-server clean generate-resources
> $ export MSSQL_PASSWORD='hVn?1AY6b\l&'
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> ba7ad59f747eac75e696cbab8ed7f30af0c98dc81250ee393ebf0e01e71f2965
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 107
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (0 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (1 rows affected)
> 
> (1 rows affected)
> 
> (184 rows affected)
> 
> (53 rows affected)
> 
> (7 rows affected)
> 
> (1 rows affected)
> 
> (8 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (54 rows affected)
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (14 rows affected)
> 
> (19 rows affected)
> 
> (24 rows affected)
> 
> (31 rows affected)
> 
> (42 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> 
> $ docker rm -f mssql
> mssql
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> 5dfdd09a70b76f5cd9716fff94680b758c92f3850b227c0c274eea800bdf3402
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (14 rows affected)
> 
> (19 rows affected)
> 
> (24 rows affected)
> 
> (31 rows affected)
> 
> (42 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---

Re: Review Request 58840: AMBARI-20886. Create idempotent Ambari DB Schema SQL script for AzureDB

2017-04-28 Thread Attila Doroszlai


> On April 28, 2017, 6:59 p.m., Sid Wagle wrote:
> > ambari-server/src/main/perl/azuredb_delete_generator.pl
> > Lines 20 (patched)
> > 
> >
> > So delete ordering follows insert but this works because we insert in 
> > very few tables which have inserts in the correct order of foreign keys? 
> > That's why delete will work? I am not sure if there is silence constraints 
> > in SQLServer but I would think we would need something like that to make 
> > sure deletes succeed. Not an issue but more for understanding how deletes 
> > do not violate constraints.

`unshift` adds the new item to the head of the list, so `delete` order is the 
reverse of `insert` order.


- Attila


---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58840/#review173342
---


On April 28, 2017, 6:21 p.m., Attila Doroszlai wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/58840/
> ---
> 
> (Updated April 28, 2017, 6:21 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, Laszlo Puskas, Sandor Magyari, 
> Sumit Mohanty, Sebastian Toader, and Sid Wagle.
> 
> 
> Bugs: AMBARI-20886
> https://issues.apache.org/jira/browse/AMBARI-20886
> 
> 
> Repository: ambari
> 
> 
> Description
> ---
> 
> Based on existing SQL Server script generate at compile-time for AzureDB a 
> SQL script that:
>  * runs CREATE TABLE, CREATE INDEX and ADD CONSTRAINT statements only if the 
> objects do not exist yet,
>  * DELETEs rows before running INSERT statements.
> 
> 
> Diffs
> -
> 
>   ambari-server/pom.xml da1f09eceb999650c33729120b6959462445a115 
>   ambari-server/src/main/assemblies/server.xml 
> 27835265f78a3a7aed37eaa544e25679eee8b400 
>   ambari-server/src/main/perl/azuredb_create_generator.pl PRE-CREATION 
>   ambari-server/src/main/perl/azuredb_delete_generator.pl PRE-CREATION 
>   ambari-server/src/main/resources/.gitignore PRE-CREATION 
>   ambari-server/src/main/sh/azuredb_create_generator.sh PRE-CREATION 
> 
> 
> Diff: https://reviews.apache.org/r/58840/diff/3/
> 
> 
> Testing
> ---
> 
> Tested with Microsoft SQL Server on Linux using Docker:
> 
> ```
> $ mvn -q -pl ambari-server clean generate-resources
> $ export MSSQL_PASSWORD='hVn?1AY6b\l&'
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> ba7ad59f747eac75e696cbab8ed7f30af0c98dc81250ee393ebf0e01e71f2965
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 107
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (0 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (1 rows affected)
> 
> (1 rows affected)
> 
> (184 rows affected)
> 
> (53 rows affected)
> 
> (7 rows affected)
> 
> (1 rows affected)
> 
> (8 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (54 rows affected)
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (14 rows affected)
> 
> (19 rows affected)
> 
> (24 rows affected)
> 
> (31 rows affected)
> 
> (42 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> 
> $ docker rm -f mssql
> mssql
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> 5dfdd09a70b76f5cd9716fff94680b758c92f3850b227c0c274eea800bdf3402
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> 

Re: Review Request 58840: AMBARI-20886. Create idempotent Ambari DB Schema SQL script for AzureDB

2017-04-28 Thread Alejandro Fernandez

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58840/#review173347
---




ambari-server/src/main/perl/azuredb_delete_generator.pl
Lines 20 (patched)


Why introduce a dependency on perl?

Can't this be done with shell script or python so it's consistent with the 
rest of Ambari?


- Alejandro Fernandez


On April 28, 2017, 4:21 p.m., Attila Doroszlai wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/58840/
> ---
> 
> (Updated April 28, 2017, 4:21 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, Laszlo Puskas, Sandor Magyari, 
> Sumit Mohanty, Sebastian Toader, and Sid Wagle.
> 
> 
> Bugs: AMBARI-20886
> https://issues.apache.org/jira/browse/AMBARI-20886
> 
> 
> Repository: ambari
> 
> 
> Description
> ---
> 
> Based on existing SQL Server script generate at compile-time for AzureDB a 
> SQL script that:
>  * runs CREATE TABLE, CREATE INDEX and ADD CONSTRAINT statements only if the 
> objects do not exist yet,
>  * DELETEs rows before running INSERT statements.
> 
> 
> Diffs
> -
> 
>   ambari-server/pom.xml da1f09eceb999650c33729120b6959462445a115 
>   ambari-server/src/main/assemblies/server.xml 
> 27835265f78a3a7aed37eaa544e25679eee8b400 
>   ambari-server/src/main/perl/azuredb_create_generator.pl PRE-CREATION 
>   ambari-server/src/main/perl/azuredb_delete_generator.pl PRE-CREATION 
>   ambari-server/src/main/resources/.gitignore PRE-CREATION 
>   ambari-server/src/main/sh/azuredb_create_generator.sh PRE-CREATION 
> 
> 
> Diff: https://reviews.apache.org/r/58840/diff/3/
> 
> 
> Testing
> ---
> 
> Tested with Microsoft SQL Server on Linux using Docker:
> 
> ```
> $ mvn -q -pl ambari-server clean generate-resources
> $ export MSSQL_PASSWORD='hVn?1AY6b\l&'
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> ba7ad59f747eac75e696cbab8ed7f30af0c98dc81250ee393ebf0e01e71f2965
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 107
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (0 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (1 rows affected)
> 
> (1 rows affected)
> 
> (184 rows affected)
> 
> (53 rows affected)
> 
> (7 rows affected)
> 
> (1 rows affected)
> 
> (8 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (54 rows affected)
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (14 rows affected)
> 
> (19 rows affected)
> 
> (24 rows affected)
> 
> (31 rows affected)
> 
> (42 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> 
> $ docker rm -f mssql
> mssql
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> 5dfdd09a70b76f5cd9716fff94680b758c92f3850b227c0c274eea800bdf3402
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (14 rows affected)
> 
> (19 rows affected)
> 
> (24 rows affected)
> 
> (31 rows affected)
> 
> (42 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (1 rows affected)
> $ 

Re: Review Request 58840: AMBARI-20886. Create idempotent Ambari DB Schema SQL script for AzureDB

2017-04-28 Thread Sid Wagle

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58840/#review173342
---




ambari-server/src/main/perl/azuredb_delete_generator.pl
Lines 20 (patched)


So delete ordering follows insert but this works because we insert in very 
few tables which have inserts in the correct order of foreign keys? That's why 
delete will work? I am not sure if there is silence constraints in SQLServer 
but I would think we would need something like that to make sure deletes 
succeed. Not an issue but more for understanding how deletes do not violate 
constraints.


- Sid Wagle


On April 28, 2017, 4:21 p.m., Attila Doroszlai wrote:
> 
> ---
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/58840/
> ---
> 
> (Updated April 28, 2017, 4:21 p.m.)
> 
> 
> Review request for Ambari, Jonathan Hurley, Laszlo Puskas, Sandor Magyari, 
> Sumit Mohanty, Sebastian Toader, and Sid Wagle.
> 
> 
> Bugs: AMBARI-20886
> https://issues.apache.org/jira/browse/AMBARI-20886
> 
> 
> Repository: ambari
> 
> 
> Description
> ---
> 
> Based on existing SQL Server script generate at compile-time for AzureDB a 
> SQL script that:
>  * runs CREATE TABLE, CREATE INDEX and ADD CONSTRAINT statements only if the 
> objects do not exist yet,
>  * DELETEs rows before running INSERT statements.
> 
> 
> Diffs
> -
> 
>   ambari-server/pom.xml da1f09eceb999650c33729120b6959462445a115 
>   ambari-server/src/main/assemblies/server.xml 
> 27835265f78a3a7aed37eaa544e25679eee8b400 
>   ambari-server/src/main/perl/azuredb_create_generator.pl PRE-CREATION 
>   ambari-server/src/main/perl/azuredb_delete_generator.pl PRE-CREATION 
>   ambari-server/src/main/resources/.gitignore PRE-CREATION 
>   ambari-server/src/main/sh/azuredb_create_generator.sh PRE-CREATION 
> 
> 
> Diff: https://reviews.apache.org/r/58840/diff/3/
> 
> 
> Testing
> ---
> 
> Tested with Microsoft SQL Server on Linux using Docker:
> 
> ```
> $ mvn -q -pl ambari-server clean generate-resources
> $ export MSSQL_PASSWORD='hVn?1AY6b\l&'
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> ba7ad59f747eac75e696cbab8ed7f30af0c98dc81250ee393ebf0e01e71f2965
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 107
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (0 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql
> 
> (1 rows affected)
> 
> (1 rows affected)
> 
> (184 rows affected)
> 
> (53 rows affected)
> 
> (7 rows affected)
> 
> (1 rows affected)
> 
> (8 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (54 rows affected)
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (14 rows affected)
> 
> (19 rows affected)
> 
> (24 rows affected)
> 
> (31 rows affected)
> 
> (42 rows affected)
> 
> (53 rows affected)
> 
> (1 rows affected)
> 
> (1 rows affected)
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD"
> 1> select count(*) from sys.objects;
> 2> go
> 
> ---
> 525
> 
> (1 rows affected)
> 1> select count(*) from ambari_sequences;
> 2> go
> 
> ---
>  54
> 
> (1 rows affected)
> 
> $ docker rm -f mssql
> mssql
> $ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
> -p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
> 5dfdd09a70b76f5cd9716fff94680b758c92f3850b227c0c274eea800bdf3402
> $ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
> "$MSSQL_PASSWORD" -i 
> /tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql
> 
> (54 rows affected)
> 
> (3 rows affected)
> 
> (1 rows affected)
> 
> (3 rows affected)
> 
> (8 rows affected)
> 
> (1 rows affected)
> 
> (7 rows 

Re: Review Request 58840: AMBARI-20886. Create idempotent Ambari DB Schema SQL script for AzureDB

2017-04-28 Thread Attila Doroszlai

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58840/
---

(Updated April 28, 2017, 3:46 p.m.)


Review request for Ambari, Jonathan Hurley, Laszlo Puskas, Sandor Magyari, and 
Sebastian Toader.


Changes
---

Fixed `/usr/bin/env: perl -wpl -0073: No such file or directory` error on Linux


Bugs: AMBARI-20886
https://issues.apache.org/jira/browse/AMBARI-20886


Repository: ambari


Description
---

Based on existing SQL Server script generate at compile-time for AzureDB a SQL 
script that:
 * runs CREATE TABLE, CREATE INDEX and ADD CONSTRAINT statements only if the 
objects do not exist yet,
 * DELETEs rows before running INSERT statements.


Diffs (updated)
-

  ambari-server/pom.xml da1f09eceb999650c33729120b6959462445a115 
  ambari-server/src/main/assemblies/server.xml 
27835265f78a3a7aed37eaa544e25679eee8b400 
  ambari-server/src/main/perl/azuredb_create_generator.pl PRE-CREATION 
  ambari-server/src/main/perl/azuredb_delete_generator.pl PRE-CREATION 
  ambari-server/src/main/resources/.gitignore PRE-CREATION 
  ambari-server/src/main/sh/azuredb_create_generator.sh PRE-CREATION 


Diff: https://reviews.apache.org/r/58840/diff/3/

Changes: https://reviews.apache.org/r/58840/diff/2-3/


Testing
---

Tested with Microsoft SQL Server on Linux using Docker:

```
$ mvn -q -pl ambari-server clean generate-resources
$ export MSSQL_PASSWORD='hVn?1AY6b\l&'
$ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
-p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
ba7ad59f747eac75e696cbab8ed7f30af0c98dc81250ee393ebf0e01e71f2965
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
107

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql

(0 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql

(1 rows affected)

(1 rows affected)

(184 rows affected)

(53 rows affected)

(7 rows affected)

(1 rows affected)

(8 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(54 rows affected)

(54 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(8 rows affected)

(1 rows affected)

(7 rows affected)

(53 rows affected)

(1 rows affected)

(14 rows affected)

(19 rows affected)

(24 rows affected)

(31 rows affected)

(42 rows affected)

(53 rows affected)

(1 rows affected)

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)

$ docker rm -f mssql
mssql
$ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
-p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
5dfdd09a70b76f5cd9716fff94680b758c92f3850b227c0c274eea800bdf3402
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql

(54 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(8 rows affected)

(1 rows affected)

(7 rows affected)

(53 rows affected)

(1 rows affected)

(14 rows affected)

(19 rows affected)

(24 rows affected)

(31 rows affected)

(42 rows affected)

(53 rows affected)

(1 rows affected)

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)
```


Thanks,

Attila Doroszlai



Re: Review Request 58840: AMBARI-20886. Create idempotent Ambari DB Schema SQL script for AzureDB

2017-04-28 Thread Attila Doroszlai

---
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/58840/
---

(Updated April 28, 2017, 2:20 p.m.)


Review request for Ambari, Jonathan Hurley, Laszlo Puskas, Sandor Magyari, and 
Sebastian Toader.


Changes
---

Include generated SQL file in the package


Bugs: AMBARI-20886
https://issues.apache.org/jira/browse/AMBARI-20886


Repository: ambari


Description
---

Based on existing SQL Server script generate at compile-time for AzureDB a SQL 
script that:
 * runs CREATE TABLE, CREATE INDEX and ADD CONSTRAINT statements only if the 
objects do not exist yet,
 * DELETEs rows before running INSERT statements.


Diffs (updated)
-

  ambari-server/pom.xml da1f09eceb999650c33729120b6959462445a115 
  ambari-server/src/main/assemblies/server.xml 
27835265f78a3a7aed37eaa544e25679eee8b400 
  ambari-server/src/main/perl/azuredb_create_generator.pl PRE-CREATION 
  ambari-server/src/main/perl/azuredb_delete_generator.pl PRE-CREATION 
  ambari-server/src/main/resources/.gitignore PRE-CREATION 
  ambari-server/src/main/sh/azuredb_create_generator.sh PRE-CREATION 


Diff: https://reviews.apache.org/r/58840/diff/2/

Changes: https://reviews.apache.org/r/58840/diff/1-2/


Testing
---

Tested with Microsoft SQL Server on Linux using Docker:

```
$ mvn -q -pl ambari-server clean generate-resources
$ export MSSQL_PASSWORD='hVn?1AY6b\l&'
$ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
-p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
ba7ad59f747eac75e696cbab8ed7f30af0c98dc81250ee393ebf0e01e71f2965
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
107

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql

(0 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-AzureDB-CREATE.sql

(1 rows affected)

(1 rows affected)

(184 rows affected)

(53 rows affected)

(7 rows affected)

(1 rows affected)

(8 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(54 rows affected)

(54 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(8 rows affected)

(1 rows affected)

(7 rows affected)

(53 rows affected)

(1 rows affected)

(14 rows affected)

(19 rows affected)

(24 rows affected)

(31 rows affected)

(42 rows affected)

(53 rows affected)

(1 rows affected)

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)

$ docker rm -f mssql
mssql
$ docker run -e 'ACCEPT_EULA=Y' -e "SA_PASSWORD=$MSSQL_PASSWORD" --name mssql 
-p 1433:1433 -v $(PWD):/tmp/ambari -d microsoft/mssql-server-linux
5dfdd09a70b76f5cd9716fff94680b758c92f3850b227c0c274eea800bdf3402
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD" -i 
/tmp/ambari/ambari-server/src/main/resources/Ambari-DDL-SQLServer-CREATE.sql

(54 rows affected)

(3 rows affected)

(1 rows affected)

(3 rows affected)

(8 rows affected)

(1 rows affected)

(7 rows affected)

(53 rows affected)

(1 rows affected)

(14 rows affected)

(19 rows affected)

(24 rows affected)

(31 rows affected)

(42 rows affected)

(53 rows affected)

(1 rows affected)

(1 rows affected)
$ docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P 
"$MSSQL_PASSWORD"
1> select count(*) from sys.objects;
2> go

---
525

(1 rows affected)
1> select count(*) from ambari_sequences;
2> go

---
 54

(1 rows affected)
```


Thanks,

Attila Doroszlai