Beispiel #1
0
    def test_watermarks_from_source(self):
        rowtime = Rowtime()

        rowtime = rowtime.watermarks_from_source()

        properties = rowtime.to_properties()
        expect = {'rowtime.watermarks.type': 'from-source'}
        assert properties == expect
Beispiel #2
0
    def test_watermarks_periodic_ascending(self):
        rowtime = Rowtime()

        rowtime = rowtime.watermarks_periodic_ascending()

        properties = rowtime.to_properties()
        expect = {'rowtime.watermarks.type': 'periodic-ascending'}
        assert properties == expect
Beispiel #3
0
    def test_timestamps_from_field(self):
        rowtime = Rowtime()

        rowtime = rowtime.timestamps_from_field("rtime")

        properties = rowtime.to_properties()
        expect = {'rowtime.timestamps.type': 'from-field', 'rowtime.timestamps.from': 'rtime'}
        assert properties == expect
Beispiel #4
0
    def test_timestamps_from_source():
        rowtime = Rowtime()

        rowtime = rowtime.timestamps_from_source()

        properties = rowtime.to_properties()
        expect = {'rowtime.timestamps.type': 'from-source'}
        assert properties == expect
Beispiel #5
0
    def test_watermarks_periodic_bounded(self):
        rowtime = Rowtime()

        rowtime = rowtime.watermarks_periodic_bounded(1000)

        properties = rowtime.to_properties()
        expect = {'rowtime.watermarks.type': 'periodic-bounded',
                  'rowtime.watermarks.delay': '1000'}
        assert properties == expect
Beispiel #6
0
    def test_watermarks_periodic_bounded(self):
        rowtime = Rowtime().watermarks_periodic_bounded(1000)

        properties = rowtime.to_properties()
        expected = {
            'rowtime.watermarks.type': 'periodic-bounded',
            'rowtime.watermarks.delay': '1000'
        }
        self.assertEqual(expected, properties)
Beispiel #7
0
    def test_timestamps_from_field(self):
        rowtime = Rowtime().timestamps_from_field("rtime")

        properties = rowtime.to_properties()
        expected = {
            'rowtime.timestamps.type': 'from-field',
            'rowtime.timestamps.from': 'rtime'
        }
        self.assertEqual(expected, properties)
Beispiel #8
0
    def test_rowtime(self):
        schema = Schema()

        schema = schema\
            .field("int_field", DataTypes.INT())\
            .field("long_field", DataTypes.BIGINT())\
            .field("rtime", DataTypes.BIGINT())\
            .rowtime(
                Rowtime().timestamps_from_field("long_field").watermarks_periodic_bounded(5000))\
            .field("string_field", DataTypes.STRING())

        properties = schema.to_properties()
        print(properties)
        expected = {'schema.0.name': 'int_field',
                    'schema.0.type': 'INT',
                    'schema.1.name': 'long_field',
                    'schema.1.type': 'BIGINT',
                    'schema.2.name': 'rtime',
                    'schema.2.type': 'BIGINT',
                    'schema.2.rowtime.timestamps.type': 'from-field',
                    'schema.2.rowtime.timestamps.from': 'long_field',
                    'schema.2.rowtime.watermarks.type': 'periodic-bounded',
                    'schema.2.rowtime.watermarks.delay': '5000',
                    'schema.3.name': 'string_field',
                    'schema.3.type': 'VARCHAR'}
        assert properties == expected
Beispiel #9
0
    def test_timestamps_from_extractor(self):
        rowtime = Rowtime()

        rowtime = rowtime.timestamps_from_extractor(
            "org.apache.flink.table.descriptors.RowtimeTest$CustomExtractor")

        properties = rowtime.to_properties()
        expect = {'rowtime.timestamps.type': 'custom',
                  'rowtime.timestamps.class':
                  'org.apache.flink.table.descriptors.RowtimeTest$CustomExtractor',
                  'rowtime.timestamps.serialized':
                  'rO0ABXNyAD5vcmcuYXBhY2hlLmZsaW5rLnRhYmxlLmRlc2NyaXB0b3JzLlJvd3RpbWVUZXN0JEN1c3R'
                  'vbUV4dHJhY3RvcoaChjMg55xwAgABTAAFZmllbGR0ABJMamF2YS9sYW5nL1N0cmluZzt4cgA-b3JnLm'
                  'FwYWNoZS5mbGluay50YWJsZS5zb3VyY2VzLnRzZXh0cmFjdG9ycy5UaW1lc3RhbXBFeHRyYWN0b3Jf1'
                  'Y6piFNsGAIAAHhwdAACdHM'}
        assert properties == expect
Beispiel #10
0
    def test_watermarks_from_strategy(self):
        rowtime = Rowtime()

        rowtime = rowtime.watermarks_from_strategy(
            "org.apache.flink.table.descriptors.RowtimeTest$CustomAssigner")

        properties = rowtime.to_properties()
        expect = {'rowtime.watermarks.type': 'custom',
                  'rowtime.watermarks.class':
                  'org.apache.flink.table.descriptors.RowtimeTest$CustomAssigner',
                  'rowtime.watermarks.serialized':
                  'rO0ABXNyAD1vcmcuYXBhY2hlLmZsaW5rLnRhYmxlLmRlc2NyaXB0b3JzLlJvd3RpbWVUZXN0JEN1c3R'
                  'vbUFzc2lnbmVyeDcuDvfbu0kCAAB4cgBHb3JnLmFwYWNoZS5mbGluay50YWJsZS5zb3VyY2VzLndtc3'
                  'RyYXRlZ2llcy5QdW5jdHVhdGVkV2F0ZXJtYXJrQXNzaWduZXKBUc57oaWu9AIAAHhyAD1vcmcuYXBhY'
                  '2hlLmZsaW5rLnRhYmxlLnNvdXJjZXMud21zdHJhdGVnaWVzLldhdGVybWFya1N0cmF0ZWd53nt-g2OW'
                  'aT4CAAB4cA'}
        assert properties == expect
Beispiel #11
0
    def test_watermarks_from_source(self):
        rowtime = Rowtime().watermarks_from_source()

        properties = rowtime.to_properties()
        expected = {'rowtime.watermarks.type': 'from-source'}
        self.assertEqual(expected, properties)
Beispiel #12
0
    def test_watermarks_periodic_ascending(self):
        rowtime = Rowtime().watermarks_periodic_ascending()

        properties = rowtime.to_properties()
        expected = {'rowtime.watermarks.type': 'periodic-ascending'}
        self.assertEqual(expected, properties)