You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by ke...@apache.org on 2017/03/17 21:46:56 UTC
[25/50] [abbrv] beam git commit: add unicode type to the typeDict
attribute in Python SDK
add unicode type to the typeDict attribute in Python SDK
Project: http://git-wip-us.apache.org/repos/asf/beam/repo
Commit: http://git-wip-us.apache.org/repos/asf/beam/commit/7daf9abd
Tree: http://git-wip-us.apache.org/repos/asf/beam/tree/7daf9abd
Diff: http://git-wip-us.apache.org/repos/asf/beam/diff/7daf9abd
Branch: refs/heads/gearpump-runner
Commit: 7daf9abd52d4b89c563d370396506d2db71b7700
Parents: 818fc94
Author: tajima <ta...@tajima-taso.jp>
Authored: Thu Mar 9 18:08:25 2017 +0900
Committer: Ahmet Altay <al...@google.com>
Committed: Fri Mar 10 11:56:06 2017 -0800
----------------------------------------------------------------------
sdks/python/apache_beam/transforms/display.py | 1 +
sdks/python/apache_beam/transforms/display_test.py | 11 +++++++++++
2 files changed, 12 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/beam/blob/7daf9abd/sdks/python/apache_beam/transforms/display.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/display.py b/sdks/python/apache_beam/transforms/display.py
index 5e25060..2ced1af 100644
--- a/sdks/python/apache_beam/transforms/display.py
+++ b/sdks/python/apache_beam/transforms/display.py
@@ -160,6 +160,7 @@ class DisplayDataItem(object):
display item belongs to.
"""
typeDict = {str:'STRING',
+ unicode:'STRING',
int:'INTEGER',
float:'FLOAT',
bool: 'BOOLEAN',
http://git-wip-us.apache.org/repos/asf/beam/blob/7daf9abd/sdks/python/apache_beam/transforms/display_test.py
----------------------------------------------------------------------
diff --git a/sdks/python/apache_beam/transforms/display_test.py b/sdks/python/apache_beam/transforms/display_test.py
index 5a95c42..5e106e5 100644
--- a/sdks/python/apache_beam/transforms/display_test.py
+++ b/sdks/python/apache_beam/transforms/display_test.py
@@ -122,6 +122,17 @@ class DisplayDataTest(unittest.TestCase):
DisplayDataItemMatcher('extra_packages',
str(['package1', 'package2']))))
+ def test_unicode_type_display_data(self):
+ class MyDoFn(beam.DoFn):
+ def display_data(self):
+ return {'unicode_string': unicode('my string'),
+ 'unicode_literal_string': u'my literal string'}
+
+ fn = MyDoFn()
+ dd = DisplayData.create_from(fn)
+ for item in dd.items:
+ self.assertEqual(item.type, 'STRING')
+
def test_base_cases(self):
""" Tests basic display data cases (key:value, key:dict)
It does not test subcomponent inclusion