Можете ли вы увеличить количество разделов? В зависимости от размера таблицы вам может понадобиться увеличить количество разделов. Можете ли вы попробовать увеличить количество разделов до 30 и посмотреть, не возникли ли у вас проблемы с нехваткой памяти?
val yearDF = spark.read.format("io.pivotal.greenplum.spark.GreenplumRelationProvider").option("url", "jdbc:postgresql://1.2.3.166:5432/finance?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory").option("server.port","8020").option("dbtable", "tablename").option("dbschema","schema").option("user", "123415").option("password", "etl_123").option("partitionColumn","je_id").option("partitions",30).load().where("period_year=2017 and period_num=12 and source_system_name='SSS'").select(splitSeq map col:_*).withColumn("flagCol", lit(0))
yearDF.write.format("csv").save("hdfs://dev/apps/hive/warehouse/header_test_data/")
Взгляды хорошо мне, там что-либо определенное, которое Вы хотите изменить к лучшему?
Вы могли сделать что-то как:
(define (max2 . l)
(lambda ()
(let ((a (apply max l)))
(values a (apply max (remv a l))))))
(define (q a b c)
(call-with-values (max2 a b c)
(lambda (a b)
(+ (* a a) (* b b)))))
(define (skip-min . l)
(lambda ()
(apply values (remv (apply min l) l))))
(define (p a b c)
(call-with-values (skip-min a b c)
(lambda (a b)
(+ (* a a) (* b b)))))
И это (proc p) может быть легко преобразовано для обработки любого количества аргументов.
Ниже приведено решение, которое я придумала. Мне легче рассуждать о решении, когда код разбит на маленькие функции.
; Exercise 1.3
(define (sum-square-largest a b c)
(+ (square (greatest a b))
(square (greatest (least a b) c))))
(define (greatest a b)
(cond (( > a b) a)
(( < a b) b)))
(define (least a b)
(cond ((> a b) b)
((< a b) a)))
(define (square a)
(* a a))
Вот еще один способ сделать это:
#!/usr/bin/env mzscheme #lang scheme/load (module ex-1.3 scheme/base (define (ex-1.3 a b c) (let* ((square (lambda (x) (* x x))) (p (lambda (a b c) (+ (square a) (square (if (> b c) b c)))))) (if (> a b) (p a b c) (p b a c)))) (require scheme/contract) (provide/contract [ex-1.3 (-> number? number? number? number?)])) ;; tests (module ex-1.3/test scheme/base (require (planet "test.ss" ("schematics" "schemeunit.plt" 2)) (planet "text-ui.ss" ("schematics" "schemeunit.plt" 2))) (require 'ex-1.3) (test/text-ui (test-suite "ex-1.3" (test-equal? "1 2 3" (ex-1.3 1 2 3) 13) (test-equal? "2 1 3" (ex-1.3 2 1 3) 13) (test-equal? "2 1. 3.5" (ex-1.3 2 1. 3.5) 16.25) (test-equal? "-2 -10. 3.5" (ex-1.3 -2 -10. 3.5) 16.25) (test-exn "2+1i 0 0" exn:fail:contract? (lambda () (ex-1.3 2+1i 0 0))) (test-equal? "all equal" (ex-1.3 3 3 3) 18)))) (require 'ex-1.3/test)
Пример:
$ mzscheme ex-1.3.ss 6 success(es) 0 failure(s) 0 error(s) 6 test(s) run 0
Можно также отсортировать список и добавить квадраты первого и второго элемента отсортированного списка:
(require (lib "list.ss")) ;; I use PLT Scheme
(define (exercise-1-3 a b c)
(let* [(sorted-list (sort (list a b c) >))
(x (first sorted-list))
(y (second sorted-list))]
(+ (* x x) (* y y))))
Используя только понятия, введенные до этого момента в тексте, , который я считаю довольно важным , вот другое решение:
(define (smallest-of-three a b c)
(if (< a b)
(if (< a c) a c)
(if (< b c) b c)))
(define (square a)
(* a a))
(define (sum-of-squares-largest a b c)
(+ (square a)
(square b)
(square c)
(- (square (smallest-of-three a b c)))))
Что относительно чего-то вроде этого?
(define (p a b c)
(if (> a b)
(if (> b c)
(+ (square a) (square b))
(+ (square a) (square c)))
(if (> a c)
(+ (square a) (square b))
(+ (square b) (square c)))))
Я сделал это с помощью следующего кода, который использует встроенные процедуры min
, max
и square
. Их достаточно просто реализовать, используя только то, что было введено в тексте до этого момента.
(define (sum-of-highest-squares x y z)
(+ (square (max x y))
(square (max (min x y) z))))
big
назван max
. Используйте стандартную функциональность библиотеки, когда это будет там.
Мой подход отличается. Вместо большого количества тестов, я просто добавляю квадраты всех трех, затем вычитаю квадрат самого маленького.
(define (exercise1.3 a b c)
(let ((smallest (min a b c))
(square (lambda (x) (* x x))))
(+ (square a) (square b) (square c) (- (square smallest)))))
, Предпочитаете ли Вы, этот подход или набор if
тесты, ваше дело, конечно.
Альтернативная реализация с помощью SRFI 95:
(define (exercise1.3 . args)
(let ((sorted (sort! args >))
(square (lambda (x) (* x x))))
(+ (square (car sorted)) (square (cadr sorted)))))
Как выше, но как острота (благодарит synx freenode #scheme); также требует SRFI 1 и SRFI 26:
(define (exercise1.3 . args)
(apply + (map! (cut expt <> 2) (take! (sort! args >) 2))))
Используя только концепции, представленные в этой части книги, я бы сделал это:
(define (square x) (* x x))
(define (sum-of-squares x y) (+ (square x) (square y)))
(define (min x y) (if (< x y) x y))
(define (max x y) (if (> x y) x y))
(define (sum-squares-2-biggest x y z)
(sum-of-squares (max x y) (max z (min x y))))
С помощью Скотта Хоффмана и некоторой помощи irc я исправил свой ошибочный код, вот он
(define (p a b c)
(cond ((> a b)
(cond ((> b c)
(+ (square a) (square b)))
(else (+ (square a) (square c)))))
(else
(cond ((> a c)
(+ (square b) (square a))))
(+ (square b) (square c)))))
Я пробовал:
(define (procedure a b c)
(let ((y (sort (list a b c) >)) (square (lambda (x) (* x x))))
(+ (square (first y)) (square(second y)))))