James – Thank you for the test cases. This is a good start. Some quick notes:
1. The name of the new test is simply "tables.sql", which is a bit vague--based on the name alone I don't think I could guess what it's actually testing. Is it possible to rename the test to something more descriptive, such as "CreateTableFromQuery.sql"?
2. The test is an ij (.sql) test, which is okay but is not ideal. Over the past several months we have been trying to move the test harness to JUnit, so it'd be better if all new tests were added as JUnit tests. In this particular case I think it should be easy to do: I ran the "ijToJUnit" tool that is attached to
DERBY-2151 against the .out file in your patch and the tool ran without problem, creating a default JUnit test that should (in theory) run. You would of course have to add a package declaration and license header, etc., but you should be able to do that by looking at existing JUnit tests. If you have any problems with the tool or with the resulting JUnit test, please feel free to post.
3. The test cases that you have ensure that the CREATE TABLE statements execute without error, but they do not show what was actually created. In order to verify that the correct columns were created with the correct names, it might be good to do a "select * " from the newly created tables before deleting them. Ex:
– create table based on t1
create table t2 as select * from t1 with no data;
select * from t2;
drop table t2;
It would be even better if you could add tests to check that the types of the columns are what they should be, as well. This is one thing that would probably be easier in ij than in JUnit (because ij has the "describe table" commands), but it should be doable in JUnit, too.
4. The SQL spec indicates that if a column in the query is known to be non-nullable then the corresponding column in the new table should be non-nullable, as well. I did a quick test and this is in fact correct with your patch--but it doesn't look like you have any test cases to show this. Is it possible to add one?
Thanks for replying to my comment in such timely fashion, and for the initial test cases. If you have any questions/concerns about my feedback above, please do ask!