RPAraujo commented on issue #37737:
URL: https://github.com/apache/arrow/issues/37737#issuecomment-1723112829

   Yes, I can show you my code:
   ```
   func (svc *DpeService) ExecuteParameterizedQuery(query string, args []any) {
        config := flightsql.DriverConfig{
                Address: fmt.Sprintf("%s:%s", svc.Host, svc.Port),
                Token:   "",
                Timeout: 10 * time.Second,
                Params:  make(map[string]string),
        }
        db, err := sql.Open("flightsql", config.DSN())
        if err != nil {
                log.Fatalf("open failed: %v", err)
        }
        defer db.Close()
   
        stmt, err := db.Prepare(query)
        if err != nil {
                log.Fatalf("query failed: %s", err)
        }
        rows, err := stmt.Query(args...)
        if err != nil {
                log.Fatalf("query failed: %s", err)
        }
        defer rows.Close()
   
        columns, err := rows.Columns()
        if err != nil {
                log.Fatalf("getting columns failed: %s", err)
        }
        log.Println("columns:", columns)
   
        // Prepare the list of data-points according to the received row
        columnData := make([]interface{}, len(columns))
        columnDataPtr := make([]interface{}, len(columns))
   
        for i := range columnData {
                columnDataPtr[i] = &columnData[i]
        }
   
        idx := 0
        for rows.Next() {
                idx++
                if err := rows.Scan(columnDataPtr...); err != nil {
                        log.Fatalf("scanning row %d failed: %s", idx, err)
                }
                for j := range columns {
                        fmt.Printf("%.22v    ", columnData[j])
                }
                fmt.Println()
        }
   
        if err := rows.Err(); err != nil {
                log.Fatalf("iterating rows failed: %s", err)
        }
   
   }
   ```
   
   Trying to run the query:
   ```
   func (svc *assetService) GetSensorsByAssetId(assetId string) {
        query := `SELECT * FROM $1 WHERE ASSET_ID = $2 LIMIT 1`
   
        args := []any{
                svc.assetType,
                id.String(),
        }
        svc.dpeSvc.ExecuteParameterizedQuery(query, args)
   }
   ```
   
   With this code I get the error:
   `SQL error: ParserError(\"Expected identifier, found: $1\")`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to