Exemplo n.º 1
0
class TestAggregate(AgateTestCase):
    def setUp(self):
        self.rows = (
            (1, 4, 'a'),
            (2, 3, 'b'),
            (None, 2, u'👍')
        )

        self.number_type = Number()
        self.text_type = Text()

        self.column_names = ['one', 'two', 'three']
        self.column_types = [self.number_type, self.number_type, self.text_type]

        self.table = Table(self.rows, self.column_names, self.column_types)

    def test_count(self):
        self.assertEqual(self.table.aggregate(Count()), 3)

    def test_sum(self):
        self.assertEqual(self.table.aggregate(Sum('two')), 9)

    def test_multiple(self):
        self.assertEqual(
            self.table.aggregate([
                ('count', Count()),
                ('sum', Sum('two'))
            ]),
            {
                'count': 3,
                'sum': 9
            }
        )
Exemplo n.º 2
0
class TestAggregate(AgateTestCase):
    def setUp(self):
        self.rows = (
            (1, 4, 'a'),
            (2, 3, 'b'),
            (None, 2, u'👍')
        )

        self.number_type = Number()
        self.text_type = Text()

        self.column_names = ['one', 'two', 'three']
        self.column_types = [self.number_type, self.number_type, self.text_type]

        self.table = Table(self.rows, self.column_names, self.column_types)

    def test_length(self):
        self.assertEqual(self.table.aggregate(Length()), 3)

    def test_sum(self):
        self.assertEqual(self.table.aggregate(Sum('two')), 9)

    def test_multiple(self):
        self.assertSequenceEqual(
            self.table.aggregate([
                Length(),
                Sum('two')
            ]),
            [3, 9]
        )
Exemplo n.º 3
0
 def convert_number_type(
         cls, agate_table: agate.Table, col_idx: int
 ) -> str:
     # TODO: handle different precisions?
     decimals = agate_table.aggregate(agate.MaxPrecision(col_idx))
     return "float" if decimals else "int"
Exemplo n.º 4
0
 def convert_number_type(cls, agate_table: agate.Table, col_idx: int) -> str:
     decimals = agate_table.aggregate(agate.MaxPrecision(col_idx))
     return "float" if decimals else "integer"
Exemplo n.º 5
0
 def convert_number_type(cls, agate_table: agate.Table,
                         col_idx: int) -> str:
     decimals = agate_table.aggregate(agate.MaxPrecision(col_idx))
     return 'Float32' if decimals else 'Int32'
Exemplo n.º 6
0
 def convert_text_type(cls, agate_table: agate.Table, col_idx: int) -> str:
     max_str_length = agate_table.aggregate(agate.MaxLength(
         col_idx)) + cls.oracle_additional_text_space_for_dbt()
     return f"VARCHAR2({max_str_length} CHAR)"