示例#1
0
func init() {

	LoadTestDataOnce()

	builtins.LoadAllBuiltins()

	MockSchema, _ = registry.Schema("mockcsv")
}
示例#2
0
func init() {
	flag.Parse()
	if *VerboseTests {
		u.SetupLogging("debug")
		u.SetColorOutput()
	}
	builtins.LoadAllBuiltins()
}
示例#3
0
func init() {
	lex.IDENTITY_CHARS = lex.IDENTITY_SQL_CHARS
	flag.Parse()
	if *VerboseTests {
		u.SetupLogging("debug")
		u.SetColorOutput()
	}

	builtins.LoadAllBuiltins()
}
示例#4
0
func main() {

	if sqlText == "" {
		u.Errorf("You must provide a valid select query in argument:    --sql=\"select ...\"")
		return
	}

	// load all of our built-in functions
	builtins.LoadAllBuiltins()

	// Add a custom function to the VM to make available to SQL language
	expr.FuncAdd("email_is_valid", EmailIsValid)

	// Our file source of csv's is stdin
	stdIn, err := os.Open("/dev/stdin")
	if err != nil {
		u.Errorf("could not open stdin? %v", err)
		return
	}

	// We are registering the "csv" datasource, to show that
	// the backend/sources can be easily created/added.  This csv
	// reader is an example datasource that is very, very simple.
	exit := make(chan bool)
	src, _ := datasource.NewCsvSource("stdin", 0, stdIn, exit)
	datasource.Register("csv", src)

	db, err := sql.Open("qlbridge", "csv:///dev/stdin")
	if err != nil {
		panic(err.Error())
	}
	defer db.Close()

	rows, err := db.Query(sqlText)
	if err != nil {
		u.Errorf("could not execute query: %v", err)
		return
	}
	defer rows.Close()
	cols, _ := rows.Columns()

	// this is just stupid hijinx for getting pointers for unknown len columns
	readCols := make([]interface{}, len(cols))
	writeCols := make([]string, len(cols))
	for i, _ := range writeCols {
		readCols[i] = &writeCols[i]
	}
	fmt.Printf("\n\nScanning through CSV: (%v)\n\n", strings.Join(cols, ","))
	for rows.Next() {
		rows.Scan(readCols...)
		fmt.Println(strings.Join(writeCols, ", "))
	}
	fmt.Println("")
}
示例#5
0
文件: main.go 项目: kyledj/qlbridge
func init() {

	flag.StringVar(&logging, "logging", "info", "logging [ debug,info ]")
	flag.StringVar(&cpuProfileFile, "cpuprofile", "", "cpuprofile")
	flag.StringVar(&memProfileFile, "memprofile", "", "memProfileFile")
	flag.StringVar(&command, "command", "parse", "command to run [parse,vm]")
	flag.Parse()

	builtins.LoadAllBuiltins()

}
示例#6
0
func init() {
	flag.Parse()
	if testing.Verbose() {
		u.SetupLogging("debug")
	} else {
		u.SetupLogging("warn")
	}
	u.SetColorOutput()

	LoadTestDataOnce()

	builtins.LoadAllBuiltins()
}
示例#7
0
func init() {
	flag.Parse()
	if *VerboseTests {
		u.SetupLogging("debug")
		u.SetColorOutput()
	}

	builtins.LoadAllBuiltins()

	//expr.FuncAdd("eq", Eq)
	//expr.FuncAdd("toint", ToInt)
	//expr.FuncAdd("yy", Yy)
	//expr.FuncAdd("oneof", OneOfFunc)
}
示例#8
0
func init() {
	u.SetupLogging("debug")
	u.SetColorOutput()

	builtins.LoadAllBuiltins()

	u.Infof("show curent env info: %v", rtConf.Sources.String())

	mockcsv.MockData["users"] = `user_id,email,interests,reg_date,item_count
9Ip1aKbeZe2njCDM,"*****@*****.**","fishing","2012-10-17T17:29:39.738Z",82
hT2impsOPUREcVPc,"*****@*****.**","swimming","2009-12-11T19:53:31.547Z",12
hT2impsabc345c,"not_an_email","swimming","2009-12-11T19:53:31.547Z",12`

	mockcsv.MockData["orders"] = `user_id,item_id,price,order_date,item_count
9Ip1aKbeZe2njCDM,1,22.50,"2012-10-24T17:29:39.738Z",82
9Ip1aKbeZe2njCDM,1,22.50,"2012-10-24T17:29:39.738Z",82
`

}
示例#9
0
// SetupLogging enables -vv verbose logging or sends logs to /dev/null
// env var VERBOSELOGS=true was added to support verbose logging with alltests
func Setup() {
	setupOnce.Do(func() {

		if flag.CommandLine.Lookup("vv") == nil {
			verbose = flag.Bool("vv", false, "Verbose Logging?")
		}

		flag.Parse()
		if *verbose || os.Getenv("VERBOSELOGS") != "" {
			u.SetupLogging("debug")
			u.SetColorOutput()
		} else {
			// make sure logging is always non-nil
			dn, _ := os.Open(os.DevNull)
			u.SetLogger(log.New(dn, "", 0), "error")
		}

		builtins.LoadAllBuiltins()

	})
}