Skip to content

Commit 945b16e

Browse files
committed
Override StreamableExecutor::getSchema
1 parent d8508ae commit 945b16e

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

pdal/StreamableExecutor.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,5 +229,16 @@ void StreamableExecutor::done()
229229
m_executed = true;
230230
}
231231

232+
std::string StreamableExecutor::getSchema() const
233+
{
234+
if (!m_executed)
235+
throw pdal_error("Pipeline has not been executed!");
236+
237+
std::stringstream strm;
238+
MetadataNode root = m_table.layout()->toMetadata().clone("schema");
239+
pdal::Utils::toJSON(root, strm);
240+
return strm.str();
241+
}
242+
232243
} // namespace python
233244
} // namespace pdal

pdal/StreamableExecutor.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class StreamableExecutor : public PipelineExecutor
8888
StreamableExecutor(std::string const& json, point_count_t chunkSize, int prefetch);
8989
~StreamableExecutor();
9090

91+
std::string getSchema() const;
9192
PyArrayObject* executeNext();
9293
void stop();
9394

pdal/libpdalpython.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ cdef class PipelineIterator(PipelineResultsMixin):
248248
def __dealloc__(self):
249249
self._executor.get().stop()
250250

251+
@property
252+
def schema(self):
253+
return json.loads(self._executor.get().getSchema())
254+
251255
def __iter__(self):
252256
return self
253257

test/test_pipeline.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ def test_metadata(self):
445445

446446
assert r.metadata == it.metadata
447447

448-
@pytest.mark.xfail
449448
def test_schema(self):
450449
"""Fetching a schema works"""
451450
r = get_pipeline("range.json")

0 commit comments

Comments
 (0)