[ 
https://issues.apache.org/jira/browse/ARROW-2327?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16419915#comment-16419915
 ] 

ASF GitHub Bot commented on ARROW-2327:
---------------------------------------

wesm closed pull request #1808: ARROW-2327: [JS] Table.fromStruct missing from 
externs
URL: https://github.com/apache/arrow/pull/1808
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/js/src/Arrow.externs.js b/js/src/Arrow.externs.js
index 4932c6775..b1ebd2d3c 100644
--- a/js/src/Arrow.externs.js
+++ b/js/src/Arrow.externs.js
@@ -34,6 +34,8 @@ Table.from = function() {};
 /** @type {?} */
 Table.fromAsync = function() {};
 /** @type {?} */
+Table.fromStruct = function() {};
+/** @type {?} */
 Table.empty = function() {};
 /** @type {?} */
 Table.prototype.schema;
diff --git a/js/src/Arrow.ts b/js/src/Arrow.ts
index 23e8b9983..e4cf97539 100644
--- a/js/src/Arrow.ts
+++ b/js/src/Arrow.ts
@@ -221,6 +221,7 @@ try {
 Schema['from'] = Schema.from;
 Table['from'] = Table.from;
 Table['fromAsync'] = Table.fromAsync;
+Table['fromStruct'] = Table.fromStruct;
 Table['empty'] = Table.empty;
 Vector['create'] = Vector.create;
 RecordBatch['from'] = RecordBatch.from;
diff --git a/js/test/Arrow.ts b/js/test/Arrow.ts
index 5921c4cec..9e027377c 100644
--- a/js/test/Arrow.ts
+++ b/js/test/Arrow.ts
@@ -43,8 +43,8 @@ import { read, readAsync } from '../src/Arrow';
 export { read, readAsync };
 import { View,  VectorLike } from '../src/Arrow';
 export { View,  VectorLike };
-import { Table, Field, Schema, RecordBatch, Type } from '../src/Arrow';
-export { Table, Field, Schema, RecordBatch, Type };
+import { Table, Field, Schema, RecordBatch, Type, vector } from '../src/Arrow';
+export { Table, Field, Schema, RecordBatch, Type, vector };
 
 import { TypedArray, TypedArrayConstructor, IntBitWidth, TimeBitWidth } from 
'../src/Arrow';
 export { TypedArray, TypedArrayConstructor, IntBitWidth, TimeBitWidth };
diff --git a/js/test/unit/table-tests.ts b/js/test/unit/table-tests.ts
index 37bbf6242..d4dc75fb7 100644
--- a/js/test/unit/table-tests.ts
+++ b/js/test/unit/table-tests.ts
@@ -15,7 +15,7 @@
 // specific language governing permissions and limitations
 // under the License.
 
-import Arrow, { RecordBatch } from '../Arrow';
+import Arrow, { vector, RecordBatch } from '../Arrow';
 
 const { predicate, Table } = Arrow;
 
@@ -24,7 +24,7 @@ const { col, lit, custom } = predicate;
 const F32 = 0, I32 = 1, DICT = 2;
 const test_data = [
     {name: `single record batch`,
-     table: Table.from({
+     table: () => Table.from({
           'schema': {
             'fields': [
               {
@@ -114,7 +114,7 @@ const test_data = [
           }]
         }),
         // Use Math.fround to coerce to float32
-     values: [
+     values: () => [
          [Math.fround(-0.3), -1, 'a'],
          [Math.fround(-0.2),  1, 'b'],
          [Math.fround(-0.1), -1, 'c'],
@@ -124,7 +124,7 @@ const test_data = [
          [Math.fround( 0.3), -1, 'a']
      ]},
      {name: `multiple record batches`,
-      table: Table.from({
+      table: () => Table.from({
           'schema': {
             'fields': [
               {
@@ -257,7 +257,7 @@ const test_data = [
             ]
           }]
       }),
-      values: [
+      values: () => [
             [Math.fround(-0.3), -1, 'a'],
             [Math.fround(-0.2),  1, 'b'],
             [Math.fround(-0.1), -1, 'c'],
@@ -267,7 +267,123 @@ const test_data = [
             [Math.fround( 0.3), -1, 'a'],
             [Math.fround( 0.2),  1, 'b'],
             [Math.fround( 0.1), -1, 'c'],
-      ]}
+      ]},
+    {name: `struct`,
+     table: () => Table.fromStruct(Table.from({
+          'schema': {
+            'fields': [
+              {
+                'name': 'struct',
+                'type': {
+                  'name': 'struct'
+                },
+                'nullable': false,
+                'children': [
+                  {
+                    'name': 'f32',
+                    'type': {
+                      'name': 'floatingpoint',
+                      'precision': 'SINGLE'
+                    },
+                    'nullable': false,
+                    'children': [],
+                  },
+                  {
+                    'name': 'i32',
+                    'type': {
+                      'name': 'int',
+                      'isSigned': true,
+                      'bitWidth': 32
+                    },
+                    'nullable': false,
+                    'children': [],
+                  },
+                  {
+                    'name': 'dictionary',
+                    'type': {
+                      'name': 'utf8'
+                    },
+                    'nullable': false,
+                    'children': [],
+                    'dictionary': {
+                      'id': 0,
+                      'indexType': {
+                        'name': 'int',
+                        'isSigned': true,
+                        'bitWidth': 8
+                      },
+                      'isOrdered': false
+                    }
+                  }
+                ]
+              }
+            ]
+          },
+          'dictionaries': [{
+            'id': 0,
+            'data': {
+              'count': 3,
+              'columns': [
+                {
+                  'name': 'DICT0',
+                  'count': 3,
+                  'VALIDITY': [],
+                  'OFFSET': [
+                    0,
+                    1,
+                    2,
+                    3
+                  ],
+                  'DATA': [
+                    'a',
+                    'b',
+                    'c',
+                  ]
+                }
+              ]
+            }
+          }],
+          'batches': [{
+            'count': 7,
+            'columns': [
+              {
+                'name': 'struct',
+                'count': 7,
+                'VALIDITY': [],
+                'children': [
+                  {
+                    'name': 'f32',
+                    'count': 7,
+                    'VALIDITY': [],
+                    'DATA': [-0.3, -0.2, -0.1, 0, 0.1, 0.2, 0.3]
+                  },
+                  {
+                    'name': 'i32',
+                    'count': 7,
+                    'VALIDITY': [],
+                    'DATA': [-1, 1, -1, 1, -1, 1, -1]
+                  },
+                  {
+                    'name': 'dictionary',
+                    'count': 7,
+                    'VALIDITY': [],
+                    'DATA': [0, 1, 2, 0, 1, 2, 0]
+                  }
+                ]
+              }
+            ]
+          }]
+        }).getColumn('struct') as vector.StructVector),
+        // Use Math.fround to coerce to float32
+     values: () => [
+         [Math.fround(-0.3), -1, 'a'],
+         [Math.fround(-0.2),  1, 'b'],
+         [Math.fround(-0.1), -1, 'c'],
+         [Math.fround( 0  ),  1, 'a'],
+         [Math.fround( 0.1), -1, 'b'],
+         [Math.fround( 0.2),  1, 'c'],
+         [Math.fround( 0.3), -1, 'a']
+     ]},
 ];
 
 describe(`Table`, () => {
@@ -282,8 +398,8 @@ describe(`Table`, () => {
     });
     for (let datum of test_data) {
         describe(datum.name, () => {
-            const table = datum.table;
-            const values = datum.values;
+            const table = datum.table();
+            const values = datum.values();
 
             test(`has the correct length`, () => {
                 expect(table.length).toEqual(values.length);


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> [JS] Table.fromStruct missing from externs
> ------------------------------------------
>
>                 Key: ARROW-2327
>                 URL: https://issues.apache.org/jira/browse/ARROW-2327
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: JavaScript
>            Reporter: Brian Hulette
>            Assignee: Brian Hulette
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: JS-0.4.0
>
>
> {{Table.fromStruct}} is not listed in externs, so its obfuscated by the 
> closure compiler



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to