Code Monkey home page Code Monkey logo

Comments (3)

thmeitz avatar thmeitz commented on June 18, 2024

Hi @fenix01,

forget my previous answer, I was wrong.

ksqldb-go/types.go

Lines 90 to 93 in 895ad65

type Header struct {
QueryId string `json:"queryId"`
Columns []Column `json:"Columns"`
}

The Header contains Colum Data

ksqldb-go/types.go

Lines 96 to 99 in 895ad65

type Column struct {
Name string
Type string
}

fmt.Printf("%s\n",header.QueryId)

Here is the code how the header processing is working:

ksqldb-go/pull.go

Lines 115 to 132 in 895ad65

func processHeader(data map[string]interface{}) (header Header) {
if _, ok := data["queryId"].(string); ok {
header.QueryId = data["queryId"].(string)
}
names, okNames := data["columnNames"].([]interface{})
types, okTypes := data["columnTypes"].([]interface{})
if okNames && okTypes {
for col := range names {
if colName, ok := names[col].(string); colName != "" && ok {
if colType, ok := types[col].(string); colType != "" && ok {
header.Columns = append(header.Columns, Column{Name: colName, Type: colType})
}
}
}
}
return
}

from ksqldb-go.

fenix01 avatar fenix01 commented on June 18, 2024

Hi @thmeitz !
Thank you for your response. I tried to understand your current message and the first one. But I don't understand how I can access the column name with the headerChannel variable.
If I understand correctly you say that I should not be able to read from the header channel while processing the row channel. But my printf function is able to display the header from the row channel. But I cannot access the Columns field, neither its QueryId field.
I would like to parse a row and know what is the corresponding column name. But it doesn't work.

from ksqldb-go.

fenix01 avatar fenix01 commented on June 18, 2024

Finally I found the problem @thmeitz !
I was using ksqldb-go in version v0.0.4 because it is the latest version in the release page. But in this version the Header struct is written like this.

ksqldb-go/types.go

Lines 113 to 116 in 7babf9f

type Header struct {
queryId string
columns []Column
}

As you can see, all fields are in lowercase and are not exposed to the outside. So I cannot access columns field from my code.
It has been changed in the master branch :

ksqldb-go/types.go

Lines 90 to 93 in 895ad65

type Header struct {
QueryId string `json:"queryId"`
Columns []Column `json:"Columns"`
}

I added the library by pointing to the latest commit and now it works correctly.

go get github.com/thmeitz/ksqldb-go@895ad659e4025274b4d4ddbaae941903525f078a

from ksqldb-go.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.