Beispiel #1
0
 def test_strange_arithmetic(self):
     try:
         compiler.compile_text('SELECT times + ints + floats + bools FROM '
                               'rainbow_table', self.tables_by_name)
     except compiler.CompileError:
         self.fail('Compiler exception on arithmetic across all numeric '
                   'types.')
Beispiel #2
0
 def test_strange_arithmetic(self):
     try:
         compiler.compile_text('SELECT times + ints + floats + bools FROM '
                               'rainbow_table', self.tables_by_name)
     except compiler.CompileError:
         self.fail('Compiler exception on arithmetic across all numeric '
                   'types.')
Beispiel #3
0
 def make_view(self, view_name, query):
     # TODO: Figure out the schema by compiling the query, and refactor the
     # code so that the compiler can use the schema instead of expecting
     # every TableId to have actual Columns. For now, we just validate that
     # the view works, and things will break later if the view is actually
     # used.
     compiler.compile_text(query, self.tables_by_name)
     return View(view_name, query)
Beispiel #4
0
 def make_view(self, view_name, query):
     # TODO: Figure out the schema by compiling the query, and refactor the
     # code so that the compiler can use the schema instead of expecting
     # every TableId to have actual Columns. For now, we just validate that
     # the view works, and things will break later if the view is actually
     # used.
     compiler.compile_text(query, self.tables_by_name)
     return View(view_name, query)
Beispiel #5
0
 def test_within_clause_error(self):
     with self.assertRaises(compiler.CompileError) as context:
         compiler.compile_text(
             'SELECT r1.s, COUNT(r1.s) WITHIN r2 AS '
             'num_s_in_r1 FROM record_table',
             self.tables_by_name)
         self.assertTrue('WITHIN clause syntax error' in
                         str(context.exception))
Beispiel #6
0
def background_process():
    text = request.args.get('proglang', 0, type=str)
    lang = request.args.get('lang', 0, type=str)
    result = compile_text(text=text,
                          language=lang,
                          input_values=["2 3", "190 23"],
                          output_values=["5\n", "213\n"])
    return jsonify(result=result)
Beispiel #7
0
 def evaluate_query(self, query):
     select_ast = compiler.compile_text(query, self.tables_by_name)
     select_evaluator = evaluator.Evaluator(self.tables_by_name)
     return select_evaluator.evaluate_select(select_ast)
Beispiel #8
0
 def evaluate_query(self, query):
     select_ast = compiler.compile_text(query, self.tables_by_name)
     select_evaluator = evaluator.Evaluator(self.tables_by_name)
     return select_evaluator.evaluate_select(select_ast)
Beispiel #9
0
 def assert_compiled_select(self, text, expected_ast):
     ast = compiler.compile_text(text, self.tables_by_name)
     self.assertEqual(expected_ast, ast)
Beispiel #10
0
 def test_mistyped_function_call(self):
     with self.assertRaises(compiler.CompileError) as context:
         compiler.compile_text('SELECT SUM(strings) FROM rainbow_table',
                               self.tables_by_name)
     self.assertTrue('Invalid types for function' in str(context.exception))
Beispiel #11
0
 def test_mistyped_binary_operator(self):
     with self.assertRaises(compiler.CompileError) as context:
         compiler.compile_text('SELECT ints CONTAINS strings FROM '
                               'rainbow_table',
                               self.tables_by_name)
     self.assertTrue('Invalid types for operator' in str(context.exception))
Beispiel #12
0
 def assert_compiled_select(self, text, expected_ast):
     ast = compiler.compile_text(text, self.tables_by_name)
     self.assertEqual(expected_ast, ast)
Beispiel #13
0
 def test_mistyped_function_call(self):
     with self.assertRaises(compiler.CompileError) as context:
         compiler.compile_text('SELECT SUM(strings) FROM rainbow_table',
                               self.tables_by_name)
     self.assertTrue('Invalid types for function' in str(context.exception))
Beispiel #14
0
 def test_mistyped_binary_operator(self):
     with self.assertRaises(compiler.CompileError) as context:
         compiler.compile_text('SELECT ints CONTAINS strings FROM '
                               'rainbow_table',
                               self.tables_by_name)
     self.assertTrue('Invalid types for operator' in str(context.exception))