Skip to content

Instantly share code, notes, and snippets.

@kastner
Created July 26, 2012 03:45
Show Gist options
  • Select an option

  • Save kastner/3180121 to your computer and use it in GitHub Desktop.

Select an option

Save kastner/3180121 to your computer and use it in GitHub Desktop.
hiveGetQuery <- function(query) {
tmpfn = tempfile("hive")
cmd = sprintf("ssh hadoop@HOST 'hive -e \"%s\" 2>/dev/null' 2>/dev/null > %s", query, tmpfn)
system(cmd, intern=TRUE)
df = read.table(tmpfn, sep='\t', header=FALSE, na.strings=c("null", "NaN"), fill=TRUE)
file.remove(tmpfn)
return(df[,1:ncol(df)-1]) #remove extra tab at end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment