예제 #1
0
 def test_simple_script(self):
     _run_program(PYTHON_EXEC, 'test_scripts/simple.py')
     sdf = ama_context.get_dataset(conf.job_metadata.actionName, 'odd')
     stored_list = sdf.select('pow_number').orderBy(
         'pow_number').rdd.flatMap(lambda x: x).collect()
     expected_list = [1, 4, 9, 16]
     self.assertEquals(stored_list, expected_list)
예제 #2
0
 def test_ama_contrxt_write_then_read_should_yield_same_dataframe(self):
     a = [[1], [2], [3], [4]]
     schema = StructType([StructField('number', IntegerType(), True)])
     input_df = ama_context.spark.createDataFrame(a, schema)
     ama_context.persist('odd', input_df)
     stored_df = ama_context.get_dataset(conf.job_metadata.actionName,
                                         'odd')
     input_list = input_df.select('number').collect()
     stored_list = stored_df.select('number').orderBy('number').collect()
     self.assertEqual(input_list, stored_list)
예제 #3
0
 def test_ama_context_read_df_from_valid_path_should_yield_dataframe(self):
     a = [[1], [2], [3], [4]]
     schema = StructType([StructField('number', IntegerType(), True)])
     input_df = ama_context.spark.createDataFrame(a, schema)
     input_df.write.format('parquet').mode(
         'overwrite').save(conf.env.workingDir + "/" +
                           conf.job_metadata.jobId + "/test/test_df")
     stored_df = ama_context.get_dataset('test', 'test_df')
     input_list = input_df.select('number').collect()
     stored_list = stored_df.select('number').orderBy('number').collect()
     self.assertEqual(input_list, stored_list)
예제 #4
0
 def test_simple_script_with_spark_submit_should_persist_list_of_squares(
         self):
     spark_submit = '{}/bin/spark-submit'
     _run_program('spark-submit',
                  'test_scripts/simple.py',
                  env={
                      'PYSPARK_PYTHON': PYTHON_EXEC,
                  })
     sdf = ama_context.get_dataset(conf.job_metadata.actionName, 'odd')
     stored_list = sdf.select('pow_number').orderBy(
         'pow_number').rdd.flatMap(lambda x: x).collect()
     expected_list = [1, 4, 9, 16]
     self.assertEqual(stored_list, expected_list)
예제 #5
0
"""
 Licensed to the Apache Software Foundation (ASF) under one or more
 contributor license agreements.  See the NOTICE file distributed with
 this work for additional information regarding copyright ownership.
 The ASF licenses this file to You under the Apache License, Version 2.0
 (the "License"); you may not use this file except in compliance with
 the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
"""
from amaterasu_pyspark.runtime import ama_context, notifier

rdd = ama_context.sc.parallelize([1, 2, 3, 4])

ama_context.persist('extraction', 'extracted_raw_data', rdd.toDF())
ama_context.get_dataset('extraction', 'extracted_raw_data')

notifier.info('')