5.1.1.6 스키마 정보 가져오기
printSchema 메서드를 사용해 서로 다른 방식으로 생성한 itPostsDFStruct와 itPostsDFCase 스키마가 동일한지 확인해 보자. 또 DataFrame의 schema 필드를 사용해 StructType 객체로 정의된 스키마를 참조할 수도 있다.
이외에도 columns와 dtypes 메서드로 DataFrame의 스키마 정보를 확인할 수 있다. columns 메서드는 칼럼 이름 목록을 반환하며, dtypes 메서드는 각 칼럼 이름과 타입으로 구성된 튜플 목록을 반환한다. itPostsDFCase DataFrame을 대상으로 두 메서드를 호출한 결과는 다음과 같다.
scala> itPostsDFCase.columns res0: Array[String] = Array(commentCount, lastActivityDate, ownerUserId, body, score, creationDate, viewCount, title, tags, answerCount, acceptedAnswerId, postTypeId, id) scala> itPostsDFStruct.dtypes res1: Array[(String, String)] = Array((commentCount,IntegerType), (lastActivityDate,TimestampType), (ownerUserId,LongType), (body,StringType), (score,IntegerType), (creationDate,TimestampType), (viewCount,IntegerType), (title,StringType), (tags,StringType), (answerCount,IntegerType), (acceptedAnswerId,LongType), (postTypeId,LongType), (id,LongType))