|
5 | 5 | import psutil
|
6 | 6 | import unittest
|
7 | 7 | from chdb import session
|
| 8 | +import chdb |
8 | 9 |
|
9 | 10 |
|
10 | 11 | test_state_dir = ".state_tmp_auxten_"
|
@@ -68,9 +69,7 @@ def test_path(self):
|
68 | 69 |
|
69 | 70 | def test_mergetree(self):
|
70 | 71 | sess = session.Session()
|
71 |
| - sess.query( |
72 |
| - "CREATE DATABASE IF NOT EXISTS db_xxx_merge ENGINE = Atomic;", "CSV" |
73 |
| - ) |
| 72 | + sess.query("CREATE DATABASE IF NOT EXISTS db_xxx_merge ENGINE = Atomic;", "CSV") |
74 | 73 | sess.query(
|
75 | 74 | "CREATE TABLE IF NOT EXISTS db_xxx_merge.log_table_xxx (x String, y Int) ENGINE = MergeTree ORDER BY x;"
|
76 | 75 | )
|
@@ -113,6 +112,42 @@ def test_two_sessions(self):
|
113 | 112 | self.assertEqual(str(ret), "1\n2\n3\n4\n")
|
114 | 113 | ret = sess2.query("SELECT * FROM db_xxx.tbl2", "CSV")
|
115 | 114 | self.assertEqual(str(ret), "5\n6\n7\n8\n")
|
| 115 | + sess1.query( |
| 116 | + """ |
| 117 | + SET input_format_csv_use_best_effort_in_schema_inference = 0; |
| 118 | + SET input_format_csv_skip_first_lines = 1;""" |
| 119 | + ) |
| 120 | + # query level settings should not affect session level settings |
| 121 | + ret = sess1.query( |
| 122 | + "SELECT 123 SETTINGS input_format_csv_use_best_effort_in_schema_inference = 1;" |
| 123 | + ) |
| 124 | + # check sess1 settings |
| 125 | + ret = sess1.query("""SELECT value, changed FROM system.settings |
| 126 | + WHERE name = 'input_format_csv_use_best_effort_in_schema_inference';""") |
| 127 | + self.assertEqual(str(ret), '"0",1\n') |
| 128 | + ret = sess1.query("""SELECT value, changed FROM system.settings |
| 129 | + WHERE name = 'input_format_csv_skip_first_lines';""") |
| 130 | + self.assertEqual(str(ret), '"1",1\n') |
| 131 | + |
| 132 | + # sess2 should not be affected |
| 133 | + ret = sess2.query("""SELECT value, changed FROM system.settings |
| 134 | + WHERE name = 'input_format_csv_use_best_effort_in_schema_inference';""") |
| 135 | + self.assertEqual(str(ret), '"1",0\n') |
| 136 | + ret = sess2.query("""SELECT value, changed FROM system.settings |
| 137 | + WHERE name = 'input_format_csv_skip_first_lines';""") |
| 138 | + self.assertEqual(str(ret), '"0",0\n') |
| 139 | + |
| 140 | + # stateless query should not be affected |
| 141 | + ret = chdb.query( |
| 142 | + """SELECT value, changed FROM system.settings |
| 143 | + WHERE name = 'input_format_csv_use_best_effort_in_schema_inference';""" |
| 144 | + ) |
| 145 | + self.assertEqual(str(ret), '"1",0\n') |
| 146 | + ret = chdb.query( |
| 147 | + """SELECT value, changed FROM system.settings |
| 148 | + WHERE name = 'input_format_csv_skip_first_lines';""" |
| 149 | + ) |
| 150 | + self.assertEqual(str(ret), '"0",0\n') |
116 | 151 |
|
117 | 152 | def test_context_mgr(self):
|
118 | 153 | with session.Session() as sess:
|
|
0 commit comments