Пример #1
0
 def expand(self, pcoll):
     dir, name = io.filesystems.FileSystems.split(self.path)
     return pcoll | fileio.WriteToFiles(
         path=dir,
         file_naming=fileio.default_file_naming(name),
         sink=_WriteToPandasFileSink(self.writer, self.args, self.kwargs,
                                     self.incremental, self.binary))
Пример #2
0
 def test_shard_naming(self):
     namer = fileio.default_file_naming(prefix='/path/to/file',
                                        suffix='.txt')
     self.assertEqual(namer(GlobalWindow(), None, None, None, None, None),
                      '/path/to/file.txt')
     self.assertEqual(namer(GlobalWindow(), None, 1, 5, None, None),
                      '/path/to/file-00001-of-00005.txt')
     self.assertEqual(namer(GlobalWindow(), None, 1, 5, 'gz', None),
                      '/path/to/file-00001-of-00005.txt.gz')
     self.assertEqual(
         namer(IntervalWindow(0, 100), None, 1, 5, None, None),
         '/path/to/file'
         '-1970-01-01T00:00:00-1970-01-01T00:01:40-00001-of-00005.txt')