-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed need for random temp tables + added join tests
- Loading branch information
Showing
2 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -951,6 +951,54 @@ class SqlTests(AbstractQTestCase): | |
self.assertEquals(o[1], 'ppp [email protected]') | ||
self.assertEquals(o[2], 'ppp [email protected]') | ||
|
||
def test_self_join1(self): | ||
tmpfile = self.create_file_with_data("\n".join(["%s 9000" % i for i in range(0,10)])) | ||
cmd = '../bin/q "select * from %s a1 join %s a2 on (a1.c1 = a2.c1)"' % (tmpfile.name,tmpfile.name) | ||
retcode, o, e = run_command(cmd) | ||
|
||
self.assertEquals(retcode, 0) | ||
self.assertEquals(len(e), 0) | ||
self.assertEquals(len(o), 10) | ||
|
||
self.cleanup(tmpfile) | ||
|
||
def test_self_join_reuses_table(self): | ||
tmpfile = self.create_file_with_data("\n".join(["%s 9000" % i for i in range(0,10)])) | ||
cmd = '../bin/q "select * from %s a1 join %s a2 on (a1.c1 = a2.c1)" -A' % (tmpfile.name,tmpfile.name) | ||
retcode, o, e = run_command(cmd) | ||
|
||
self.assertEquals(retcode, 0) | ||
self.assertEquals(len(e), 0) | ||
self.assertEquals(len(o), 3) | ||
|
||
self.assertEquals(o[0],'Table for file: %s' % tmpfile.name) | ||
self.assertEquals(o[1],' `c1` - int') | ||
self.assertEquals(o[2],' `c2` - int') | ||
|
||
self.cleanup(tmpfile) | ||
|
||
def test_self_join2(self): | ||
tmpfile1 = self.create_file_with_data("\n".join(["%s 9000" % i for i in range(0,10)])) | ||
cmd = '../bin/q "select * from %s a1 join %s a2 on (a1.c2 = a2.c2)"' % (tmpfile1.name,tmpfile1.name) | ||
retcode, o, e = run_command(cmd) | ||
|
||
self.assertEquals(retcode, 0) | ||
self.assertEquals(len(e), 0) | ||
self.assertEquals(len(o), 10*10) | ||
|
||
self.cleanup(tmpfile1) | ||
|
||
tmpfile2 = self.create_file_with_data("\n".join(["%s 9000" % i for i in range(0,10)])) | ||
cmd = '../bin/q "select * from %s a1 join %s a2 on (a1.c2 = a2.c2) join %s a3 on (a1.c2 = a3.c2)"' % (tmpfile2.name,tmpfile2.name,tmpfile2.name) | ||
retcode, o, e = run_command(cmd) | ||
|
||
self.assertEquals(retcode, 0) | ||
self.assertEquals(len(e), 0) | ||
self.assertEquals(len(o), 10*10*10) | ||
|
||
self.cleanup(tmpfile2) | ||
|
||
|
||
def suite(): | ||
tl = unittest.TestLoader() | ||
basic_stuff = tl.loadTestsFromTestCase(BasicTests) | ||
|