Spark 데이터 프레임의 StatFunctions 패키지 함수 중 monotonically_increasing_id를 사용하면

데이터 프레임의 로우에 할당된 고유 ID를 출력한다.



import org.apache.spark.sql.functions.monotonically_increasing_id
df.select(monotonically_increasing_id()).show(5)



결과


+-----------------------------+

|monotonically_increasing_id()|

+-----------------------------+

|                            0|

|                            1|

|                            2|

|                            3|

|                            4|

+-----------------------------+

only showing top 5 rows


Posted by '김용환'
,



Spark에서 DataFrame으로 장난치다가

 requirement failed: Currently correlation calculation for columns with dataType string not supported.라는 에러를 만날 수 있다. 


이는 데이터 타입을 inferScheme을 통해 추론하는데 데이터 타입이 Long/Int로 변환되야 하는데 String 타입으로 변환된 컬럼 데이터를 corr라는 sql 함수로 계산하다가 에러가 발생한 것이다.


이럴 때는 명시적으로 StructType을 사용해 스키마를 지원하는 것이 좋다.



import org.apache.spark.sql.types.{StructType, StructField, StringType, LongType}

val myManualSchema = StructType(Array(
StructField("InvoiceNo", LongType, true),
StructField("StockCode", StringType, true),
StructField("Description", StringType, true),
StructField("Quantity", LongType, true),
StructField("InvoiceDate", StringType, true),
StructField("UnitPrice", LongType, true),
StructField("CustomerID", StringType, true),
StructField("Country", StringType, true)
))

val df = spark.read.format("csv")
.option("header", true)
.schema(myManualSchema)
.load("origin-source/data/retail-data/by-day/2010-12-01.csv")


Posted by '김용환'
,


ssh-keyscan, ssh-keygen 예시






$ ssh-keyscan github.com


github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccK...





$ ssh-keyscan -H github.com


|1|IVo9dmTn5FMnAkZ+4xWUuevH5To=|BQBOJ80KCa5BxDJxjGV+ElrfSvw= ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccK..





$ ssh-keygen -lf <(ssh-keyscan github.com 2>/dev/null)


2048 SHA256:nThbg6kXUpJWGl7E1IGO,,, github.com (RSA)







$ ssh-keygen -lf <(ssh-keyscan -H github.com 2>/dev/null)


2048 SHA256:nThbg6kXUpJWGl7E1IGO... (RSA)

Posted by '김용환'
,





깃허브를 깃 서버로 사용한다면 깃허브 웹 사이트에서 SSH 키 지문(http://bit.ly/1DffcxK)을 조회할 수 있다.


이 글을 쓰는 시점에서 깃허브의 base64 포맷의 SHA256 RSA 지문(최신 포맷)은 SHA256:abc...이며 16진수 MD5 RSA 지문(이전 포맷)은 11:22:33:...:44의 포맷이다.


OpenSSH 6.8에서 기본 지문 포맷을 16진수 MD5에서 base64 SHA256으로 변경했고 현재 번역하는 시점의 7.9에서도 여전히 동일한 포맷을 사용 중이다


https://www.openssh.com/txt/release-7.9


Posted by '김용환'
,


ssh agent forwarding(에이전트 포워딩)에 sudo를 사용할 때 참고할만한 싸이트


https://gist.github.com/scottjacobsen/4281310




> sudo SSH_AUTH_SOCK=$SSH_AUTH_SOCK git clone git@github.com:my-github-account/my-repo.git


Posted by '김용환'
,