예제 #1
0
def test_translate_query(mock_protect_regex_curly_brackets: MagicMock) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    GHTP._remove_dollar_sign = MagicMock(side_effect=lambda x: x)
    GHTP._replace_double_quotes = MagicMock(side_effect=lambda x: x)
    GHTP._replace_back_ticks = MagicMock(side_effect=lambda x: x)
    GHTP._add_double_quotes = MagicMock(side_effect=lambda x: x)
    GHTP._increment_array_indexes = MagicMock(side_effect=lambda x: x)
    GHTP._cast_divisions_to_double = MagicMock(side_effect=lambda x: x)
    GHTP._fix_rlike_calls = MagicMock(side_effect=lambda x: x)
    GHTP._fix_lateral_view_explode_calls = MagicMock(side_effect=lambda x: x)
    GHTP._fix_interval_formatting = MagicMock(side_effect=lambda x: x)
    GHTP._fix_aliasing_on_broadcasting = MagicMock(side_effect=lambda x: x)
    GHTP.gbt.fix_group_by_calls = MagicMock(side_effect=lambda x: x)
    assert GHTP.translate_query(
        "select * from db.table") == "select * from db.table"
예제 #2
0
def test_cast_divisions_to_double(query: str, expected: str) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    assert GHTP._cast_divisions_to_double(query) == expected
예제 #3
0
def test_increment_array_indexes(query: str, expected: str) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    assert GHTP._increment_array_indexes(query) == expected
예제 #4
0
def test_remove_dollar_sign(query: str, expected: str) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    assert GHTP._remove_dollar_sign(query) == expected
예제 #5
0
def test_add_double_quotes(query: str, expected: str) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    assert GHTP._add_double_quotes(query) == expected
예제 #6
0
def test_replace_back_ticks(query: str, expected: str) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    assert GHTP._replace_back_ticks(query) == expected
예제 #7
0
def test_move_insert_statement(query_section: str, expected: str) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    assert GHTP.move_insert_statement(query_section) == expected
예제 #8
0
def test__fix_aliasing_on_broadcasting(query: str, expected: str) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    assert GHTP._fix_aliasing_on_broadcasting(query) == expected
예제 #9
0
def test_fix_interval_formatting(query: str, expected: str) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    assert GHTP._fix_interval_formatting(query) == expected
예제 #10
0
def test_fix_double_equals(query: str, expected: str) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    assert GHTP._fix_double_equals(query) == expected
예제 #11
0
def test_fix_lateral_view_explode_calls(query: str, expected: str) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    assert GHTP._fix_lateral_view_explode_calls(query) == expected
예제 #12
0
import pytest
import sqlparse
from typing import Tuple, List, Optional
from unittest.mock import patch, MagicMock
from sql_translate.engine import global_translation
from sql_translate import utils

GHTP = global_translation.GlobalHiveToPresto()


def test_create_parent() -> None:
    _GlobalHiveToPresto = global_translation._GlobalTranslator()


@patch('sql_translate.utils.protect_regex_curly_brackets',
       side_effect=lambda x: x)
def test_translate_query(mock_protect_regex_curly_brackets: MagicMock) -> None:
    GHTP = global_translation.GlobalHiveToPresto()
    GHTP._remove_dollar_sign = MagicMock(side_effect=lambda x: x)
    GHTP._replace_double_quotes = MagicMock(side_effect=lambda x: x)
    GHTP._replace_back_ticks = MagicMock(side_effect=lambda x: x)
    GHTP._add_double_quotes = MagicMock(side_effect=lambda x: x)
    GHTP._increment_array_indexes = MagicMock(side_effect=lambda x: x)
    GHTP._cast_divisions_to_double = MagicMock(side_effect=lambda x: x)
    GHTP._fix_rlike_calls = MagicMock(side_effect=lambda x: x)
    GHTP._fix_lateral_view_explode_calls = MagicMock(side_effect=lambda x: x)
    GHTP._fix_interval_formatting = MagicMock(side_effect=lambda x: x)
    GHTP._fix_aliasing_on_broadcasting = MagicMock(side_effect=lambda x: x)
    GHTP.gbt.fix_group_by_calls = MagicMock(side_effect=lambda x: x)
    assert GHTP.translate_query(
        "select * from db.table") == "select * from db.table"